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

wjp wjp at usecode.org
Thu Oct 17 23:20:39 CEST 2013


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

Summary:
d0b341e6ca ZVISION: Create zvision bare structure
0303850bf7 ZVISION: Allow detection to go off inner directory
5d64107ff3 ZVISION: normalized file endings
8ae85892d6 ZVISION: Alter video handling to follow the new video audio track wrapper.
179f5de498 ZVISION: Add support for ZFS archive files
ef37f14d53 ZVISION: Add xor encryption handling to ZfsArchive class
b65fd98441 ZVISION: Clean up includes
160d6256f2 ZVISION: Create skeleton engine and move code away from Engine::Run
a8980a4f77 ZVISION: Create utility function that writes File contents to another File
f444a1fd38 ZVISION: Create Object class.
2ada5a8dd7 ZVISION: Split puzzleControl into two files. Add ResultAction enum
8243263b33 ZVISION: Add documentation to utility functions and add a glorified trim function
75e513c46c ZVISION: Create base puzzle parsing.
cf7c04a001 ZVISION: Fix code formatting to follow the convention
8cc678e2ee ZVISION: Convert 'Object' implicit conversion operators to accessors
7803c9fddf ZVISION: Force 'Object' constructors to be explicit.
3283176f6d ZVISION: Move initialization code from run() and into its own method
d5fa6612ed ZVISION: Modify utility and puzzle comments to make them more clear
5fef809941 ZVISION: Convert union of pointers to union of values except for String.
30208f7f2b ZVISION: Add documentation to 'Object' accessors
c3c7566962 ZVISION: Rename 'Object' class to 'SingleValueContainer'
063d6c3400 ZVISION: Rename object.h and object.cpp to fit the new class name
526c1dc465 ZVISION: Use spaces in doxygen comments for alignement instead of tabs
ac96b943fa ZVISION: Create an instance of ScriptManager inside ZVision
b3b7bd29b1 ZVISION: Create ResultAction base class and ActionAdd child class
464cc44a82 ZVISION: Convert ScriptManager methods to use ResultAction classes logic
b70f85b9a0 ZVISION: Comment clarification for ScriptManager methods and helper structs
dec34c174b ZVISION: Create global state accessor/mutator methods for ScriptManager
8d9f90bf12 ZVISION: Create ScriptManager accessor for ZVision
7bc0097dde ZVISION: Fix include for singleValueContainer.cpp
daa2c4b670 ZVISION: Move test functions out of video.cpp and into their own file
f99d613dcb ZVISION: Rename files to use underscores instead of camelCase
1710468121 ZVISION: Fix includes to use new underscore names
0b9dce40a0 ZVISION: Fix usage of Puzzle struct to use 'key' instead of 'id'
c0c4ee6533 ZVISION: Fix single_value_container.h include to use the new file name
187c119e93 ZVISION: Create ResultAction 's for Add and Random.
16cc970c9e ZVISION: Normalize remaining CRLF to LF for the remote
0ba9ca8fa0 ZVISION: Forward declare ZVision in result_action.h
3822de2aec ZVISION: Change Puzzle::resultActions to a List of pointers instead of ResultAction objects
3f93f7d27f ZVISION: Change trimCommentsAndWhiteSpace to use a pointer instead of a reference.
ebb546c468 ZVISION: Create utility method to dump result action signatures from various .scr files
a77ae2163b ZVISION: Add definitions for more ResultActions
4209236994 ZVISION: Create debug console and apply console logic to main loop
46865dc394 ZVISION: Create renderImageToScreen method and add a console command for it
540dde67db ZVISION: Cleanup dump method from run()
c882f79695 ZVISION: Remove direct inclusion of stdio.h
258ecb0aeb ZVISION: Remove nonstandard C type declaration from the StateFlags enum
a8e5e1e2db ZVISION: Rename result_action.h/.cpp files to actions.h/.cpp
fa365dffce ZVISION: Change #include scummsys.h to types.h
89693d4074 ZVISION: Create class for decompressing and reading LZSS
399e512be2 ZVISION: Update renderImageToScreen to handle TGZ image files
ca89f76798 ZVISION: Move early break out above the for loop. LzssReadStream::decompressBytes()
00c0284765 ZVISION: Conform to new eventRecorder code
ec7915bcb9 ZVISION: Fix eos checking in LzssReadStream
811ea39486 ZVISION: Update module.mk with current objs
4c7db7f5de ZVISION: renderImageToScreen: Check for TGZ first instead of TGA
afbcca2187 ZVISION: Move engine width, height, and pixelFormat to const member variables
76b2aa33ca ZVISION: Create/refactor methods for playing video.
4398c04a7b ZVISION: Create console command for loading a video
0451503ecc ZVISION: Remove implicit cast between integer types
61a2fffafd ZVISION: Standardize naming conventions to fit the rest of the code base
4e55d7ba94 ZVISION: Clean up includes
9d478206f8 ZVISION: Move utility functions to a cpp file with declarations in a header file
d672c2c440 ZVISION: Remove unused methods from ZVision class
3397edb4f5 ZVISION: Add ActionNode class
ba22c83861 ZVISION: Implement ActionTimer::execute()
78daaeb583 ZVISION: Create main containers in ScriptManager
9c7203c4b9 ZVISION: Create utility method to remove duplicate entries from a Common::Array
24dc3e1793 ZVISION: Create ScriptManager state handling logic
29061acd4e ZVISION: Add operator< to the Puzzle struct
ae84e9508e ZVISION: Add 2x scaling to videos
09358141de ZVISION: Allow the console to stay open when errors occur
8d2bef2936 ZVISION: Create console command for loading sounds
535d6a2a40 ZVISION: Modify RawZorkStream to use a modified ADPCM codec
f88127104b ZVISION: Fix implicit conversion for scanf-type functions
c45a13cdd7 ZVISION: Conform to GCC spacing for template inside template
644313e8f2 ZVISION: Add stereo/mono handling for Zork sound
8de12fcbd2 ZVISION: Add underscore prefix to public static variable names
a30f49b556 ZVISION: Add a game type enum to detection
9f7ff84fe4 ZVISION: Create utility function to parse fileName from a full/partial path
76f4d2b3d8 ZVISION: Create logic to decode sound rate and isStereo from fileName
92f3de72de ZVISION: Convert console sound handling to use new fileName decoding
071d9f2241 ZVISION: Add logic to allow the user to break out of videos
c7ce580bbd ZVISION: Removed 'packed' audio handling from RawZorkStream.
d771b615e0 ZVISION: Use individual initialization instead of inline.
03c871ff30 ZVISION: Convert _stereo to a byte since it is used for a bitwise and
134f8fda17 ZVISION: Fix incorrect assumptions about a file being stereo
e897a1bb2a ZVISION: Fix logic concerning whether a stream is packed or not
7644e00bf3 ZVISION: Convert ResultActions to take a String pointer in their constructors
32f8848605 ZVISION: Create utility function to convert .RAW to .WAV
8f32592ab9 ZVISION: Create console command to use the raw2wav function
1c44fe7afb ZVISION: Fix the error causing distortions in the sound
125a061a96 ZVISION: Convert to using MKTAG() instead of checking each char individually
47161ef30d ZVISION: LZSSReadStream - Decompress directly to the destination buffer instead of an intermediate buffer
b316df9e82 ZVISION: Add a return statement for when image load fails
d546e11cf1 ZVISION: Fix namespace indentation
4713640779 ZVISION: Remove extraneous member variable
94000e0781 ZVISION: Replace includes with forward declarations
6d7541a430 ZVISION: Create RenderManager class and move code from image.cpp
4bd95987d2 ZVISION: Convert old code to use RenderManager
2bfefd9691 ZVISION: Remove extraneous file
b3eb48996a ZVISION: Fix memory leaks
9e6b2dfc12 ZVISION: Create member function for creating a panorama look up table
cd51b646f3 ZVISION: Create a class for handling all render table logic
ed44907309 ZVISION: Move rendering logic from ZVision class to RenderManager class
de2e7fd144 ZVISION: Convert error() to warning()
88934cd5d0 ZVISION: Convert console code to use RenderManager and add method for setRenderState
73f02759f9 ZVISION: Remove supurflouous 'const' and add 'inline'
df2e78e6f8 ZVISION: Remove variable used for debugging purposes
65a08c71c6 ZVISION: Fix unsigned/signed compiler warning
364e9d659c ZVISION: Force all files to be registered with SearchMan as 'flat'
2349fcfd31 ZVISION: Modify renderImageToScreen to take into account the current RenderState
3d223e2123 ZVISION: Modify the RenderTable panorama math to account for panoramas being transposed
c8359ad56c ZVISION: Modify loadImage console command to account for new render options
34b3a78898 ZVISION: Fix error causing image discontinutities
611ff31a56 ZVISION: Copy Point struct from rect.h and turn it into a templated class
a23970bbc6 ZVISION: Convert RenderTable to only storing (x,y) offsets instead of absolute postions.
4acdf5b7d5 ZVISION: Convert panoramaOptions and tiltOptions to floats
f8bc82080a ZVISION: Create function for mixing two RGB<555> colors
48b9741f41 ZVISION: Rename Point template class to Vector2
564379d3ee ZVISION: Create method to get RenderTable object pointer from RenderManager
5376aa7b3c ZVISION: Move generating the RenderTable to outside setRenderState
b9dd61437c ZVISION: Create class for ActionDelayRender
0e4e6ee9bf ZVISION: Create methods for altering panoramaOptions and create console commands for them
8f3e27cbd0 ZVISION: Fix closing braces on generateTiltLookupTable
e076d8e52f ZVISION: Change default panorama FoV to 27 degrees
1c551d4359 ZVISION: Only scale videos when needed
032afd3c1a ZVISION: Fix compilation
93c6670f6f ZVISION: Create clone member function for ResultAction class
7d58ebf281 ZVISION: Convert Puzzle to a class
cf9790a9d6 ZVISION: Create mutators for _tiltOptions
b20437a17d ZVISION: Modify Criteria parsing to handle empty Criteria
c22c91b7d3 ZVISION: Create Control class
48a3a1530d ZVISION: Move the criteriaMet bool outside of the loop
2063cb711d ZVISION: Add 'reverse' to _tiltOptions and _panoramaOptions to handle Control options
d4ae293f88 ZVISION: Rename parseResult() to parseResults()
070042fcb4 ZVISION: Modify Control parsing to use new Control class structure
00eb279243 ZVISION: Create ScriptManager member function to change location
ea47c28ddf ZVISION: Make ActionNode::process() pure virtual
f975fbe521 ZVISION: Move Puzzle logic into a .cpp file
f39e1fdc43 ZVISION: Move CriteriaOperator, Criteria, and StateFlag inside the Puzzle class
89d8496dba ZVISION: Add detection entry and directories for ZGI
f1135292d0 ZVISION: Optimize integer type usages
5e442c363e ZVISION: Convert String pointers to const references
d06083aa96 ZVISION: Convert sscanf formats to follow new int lengths
903e21b8af ZVISION: Initialize the iterator
8ec0a90611 ZVISION: Convert _blockSize to an anonymous enum
e170be4ea5 ZVISION: Remove redundant class qualifier
87f2e9a894 ZVISION: Update module.mk with current obj
d43e1e9741 ZVISION: Add filename parsing for ActionPlayAnimation
8e3ffdece8 ZVISION: Initialize _needsScreenUpdate in RenderManager
4729641cf9 ZVISION: Fix typo in format string
3df425004d ZVISION: Remove superfluous comma
99ecc80e86 ZVISION: Initialize iterator
cf45312016 ZVISION: Fix unsigned/signed mismatch warning
2faaf8488b ZVISION: Convert ResultAction pointers to SharePtr
93e4f4dbf7 ZVISION: Sort using iterators instead of the actual elements
44ee28c13f ZVISION: Remove ResultAction clone member function
87be3180c7 ZVISION: Fix sscanf formatting errors
8d5e92b935 ZVISION: Add console cmd for changing location
5ef19407b4 ZVISION: Fix typo in panarama and tilt control parsing
ebe83ed390 ZVISION: Make panorama and tilt control generate the RenderTable after setting all the settings
47f10fe784 ZVISION: Overload renderImageToScreen to handle fileNames and ReadStreams
9e996c4fec ZVISION: Convert _activeNodes and _activeControls to Lists of SharedPtr
11118262e4 ZVISION: Add logic to check _referenceTable Puzzles every time a globalState is changed
8bbc260b86 ZVISION: Create RenderManager method to set the current background image
32b3363acd ZVISION: Add ActionSetScreen
d89a55d3de ZVISION: Create class definitions for mutliple ResultAction children
3fd5a8ab5a ZVISION: Offset the RenderTable index by the normalized coords, not the subRect coords
c828074df9 ZVISION: Remove extraneous comments
0a8f57721b ZVISION: Create Clock class to handle deltaTime while pausing and unpausing the game
a86a0832e0 ZVISION: Create console method for dumping a file by name
7b9858d6b4 ZVISION: Make video code blocking.
c4dc3989a7 ZVISION: Make the return from makeRawZorkStream more specific
ec7036469c ZVISION: Make _clock a member variable instead of a pointer to the heap
1d694dcb81 ZVISION: Add support for engine pausing from higher up (GMM, phone call, etc.)
4b0015b8e9 ZVISION: Check if a key exists before returning _globalState value.
20c8920929 ZVISION: Pass the scr fileName as a const reference
6515e2d31b ZVISION: Add ActionMusic
65b5a2797b ZVISION: Fix index out of range error
cefb0253ae ZVISION: Change _pausedTime to be a reference to when time was paused, instead of accumulation of time
3f5cf50049 ZVISION: Use videoDecoder.getTimeToNextFrame() to calculate the frame delay
9dec0adcdc ZVISION: Conform to gcc template spacing requirements
3723a0bad3 ZVISION: sscanf to a uint first instead of directly to a bool
9147636003 ZVISION: Allow _deltaTime to go negative so it can be clamped to zero properly
9036b8d3d2 ZVISION: Create ZVisionGameId entry None
623b2625ff ZVISION: Properly end the AD table
1b05d2fd7d ZVISION: Add linking for clock.o
6564dc0444 ZVISION: Rename inner variable to prevent variable shadowing
76d4fb569d ZVISION: Comment out usage of ActionUnloadAnimation until it is implemented
4806a3726b ZVISION: Add default case statements for event handling in videos
f2823933b4 ZVISION: Remove extraneous include
9bea3cb1c2 ZVISION: Add memory cleanup for _currentBackground
1cff0fb0d6 ZVISION: Fix memory free mismatch caused by MemoryReadStream using free()
6598bb20fd ZVISION: Create image auto screen centering during blitting
946f98b34d ZVISION: Fix frame delay calculation being reversed. Also convert to int to ensure proper 0 clamping
30afe1a815 ZVISION: Add some comments concerning StateFlag::DO_ME_NOW
a31a97c520 ZVISION: Add debug statements for Puzzle checking
435ed16e03 ZVISION: Set the puzzle global variable after a Puzzle is completed
387bfb2806 ZVISION: Fix typo in Puzzle checking
931ad00a2d ZVISION: Add StateFlag handling to Puzzle checking
b98a8fbf12 ZVISION: Fix loop logic so videos can end
f67e0042b0 ZVISION: Create console method to dump all cursor file names
b4b60e1f63 ZVISION: Call _system->updateScreen() every frame
268282ab22 ZVISION: Create class for decoding .zcr cursor files
f31f35bf7b ZVISION: Create console command to render a cursor image to the screen
06e6cb5d1f ZVISION: Create method for cycling through all the cursors so as to identify them more easily
0feac806b2 ZVISION: Add a ZGI folder directory to the SearchMan
f89120310c ZVISION: Test for file.open before trying to read
1b277d34ac ZVISION: Add class to manage cursors
ed4977848b ZVISION: Fix invalid argument for String::format()
9740087441 ZVISION: Add documentation for the ResultAction base class
86b3dfa221 ZVISION: Make ZFS Archive member name indexing case-insensitive
416cde1358 ZVISION: Change video code to support arbitrary scaling and whether the video can be skipped
694a6099a6 ZVISION: Implement ActionQuit
2176aa55fc ZVISION: Implement ActionStreamVideo
5bba509db8 ZVISION: Create a global puzzle list and parse universe.scr into it during ScriptManager::initialize()
dd11566ffd ZVISION: Move the ScriptManager update functions to a single update() function.
2565f96c55 ZVISION: Make ScriptManager::changeLocation delay the actual change until the end of the frame
327d4a1ccf ZVISION: Implement ActionChangeLocation::execute()
309034c153 ZVISION: Stop checking puzzles if ResultAction::execute() returns false
17a806a01b ZVISION: Add parsing skip for action::copy_file. It is not used.
c6b82e7753 ZVISION: Fix parsed arguments in ActionStreamVideo
bd4e6e0c18 ZVISION: Remove Graphics::Cursor inheritance and remove extraneous methods
f6033afa02 ZVISION: Change CursorManager to go through CursorMan instead going directly to OSystem
b76927ab4e ZVISION: Remove extraneous _needsScreenUpdate bool
a3315037ff ZVISION: Create methods for converting screen coords to image coords
3eb6c0ebd8 ZVISION: Convert hardcoded constants to anonymous enum variables
668b0e6c89 ZVISION: Throw a warning when a .scr file isn't opened
19e829ae95 ZVISION: Ignore .scr file lines that are empty
9f0420e1ce ZVISION: Change the initializer list formatting to conform to how everything else is formatted
9681d7515e ZVISION: Fix enum qualifiers
553a3ced68 ZVISION: Remove a verbose debug message
ca76805995 ZVISION: Fix accidental redeclaration of the scale variable
dd77956819 ZVISION: Move SearchMan directory registration outside ZVision constructor
3e8bc76127 ZVISION: Create MousEvent class to handle mouse hovers/clicks
269bed7c7d ZVISION: Implement mouse event handling
00a17a66d0 ZVISION: Implement push_toggle control handling
a49b77cd79 ZVISION: Fix memory leak
19a2a59c3c ZVISION: Fix unsigned/signed mismatch
5ef23e6f8d ZVISION: Restart the Clock after the video finishes
e3f352cb0c ZVISION: Delete the scaledVideoFrameBuffer after we're done with it
d8e45fc438 ZVISION: Only allocate memory for the scaled buffer if we're actually going to scale the video
372c55fd8b VIDEO: Disable SCI_32 plugin guard for DUCK Truemotion
7e93b6407a ZVISION: Fix frame scaling for 2bpp
b9b8207a14 ZVISION: Dispose of .zfs file streams after processing them
878fde365e ZVISION: Fix alignment formatting
c020c6bf53 ZVISION: Add check to CursorMan::changeCursor to prevent extraneous cursor changes
4c1e8b3f45 ZVISION: Allow CursorManager::revertToIdle to take _cursorIsPushed into account
003b30c77b ZVISION: Create methods for setting left, right, up, down cursors
54f16f2539 ZVISION: Create the concept of a working window
85c67e5e2f ZVISION: Implement ZVISION::getCursorManager()
65853bfe2b ZVISION: Fix header #defines to match their file names
39934b1da7 ZVISION: Set the initial game location (The opening video and menu)
1dcc56f7d2 ZVISION: Slight function name change to increase clarity
d8f9be74ff ZVISION: Add panning support
8d57880c51 ZVISION: Clip coords outside the working window
6be19d850a ZVISION: Add background image wrapping
0fe3ae711a ZVISION: Add cursor and background image resets during location change
9b8bad3c83 ZVISION: Add _renderManager::update() to ZEngene::run()
4e827b4dda ZVISION: Add documentation
435419cfe9 ZVISION: Modify ASCII velocity drawing to represent the actual code
95d1ef68ab Merge branch 'master' into zvision
c0305d9534 ZVISION: Rename variables and add comments to clarify the math behind panorama warping
08a8ab885b ZVISION: Apply panorama/tilt warping after all images have been rendered to a backbuffer
999de6d400 ZVISION: Convert Surface::pixels to Surface::getBasePtr(0, 0)
7e8e9bf3d1 GRAPHICS: Create copyRectToSurface member function
62043e949d VIDEO: Add an over-ridable wrapper for the AVI audio track handler
c2366dc99e ZVISION: Fix error using subRectangle.right instead of .top
bdd9b18292 ZVISION: Disable videos until I can figure out how to fix the decoder
e6aa2d15ca ZVISION: Only skip the background moving if velocity is 0 instead of returning and skipping everything
26159e6ea5 ZVISION: Only warp the backbuffer if we're in PANORAMA or TILT
af0a58ecda ZVISION: Fix copyTransposedRectToBackBuffer
e0937a12cd ZVISION: Move _cursorManager construction after the folder directories have been registered with SearchMan
1c6ffd133a ZVISION: Clean up backbuffer memory after we're finished with it
a3c39f4876 ZVISION: Fix memory corruption in copyTransposedRectToBackBuffer
0a840fa664 ZVISION: Rename 'x' variable in changeLocation to 'offset'
7d24f46e7e ZVISION: Modify cmdLoadSound to allow manual rate and isStereo
e769164f79 ZVISION: Render images by specifying a destination and then clipping
b22ed391fe ZVISION: Set the background position after the .scr file has been parsed so we know the RenderState
bbb8598a3e ZVISION: Modify cmdLoadImage to match new render code
f2477610cf VIDEO: Add AVI LIST handling for ZVision custom types
8fafde8a33 ZVISION: Re-enable video handling now that AVI code is fixed
7e6a04dc62 ZVISION: Store the background offset from the center instead of from the top left corner
acea03a9cd ZVISION: Allow RenderTable indicies to be negative
80cba07b31 ZVISION: Allow destinations to be negative
f1d44bdf8c ZVISION: Protect against indicies that are more than an imageWidth/Height from the actual image dimensions
77219705e6 ZVISION: Prevent endless looping due to incorrect file structure
eafd6608cf ZVISION: Change the CLIP template argument to match the type of the indicies
c840d082ce ZVISION: Allow ONCE_PER_INST puzzles to be repeated once per room instead of once per game
09ae4443d4 ZVISION: Reset push_toggle controls global state value to 0 during initialization
589c29e6e1 ZVISION: Add newlines to console debug statements
1f653f9a34 ZVISION: Allow MouseEvents to be unregistered
9051f62136 ZVISION: Make MousEvent fully public
25deaf3a35 ZVISION: Reset MouseEvent globalStateValue's when clearing them
3a23873c45 ZVISION: Convert _activeControls from a List to a HashMap
908e784957 ZVISION: Allow controls to be enabled or disabled
5a86355e7d ZVISION: Implement ActionEnableControl and ActionDisableControl
46ab355766 ZVISION: Allow Puzzles to have mutiple 'sets' of CriteriaEntries
6ee93ad5c2 ZVISION: Convert _puzzlesToCheck to a Queue instead of a Stack
d26c814d1e ZVISION: Force & operator to have precedence over == operator
5eab8a8d77 ZVISION: Reimplement PushToggleControl
4d5914ac21 ZVISION: Fix argument passing for warning()
2fcba2743c ZVISION: Don't cast away const qualifier
b0635edff8 ZVISION: Revert to normal pointers instead of shared pointers
695257cb79 ZVISION: Create class to parse RLF animation files
760dd3e632 ZVISION: Rename _warpedBuffer to _workingWindowBuffer
7c02b66b2e ZVISION: Create method to clear the working window area of the screen to a single color
683e24cd75 ZVISION: Implement ActionSetPartialScreen
6e427ebef8 ZVISION: Create method to play RlfAnimations
9294c5eac9 ZVISION: Initialize inline with construction
6c7303995f ZVISION: Always update the screen to ensure the mouse continues to render
7dcfa9ef4c ZVISION: Call RenderManager::update() before ScriptManager::update()
94a55024ac ZVISION: Fix seek() whence argument
4bd7951840 ZVISION: Normalize comment alignment
6f080b3631 ZVISION: Create keypress event to test rlf animation
610b563790 ZVISION: Convert abs() to ABS() to ensure portability
9af92b8723 ZVISION: Handle rlf frame transitions internally
cf8a8df776 ZVISION: Remove superfluous file
1251da96e2 ZVISION: Add animation.o and rlf_animation.o to module.mk
aba3ba634c ZVISION: Add TODO's of what is left for the engine to be complete
ad5756fa31 ZVISION: Add a destructor to Puzzle
35622827f8 ZVISION: Store the Puzzles in _activePuzzles and _globalPuzzles on the heap
8e22af36b7 ZVISION: Add TODO to subtitles
ac7b2251bb ZVISION: Delete Puzzles from heap before clearing _activePuzzles
fa7fb2e029 ZVISION: Initialize Puzzle::key and Puzzle::flags
ca5066db52 ZVISION: Remove static Control::parsePushToggleControl
25f95ebdcd ZVISION: Implement streaming support for RlfAnimations
f759584d3b ZVISION: Make ZVision::_workingWindow and ZVision::_pixelFormat public
b28d502288 ZVISION: Convert ScriptManager::_activeNodes to normal pointers instead of SharedPtrs
adb3bd7b71 ZVISION: Make MouseEvent purely virtual
2431f60c02 ZVISION: Make Control purely virtual
7095e613d5 ZVISION: Keep a member variable ZVision pointer instead of passing it in every process()
3054489a8b ZVISION: Have PushToggleControl inherit from MouseEvent and handle the methods internally.
0da3d3e5eb ZVISION: Convert _mouseEvents to pointers since MouseEvent is now abstract
aed38867ce ZVISION: Change variable name to match its purpose
6610ca1b82 ZVISION: Fix error: decrementing instead of incrementing
c6242e7134 ZVISION: Fix signed/unsigned mismatch
d2df3eb24e ZVISION: Check if we can use getNextFrame() or getPreviousFrame() before using getFrameData()
0ed7df9a36 ZVISION: Add TODO's about the verbosity of the frame decoding overflow warning
fc5727c522 ZVISION: Fix memory leak
a9db1e1712 ZVISION: Add note about _activeNodes
a596d1241c ZVISION: Add console method to dump all .lev files
7d48a3e4b1 ZVISION: Partially implement LeverControl
af762dc417 ZVISION: Fix signed/unsigned mismatch
5ff032c27d ZVISION: Cast completeFrame and frameNumber to int so their difference can go negative
9d8243245c ZVISION: Fix signed/unsigned mismatch
ff97bb2ead ZVISION: Move PushToggleControl and LeverControl to their own files
5e1215837a ZVISION: Fixed signed/unsigned mismatch
52af1f7f10 ZVISION: Bake ActionNode and MouseEvent into Control
93bc3570ea ZVISION: Create the default implementation for Control::enable()/disable()
3263ab7390 ZVISION: Modify TimerNode to use Control base class
4d344cb5a8 ZVISION: Change LeverControl to comply with the new Control base class
7fb024c7fc ZVISION: Change PushToggleControl to comply with new Control base class
e32f6f7e38 ZVISION: Remove extraneous semicolon
a1d11054b5 ZVISION: Fix signed/unsigned mismatch
b667002124 ZVISION: Update ScriptManager::enableControl()/disableControl() to fit new Control syntax
a6b2bb7581 ZVISION: Remove ScriptManager::_activeNodes and change all iterators to iterate over _activeControls
e3b08793dd ZVISION: Add ScriptManager mouse event handlers
84c645968c ZVISION: Remove ZVision::_mousEvents and all associated functions
610eb11824 ZVISION: Prevent variable shadowing
da3f137b6b ZVISION: sscanf to ints before storing them in Rect coords
f60b054b49 ZVISION: Fix comment spacing
b317ea45fe ZVISION: Allow a angle buffer zone on *both* sides of the actual angle
3a9b384114 ZVISION: Round to int *after* converting to degrees
ab18d20ead ZVISION: Fix the quadrant numbers in angle calculations
3e6144970e ZVISION: Implement avi frame seeking
945982c857 ZVISION: Add support for animation 'mirroring'
a1a70170d4 ZVISION: Remove RlfAnimation::getPreviousFrame()
7d255c3d80 ZVISION: Fix: Signal a cursor change
ce9e9a55c6 ZVISION: Fix: Store what type of animation file is used
952fb83793 ZVISION: Fix: Change infndef to correct constant
f1f36e7c9d ZVISION: Add LeverControl to scr file parsing
f3514534ce ZVISION: Increase background rotation speed
6417192584 Merge branch 'master' into zvision
bb77333d4f ZVISION: Create console method for parsing ALL .scr files
a81c9a52a3 ZVISION: Fix LeverControl 'mirrored' support
c15454d7d4 ZVISION: Keep a Graphics::Surface of the current background instead of re-reading the file each time
0271a2c59d ZVISION: Transpose is done in RenderManager::readImageToSurface(), so remove it from mutateImage
94378d0644 ZVISION: Force comparison to be between signed ints and ensure CLIP happens on a signed int
07770eeafb ZVISION: Convert cursors to RBG 565
f146a0209f ZVISION: Convert image rendering to RBG 565
cdc4842181 ZVISION: Convert RLF animations to RBG 565
4288c4fa0e ZVISION: Remove unnecessary pixel format switching from video code
fa578497b3 ZVISION: Use Surface::getPixels() rather than getBasePtr(0, 0)
03d3646f84 ZVISION: Remove unnecessary check if a pointer was non-NULL before deleting.
7d1dca9ad1 ZVISION: Implement enabled/disabled support in Controls
ef3e26a073 ZVISION: Fix typo in PixelFormat
21474d32ab ZVISION: Fix error is RenderManager backgroundOffset handling
dfe143137a ZVISION: Remove extraneous TODO
3c3a6bd935 ZVISION: Fix typo in point range clipping
94f350b154 ZVISION: Implement TILT RenderTable creation
97b0d5988a ZVISION: Fix how LeverControl return routes are parsed
1ad594bd30 ZVISION: Add default values for tilt options
d2d3755009 ZVISION: Fix tilt render table comment
04bf6f79e9 ZVISION: Implement return pathing for LeverControls
07fdcdf312 ZVISION: Only do return pathing after the mouse is captured
2ad40edd47 ZVISION: Limit tilt movement to the size of the image
f1bd8de21d ZVISION: Overload ZVision::playAnimation to support general video files
c3fcff9612 ZVISION: Move TimerNode to it's own file
a76f852c38 Merge branch 'master' into zvision
78d5a41cd0 ZVISION: Call Surface::free() in the cursor destructor
34dcea106a ZVISION: Cleanup _activeControls in ScriptManager destructor
4d86061b57 ZVISION: Cleanup all used memory in RLF animations
98dc015dc1 ZVISION: Free the _currentBackground Surface in RenderManager destructor
efb0495758 ZVISION: Fix signed/unsigned mismatch
b3a3274616 ZVISION: Remove unnecessary file.open()
5d86eb4a4a ZVISION: Change ActionPlayAnimation::_loop refer to a count rather than a boolean
9ea91f5c9c ZVISION: Convert ZVision singleton accessors to be inline
117eea1be6 ZVISION: Allow changeLocation to be executed right away instead of next frame
dd307c2484 ZVISION: Create method to get the current background offset
9dd54a16e0 ZVISION: Remove zero valued entries in the global state table once a frame
b45c9e7c26 ZVISION: Create method for getting the current location
11bf2405f8 ZVISION: Create base methods for Control serialization
ac578bf9b7 ZVISION: Implement TimerNode serialization
644af30df5 ZVISION: Create ScriptManager state table serialization methods
23ae67c777 ZVISION: Create ScriptManager _activeControls serialization methods
235620750a ZVISION: Create methods for generating save file names
488484d2dc ZVISION: Implement SaveManager
7ff45447ad ZVISION: Create an instance of SaveManager
150a4793a6 ZVISION: Initialize Location to the main menu
1697a9c831 Merge branch 'master' into zvision
2dab04e14b ZVISION: Do full working window warp instead of image at a time
6ce62475ca ZVISION: Disable saving until it can be fixed
b6366a2697 ZVISION: Fix signed/unsigned mismatch
2840ce750e ZVISION: Save the Puzzle key, since ChangeLocation could be called
e92e3c5b0b ZVISION: Delete action_node
558a987143 ZVISION: Fix accidental signed read from save file header
db83d1b5e5 ZVISION: Actually use the converted color instead of the old one
1e1d5cafe5 ZVISION: Re-enable rendering to the backbuffer
94268fed06 ZVISION: Update ActionSetPartialScreen to use new function name
2f12ac0d71 ZVISION: Fix pixel copying errors in renderRectToWorkingWindow
48745ad197 ZVISION: Add dirty rectangling support for pure image rendering
70e75dd640 ZVISION: Make the declaration and implementation of copyRectToWorkingWindow be the same
47ee636f05 ZVISION: Make LeverControl render to the working window instead of directly to the screen
aea1070713 ZVISION: Allow RLF seeking without returning a frame
acfa7ff3e1 ZVISION: Add scr parse line for ActionAssign
81184d342c ZVISION: Delete a Control * when removing it from _activeControls
eeace477a0 ZVISION: Set a Puzzle as completed before executing its ResultActions
6a9572670c ZVISION: Add method for getting a pointer to a Control
46278f6f59 ZVISION: Implement AnimationControl
5c3cfaa6d2 ZVISION: Implement ActionPreloadAnimation::execute()
b1587f8ba0 ZVISION: Implement ActionPlayPreloadAnimation
6e806e51ad ZVISION: Stop avi playback once the animation is finished
106522661c ZVISION: Create method for rendering to the working window with binary alpha
87e78e4c33 ZVISION: Create method for getting the RenderManager backbuffer
af94158723 ZVISION: Save a thumbnail of the RenderManager backbuffer instead of the actual screen
c7358ed4f7 ZVISION: Create class for rendering TrueType fonts
511cb7447e ZVISION: Create method for converting image space to working window space
a415964c6d ZVISION: Create method for clipping a rect to the working window
f9b9bf5b9b ZVISION: Create method for transposing a surface
3b7189993c ZVISION: Let Rlf animations output Surfaces instead of uint16 arrays
31cdf227d2 ZVISION: Clip animations to the working window
8354f23628 ZVISION: Add a debug assert to make sure we're not trying to render ouside the working window
077f0b2491 ZVISION: Update LeverControl to use the new RlfAnimation outputs
9e563f0113 ZVISION: Add comments to AnimationControl::process()
edd1a117ae ZVISION: Cache animation frames so they can be re-rendered when the background moves
072b852cdc ZVISION: Remove extraneous methods from TrueTypeFont
f5f053d335 ZVISION: Use default dpi for font
4a4330cec7 ZVISION: Cleanup the cached frame before loading the next one
0874212fa7 ZVISION: Cleanup _currentFrameBuffer during descruction
6f4e80e36e ZVISION: Add wrapper function for copyRectToSurface
d643ca1571 ZVISION: Remove unused Console functions
c20a9ac6ae ZVISION: Add key press support to Controls
d3b6caab2f ZVISION: Remove unused key functions
752807b471 ZVISION: Add method to copy a portion of the working window to a surface
b50afa2b15 ZVISION: Remove unused function
0eeeeded92 ZVISION: Add ScriptManager support for key press events
8ba295d710 ZVISION: Add key press support to the main event loop
466eba1e9f ZVISION: Fix signed/unsigned mismatch
3986f333ef ZVISION: Move dirty rect extension to the correct function
36a0b666b3 ZVISION: Add better alpha support for blitting
259d11762d ZVISION: Add support for ActionRandom and ActionTimer
0d78208562 ZVISION: Add focus support for Controls
6ee253a4d8 ZVISION: Add focus support for the ScriptManager
5cd1d2d1c2 ZVISION: Ensure getControl always returns something
2900aaa90a ZVISION: Add a reminder for how inventory is accessed
a2d19c7a6e ZVISION: Actually store the ZVision pointer
f6c36aa14c ZVISION: Create an instance of the SaveManager
c643718dae ZVISION: Clean up the TruetypeFont class and add alpha support
dc8c7ca2c0 ZVISION: Add RenderManager text support
05b3b170d4 ZVISION: Add more documentation for clearWorkingWindowTo555Color()
82ea7ca0e7 ZVISION: Create the StringManager class
c312b147fa ZVISION: Create an instance of StringManager
d82ff7aea8 ZVISION: Create Console method to render text
2b2f85063a ZVISION: Clean up StringManager and SaveManager after use
41afb2dd90 ZVISION: Move clearing dirty rects to after they are blitted instead the beginning of each frame
7ce6823158 ZVISION: Convert _alphaDataEntries to a HashMap
cdd793ed22 ZVISION: Check is a dirty rect is empty before extending it
3a6cb86489 ZVISION: Add methods to clear and remove AlphaEntries
2187245012 ZVISION: Remove all AlphaEntries on room change
1f9f392279 ZVISION: Enable auto saving
4c4f08a99e ZVISION: Convert cmdRenderText to use new function syntax
14cfc65c0d ZVISION: Use wide-to-ASCII conversion to read a line instead of stream.readLine()
d59cf9fda6 ZVISION: Convert StringManager::parseStr to use readWideLine()
a2c36a16b5 ZVISION: Fix parseTag font name logic
c7e2bdd2b2 ZVISION: Remove extraneous function
2b60cc8a0c ZVISION: Test for file.open() success before continuing with font loading
ff5b7ba2a8 ZVISION: Draw string to 0, 0 instead of destX, destY
0c28fbca7c ZVISION: Remove extraneous empty line
035ee29f1d ZVISION: Initialize StringManager
4af62cfd3a ZVISION: Register the "fonts" directory with SearchMan
a0a67a2d47 ZVISION: Partially implement InputControl
b5c762168e Merge branch 'master' into zvision
5ec472ae2f ZVISION: Add version support for save files
6664f31ed2 ZVISION: Convert the current save version to a const
6148a0a878 ZVISION: Add a check against reading newer save game versions
d06c64d076 ZVISION: Append chars to a Common::String object instead of using a static buffer
8557b06197 ZVISION: Load the state values before changing location
ca80deea62 ZVISION: Only allow save slots in the range [1, 20]
51fc627c05 ZVISION: Clear out the current state table values before loading any from a save file
8f7fa517d6 ZVISION: Directly access _globalState instead of using setStateValue
1ced56fee7 ZVISION: Add documentation to SaveManager
7ff86ba6f9 ZVISION: Add documentation for RlfAnimation
2d9c9e8c7f ZVISION: Remove unused animation functions
cfe176619a ZVISION: Remove unused function arguments
7a557c4bcd ZVISION: Add documentation to TruetypeFont
69bcb76d05 ZVISION: Add documentation to RenderManager
48979c557b ZVISION: Remove animation.o since animation.cpp is now gone
9a5305a977 ZVISION: Add vertical pipes to prevent multi-line comments
79573d0331 ZVISION: Fix shadowing in the Direction constructor
9fefed67f4 ZVISION: Fix signed/unsigned mismatch
713baa3769 ZVISION: Fix memory leak in SaveManager
dd0a6fe0e3 ZVISION: Convert hardcoded number to an anonymous enum
9d1b0e1f8b ZVISION: Assert that we don't exceed our hardcoded number of lines
701250efb5 GRAPHICS: Remove variable shadowing
a7ffd9ade6 ZVISION: Cleanup all AlphaEntries after use
fdd477df61 ZVISION: Free AlphaDataEntry Surfaces before deleting them
dfba1a0144 ZVISION: Don't cast away const-ness
29db14c7dd ZVISION: Don't cast away const-ness
dfb37fb2f0 ZVISION: Remove CLIPs from mutateImage
d8bee6be13 ZVISION: Set the state value at each frame of a return animation
cd3dc276d9 ZVISION: Only save a thumbnail of the backbuffer instead of the whole thing
07c3231214 ZVISION: Remove memory corrupting assignment
49d67caa31 Merge branch 'master' into zvision
11576c5aa9 ZVISION: Rename ZVisionGameIds to use standard format
7854f05b79 ZVISION: Remove empty file
a6ae661ef8 ZVISION: Add newline at end of file
ea5a6a7bde ZVISION: Fix debug typo copy-paste error
229e4fe3be ZVISION: Move creation of the managers to ZVision::initialize()
031be61b07 ZVISION: Clean up the ZVision constructor
02aaffd894 ZVISION: Break comment into multiple lines for readability
72ae75e64a ZVISION: Clean up zvision.h
98e7627591 ZVISION: Add debug levels
3c8c4c836f ZVISION: Move bit flag to an enum for clarity
db28babf06 ZVISION: Create file on the heap to prevent memory scope problems
01238925da ZVISION: Fix curly braces formatting
e08023c4b6 ZVISION: Add newline to end of module.mk
239493305d ZVISION: Replace all occurances of (*iter). with iter->
ffaffa2bc4 ZVISION: Convert all for-loops to use pre-increment instead of post-increment
4172334b51 ZVISION: Remove global const variables
4c06affe84 ZVISION: Convert _completeFrames to an Array
afe8cba1a1 ZVISION: Fix spacing
0deb845229 ZVISION: Remove global const variable
28ac59307b ZVISION: Update warning message to correspond to the behavior
1f9ba897b8 ZVISION: Convert _timeLeft to a signed int
b913e9f8a3 ZVISION: Update removeDuplicateEntries to preserve order
1c8a5582a2 ZVISION: Remove unnesessary operator overload
18b1c3130f ZVISION: Move two lookup tables inside the RawZorkStream class
1140c8b48d ZVISION: Fix space formatting
1bdcae7f18 ZVISION: Rename zvision.h inclusion guard to be consistent with the other files
bad28dc158 ZVISION: Standardize includes order and format
23a1a1a70f ZVISION: Fix signed/unsigned mismatch
c73159150d ZVISION: Re-enable Truemotion plugin guard, but add a case for ZVISION
8a69bcfe97 ZVISION: Add typedefs to shorten long type names
39a8243c69 ZVISION: Remove Vector2 class
2887e8295d ZVISION: Fix nested template formatting
260ba64bda ZVISION: Fix signed/unsigned mismatch
bbf8e647e9 ZVISION: Add an entry in AUTHORS for ZVision
8e8e5af0ec ZVISION: Add an entry in credits.pl for ZVision
ef87ba54b4 ZVISION: Add an entry in credits.pl for Marisa Chan / Zidane
7a97c992de ZVISION: Use credits.pl to update AUTHORS and credits.h
a532c7729f Merge branch 'zvision'


Commit: d0b341e6ca7010641c362bb36ebfc3d225955056
    https://github.com/scummvm/scummvm/commit/d0b341e6ca7010641c362bb36ebfc3d225955056
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:29:44-07:00

Commit Message:
ZVISION: Create zvision bare structure

Add zvision base engine to engines/zvision as well as
modify the necessary engine files (configure.engines, etc.)
in order for it to be recognized.

Changed paths:
  A engines/zvision/detection.cpp
  A engines/zvision/module.mk
  A engines/zvision/zork_avi_decoder.cpp
  A engines/zvision/zork_avi_decoder.h
  A engines/zvision/zork_raw.cpp
  A engines/zvision/zork_raw.h
  A engines/zvision/zvision.cpp
  A engines/zvision/zvision.h
    engines/configure.engines
    engines/engines.mk
    engines/plugins_table.h



diff --git a/engines/configure.engines b/engines/configure.engines
index 963b9f7..a352557 100644
--- a/engines/configure.engines
+++ b/engines/configure.engines
@@ -52,3 +52,4 @@ add_engine tony "Tony Tough and the Night of Roasted Moths" yes "" "" "16bit"
 add_engine tsage "TsAGE" yes
 add_engine tucker "Bud Tucker in Double Trouble" yes
 add_engine wintermute "Wintermute" no "" "" "png zlib vorbis 16bit"
+add_engine zvision "ZVision" no
diff --git a/engines/engines.mk b/engines/engines.mk
index f58dba0..e399713 100644
--- a/engines/engines.mk
+++ b/engines/engines.mk
@@ -246,3 +246,8 @@ ifdef ENABLE_WINTERMUTE
 DEFINES += -DENABLE_WINTERMUTE=$(ENABLE_WINTERMUTE)
 MODULES += engines/wintermute
 endif
+
+ifdef ENABLE_ZVISION
+DEFINES += -DENABLE_ZVISION=$(ENABLE_ZVISION)
+MODULES += engines/zvision
+endif
\ No newline at end of file
diff --git a/engines/plugins_table.h b/engines/plugins_table.h
index edc94eb..793f151 100644
--- a/engines/plugins_table.h
+++ b/engines/plugins_table.h
@@ -119,3 +119,6 @@ LINK_PLUGIN(TUCKER)
 #if PLUGIN_ENABLED_STATIC(WINTERMUTE)
 LINK_PLUGIN(WINTERMUTE)
 #endif
+#if PLUGIN_ENABLED_STATIC(ZVISION)
+LINK_PLUGIN(ZVISION)
+#endif
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
new file mode 100644
index 0000000..345138b
--- /dev/null
+++ b/engines/zvision/detection.cpp
@@ -0,0 +1,249 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ *

+ *

+ */

+

+#include "base/plugins.h"

+

+#include "engines/advancedDetector.h"

+

+#include "common/translation.h"

+#include "common/savefile.h"

+#include "common/str-array.h"

+#include "common/system.h"

+

+#include "zvision/zvision.h"

+

+

+namespace ZVision {

+

+struct ZVisionGameDescription {

+	ADGameDescription desc;

+};

+

+uint32 ZVision::getFeatures() const {

+	return _gameDescription->desc.flags;

+}

+

+Common::Language ZVision::getLanguage() const {

+	return _gameDescription->desc.language;

+}

+

+}

+

+static const PlainGameDescriptor zVisionGames[] = {

+	{"zvision",  "ZVision Game"},

+	{"znemesis", "Zork Nemesis: The Forbidden Lands"},

+	{"zgi",      "Zork: Grand Inquisitor"},

+	{0, 0}

+};

+

+

+namespace ZVision {

+

+static const ZVisionGameDescription gameDescriptions[] = {

+

+	{

+		// Zork Nemesis English version

+		{

+			"znemesis",

+			0,

+			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),

+			Common::EN_ANY,

+			Common::kPlatformWindows,

+			ADGF_NO_FLAGS,

+			GUIO1(GUIO_NONE)

+		},

+	},

+

+	{ AD_TABLE_END_MARKER }

+};

+

+} // End of namespace ZVision

+

+static const ExtraGuiOption ZVisionExtraGuiOption = {

+	_s("Use original save/load screens"),

+	_s("Use the original save/load screens, instead of the ScummVM ones"),

+	"originalsaveload",

+	false

+};

+

+class ZVisionMetaEngine : public AdvancedMetaEngine {

+public:

+	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {

+		_singleid = "zvision";

+	}

+

+	virtual const char *getName() const {

+		return "ZVision";

+	}

+

+	virtual const char *getOriginalCopyright() const {

+		return "ZVision Activision (C) 1996";

+	}

+

+	virtual bool hasFeature(MetaEngineFeature f) const;

+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;

+	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {

+	return false;

+		/*

+		(f == kSupportsListSaves) ||

+		(f == kSupportsLoadingDuringStartup) ||

+		(f == kSupportsDeleteSave) ||

+		(f == kSavesSupportMetaInfo) ||

+		(f == kSavesSupportThumbnail) ||

+		(f == kSavesSupportCreationDate) ||

+		(f == kSavesSupportPlayTime);

+		*/

+}

+

+/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {

+	return

+		(f == kSupportsRTL) ||

+		(f == kSupportsLoadingDuringRuntime) ||

+		(f == kSupportsSavingDuringRuntime);

+}*/

+

+bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {

+	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;

+	if (gd) {

+		*engine = new ZVision::ZVision(syst, gd);

+	}

+	return gd != 0;

+}

+

+const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {

+	ExtraGuiOptions options;

+	options.push_back(ZVisionExtraGuiOption);

+	return options;

+}

+

+SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {

+	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

+	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {

+					saveList.push_back(SaveStateDescriptor(slotNum, header.description));

+				}

+				delete in;

+			}

+		}

+	}*/

+

+	return saveList;

+}

+

+int ZVisionMetaEngine::getMaximumSaveSlot() const {

+	return 999;

+}

+

+void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {

+	/*

+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

+	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);

+		}

+	}

+	*/

+}

+

+SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {

+	/*

+	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);

+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());

+

+	if (in) {

+		ZVision::ZVision::SaveHeader header;

+		ZVision::ZVision::kReadSaveHeaderError error;

+

+		error = ZVision::ZVision::readSaveHeader(in, true, header);

+		delete in;

+

+		if (error == ZVision::ZVision::kRSHENoError) {

+			SaveStateDescriptor desc(slot, header.description);

+

+			desc.setThumbnail(header.thumbnail);

+

+			if (header.version > 0) {

+				int day = (header.saveDate >> 24) & 0xFF;

+				int month = (header.saveDate >> 16) & 0xFF;

+				int year = header.saveDate & 0xFFFF;

+

+				desc.setSaveDate(year, month, day);

+

+				int hour = (header.saveTime >> 16) & 0xFF;

+				int minutes = (header.saveTime >> 8) & 0xFF;

+

+				desc.setSaveTime(hour, minutes);

+

+				desc.setPlayTime(header.playTime * 1000);

+			}

+

+			return desc;

+		}

+	}

+	*/

+

+	return SaveStateDescriptor();

+}

+

+#if PLUGIN_ENABLED_DYNAMIC(ZVISION)

+	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

+#else

+	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

+#endif

diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
new file mode 100644
index 0000000..854ee03
--- /dev/null
+++ b/engines/zvision/module.mk
@@ -0,0 +1,18 @@
+MODULE := engines/zvision

+ 

+MODULE_OBJS := \

+	detection.o \

+	zvision.o \

+	zork_avi_decoder.o \

+	zork_raw.o

+ 

+MODULE_DIRS += \

+	engines/zvision

+ 

+# This module can be built as a plugin

+ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN)

+PLUGIN := 1

+endif

+ 

+# Include common rules 

+include $(srcdir)/rules.mk
\ No newline at end of file
diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
new file mode 100644
index 0000000..9bcc163
--- /dev/null
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -0,0 +1,136 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ *

+ *

+ */

+

+#include "common/stream.h"

+#include "audio/audiostream.h"

+

+#include "engines/zvision/zork_avi_decoder.h"

+#include "engines/zvision/zork_raw.h"

+

+namespace ZVision {

+

+// Redefinitions from avi_decoder.cpp

+#define ID_VIDS MKTAG('v','i','d','s')

+#define ID_TXTS MKTAG('t','x','t','s')

+#define ID_STRF MKTAG('s','t','r','f')

+#define ID_AUDS MKTAG('a','u','d','s')

+#define ID_MIDS MKTAG('m','i','d','s')

+

+// Copied off AVIDecoder::handleStreamHeader()

+void ZorkAVIDecoder::handleStreamHeader() {

+	AVIStreamHeader sHeader;

+	sHeader.size = _fileStream->readUint32LE();

+	sHeader.streamType = _fileStream->readUint32BE();

+

+	if (sHeader.streamType == ID_MIDS || sHeader.streamType == ID_TXTS)

+		error("Unhandled MIDI/Text stream");

+

+	sHeader.streamHandler = _fileStream->readUint32BE();

+	sHeader.flags = _fileStream->readUint32LE();

+	sHeader.priority = _fileStream->readUint16LE();

+	sHeader.language = _fileStream->readUint16LE();

+	sHeader.initialFrames = _fileStream->readUint32LE();

+	sHeader.scale = _fileStream->readUint32LE();

+	sHeader.rate = _fileStream->readUint32LE();

+	sHeader.start = _fileStream->readUint32LE();

+	sHeader.length = _fileStream->readUint32LE();

+	sHeader.bufferSize = _fileStream->readUint32LE();

+	sHeader.quality = _fileStream->readUint32LE();

+	sHeader.sampleSize = _fileStream->readUint32LE();

+

+	_fileStream->skip(sHeader.size - 48); // Skip over the remainder of the chunk (frame)

+

+	if (_fileStream->readUint32BE() != ID_STRF)

+		error("Could not find STRF tag");

+

+	uint32 strfSize = _fileStream->readUint32LE();

+	uint32 startPos = _fileStream->pos();

+

+	if (sHeader.streamType == ID_VIDS) {

+		BitmapInfoHeader bmInfo;

+		bmInfo.size = _fileStream->readUint32LE();

+		bmInfo.width = _fileStream->readUint32LE();

+		bmInfo.height = _fileStream->readUint32LE();

+		bmInfo.planes = _fileStream->readUint16LE();

+		bmInfo.bitCount = _fileStream->readUint16LE();

+		bmInfo.compression = _fileStream->readUint32BE();

+		bmInfo.sizeImage = _fileStream->readUint32LE();

+		bmInfo.xPelsPerMeter = _fileStream->readUint32LE();

+		bmInfo.yPelsPerMeter = _fileStream->readUint32LE();

+		bmInfo.clrUsed = _fileStream->readUint32LE();

+		bmInfo.clrImportant = _fileStream->readUint32LE();

+

+		if (bmInfo.clrUsed == 0)

+			bmInfo.clrUsed = 256;

+

+		if (sHeader.streamHandler == 0)

+			sHeader.streamHandler = bmInfo.compression;

+

+		AVIVideoTrack *track = new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo);

+

+		if (bmInfo.bitCount == 8) {

+			byte *palette = const_cast<byte *>(track->getPalette());

+			for (uint32 i = 0; i < bmInfo.clrUsed; i++) {

+				palette[i * 3 + 2] = _fileStream->readByte();

+				palette[i * 3 + 1] = _fileStream->readByte();

+				palette[i * 3] = _fileStream->readByte();

+				_fileStream->readByte();

+			}

+

+			track->markPaletteDirty();

+		}

+

+		addTrack(track);

+	} else if (sHeader.streamType == ID_AUDS) {

+		PCMWaveFormat wvInfo;

+		wvInfo.tag = _fileStream->readUint16LE();

+		wvInfo.channels = _fileStream->readUint16LE();

+		wvInfo.samplesPerSec = _fileStream->readUint32LE();

+		wvInfo.avgBytesPerSec = _fileStream->readUint32LE();

+		wvInfo.blockAlign = _fileStream->readUint16LE();

+		wvInfo.size = _fileStream->readUint16LE();

+

+		// AVI seems to treat the sampleSize as including the second

+		// channel as well, so divide for our sake.

+		if (wvInfo.channels == 2)

+			sHeader.sampleSize /= 2;

+

+		addTrack(new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType));

+	}

+

+	// Ensure that we're at the end of the chunk

+	_fileStream->seek(startPos + strfSize);

+}

+

+void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {

+	if (_audStream) {

+		if (_wvInfo.tag == kWaveFormatZorkPCM) {

+			assert(_wvInfo.size == 8);

+			_audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES);

+		}

+	} else {

+		delete stream;

+	}

+}

+

+} // End of namespace ZVision

diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
new file mode 100644
index 0000000..f6b2ca7
--- /dev/null
+++ b/engines/zvision/zork_avi_decoder.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public 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 ZORK_AVI_DECODER_H

+#define ZORK_AVI_DECODER_H

+

+#include "video/avi_decoder.h"

+ 

+namespace ZVision {

+

+class ZorkAVIDecoder : public Video::AVIDecoder {

+public:

+	ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :

+	  Video::AVIDecoder(soundType) {}

+

+	  virtual ~ZorkAVIDecoder() {}

+

+private:

+	class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {

+	public:

+		ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :

+			Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {}

+		virtual ~ZorkAVIAudioTrack() {}

+

+		void queueSound(Common::SeekableReadStream *stream);

+	};

+

+	void handleStreamHeader();

+

+	private:

+		// Audio Codecs

+		enum {

+			kWaveFormatZorkPCM = 17	// special Zork PCM audio format (clashes with MS IMA ADPCM)

+		};

+};

+

+} // End of namespace ZVision

+ 

+#endif

diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
new file mode 100644
index 0000000..9332aeb
--- /dev/null
+++ b/engines/zvision/zork_raw.cpp
@@ -0,0 +1,186 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ *

+ */

+

+#include "common/endian.h"

+#include "common/memstream.h"

+#include "common/textconsole.h"

+#include "common/util.h"

+

+#include "audio/audiostream.h"

+

+#include "engines/zvision/zork_raw.h"

+

+namespace ZVision {

+

+#pragma mark -

+#pragma mark --- RawZorkStream ---

+#pragma mark -

+

+/**

+ * This is a stream, which allows for playing raw PCM data from a stream.

+ */

+class RawZorkStream : public Audio::SeekableAudioStream {

+public:

+	RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)

+		: _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) {

+		// Setup our buffer for readBuffer

+		_buffer = new byte[kSampleBufferLength];

+		assert(_buffer);

+

+		// Calculate the total playtime of the stream

+		_playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate);

+	}

+

+	~RawZorkStream() {

+		delete[] _buffer;

+	}

+

+	int readBuffer(int16 *buffer, const int numSamples);

+

+	bool isStereo() const  { return true; }

+	bool endOfData() const { return _endOfData; }

+

+	int getRate() const         { return _rate; }

+	Audio::Timestamp getLength() const { return _playtime; }

+

+	bool seek(const Audio::Timestamp &where);

+private:

+	const int _rate;                                           ///< Sample rate of stream

+	Audio::Timestamp _playtime;                                       ///< Calculated total play time

+	Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from

+	bool _endOfData;                                           ///< Whether the stream end has been reached

+

+	byte *_buffer;                                             ///< Buffer used in readBuffer

+	enum {

+		/**

+		 * How many samples we can buffer at once.

+		 *

+		 * TODO: Check whether this size suffices

+		 * for systems with slow disk I/O.

+		 */

+		kSampleBufferLength = 2048

+	};

+

+	/**

+	 * Fill the temporary sample buffer used in readBuffer.

+	 *

+	 * @param maxSamples Maximum samples to read.

+	 * @return actual count of samples read.

+	 */

+	int fillBuffer(int maxSamples);

+};

+

+int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {

+	int samplesLeft = numSamples;

+

+	while (samplesLeft > 0) {

+		// Try to read up to "samplesLeft" samples.

+		int len = fillBuffer(samplesLeft);

+

+		// In case we were not able to read any samples

+		// we will stop reading here.

+		if (!len)

+			break;

+

+		// Adjust the samples left to read.

+		samplesLeft -= len;

+

+		// Copy the data to the caller's buffer.

+		const byte *src = _buffer;

+		while (len-- > 0) {

+			if (*src < 128)

+				*buffer++ = ((128 - *src) << 8) ^ 0x8000;

+			else

+				*buffer++ = (*src << 8) ^ 0x8000;

+			src++;

+		}

+	}

+

+	return numSamples - samplesLeft;

+}

+

+int RawZorkStream::fillBuffer(int maxSamples) {

+	int bufferedSamples = 0;

+	byte *dst = _buffer;

+

+	// We can only read up to "kSampleBufferLength" samples

+	// so we take this into consideration, when trying to

+	// read up to maxSamples.

+	maxSamples = MIN<int>(kSampleBufferLength, maxSamples);

+

+	// We will only read up to maxSamples

+	while (maxSamples > 0 && !endOfData()) {

+		// Try to read all the sample data and update the

+		// destination pointer.

+		const int bytesRead = _stream->read(dst, maxSamples);

+		dst += bytesRead;

+

+		// Calculate how many samples we actually read.

+		const int samplesRead = bytesRead;

+

+		// Update all status variables

+		bufferedSamples += samplesRead;

+		maxSamples -= samplesRead;

+

+		// We stop stream playback, when we reached the end of the data stream.

+		// We also stop playback when an error occures.

+		if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos())

+			_endOfData = true;

+	}

+

+	return bufferedSamples;

+}

+

+bool RawZorkStream::seek(const Audio::Timestamp &where) {

+	_endOfData = true;

+

+	if (where > _playtime)

+		return false;

+

+	const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames();

+	_stream->seek(seekSample, SEEK_SET);

+

+	// In case of an error we will not continue stream playback.

+	if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size())

+		_endOfData = false;

+

+	return true;

+}

+

+#pragma mark -

+#pragma mark --- Raw stream factories ---

+#pragma mark -

+

+Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,

+                                   int rate,

+                                   DisposeAfterUse::Flag disposeAfterUse) {

+	assert(stream->size() % 2 == 0);

+	return new RawZorkStream(rate, disposeAfterUse, stream);

+}

+

+Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,

+                                   int rate,

+                                   DisposeAfterUse::Flag disposeAfterUse) {

+	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);

+}

+

+} // End of namespace Audio

diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
new file mode 100644
index 0000000..a8f8ce0
--- /dev/null
+++ b/engines/zvision/zork_raw.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public 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 ZVISION_ZORK_RAW_H

+#define ZVISION_ZORK_RAW_H

+

+#include "common/scummsys.h"

+#include "common/types.h"

+

+#include "common/list.h"

+

+

+namespace Common {

+class SeekableReadStream;

+}

+

+namespace ZVision {

+

+class SeekableAudioStream;

+

+/**

+ * Creates an audio stream, which plays from the given buffer.

+ *

+ * @param buffer Buffer to play from.

+ * @param size   Size of the buffer in bytes.

+ * @param rate   Rate of the sound data.

+ * @param disposeAfterUse Whether to free the buffer after use (with free!).

+ * @return The new SeekableAudioStream (or 0 on failure).

+ */

+Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,

+                                   int rate,

+                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

+

+/**

+ * Creates an audio stream, which plays from the given stream.

+ *

+ * @param stream Stream object to play from.

+ * @param rate   Rate of the sound data.

+ * @param disposeAfterUse Whether to delete the stream after use.

+ * @return The new SeekableAudioStream (or 0 on failure).

+ */

+Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,

+                                   int rate,

+                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

+

+} // End of namespace Audio

+

+#endif

diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
new file mode 100644
index 0000000..0e553e6
--- /dev/null
+++ b/engines/zvision/zvision.cpp
@@ -0,0 +1,217 @@
+#include "common/scummsys.h"

+ 

+#include "common/config-manager.h"

+#include "common/debug.h"

+#include "common/debug-channels.h"

+#include "common/error.h"

+#include "common/EventRecorder.h"

+#include "common/file.h"

+#include "common/fs.h"

+

+#include "audio/audiostream.h"

+#include "audio/mixer.h"

+

+#include "graphics/palette.h"

+#include "graphics/surface.h"

+#include "graphics/decoders/tga.h"

+

+#include "video/video_decoder.h"

+#include "video/avi_decoder.h"

+

+#include "engines/util.h"

+ 

+#include "zvision/zvision.h"

+#include "zvision/zork_avi_decoder.h"

+#include "zvision/zork_raw.h"

+

+namespace ZVision {

+ 

+ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {

+	// Put your engine in a sane state, but do nothing big yet;

+	// in particular, do not load data from files; rather, if you

+	// need to do such things, do them from run().

+ 

+	// Do not initialize graphics here

+ 

+	// However this is the place to specify all default directories

+	const Common::FSNode gameDataDir(ConfMan.get("path"));

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/asylum");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/castle");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/conserv");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/endgame");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global/venus");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global2");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global3");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/monast");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/temple");

+ 

+	// Here is the right place to set up the engine specific debug channels

+	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");

+	//DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");

+ 

+	// Don't forget to register your random source

+	_rnd = new Common::RandomSource("zvision");

+ 

+	debug("ZVision::ZVision");

+}

+ 

+ZVision::~ZVision() {

+	debug("ZVision::~ZVision");

+ 

+	// Dispose your resources here

+	delete _rnd;

+ 

+	// Remove all of our debug levels here

+	DebugMan.clearAllDebugChannels();

+}

+

+void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {

+	if (!videoDecoder)

+		return;

+

+	videoDecoder->start();

+

+	byte *scaleBuffer = 0;

+	byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;

+	uint16 width = videoDecoder->getWidth();

+	uint16 height = videoDecoder->getHeight();

+	uint16 pitch = videoDecoder->getWidth() * bytesPerPixel;

+	uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();

+	uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();

+

+	//videoState.fileName.toLowercase();

+

+	/*if (screenWidth == 640 && width <= 320 && height <= 240 && ((videoState.flags & kDoubled))) {

+		width *= 2;

+		height *= 2;

+		pitch *= 2;

+		scaleBuffer = new byte[width * height * bytesPerPixel];

+	}*/

+

+	uint16 x, y;

+

+	// Sanity check...

+	/*if (videoState.x > 0 && videoState.y > 0 && isVMD) {

+		x = videoState.x;

+		y = videoState.y;

+

+		if (x + width > screenWidth || y + height > screenHeight) {

+			// Happens in the Lighthouse demo

+			warning("VMD video won't fit on screen, centering it instead");

+			x = (screenWidth - width) / 2;

+			y = (screenHeight - height) / 2;

+		}

+	} else {*/

+		x = (screenWidth - width) / 2;

+		y = (screenHeight - height) / 2;

+	//}

+

+	bool skipVideo = false;

+

+	while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {

+		if (videoDecoder->needsUpdate()) {

+			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();

+

+			if (frame) {

+				if (scaleBuffer) {

+					// TODO: Perhaps reuse the relevant function from SCI?

+					//g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);

+					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);

+				} else {

+					g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);

+				}

+

+				g_system->updateScreen();

+			}

+		}

+

+		Common::Event event;

+		while (g_system->getEventManager()->pollEvent(event)) {

+			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)

+				skipVideo = true;

+		}

+

+		g_system->delayMillis(10);

+	}

+

+	delete[] scaleBuffer;

+	delete videoDecoder;

+}

+

+Common::Error ZVision::run() {

+	//Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);	// ARGB8888

+	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555

+	initGraphics(640, 480, true, &format);

+

+	// Create debugger console. It requires GFX to be initialized

+	_console = new Console(this);

+ 

+	// Additional setup.

+	debug("ZVision::init");

+ 

+	// Your main even loop should be (invoked from) here.

+	debug("ZVision::go: Hello, World!");

+ 

+	// This test will show up if -d1 and --debugflags=example are specified on the commandline

+	//debugC(1, kZVisionDebugExample, "Example debug call");

+ 

+	// This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline

+	//debugC(3, kZVisionDebugExample | kZVisionDebugExample2, "Example debug call two");

+

+#if 1

+	// Video test

+	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();

+	if (videoDecoder && videoDecoder->loadFile(/*"TD9EAZ1C.AVI"*/"T000A11C.AVI")) {

+		Common::List<Graphics::PixelFormat> formats;

+		formats.push_back(videoDecoder->getPixelFormat());

+		initGraphics(640, 480, true, formats);

+		

+		playVideo(videoDecoder);

+	}

+#endif

+

+	Common::File f;

+

+#if 1

+	// Image test

+	f.open("CB8EB11C.TGA");

+

+	Graphics::TGADecoder tga;

+	if (!tga.loadStream(f))

+		error("Error while reading TGA image");

+	f.close();

+

+	const Graphics::Surface *tgaSurface = tga.getSurface();

+

+	Graphics::Surface *screen = g_system->lockScreen();

+	for (uint16 y = 0; y < tgaSurface->h; y++)

+		memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);

+	g_system->unlockScreen();

+

+	tga.destroy();

+#endif

+

+#if 1

+	// Sound test

+	f.open("C000H9TC.RAW");

+	Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);

+	Audio::SoundHandle handle;

+	g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);

+#endif

+

+	// Main loop

+	Common::EventManager *eventMan = g_system->getEventManager();

+	Common::Event event;

+

+	while (!shouldQuit()) {

+		eventMan->pollEvent(event);	// eat events

+		g_system->updateScreen();

+		g_system->delayMillis(10);

+	}

+

+	return Common::kNoError;

+}

+ 

+} // End of namespace ZVision

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
new file mode 100644
index 0000000..c2a42f1
--- /dev/null
+++ b/engines/zvision/zvision.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.

+ *

+ *

+ */

+

+#ifndef ZVISION_H

+#define ZVISION_H

+ 

+#include "common/random.h"

+#include "engines/engine.h"

+#include "gui/debugger.h"

+ 

+namespace ZVision {

+

+struct ZVisionGameDescription;

+class Console;

+ 

+// our engine debug channels

+enum {

+	kZDebugExample = 1 << 0,

+	kZDebugExample2 = 1 << 1

+	// next new channel must be 1 << 2 (4)

+	// the current limitation is 32 debug channels (1 << 31 is the last one)

+};

+ 

+class ZVision : public Engine {

+public:

+	ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);

+	~ZVision();

+ 

+	uint32 getFeatures() const;

+	Common::Language getLanguage() const;

+	virtual Common::Error run();

+ 

+private:

+	Console *_console;

+	const ZVisionGameDescription *_gameDescription;

+

+	// We need random numbers

+	Common::RandomSource *_rnd;

+};

+ 

+// Example console class

+class Console : public GUI::Debugger {

+public:

+	Console(ZVision *vm) {}

+	virtual ~Console(void) {}

+};

+ 

+} // End of namespace ZVision

+ 

+#endif



Commit: 0303850bf7089637b34ae487855bca866d57b580
    https://github.com/scummvm/scummvm/commit/0303850bf7089637b34ae487855bca866d57b580
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:30:32-07:00

Commit Message:
ZVISION: Allow detection to go off inner directory

Game detection needs to be off an actual resource, but all the resources
are in subdirectories. This updates the code to search for the specific
subdirectory.

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



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 345138b..f8ed6a7 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -68,7 +68,7 @@ static const ZVisionGameDescription gameDescriptions[] = {
 			0,

 			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),

 			Common::EN_ANY,

-			Common::kPlatformWindows,

+			Common::kPlatformDOS,

 			ADGF_NO_FLAGS,

 			GUIO1(GUIO_NONE)

 		},

@@ -79,6 +79,11 @@ static const ZVisionGameDescription gameDescriptions[] = {
 

 } // End of namespace ZVision

 

+static const char *directoryGlobs[] = {
+	"znemscr",
+	0
+};

+

 static const ExtraGuiOption ZVisionExtraGuiOption = {

 	_s("Use original save/load screens"),

 	_s("Use the original save/load screens, instead of the ScummVM ones"),

@@ -89,6 +94,8 @@ static const ExtraGuiOption ZVisionExtraGuiOption = {
 class ZVisionMetaEngine : public AdvancedMetaEngine {

 public:

 	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {

+		_maxScanDepth = 2;

+		_directoryGlobs = directoryGlobs;

 		_singleid = "zvision";

 	}

 

diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0e553e6..d291cab 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -35,17 +35,11 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine
  

 	// However this is the place to specify all default directories

 	const Common::FSNode gameDataDir(ConfMan.get("path"));

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/asylum");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/castle");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/conserv");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/endgame");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global/venus");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global2");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/global3");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/monast");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets/temple");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data1");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data2");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data3");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");

  

 	// Here is the right place to set up the engine specific debug channels

 	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");

@@ -160,10 +154,18 @@ Common::Error ZVision::run() {
 	// This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline

 	//debugC(3, kZVisionDebugExample | kZVisionDebugExample2, "Example debug call two");

 

+	Common::File file;

+

+	if (file.open("ADLIB.MDI")) {

+		file.close();

+	}

+

+

+

 #if 1

 	// Video test

 	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();

-	if (videoDecoder && videoDecoder->loadFile(/*"TD9EAZ1C.AVI"*/"T000A11C.AVI")) {

+	if (videoDecoder && videoDecoder->loadFile("ZASSETS/TEMPLE/T000A11C.AVI")) {

 		Common::List<Graphics::PixelFormat> formats;

 		formats.push_back(videoDecoder->getPixelFormat());

 		initGraphics(640, 480, true, formats);

@@ -176,29 +178,33 @@ Common::Error ZVision::run() {
 

 #if 1

 	// Image test

-	f.open("CB8EB11C.TGA");

+	if (f.open("zassets/castle/CB8EB11C.TGA")) {

+		Graphics::TGADecoder tga;

+		if (!tga.loadStream(f))

+			error("Error while reading TGA image");

+		f.close();

 

-	Graphics::TGADecoder tga;

-	if (!tga.loadStream(f))

-		error("Error while reading TGA image");

-	f.close();

+		const Graphics::Surface *tgaSurface = tga.getSurface();

 

-	const Graphics::Surface *tgaSurface = tga.getSurface();

+		Graphics::Surface *screen = g_system->lockScreen();

+		for (uint16 y = 0; y < tgaSurface->h; y++)

+			memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);

+		g_system->unlockScreen();

 

-	Graphics::Surface *screen = g_system->lockScreen();

-	for (uint16 y = 0; y < tgaSurface->h; y++)

-		memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);

-	g_system->unlockScreen();

+		tga.destroy();

+	}

 

-	tga.destroy();

+	

 #endif

 

 #if 1

 	// Sound test

-	f.open("C000H9TC.RAW");

-	Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);

-	Audio::SoundHandle handle;

-	g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);

+	if (f.open("zassets/castle/C000H9TC.RAW")) {

+		Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);

+		Audio::SoundHandle handle;

+		g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);

+	}

+	

 #endif

 

 	// Main loop



Commit: 5d64107ff3c22324080e2a151a88c49e1ee6cb9d
    https://github.com/scummvm/scummvm/commit/5d64107ff3c22324080e2a151a88c49e1ee6cb9d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:40-07:00

Commit Message:
ZVISION: normalized file endings

Changed paths:
    engines/zvision/detection.cpp



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index f8ed6a7..5488ae5 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -1,256 +1,256 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- *

- */

-

-#include "base/plugins.h"

-

-#include "engines/advancedDetector.h"

-

-#include "common/translation.h"

-#include "common/savefile.h"

-#include "common/str-array.h"

-#include "common/system.h"

-

-#include "zvision/zvision.h"

-

-

-namespace ZVision {

-

-struct ZVisionGameDescription {

-	ADGameDescription desc;

-};

-

-uint32 ZVision::getFeatures() const {

-	return _gameDescription->desc.flags;

-}

-

-Common::Language ZVision::getLanguage() const {

-	return _gameDescription->desc.language;

-}

-

-}

-

-static const PlainGameDescriptor zVisionGames[] = {

-	{"zvision",  "ZVision Game"},

-	{"znemesis", "Zork Nemesis: The Forbidden Lands"},

-	{"zgi",      "Zork: Grand Inquisitor"},

-	{0, 0}

-};

-

-

-namespace ZVision {

-

-static const ZVisionGameDescription gameDescriptions[] = {

-

-	{

-		// Zork Nemesis English version

-		{

-			"znemesis",

-			0,

-			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),

-			Common::EN_ANY,

-			Common::kPlatformDOS,

-			ADGF_NO_FLAGS,

-			GUIO1(GUIO_NONE)

-		},

-	},

-

-	{ AD_TABLE_END_MARKER }

-};

-

-} // End of namespace ZVision

-

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+
+#include "common/translation.h"
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/system.h"
+
+#include "zvision/zvision.h"
+
+
+namespace ZVision {
+
+struct ZVisionGameDescription {
+	ADGameDescription desc;
+};
+
+uint32 ZVision::getFeatures() const {
+	return _gameDescription->desc.flags;
+}
+
+Common::Language ZVision::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
+}
+
+static const PlainGameDescriptor zVisionGames[] = {
+	{"zvision",  "ZVision Game"},
+	{"znemesis", "Zork Nemesis: The Forbidden Lands"},
+	{"zgi",      "Zork: Grand Inquisitor"},
+	{0, 0}
+};
+
+
+namespace ZVision {
+
+static const ZVisionGameDescription gameDescriptions[] = {
+
+	{
+		// Zork Nemesis English version
+		{
+			"znemesis",
+			0,
+			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+	},
+
+	{ AD_TABLE_END_MARKER }
+};
+
+} // End of namespace ZVision
+
 static const char *directoryGlobs[] = {
 	"znemscr",
 	0
-};

-

-static const ExtraGuiOption ZVisionExtraGuiOption = {

-	_s("Use original save/load screens"),

-	_s("Use the original save/load screens, instead of the ScummVM ones"),

-	"originalsaveload",

-	false

-};

-

-class ZVisionMetaEngine : public AdvancedMetaEngine {

-public:

-	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {

-		_maxScanDepth = 2;

-		_directoryGlobs = directoryGlobs;

-		_singleid = "zvision";

-	}

-

-	virtual const char *getName() const {

-		return "ZVision";

-	}

-

-	virtual const char *getOriginalCopyright() const {

-		return "ZVision Activision (C) 1996";

-	}

-

-	virtual bool hasFeature(MetaEngineFeature f) const;

-	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;

-	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {

-	return false;

-		/*

-		(f == kSupportsListSaves) ||

-		(f == kSupportsLoadingDuringStartup) ||

-		(f == kSupportsDeleteSave) ||

-		(f == kSavesSupportMetaInfo) ||

-		(f == kSavesSupportThumbnail) ||

-		(f == kSavesSupportCreationDate) ||

-		(f == kSavesSupportPlayTime);

-		*/

-}

-

-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {

-	return

-		(f == kSupportsRTL) ||

-		(f == kSupportsLoadingDuringRuntime) ||

-		(f == kSupportsSavingDuringRuntime);

-}*/

-

-bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {

-	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;

-	if (gd) {

-		*engine = new ZVision::ZVision(syst, gd);

-	}

-	return gd != 0;

-}

-

-const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {

-	ExtraGuiOptions options;

-	options.push_back(ZVisionExtraGuiOption);

-	return options;

-}

-

-SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {

-	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

-	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {

-					saveList.push_back(SaveStateDescriptor(slotNum, header.description));

-				}

-				delete in;

-			}

-		}

-	}*/

-

-	return saveList;

-}

-

-int ZVisionMetaEngine::getMaximumSaveSlot() const {

-	return 999;

-}

-

-void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {

-	/*

-	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

-	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);

-		}

-	}

-	*/

-}

-

-SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {

-	/*

-	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);

-	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());

-

-	if (in) {

-		ZVision::ZVision::SaveHeader header;

-		ZVision::ZVision::kReadSaveHeaderError error;

-

-		error = ZVision::ZVision::readSaveHeader(in, true, header);

-		delete in;

-

-		if (error == ZVision::ZVision::kRSHENoError) {

-			SaveStateDescriptor desc(slot, header.description);

-

-			desc.setThumbnail(header.thumbnail);

-

-			if (header.version > 0) {

-				int day = (header.saveDate >> 24) & 0xFF;

-				int month = (header.saveDate >> 16) & 0xFF;

-				int year = header.saveDate & 0xFFFF;

-

-				desc.setSaveDate(year, month, day);

-

-				int hour = (header.saveTime >> 16) & 0xFF;

-				int minutes = (header.saveTime >> 8) & 0xFF;

-

-				desc.setSaveTime(hour, minutes);

-

-				desc.setPlayTime(header.playTime * 1000);

-			}

-

-			return desc;

-		}

-	}

-	*/

-

-	return SaveStateDescriptor();

-}

-

-#if PLUGIN_ENABLED_DYNAMIC(ZVISION)

-	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

-#else

-	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

-#endif

+};
+
+static const ExtraGuiOption ZVisionExtraGuiOption = {
+	_s("Use original save/load screens"),
+	_s("Use the original save/load screens, instead of the ScummVM ones"),
+	"originalsaveload",
+	false
+};
+
+class ZVisionMetaEngine : public AdvancedMetaEngine {
+public:
+	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
+		_maxScanDepth = 2;
+		_directoryGlobs = directoryGlobs;
+		_singleid = "zvision";
+	}
+
+	virtual const char *getName() const {
+		return "ZVision";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "ZVision Activision (C) 1996";
+	}
+
+	virtual bool hasFeature(MetaEngineFeature f) const;
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return false;
+		/*
+		(f == kSupportsListSaves) ||
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsDeleteSave) ||
+		(f == kSavesSupportMetaInfo) ||
+		(f == kSavesSupportThumbnail) ||
+		(f == kSavesSupportCreationDate) ||
+		(f == kSavesSupportPlayTime);
+		*/
+}
+
+/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsLoadingDuringRuntime) ||
+		(f == kSupportsSavingDuringRuntime);
+}*/
+
+bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
+	if (gd) {
+		*engine = new ZVision::ZVision(syst, gd);
+	}
+	return gd != 0;
+}
+
+const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
+	ExtraGuiOptions options;
+	options.push_back(ZVisionExtraGuiOption);
+	return options;
+}
+
+SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
+	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
+					saveList.push_back(SaveStateDescriptor(slotNum, header.description));
+				}
+				delete in;
+			}
+		}
+	}*/
+
+	return saveList;
+}
+
+int ZVisionMetaEngine::getMaximumSaveSlot() const {
+	return 999;
+}
+
+void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
+	/*
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);
+		}
+	}
+	*/
+}
+
+SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	/*
+	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+	if (in) {
+		ZVision::ZVision::SaveHeader header;
+		ZVision::ZVision::kReadSaveHeaderError error;
+
+		error = ZVision::ZVision::readSaveHeader(in, true, header);
+		delete in;
+
+		if (error == ZVision::ZVision::kRSHENoError) {
+			SaveStateDescriptor desc(slot, header.description);
+
+			desc.setThumbnail(header.thumbnail);
+
+			if (header.version > 0) {
+				int day = (header.saveDate >> 24) & 0xFF;
+				int month = (header.saveDate >> 16) & 0xFF;
+				int year = header.saveDate & 0xFFFF;
+
+				desc.setSaveDate(year, month, day);
+
+				int hour = (header.saveTime >> 16) & 0xFF;
+				int minutes = (header.saveTime >> 8) & 0xFF;
+
+				desc.setSaveTime(hour, minutes);
+
+				desc.setPlayTime(header.playTime * 1000);
+			}
+
+			return desc;
+		}
+	}
+	*/
+
+	return SaveStateDescriptor();
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
+	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#endif


Commit: 8ae85892d60d502c582b43b5b6b77af2baccc739
    https://github.com/scummvm/scummvm/commit/8ae85892d60d502c582b43b5b6b77af2baccc739
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:41-07:00

Commit Message:
ZVISION: Alter video handling to follow the new video audio track wrapper.

Commit 7a49802c01b0c39be4e86335689db8f3359fde68 created an audio track
hook that allows video decoding to use a differnt audio track encoding method

Also, re-normalize line endings

Changed paths:
    engines/zvision/detection.cpp
    engines/zvision/zork_avi_decoder.cpp
    engines/zvision/zork_avi_decoder.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 5488ae5..62d834a 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -1,256 +1,256 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- */
-
-#include "base/plugins.h"
-
-#include "engines/advancedDetector.h"
-
-#include "common/translation.h"
-#include "common/savefile.h"
-#include "common/str-array.h"
-#include "common/system.h"
-
-#include "zvision/zvision.h"
-
-
-namespace ZVision {
-
-struct ZVisionGameDescription {
-	ADGameDescription desc;
-};
-
-uint32 ZVision::getFeatures() const {
-	return _gameDescription->desc.flags;
-}
-
-Common::Language ZVision::getLanguage() const {
-	return _gameDescription->desc.language;
-}
-
-}
-
-static const PlainGameDescriptor zVisionGames[] = {
-	{"zvision",  "ZVision Game"},
-	{"znemesis", "Zork Nemesis: The Forbidden Lands"},
-	{"zgi",      "Zork: Grand Inquisitor"},
-	{0, 0}
-};
-
-
-namespace ZVision {
-
-static const ZVisionGameDescription gameDescriptions[] = {
-
-	{
-		// Zork Nemesis English version
-		{
-			"znemesis",
-			0,
-			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),
-			Common::EN_ANY,
-			Common::kPlatformDOS,
-			ADGF_NO_FLAGS,
-			GUIO1(GUIO_NONE)
-		},
-	},
-
-	{ AD_TABLE_END_MARKER }
-};
-
-} // End of namespace ZVision
-
-static const char *directoryGlobs[] = {
-	"znemscr",
-	0
-};
-
-static const ExtraGuiOption ZVisionExtraGuiOption = {
-	_s("Use original save/load screens"),
-	_s("Use the original save/load screens, instead of the ScummVM ones"),
-	"originalsaveload",
-	false
-};
-
-class ZVisionMetaEngine : public AdvancedMetaEngine {
-public:
-	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
-		_maxScanDepth = 2;
-		_directoryGlobs = directoryGlobs;
-		_singleid = "zvision";
-	}
-
-	virtual const char *getName() const {
-		return "ZVision";
-	}
-
-	virtual const char *getOriginalCopyright() const {
-		return "ZVision Activision (C) 1996";
-	}
-
-	virtual bool hasFeature(MetaEngineFeature f) const;
-	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
-	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
-	return false;
-		/*
-		(f == kSupportsListSaves) ||
-		(f == kSupportsLoadingDuringStartup) ||
-		(f == kSupportsDeleteSave) ||
-		(f == kSavesSupportMetaInfo) ||
-		(f == kSavesSupportThumbnail) ||
-		(f == kSavesSupportCreationDate) ||
-		(f == kSavesSupportPlayTime);
-		*/
-}
-
-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
-	return
-		(f == kSupportsRTL) ||
-		(f == kSupportsLoadingDuringRuntime) ||
-		(f == kSupportsSavingDuringRuntime);
-}*/
-
-bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
-	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
-	if (gd) {
-		*engine = new ZVision::ZVision(syst, gd);
-	}
-	return gd != 0;
-}
-
-const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
-	ExtraGuiOptions options;
-	options.push_back(ZVisionExtraGuiOption);
-	return options;
-}
-
-SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
-	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
-					saveList.push_back(SaveStateDescriptor(slotNum, header.description));
-				}
-				delete in;
-			}
-		}
-	}*/
-
-	return saveList;
-}
-
-int ZVisionMetaEngine::getMaximumSaveSlot() const {
-	return 999;
-}
-
-void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
-	/*
-	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);
-		}
-	}
-	*/
-}
-
-SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
-	/*
-	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
-	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
-
-	if (in) {
-		ZVision::ZVision::SaveHeader header;
-		ZVision::ZVision::kReadSaveHeaderError error;
-
-		error = ZVision::ZVision::readSaveHeader(in, true, header);
-		delete in;
-
-		if (error == ZVision::ZVision::kRSHENoError) {
-			SaveStateDescriptor desc(slot, header.description);
-
-			desc.setThumbnail(header.thumbnail);
-
-			if (header.version > 0) {
-				int day = (header.saveDate >> 24) & 0xFF;
-				int month = (header.saveDate >> 16) & 0xFF;
-				int year = header.saveDate & 0xFFFF;
-
-				desc.setSaveDate(year, month, day);
-
-				int hour = (header.saveTime >> 16) & 0xFF;
-				int minutes = (header.saveTime >> 8) & 0xFF;
-
-				desc.setSaveTime(hour, minutes);
-
-				desc.setPlayTime(header.playTime * 1000);
-			}
-
-			return desc;
-		}
-	}
-	*/
-
-	return SaveStateDescriptor();
-}
-
-#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
-	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
-#else
-	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
-#endif
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ *

+ *

+ */

+

+#include "base/plugins.h"

+

+#include "engines/advancedDetector.h"

+

+#include "common/translation.h"

+#include "common/savefile.h"

+#include "common/str-array.h"

+#include "common/system.h"

+

+#include "zvision/zvision.h"

+

+

+namespace ZVision {

+

+struct ZVisionGameDescription {

+	ADGameDescription desc;

+};

+

+uint32 ZVision::getFeatures() const {

+	return _gameDescription->desc.flags;

+}

+

+Common::Language ZVision::getLanguage() const {

+	return _gameDescription->desc.language;

+}

+

+}

+

+static const PlainGameDescriptor zVisionGames[] = {

+	{"zvision",  "ZVision Game"},

+	{"znemesis", "Zork Nemesis: The Forbidden Lands"},

+	{"zgi",      "Zork: Grand Inquisitor"},

+	{0, 0}

+};

+

+

+namespace ZVision {

+

+static const ZVisionGameDescription gameDescriptions[] = {

+

+	{

+		// Zork Nemesis English version

+		{

+			"znemesis",

+			0,

+			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),

+			Common::EN_ANY,

+			Common::kPlatformDOS,

+			ADGF_NO_FLAGS,

+			GUIO1(GUIO_NONE)

+		},

+	},

+

+	{ AD_TABLE_END_MARKER }

+};

+

+} // End of namespace ZVision

+

+static const char *directoryGlobs[] = {

+	"znemscr",

+	0

+};

+

+static const ExtraGuiOption ZVisionExtraGuiOption = {

+	_s("Use original save/load screens"),

+	_s("Use the original save/load screens, instead of the ScummVM ones"),

+	"originalsaveload",

+	false

+};

+

+class ZVisionMetaEngine : public AdvancedMetaEngine {

+public:

+	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {

+		_maxScanDepth = 2;

+		_directoryGlobs = directoryGlobs;

+		_singleid = "zvision";

+	}

+

+	virtual const char *getName() const {

+		return "ZVision";

+	}

+

+	virtual const char *getOriginalCopyright() const {

+		return "ZVision Activision (C) 1996";

+	}

+

+	virtual bool hasFeature(MetaEngineFeature f) const;

+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;

+	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {

+	return false;

+		/*

+		(f == kSupportsListSaves) ||

+		(f == kSupportsLoadingDuringStartup) ||

+		(f == kSupportsDeleteSave) ||

+		(f == kSavesSupportMetaInfo) ||

+		(f == kSavesSupportThumbnail) ||

+		(f == kSavesSupportCreationDate) ||

+		(f == kSavesSupportPlayTime);

+		*/

+}

+

+/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {

+	return

+		(f == kSupportsRTL) ||

+		(f == kSupportsLoadingDuringRuntime) ||

+		(f == kSupportsSavingDuringRuntime);

+}*/

+

+bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {

+	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;

+	if (gd) {

+		*engine = new ZVision::ZVision(syst, gd);

+	}

+	return gd != 0;

+}

+

+const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {

+	ExtraGuiOptions options;

+	options.push_back(ZVisionExtraGuiOption);

+	return options;

+}

+

+SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {

+	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

+	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {

+					saveList.push_back(SaveStateDescriptor(slotNum, header.description));

+				}

+				delete in;

+			}

+		}

+	}*/

+

+	return saveList;

+}

+

+int ZVisionMetaEngine::getMaximumSaveSlot() const {

+	return 999;

+}

+

+void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {

+	/*

+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

+	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);

+		}

+	}

+	*/

+}

+

+SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {

+	/*

+	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);

+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());

+

+	if (in) {

+		ZVision::ZVision::SaveHeader header;

+		ZVision::ZVision::kReadSaveHeaderError error;

+

+		error = ZVision::ZVision::readSaveHeader(in, true, header);

+		delete in;

+

+		if (error == ZVision::ZVision::kRSHENoError) {

+			SaveStateDescriptor desc(slot, header.description);

+

+			desc.setThumbnail(header.thumbnail);

+

+			if (header.version > 0) {

+				int day = (header.saveDate >> 24) & 0xFF;

+				int month = (header.saveDate >> 16) & 0xFF;

+				int year = header.saveDate & 0xFFFF;

+

+				desc.setSaveDate(year, month, day);

+

+				int hour = (header.saveTime >> 16) & 0xFF;

+				int minutes = (header.saveTime >> 8) & 0xFF;

+

+				desc.setSaveTime(hour, minutes);

+

+				desc.setPlayTime(header.playTime * 1000);

+			}

+

+			return desc;

+		}

+	}

+	*/

+

+	return SaveStateDescriptor();

+}

+

+#if PLUGIN_ENABLED_DYNAMIC(ZVISION)

+	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

+#else

+	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

+#endif

diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index 9bcc163..b0524c7 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -29,97 +29,9 @@
 

 namespace ZVision {

 

-// Redefinitions from avi_decoder.cpp

-#define ID_VIDS MKTAG('v','i','d','s')

-#define ID_TXTS MKTAG('t','x','t','s')

-#define ID_STRF MKTAG('s','t','r','f')

-#define ID_AUDS MKTAG('a','u','d','s')

-#define ID_MIDS MKTAG('m','i','d','s')

-

-// Copied off AVIDecoder::handleStreamHeader()

-void ZorkAVIDecoder::handleStreamHeader() {

-	AVIStreamHeader sHeader;

-	sHeader.size = _fileStream->readUint32LE();

-	sHeader.streamType = _fileStream->readUint32BE();

-

-	if (sHeader.streamType == ID_MIDS || sHeader.streamType == ID_TXTS)

-		error("Unhandled MIDI/Text stream");

-

-	sHeader.streamHandler = _fileStream->readUint32BE();

-	sHeader.flags = _fileStream->readUint32LE();

-	sHeader.priority = _fileStream->readUint16LE();

-	sHeader.language = _fileStream->readUint16LE();

-	sHeader.initialFrames = _fileStream->readUint32LE();

-	sHeader.scale = _fileStream->readUint32LE();

-	sHeader.rate = _fileStream->readUint32LE();

-	sHeader.start = _fileStream->readUint32LE();

-	sHeader.length = _fileStream->readUint32LE();

-	sHeader.bufferSize = _fileStream->readUint32LE();

-	sHeader.quality = _fileStream->readUint32LE();

-	sHeader.sampleSize = _fileStream->readUint32LE();

-

-	_fileStream->skip(sHeader.size - 48); // Skip over the remainder of the chunk (frame)

-

-	if (_fileStream->readUint32BE() != ID_STRF)

-		error("Could not find STRF tag");

-

-	uint32 strfSize = _fileStream->readUint32LE();

-	uint32 startPos = _fileStream->pos();

-

-	if (sHeader.streamType == ID_VIDS) {

-		BitmapInfoHeader bmInfo;

-		bmInfo.size = _fileStream->readUint32LE();

-		bmInfo.width = _fileStream->readUint32LE();

-		bmInfo.height = _fileStream->readUint32LE();

-		bmInfo.planes = _fileStream->readUint16LE();

-		bmInfo.bitCount = _fileStream->readUint16LE();

-		bmInfo.compression = _fileStream->readUint32BE();

-		bmInfo.sizeImage = _fileStream->readUint32LE();

-		bmInfo.xPelsPerMeter = _fileStream->readUint32LE();

-		bmInfo.yPelsPerMeter = _fileStream->readUint32LE();

-		bmInfo.clrUsed = _fileStream->readUint32LE();

-		bmInfo.clrImportant = _fileStream->readUint32LE();

-

-		if (bmInfo.clrUsed == 0)

-			bmInfo.clrUsed = 256;

-

-		if (sHeader.streamHandler == 0)

-			sHeader.streamHandler = bmInfo.compression;

-

-		AVIVideoTrack *track = new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo);

-

-		if (bmInfo.bitCount == 8) {

-			byte *palette = const_cast<byte *>(track->getPalette());

-			for (uint32 i = 0; i < bmInfo.clrUsed; i++) {

-				palette[i * 3 + 2] = _fileStream->readByte();

-				palette[i * 3 + 1] = _fileStream->readByte();

-				palette[i * 3] = _fileStream->readByte();

-				_fileStream->readByte();

-			}

-

-			track->markPaletteDirty();

-		}

-

-		addTrack(track);

-	} else if (sHeader.streamType == ID_AUDS) {

-		PCMWaveFormat wvInfo;

-		wvInfo.tag = _fileStream->readUint16LE();

-		wvInfo.channels = _fileStream->readUint16LE();

-		wvInfo.samplesPerSec = _fileStream->readUint32LE();

-		wvInfo.avgBytesPerSec = _fileStream->readUint32LE();

-		wvInfo.blockAlign = _fileStream->readUint16LE();

-		wvInfo.size = _fileStream->readUint16LE();

-

-		// AVI seems to treat the sampleSize as including the second

-		// channel as well, so divide for our sake.

-		if (wvInfo.channels == 2)

-			sHeader.sampleSize /= 2;

-

-		addTrack(new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType));

-	}

-

-	// Ensure that we're at the end of the chunk

-	_fileStream->seek(startPos + strfSize);

+Video::AVIDecoder::AVIAudioTrack *ZVision::ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {

+	ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);

+	return (Video::AVIDecoder::AVIAudioTrack *)audioTrack;

 }

 

 void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {

diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index f6b2ca7..5530d92 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -45,7 +45,7 @@ private:
 		void queueSound(Common::SeekableReadStream *stream);

 	};

 

-	void handleStreamHeader();

+	Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);

 

 	private:

 		// Audio Codecs

diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index d291cab..1a72ea0 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -61,6 +61,45 @@ ZVision::~ZVision() {
 	DebugMan.clearAllDebugChannels();

 }

 

+// Taken from SCI

+void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {

+	assert(bytesPerPixel == 1 || bytesPerPixel == 2);

+	const int newWidth = srcWidth * 2;

+	const int pitch = newWidth * bytesPerPixel;

+	const byte *srcPtr = src;

+

+	if (bytesPerPixel == 1) {

+		for (int y = 0; y < srcHeight; y++) {

+			for (int x = 0; x < srcWidth; x++) {

+				const byte color = *srcPtr++;

+				dst[0] = color;

+				dst[1] = color;

+				dst[newWidth] = color;

+				dst[newWidth + 1] = color;

+				dst += 2;

+			}

+			dst += newWidth;

+		}

+	} else if (bytesPerPixel == 2) {

+		for (int y = 0; y < srcHeight; y++) {

+			for (int x = 0; x < srcWidth; x++) {

+				const byte color = *srcPtr++;

+				const byte color2 = *srcPtr++;

+				dst[0] = color;

+				dst[1] = color2;

+				dst[2] = color;

+				dst[3] = color2;

+				dst[pitch] = color;

+				dst[pitch + 1] = color2;

+				dst[pitch + 2] = color;

+				dst[pitch + 3] = color2;

+				dst += 4;

+			}

+			dst += pitch;

+		}

+	}

+}

+

 void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {

 	if (!videoDecoder)

 		return;

@@ -75,32 +114,19 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
 	uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();

 	uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();

 

-	//videoState.fileName.toLowercase();

+	bool zoom2x = true;

 

-	/*if (screenWidth == 640 && width <= 320 && height <= 240 && ((videoState.flags & kDoubled))) {

+	if (zoom2x) {

 		width *= 2;

 		height *= 2;

 		pitch *= 2;

 		scaleBuffer = new byte[width * height * bytesPerPixel];

-	}*/

+	}

 

 	uint16 x, y;

 

-	// Sanity check...

-	/*if (videoState.x > 0 && videoState.y > 0 && isVMD) {

-		x = videoState.x;

-		y = videoState.y;

-

-		if (x + width > screenWidth || y + height > screenHeight) {

-			// Happens in the Lighthouse demo

-			warning("VMD video won't fit on screen, centering it instead");

-			x = (screenWidth - width) / 2;

-			y = (screenHeight - height) / 2;

-		}

-	} else {*/

-		x = (screenWidth - width) / 2;

-		y = (screenHeight - height) / 2;

-	//}

+	x = (screenWidth - width) / 2;

+	y = (screenHeight - height) / 2;

 

 	bool skipVideo = false;

 

@@ -110,8 +136,7 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
 

 			if (frame) {

 				if (scaleBuffer) {

-					// TODO: Perhaps reuse the relevant function from SCI?

-					//g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);

+					scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);

 					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);

 				} else {

 					g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);

@@ -178,6 +203,9 @@ Common::Error ZVision::run() {
 

 #if 1

 	// Image test

+	

+	initGraphics(640, 480, true, &format);

+	

 	if (f.open("zassets/castle/CB8EB11C.TGA")) {

 		Graphics::TGADecoder tga;

 		if (!tga.loadStream(f))



Commit: 179f5de49897a723b2605a0fed18980ce144f68c
    https://github.com/scummvm/scummvm/commit/179f5de49897a723b2605a0fed18980ce144f68c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:42-07:00

Commit Message:
ZVISION: Add support for ZFS archive files

ZfsArchive implements Common::Archive.

Changed paths:
  A engines/zvision/zfsArchive.cpp
  A engines/zvision/zfsArchive.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/zfsArchive.cpp b/engines/zvision/zfsArchive.cpp
new file mode 100644
index 0000000..a3111d7
--- /dev/null
+++ b/engines/zvision/zfsArchive.cpp
@@ -0,0 +1,144 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "zfsArchive.h"
+#include "common/hashmap.h"
+#include "common/memstream.h"
+#include "common/debug.h"
+
+namespace ZVision {
+
+ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
+	Common::File zfsFile;
+
+	if (!zfsFile.open(_fileName)) {
+		warning("ZFSArchive::ZFSArchive(): Could not find the archive file");
+		return;
+	}
+
+	readHeaders(&zfsFile);
+
+	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+}
+
+ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) {
+	readHeaders(stream);
+
+	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+}
+
+ZfsArchive::~ZfsArchive() {
+	debug(0, "ZfsArchive Destructor Called");
+	ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
+	for ( ; it != _entryHeaders.end(); ++it) {
+		delete it->_value;
+	}
+}
+
+void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
+	ZfsHeader header;
+
+	// Don't do a straight struct cast since we can't guarantee endianness
+	header.magic = stream->readUint32LE();
+	header.unknown1 = stream->readUint32LE();
+	header.unknown2 = stream->readUint32LE();
+	header.filesPerBlock = stream->readUint32LE();
+	header.fileCount = stream->readUint32LE();
+	header.xorKey = stream->readUint32LE();
+	header.fileSectionOffset = stream->readUint32LE();
+
+	uint32 nextOffset;
+
+	do {
+		// Read the offset to the next block
+		nextOffset = stream->readUint32LE();
+
+		// Read in each entry header
+		for (int i = 0; i < header.filesPerBlock; i++) {
+			ZfsEntryHeader entryHeader;
+			
+			entryHeader.name = readEntryName(stream);
+			entryHeader.offset = stream->readUint32LE();
+			entryHeader.id = stream->readUint32LE();
+			entryHeader.size = stream->readUint32LE();
+			entryHeader.time = stream->readUint32LE();
+			entryHeader.unknown = stream->readUint32LE();
+
+			if (entryHeader.size != 0)
+				_entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader);
+		}
+
+		// Seek to the next block of headers
+		stream->seek(nextOffset);
+	} while (nextOffset != 0);
+}
+
+Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const {
+	// Entry Names are at most 16 bytes and are null padded
+	char buffer[16];
+	stream->read(buffer, 16);
+
+	return Common::String(buffer);
+}
+
+bool ZfsArchive::hasFile(const Common::String &name) const {
+	return _entryHeaders.contains(name);
+}
+
+int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const {
+	int matches = 0;
+
+	for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) {
+		list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this)));
+		matches++;
+	}
+
+	return matches;
+}
+
+const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const {
+	if (!_entryHeaders.contains(name))
+		return Common::ArchiveMemberPtr();
+
+	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
+}
+
+Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const {
+	if (!_entryHeaders.contains(name)) {
+		return 0;
+	}
+
+	ZfsEntryHeader *entryHeader = _entryHeaders[name];
+
+	Common::File zfsArchive;
+	zfsArchive.open(_fileName);
+	zfsArchive.seek(entryHeader->offset);
+
+	byte* buffer = new byte[entryHeader->size];
+	zfsArchive.read(buffer, entryHeader->size);
+
+	return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
+}
+
+} // End namespace ZVision
+
+
diff --git a/engines/zvision/zfsArchive.h b/engines/zvision/zfsArchive.h
new file mode 100644
index 0000000..96c002f
--- /dev/null
+++ b/engines/zvision/zfsArchive.h
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_ZFS_ARCHIVE_H
+#define ZVISION_ZFS_ARCHIVE_H
+
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+namespace ZVision {
+
+struct ZfsHeader {
+	uint32 magic;
+	uint32 unknown1;
+	uint32 unknown2;
+	uint32 filesPerBlock;
+	uint32 fileCount;
+	uint32 xorKey;
+	uint32 fileSectionOffset;
+};
+
+struct ZfsEntryHeader {
+	Common::String name;
+	uint32 offset;
+	uint32 id;
+	uint32 size;
+	uint32 time;
+	uint32 unknown;
+};
+
+typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
+
+class ZfsArchive : public Common::Archive {
+public:
+	ZfsArchive(const Common::String &fileName);
+	ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream);
+	~ZfsArchive();
+
+	/**
+	 * Check if a member with the given name is present in the Archive.
+	 * Patterns are not allowed, as this is meant to be a quick File::exists()
+	 * replacement.
+	 */
+	bool hasFile(const Common::String &fileName) const;
+
+	/**
+	 * Add all members of the Archive to list.
+	 * Must only append to list, and not remove elements from it.
+	 *
+	 * @return the number of names added to list
+	 */
+	int listMembers(Common::ArchiveMemberList &list) const;
+
+	/**
+	 * Returns a ArchiveMember representation of the given file.
+	 */
+	const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
+
+	/**
+	 * Create a stream bound to a member with the specified name in the
+	 * archive. If no member with this name exists, 0 is returned.
+	 * @return the newly created input stream
+	 */
+	Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
+
+private:
+	const Common::String _fileName;
+	ZfsEntryHeaderMap _entryHeaders;
+
+	void readHeaders(Common::SeekableReadStream *stream);
+	Common::String readEntryName(Common::SeekableReadStream *stream) const;
+};
+
+} // End of namespace Common
+
+#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 1a72ea0..b347782 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -21,6 +21,7 @@
 #include "engines/util.h"

  

 #include "zvision/zvision.h"

+#include "zvision/zfsArchive.h"

 #include "zvision/zork_avi_decoder.h"

 #include "zvision/zork_raw.h"

 

@@ -160,6 +161,17 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
 }

 

 Common::Error ZVision::run() {

+	// Register the files within the zfs archive files with the SearchMan

+	Common::ArchiveMemberList list;

+	SearchMan.listMatchingMembers(list, "*.zfs");

+

+	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {

+		Common::String name = (*iter)->getName();

+		ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream());

+

+		SearchMan.add(name, archive);

+	}

+

 	//Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);	// ARGB8888

 	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555

 	initGraphics(640, 480, true, &format);



Commit: ef37f14d539d417a1a4506c5c09df1409700aa30
    https://github.com/scummvm/scummvm/commit/ef37f14d539d417a1a4506c5c09df1409700aa30
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:42-07:00

Commit Message:
ZVISION: Add xor encryption handling to ZfsArchive class

Changed paths:
    engines/zvision/zfsArchive.cpp
    engines/zvision/zfsArchive.h



diff --git a/engines/zvision/zfsArchive.cpp b/engines/zvision/zfsArchive.cpp
index a3111d7..59e65f1 100644
--- a/engines/zvision/zfsArchive.cpp
+++ b/engines/zvision/zfsArchive.cpp
@@ -55,16 +55,17 @@ ZfsArchive::~ZfsArchive() {
 }
 
 void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
-	ZfsHeader header;
-
 	// Don't do a straight struct cast since we can't guarantee endianness
-	header.magic = stream->readUint32LE();
-	header.unknown1 = stream->readUint32LE();
-	header.unknown2 = stream->readUint32LE();
-	header.filesPerBlock = stream->readUint32LE();
-	header.fileCount = stream->readUint32LE();
-	header.xorKey = stream->readUint32LE();
-	header.fileSectionOffset = stream->readUint32LE();
+	_header.magic = stream->readUint32LE();
+	_header.unknown1 = stream->readUint32LE();
+	_header.maxNameLength = stream->readUint32LE();
+	_header.filesPerBlock = stream->readUint32LE();
+	_header.fileCount = stream->readUint32LE();
+	_header.xorKey[0] = stream->readByte();
+	_header.xorKey[1] = stream->readByte();
+	_header.xorKey[2] = stream->readByte();
+	_header.xorKey[3] = stream->readByte();
+	_header.fileSectionOffset = stream->readUint32LE();
 
 	uint32 nextOffset;
 
@@ -73,7 +74,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
 		nextOffset = stream->readUint32LE();
 
 		// Read in each entry header
-		for (int i = 0; i < header.filesPerBlock; i++) {
+		for (int i = 0; i < _header.filesPerBlock; i++) {
 			ZfsEntryHeader entryHeader;
 			
 			entryHeader.name = readEntryName(stream);
@@ -135,10 +136,18 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
 
 	byte* buffer = new byte[entryHeader->size];
 	zfsArchive.read(buffer, entryHeader->size);
+	// Decrypt the data in place
+	if (_header.xorKey != 0)
+		unXor(buffer, entryHeader->size, _header.xorKey);
 
 	return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
 }
 
+void ZfsArchive::unXor(byte *buffer, int length, const byte *xorKey) const {
+	for (uint32 i = 0; i < length; i++)
+		buffer[i] ^= xorKey[i % 4];
+}
+
 } // End namespace ZVision
 
 
diff --git a/engines/zvision/zfsArchive.h b/engines/zvision/zfsArchive.h
index 96c002f..718b26c 100644
--- a/engines/zvision/zfsArchive.h
+++ b/engines/zvision/zfsArchive.h
@@ -32,10 +32,10 @@ namespace ZVision {
 struct ZfsHeader {
 	uint32 magic;
 	uint32 unknown1;
-	uint32 unknown2;
+	uint32 maxNameLength;
 	uint32 filesPerBlock;
 	uint32 fileCount;
-	uint32 xorKey;
+	byte xorKey[4];
 	uint32 fileSectionOffset;
 };
 
@@ -85,10 +85,34 @@ public:
 
 private:
 	const Common::String _fileName;
+	ZfsHeader _header;
 	ZfsEntryHeaderMap _entryHeaders;
 
+	/**
+	 * Parses the zfs file into file entry headers that can be used later
+	 * to get the entry data.
+	 *
+	 * @param stream	The contents of the zfs file
+	 */
 	void readHeaders(Common::SeekableReadStream *stream);
+
+	/**
+	 * Entry names are contained within a 16 byte block. This reads the block
+	 * and converts it the name to a Common::String
+	 *
+	 * @param stream	The zfs file stream
+	 * @return			The entry file name
+	 */
 	Common::String readEntryName(Common::SeekableReadStream *stream) const;
+
+	/**
+	 * ZFS file entries can be encrypted using XOR encoding. This method
+	 * decodes the buffer in place using the supplied xorKey.
+	 *
+	 * @param buffer	The data to decode
+	 * @param length	Length of buffer
+	 */
+	void unXor(byte *buffer, int length, const byte *xorKey) const;
 };
 
 } // End of namespace Common


Commit: b65fd98441cadecc44b6e8e06aa2558a282d33c7
    https://github.com/scummvm/scummvm/commit/b65fd98441cadecc44b6e8e06aa2558a282d33c7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:43-07:00

Commit Message:
ZVISION: Clean up includes

Changed paths:
    engines/zvision/zfsArchive.cpp
    engines/zvision/zork_avi_decoder.cpp
    engines/zvision/zork_raw.cpp



diff --git a/engines/zvision/zfsArchive.cpp b/engines/zvision/zfsArchive.cpp
index 59e65f1..93a026e 100644
--- a/engines/zvision/zfsArchive.cpp
+++ b/engines/zvision/zfsArchive.cpp
@@ -20,7 +20,9 @@
  *
  */
 
-#include "zfsArchive.h"
+#include "common/scummsys.h"
+
+#include "zvision/zfsArchive.h"
 #include "common/hashmap.h"
 #include "common/memstream.h"
 #include "common/debug.h"
diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index b0524c7..2da5246 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -21,6 +21,8 @@
  *

  */

 

+#include "common/scummsys.h"

+

 #include "common/stream.h"

 #include "audio/audiostream.h"

 

diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 9332aeb..3c37f92 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -20,6 +20,8 @@
  *

  */

 

+#include "common/scummsys.h"

+

 #include "common/endian.h"

 #include "common/memstream.h"

 #include "common/textconsole.h"



Commit: 160d6256f2f391f37bd02c5c060f5db33db2a2f0
    https://github.com/scummvm/scummvm/commit/160d6256f2f391f37bd02c5c060f5db33db2a2f0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:43-07:00

Commit Message:
ZVISION: Create skeleton engine and move code away from Engine::Run

The goal is to have Engine::Run as clean as possible. Aka mostly method
calls.

Changed paths:
  A engines/zvision/events.cpp
  A engines/zvision/graphics.cpp
  A engines/zvision/scriptManager.h
  A engines/zvision/scripts.cpp
  A engines/zvision/video.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
new file mode 100644
index 0000000..8d10485
--- /dev/null
+++ b/engines/zvision/events.cpp
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision.h"
+#include "common/EventRecorder.h"
+
+
+namespace ZVision {
+
+void ZVision::processEvents() {
+	while (_eventMan->pollEvent(_event)) {
+		switch (_event.type) {
+		case Common::EVENT_LBUTTONDOWN:
+			onMouseDown(_event.mouse);
+			break;
+
+		case Common::EVENT_LBUTTONUP:
+			break;
+
+		case Common::EVENT_RBUTTONDOWN:
+			break;
+
+		case Common::EVENT_MOUSEMOVE:
+			onMouseMove(_event.mouse);
+			break;
+
+		case Common::EVENT_KEYDOWN:
+			switch (_event.kbd.keycode) {
+			case Common::KEYCODE_d:
+				if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
+					// Start the debugger
+					getDebugger()->attach();
+					getDebugger()->onFrame();
+				}
+				break;
+
+			case Common::KEYCODE_q:
+				if (_event.kbd.hasFlags(Common::KBD_CTRL))
+					quitGame();
+				break;
+
+			default:
+				break;
+			}
+
+			onKeyDown(_event.kbd.keycode);
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void ZVision::onMouseDown(const Common::Point &pos) {
+
+}
+
+void ZVision::onMouseMove(const Common::Point &pos) {
+
+}
+
+void ZVision::onKeyDown(uint16 keyCode) {
+
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics.cpp b/engines/zvision/graphics.cpp
new file mode 100644
index 0000000..17e7a4f
--- /dev/null
+++ b/engines/zvision/graphics.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+void ZVision::updateScripts() {
+
+}
+
+void ZVision::updateAnimations(uint32 detaTimeMillis) {
+
+}
+
+} // End namespace ZVision
diff --git a/engines/zvision/scriptManager.h b/engines/zvision/scriptManager.h
new file mode 100644
index 0000000..a6c9f2b
--- /dev/null
+++ b/engines/zvision/scriptManager.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SCRIPT_MANAGER_H
+#define ZVISION_SCRIPT_MANAGER_H
+
+#include "common/hashmap.h"
+
+namespace ZVision {
+
+class ScriptManager {
+public:
+	ScriptManager();
+	~ScriptManager();
+
+private:
+	Common::HashMap<uint32, byte> _globalState;
+};
+
+
+} // End namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripts.cpp b/engines/zvision/scripts.cpp
new file mode 100644
index 0000000..40bad8f
--- /dev/null
+++ b/engines/zvision/scripts.cpp
@@ -0,0 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+
+
+} // End namespace ZVision
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
new file mode 100644
index 0000000..ce68683
--- /dev/null
+++ b/engines/zvision/video.cpp
@@ -0,0 +1,185 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/system.h"
+
+#include "engines/engine.h"
+#include "graphics/decoders/tga.h"
+
+#include "zvision/zork_avi_decoder.h"
+#include "zvision/zork_raw.h"
+
+#include "common/EventRecorder.h"
+#include "common/file.h"
+
+namespace ZVision {
+
+// Taken from SCI
+void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+	assert(bytesPerPixel == 1 || bytesPerPixel == 2);
+	const int newWidth = srcWidth * 2;
+	const int pitch = newWidth * bytesPerPixel;
+	const byte *srcPtr = src;
+
+	if (bytesPerPixel == 1) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				dst[0] = color;
+				dst[1] = color;
+				dst[newWidth] = color;
+				dst[newWidth + 1] = color;
+				dst += 2;
+			}
+			dst += newWidth;
+		}
+	} else if (bytesPerPixel == 2) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				const byte color2 = *srcPtr++;
+				dst[0] = color;
+				dst[1] = color2;
+				dst[2] = color;
+				dst[3] = color2;
+				dst[pitch] = color;
+				dst[pitch + 1] = color2;
+				dst[pitch + 2] = color;
+				dst[pitch + 3] = color2;
+				dst += 4;
+			}
+			dst += pitch;
+		}
+	}
+}
+
+void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
+	if (!videoDecoder)
+		return;
+
+	videoDecoder->start();
+
+	byte *scaleBuffer = 0;
+	byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;
+	uint16 width = videoDecoder->getWidth();
+	uint16 height = videoDecoder->getHeight();
+	uint16 pitch = videoDecoder->getWidth() * bytesPerPixel;
+	uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();
+	uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();
+
+	bool zoom2x = true;
+
+	if (zoom2x) {
+		width *= 2;
+		height *= 2;
+		pitch *= 2;
+		scaleBuffer = new byte[width * height * bytesPerPixel];
+	}
+
+	uint16 x, y;
+
+	x = (screenWidth - width) / 2;
+	y = (screenHeight - height) / 2;
+
+	bool skipVideo = false;
+
+	while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
+		if (videoDecoder->needsUpdate()) {
+			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+
+			if (frame) {
+				if (scaleBuffer) {
+					scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
+					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
+				} else {
+					g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);
+				}
+
+				g_system->updateScreen();
+			}
+		}
+
+		Common::Event event;
+		while (g_system->getEventManager()->pollEvent(event)) {
+			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
+				skipVideo = true;
+		}
+
+		g_system->delayMillis(10);
+	}
+
+	delete[] scaleBuffer;
+	delete videoDecoder;
+}
+
+void tests() {
+#if 0
+	// Video test
+	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
+	if (videoDecoder && videoDecoder->loadFile("zassets/temple/t000a11c.avi")) {
+		Common::List<Graphics::PixelFormat> formats;
+		formats.push_back(videoDecoder->getPixelFormat());
+		//initGraphics(640, 480, true, formats);
+
+		playVideo(videoDecoder);
+	}
+#endif
+
+	Common::File f;
+
+#if 0
+	// Image test
+
+	//initGraphics(640, 480, true, &format);
+
+	if (f.open("zassets/castle/cb8eb11c.tga")) {
+		Graphics::TGADecoder tga;
+		if (!tga.loadStream(f))
+			error("Error while reading TGA image");
+		f.close();
+
+		const Graphics::Surface *tgaSurface = tga.getSurface();
+
+		Graphics::Surface *screen = g_system->lockScreen();
+		for (uint16 y = 0; y < tgaSurface->h; y++)
+			memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);
+		g_system->unlockScreen();
+
+		tga.destroy();
+	}
+
+
+#endif
+
+#if 0
+	// Sound test
+	if (f.open("zassets/castle/c000h9tc.raw")) {
+		Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);
+		Audio::SoundHandle handle;
+		g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
+	}
+
+#endif
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b347782..2cc0b47 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -1,29 +1,40 @@
+/* ScummVM - Graphic Adventure Engine

+ *

+ * ScummVM is the legal property of its developers, whose names

+ * are too numerous to list here. Please refer to the COPYRIGHT

+ * file distributed with this source distribution.

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version 2

+ * of the License, or (at your option) any later version.

+

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ *

+ */

+

 #include "common/scummsys.h"

- 

+

 #include "common/config-manager.h"

 #include "common/debug.h"

 #include "common/debug-channels.h"

 #include "common/error.h"

-#include "common/EventRecorder.h"

+#include "common/system.h"

 #include "common/file.h"

-#include "common/fs.h"

-

-#include "audio/audiostream.h"

-#include "audio/mixer.h"

-

-#include "graphics/palette.h"

-#include "graphics/surface.h"

-#include "graphics/decoders/tga.h"

-

-#include "video/video_decoder.h"

-#include "video/avi_decoder.h"

 

 #include "engines/util.h"

  

 #include "zvision/zvision.h"

 #include "zvision/zfsArchive.h"

-#include "zvision/zork_avi_decoder.h"

-#include "zvision/zork_raw.h"

+

+#include "graphics/decoders/tga.h"

 

 namespace ZVision {

  

@@ -36,9 +47,9 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine
  

 	// However this is the place to specify all default directories

 	const Common::FSNode gameDataDir(ConfMan.get("path"));

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data1");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data2");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data3");

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4);

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4);

+	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4);

 	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");

 	SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");

  

@@ -62,109 +73,12 @@ ZVision::~ZVision() {
 	DebugMan.clearAllDebugChannels();

 }

 

-// Taken from SCI

-void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {

-	assert(bytesPerPixel == 1 || bytesPerPixel == 2);

-	const int newWidth = srcWidth * 2;

-	const int pitch = newWidth * bytesPerPixel;

-	const byte *srcPtr = src;

-

-	if (bytesPerPixel == 1) {

-		for (int y = 0; y < srcHeight; y++) {

-			for (int x = 0; x < srcWidth; x++) {

-				const byte color = *srcPtr++;

-				dst[0] = color;

-				dst[1] = color;

-				dst[newWidth] = color;

-				dst[newWidth + 1] = color;

-				dst += 2;

-			}

-			dst += newWidth;

-		}

-	} else if (bytesPerPixel == 2) {

-		for (int y = 0; y < srcHeight; y++) {

-			for (int x = 0; x < srcWidth; x++) {

-				const byte color = *srcPtr++;

-				const byte color2 = *srcPtr++;

-				dst[0] = color;

-				dst[1] = color2;

-				dst[2] = color;

-				dst[3] = color2;

-				dst[pitch] = color;

-				dst[pitch + 1] = color2;

-				dst[pitch + 2] = color;

-				dst[pitch + 3] = color2;

-				dst += 4;

-			}

-			dst += pitch;

-		}

-	}

-}

-

-void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {

-	if (!videoDecoder)

-		return;

-

-	videoDecoder->start();

-

-	byte *scaleBuffer = 0;

-	byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;

-	uint16 width = videoDecoder->getWidth();

-	uint16 height = videoDecoder->getHeight();

-	uint16 pitch = videoDecoder->getWidth() * bytesPerPixel;

-	uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();

-	uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();

-

-	bool zoom2x = true;

-

-	if (zoom2x) {

-		width *= 2;

-		height *= 2;

-		pitch *= 2;

-		scaleBuffer = new byte[width * height * bytesPerPixel];

-	}

-

-	uint16 x, y;

-

-	x = (screenWidth - width) / 2;

-	y = (screenHeight - height) / 2;

-

-	bool skipVideo = false;

-

-	while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {

-		if (videoDecoder->needsUpdate()) {

-			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();

-

-			if (frame) {

-				if (scaleBuffer) {

-					scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);

-					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);

-				} else {

-					g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);

-				}

-

-				g_system->updateScreen();

-			}

-		}

-

-		Common::Event event;

-		while (g_system->getEventManager()->pollEvent(event)) {

-			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)

-				skipVideo = true;

-		}

-

-		g_system->delayMillis(10);

-	}

-

-	delete[] scaleBuffer;

-	delete videoDecoder;

-}

-

 Common::Error ZVision::run() {

-	// Register the files within the zfs archive files with the SearchMan

+	// Find zfs archive files

 	Common::ArchiveMemberList list;

 	SearchMan.listMatchingMembers(list, "*.zfs");

 

+	// Register the file entries within the zfs archives with the SearchMan

 	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {

 		Common::String name = (*iter)->getName();

 		ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream());

@@ -178,86 +92,35 @@ Common::Error ZVision::run() {
 

 	// Create debugger console. It requires GFX to be initialized

 	_console = new Console(this);

- 

-	// Additional setup.

-	debug("ZVision::init");

- 

-	// Your main even loop should be (invoked from) here.

-	debug("ZVision::go: Hello, World!");

- 

-	// This test will show up if -d1 and --debugflags=example are specified on the commandline

-	//debugC(1, kZVisionDebugExample, "Example debug call");

- 

-	// This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline

-	//debugC(3, kZVisionDebugExample | kZVisionDebugExample2, "Example debug call two");

-

-	Common::File file;

-

-	if (file.open("ADLIB.MDI")) {

-		file.close();

-	}

-

-

-

-#if 1

-	// Video test

-	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();

-	if (videoDecoder && videoDecoder->loadFile("ZASSETS/TEMPLE/T000A11C.AVI")) {

-		Common::List<Graphics::PixelFormat> formats;

-		formats.push_back(videoDecoder->getPixelFormat());

-		initGraphics(640, 480, true, formats);

-		

-		playVideo(videoDecoder);

-	}

-#endif

-

-	Common::File f;

-

-#if 1

-	// Image test

-	

-	initGraphics(640, 480, true, &format);

-	

-	if (f.open("zassets/castle/CB8EB11C.TGA")) {

-		Graphics::TGADecoder tga;

-		if (!tga.loadStream(f))

-			error("Error while reading TGA image");

-		f.close();

-

-		const Graphics::Surface *tgaSurface = tga.getSurface();

-

-		Graphics::Surface *screen = g_system->lockScreen();

-		for (uint16 y = 0; y < tgaSurface->h; y++)

-			memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);

-		g_system->unlockScreen();

-

-		tga.destroy();

-	}

-

-	

-#endif

-

-#if 1

-	// Sound test

-	if (f.open("zassets/castle/C000H9TC.RAW")) {

-		Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);

-		Audio::SoundHandle handle;

-		g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);

-	}

-	

-#endif

 

 	// Main loop

-	Common::EventManager *eventMan = g_system->getEventManager();

-	Common::Event event;

+	uint32 currentTime = _system->getMillis();

+	uint32 lastTime = currentTime;

+	const uint32 desiredFrameTime = 33; // ~30 fps

 

 	while (!shouldQuit()) {

-		eventMan->pollEvent(event);	// eat events

-		g_system->updateScreen();

-		g_system->delayMillis(10);

+		processEvents();

+		

+		currentTime = _system->getMillis();

+		uint32 deltaTime = currentTime - lastTime;

+		lastTime = currentTime;

+		

+		updateScripts();

+		updateAnimations(deltaTime);

+

+		if (_needsScreenUpdate)

+		{

+			_system->updateScreen();

+		}

+		

+		// Calculate the frame delay based off a desired frame rate

+		int delay = desiredFrameTime - (currentTime - _system->getMillis());

+		// Ensure non-negative

+		delay = delay < 0 ? 0 : delay;

+		_system->delayMillis(delay);

 	}

 

 	return Common::kNoError;

 }

- 

+

 } // End of namespace ZVision

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index c2a42f1..b4664d0 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -23,9 +23,12 @@
 

 #ifndef ZVISION_H

 #define ZVISION_H

- 

+

 #include "common/random.h"

+#include "common/events.h"

+

 #include "engines/engine.h"

+

 #include "gui/debugger.h"

  

 namespace ZVision {

@@ -45,17 +48,32 @@ class ZVision : public Engine {
 public:

 	ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);

 	~ZVision();

- 

-	uint32 getFeatures() const;

-	Common::Language getLanguage() const;

-	virtual Common::Error run();

- 

+

 private:

 	Console *_console;

 	const ZVisionGameDescription *_gameDescription;

 

 	// We need random numbers

 	Common::RandomSource *_rnd;

+

+	// To prevent allocation every time we process events

+	Common::Event _event;

+

+	bool _needsScreenUpdate;

+

+public:

+	uint32 getFeatures() const;

+	Common::Language getLanguage() const;

+	virtual Common::Error run();

+ 

+private:

+	void processEvents();

+	void onMouseDown(const Common::Point &pos);
+	void onMouseMove(const Common::Point &pos);
+	void onKeyDown(uint16 keyCode);

+

+	void updateScripts();

+	void updateAnimations(uint32 detaTimeMillis);

 };

  

 // Example console class



Commit: a8980a4f771ae0ca926c9f38ee4d2e031c29318d
    https://github.com/scummvm/scummvm/commit/a8980a4f771ae0ca926c9f38ee4d2e031c29318d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:44-07:00

Commit Message:
ZVISION: Create utility function that writes File contents to another File

scr files are stored and encrypted in archive files. This is an easy
way to dump them for debugging purposes.

Changed paths:
  A engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
new file mode 100644
index 0000000..15f9490
--- /dev/null
+++ b/engines/zvision/utility.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifndef ZVISION_UTILITY_H
+#define ZVISION_UTILITY_H
+
+#include "common/str.h"
+#include "common/file.h"
+
+namespace ZVision {
+
+void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile) {
+	Common::File f;
+	f.open(sourceFile);
+	byte* buffer = new byte[f.size()];
+	f.read(buffer, f.size());
+
+	Common::DumpFile dumpFile;
+	dumpFile.open(destFile);
+
+	uint32 writtenBytes = dumpFile.write(buffer, f.size());
+	dumpFile.flush();
+	dumpFile.close();
+
+	delete[] buffer;
+}
+
+} // End namespace ZVision
+
+#endif


Commit: f444a1fd38329e77624ecd10c753d6b5ce6edf94
    https://github.com/scummvm/scummvm/commit/f444a1fd38329e77624ecd10c753d6b5ce6edf94
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:44-07:00

Commit Message:
ZVISION: Create Object class.

Changed paths:
  A engines/zvision/object.cpp
  A engines/zvision/object.h



diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
new file mode 100644
index 0000000..253eaf7
--- /dev/null
+++ b/engines/zvision/object.cpp
@@ -0,0 +1,371 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/textconsole.h"
+
+#include "zvision/object.h"
+
+namespace ZVision {
+
+Object::Object(ObjectType type) {
+	_objectType = type;
+
+	switch (type) {
+	case BOOL:
+		_value.boolVal = new bool;
+		break;
+	case BYTE:
+		_value.byteVal = new byte;
+		break;
+	case INT16:
+		_value.int16Val = new int16;
+		break;
+	case UINT16:
+		_value.uint16Val = new uint16;
+		break;
+	case INT32:
+		_value.int32Val = new int32;
+		break;
+	case UINT32:
+		_value.uint32Val = new uint32;
+		break;
+	case FLOAT:
+		_value.floatVal = new float;
+		break;
+	case DOUBLE:
+		_value.doubleVal = new double;
+		break;
+	case STRING:
+		_value.stringVal = new Common::String;
+		break;
+	}
+}
+
+Object::Object(bool value) : _objectType(BOOL) {
+	_value.boolVal = new bool(value);
+}
+
+Object::Object(byte value) : _objectType(BYTE) {
+	_value.byteVal = new byte(value);
+}
+
+Object::Object(int16 value) : _objectType(INT16) {
+	_value.int16Val = new int16(value);
+}
+
+Object::Object(uint16 value) : _objectType(UINT16) {
+	_value.uint16Val = new uint16(value);
+}
+
+Object::Object(int32 value) : _objectType(INT32) {
+	_value.int32Val = new int32(value);
+}
+
+Object::Object(uint32 value) : _objectType(UINT32) {
+	_value.uint32Val = new uint32(value);
+}
+
+Object::Object(float value) : _objectType(FLOAT) {
+	_value.floatVal = new float(value);
+}
+
+Object::Object(double value) : _objectType(DOUBLE) {
+	_value.doubleVal = new double(value);
+}
+
+Object::Object(Common::String value) : _objectType(BYTE) {
+	_value.stringVal = new Common::String(value);
+}
+
+Object::Object(const Object& other) {
+	_objectType = other._objectType;
+
+	switch (_objectType) {
+	case BOOL:
+		_value.boolVal = new bool(*other._value.boolVal);
+		break;
+	case BYTE:
+		_value.byteVal = new byte(*other._value.byteVal);
+		break;
+	case INT16:
+		_value.int16Val = new int16(*other._value.int16Val);
+		break;
+	case UINT16:
+		_value.uint16Val = new uint16(*other._value.uint16Val);
+		break;
+	case INT32:
+		_value.int32Val = new int32(*other._value.int32Val);
+		break;
+	case UINT32:
+		_value.uint32Val = new uint32(*other._value.uint32Val);
+		break;
+	case FLOAT:
+		_value.floatVal = new float(*other._value.floatVal);
+		break;
+	case DOUBLE:
+		_value.doubleVal = new double(*other._value.doubleVal);
+		break;
+	case STRING:
+		_value.stringVal = new Common::String(*other._value.stringVal);
+		break;
+	}
+}
+
+Object::~Object() {
+	deleteValue();
+}
+
+void Object::deleteValue() {
+	// Call delete on the correct part of the union.
+	// Even though they all point to the same memory and will all be cast 
+	// to a void *, compiler optimizations could cause undefined behavior.
+	switch (_objectType) {
+	case BOOL:
+		delete _value.boolVal;
+		break;
+	case BYTE:
+		delete _value.byteVal;
+		break;
+	case INT16:
+		delete _value.int16Val;
+		break;
+	case UINT16:
+		delete _value.uint16Val;
+		break;
+	case INT32:
+		delete _value.int32Val;
+		break;
+	case UINT32:
+		delete _value.uint32Val;
+		break;
+	case FLOAT:
+		delete _value.floatVal;
+		break;
+	case DOUBLE:
+		delete _value.doubleVal;
+		break;
+	case STRING:
+		delete _value.stringVal;
+		break;
+	}
+}
+
+
+Object& Object::operator=(const bool& rhs) {
+	if (_objectType == BOOL)
+		*_value.boolVal = rhs;
+	else {
+		deleteValue();
+		_objectType = BOOL;
+		_value.boolVal = new bool(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const byte& rhs) {
+	if (_objectType == BYTE)
+		*_value.byteVal = rhs;
+	else {
+		deleteValue();
+		_objectType = BYTE;
+		_value.byteVal = new byte(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const int16& rhs) {
+	if (_objectType == INT16)
+		*_value.int16Val = rhs;
+	else {
+		deleteValue();
+		_objectType = INT16;
+		_value.int16Val = new int16(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const uint16& rhs) {
+	if (_objectType == UINT16)
+		*_value.uint16Val = rhs;
+	else {
+		deleteValue();
+		_objectType = UINT16;
+		_value.uint16Val = new uint16(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const int32& rhs) {
+	if (_objectType == INT32)
+		*_value.int32Val = rhs;
+	else {
+		deleteValue();
+		_objectType = INT32;
+		_value.int32Val = new int32(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const uint32& rhs) {
+	if (_objectType == UINT32)
+		*_value.uint32Val = rhs;
+	else {
+		deleteValue();
+		_objectType = UINT32;
+		_value.uint32Val = new uint32(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const float& rhs) {
+	if (_objectType == FLOAT)
+		*_value.floatVal = rhs;
+	else {
+		deleteValue();
+		_objectType = FLOAT;
+		_value.floatVal = new float(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const double& rhs) {
+	if (_objectType == DOUBLE)
+		*_value.doubleVal = rhs;
+	else {
+		deleteValue();
+		_objectType = DOUBLE;
+		_value.doubleVal = new double(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const Common::String& rhs) {
+	if (_objectType == STRING)
+		*_value.stringVal = rhs;
+	else {
+		deleteValue();
+		_objectType = STRING;
+		_value.stringVal = new Common::String(rhs);
+	}
+
+	return *this;
+}
+
+Object& Object::operator=(const Object& rhs) {
+	switch (_objectType) {
+	case BOOL:
+		return operator=(*rhs._value.boolVal);
+	case BYTE:
+		return operator=(*rhs._value.byteVal);
+	case INT16:
+		return operator=(*rhs._value.int16Val);
+	case UINT16:
+		return operator=(*rhs._value.uint16Val);
+	case INT32:
+		return operator=(*rhs._value.int32Val);
+	case UINT32:
+		return operator=(*rhs._value.uint32Val);
+	case FLOAT:
+		return operator=(*rhs._value.floatVal);
+	case DOUBLE:
+		return operator=(*rhs._value.doubleVal);
+	case STRING:
+		return operator=(*rhs._value.stringVal);
+	}
+
+	return *this;
+}
+
+
+Object::operator bool() {
+	if (_objectType !=  BOOL)
+		warning("'Object' not of type bool. Bad cast");
+
+	return *_value.boolVal;
+}
+
+Object::operator byte() {
+	if (_objectType !=  BYTE)
+		warning("'Object' not of type byte. Bad cast");
+
+	return *_value.byteVal;
+}
+
+Object::operator int16() {
+	if (_objectType !=  INT16)
+		warning("'Object' not of type int16. Bad cast");
+
+	return *_value.int16Val;
+}
+
+Object::operator uint16() {
+	if (_objectType !=  UINT16)
+		warning("'Object' not of type uint16. Bad cast");
+
+	return *_value.uint16Val;
+}
+
+Object::operator int32() {
+	if (_objectType !=  INT32)
+		warning("'Object' not of type int32. Bad cast");
+
+	return *_value.int32Val;
+}
+
+Object::operator uint32() {
+	if (_objectType !=  UINT32)
+		warning("'Object' not of type uint32. Bad cast");
+
+	return *_value.uint32Val;
+}
+
+Object::operator float() {
+	if (_objectType !=  FLOAT)
+		warning("'Object' not of type float. Bad cast");
+
+	return *_value.floatVal;
+}
+
+Object::operator double() {
+	if (_objectType !=  DOUBLE)
+		warning("'Object' not of type double. Bad cast");
+
+	return *_value.doubleVal;
+}
+
+Object::operator Common::String() {
+	if (_objectType !=  STRING)
+		warning("'Object' not of type Common::String. Bad cast");
+
+	return *_value.stringVal;
+}
+
+} // End namespace ZVision
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
new file mode 100644
index 0000000..02ca962
--- /dev/null
+++ b/engines/zvision/object.h
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_OBJECT_H
+#define ZVISION_OBJECT_H
+
+#include "common/str.h"
+
+namespace ZVision {
+
+
+enum ObjectType {
+	BOOL,
+	BYTE,
+	INT16,
+	UINT16,
+	INT32,
+	UINT32,
+	FLOAT,
+	DOUBLE,
+	STRING,
+};
+
+/**
+ * A generic single value storage class. It is useful for storing different 
+ * value types in a single List, Hashmap, etc.
+ *
+ * Mimics C#'s Object class
+ *
+ * Caution: The actual value is stored on the heap, so be careful creating
+ * many objects of this class. Also, when re-using 'Object', try to assign
+ * a value of the same type as before, as this will prevent an extra memory allocation.
+ */
+class Object {
+public:
+	// Constructors
+	Object(ObjectType type);
+	Object(bool value);
+	Object(byte value);
+	Object(int16 value);
+	Object(uint16 value);
+	Object(int32 value);
+	Object(uint32 value);
+	Object(float value);
+	Object(double value);
+	Object(Common::String value);
+
+	// Copy constructor
+	Object(const Object& other);
+
+	// Destructor
+	~Object();
+
+private:
+	ObjectType _objectType;
+
+	union {
+		bool *boolVal;
+		byte *byteVal;
+		int16 *int16Val;
+		uint16 *uint16Val;
+		int32 *int32Val;
+		uint32 *uint32Val;
+		float *floatVal;
+		double *doubleVal;
+		Common::String *stringVal;
+	} _value;
+
+public:
+	Object& operator=(const bool& rhs);
+	Object& operator=(const byte& rhs);
+	Object& operator=(const int16& rhs);
+	Object& operator=(const uint16& rhs);
+	Object& operator=(const int32& rhs);
+	Object& operator=(const uint32& rhs);
+	Object& operator=(const float& rhs);
+	Object& operator=(const double& rhs);
+	Object& operator=(const Common::String& rhs);
+
+	Object& operator=(const Object& rhs);
+
+	operator bool();
+	operator byte();
+	operator int16();
+	operator uint16();
+	operator int32();
+	operator uint32();
+	operator float();
+	operator double();
+	operator Common::String();
+
+private:
+	/**
+	 * Helper method for destruction and assignment. Calls delete on
+	 * the currently used data pointer			
+	 */
+	void deleteValue();
+};
+
+} // End namespace ZVision
+
+#endif


Commit: 2ada5a8dd7d953d35ddb8ad56a6827cc95daa1cb
    https://github.com/scummvm/scummvm/commit/2ada5a8dd7d953d35ddb8ad56a6827cc95daa1cb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:45-07:00

Commit Message:
ZVISION: Split puzzleControl into two files. Add ResultAction enum

After further investigation, puzzles and controls don't really share any
structs. So it makes more sense to keep them seperate.

Changed paths:
  A engines/zvision/control.h
  A engines/zvision/puzzle.h



diff --git a/engines/zvision/control.h b/engines/zvision/control.h
new file mode 100644
index 0000000..46a7211
--- /dev/null
+++ b/engines/zvision/control.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_CONTROL_H
+#define ZVISION_CONTROL_H
+
+#include "common/scummsys.h"
+
+namespace ZVision {
+
+struct Control {
+	uint16 id;
+
+};
+
+} // End namespace ZVision
+
+#endif
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
new file mode 100644
index 0000000..cb44a44
--- /dev/null
+++ b/engines/zvision/puzzle.h
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_PUZZLE_H
+#define ZVISION_PUZZLE_H
+
+#include "common/list.h"
+
+#include "zvision/object.h"
+
+namespace ZVision {
+
+/** How criteria should be decided */
+enum CriteriaOperator {
+	EQUAL_TO,
+	NOT_EQUAL_TO,
+	GREATER_THAN,
+	LESS_THAN
+};
+
+/** Criteria for a Puzzle result to be fired */
+struct Criteria {
+	/** The id of a global state */
+	uint32 id;
+	/**  
+	 * What we're comparing the value of the global state against
+	 * This can either be a pure value or it can be the id of another global state
+	 */
+	uint32 argument;
+	/** How to do the comparison */
+	CriteriaOperator criteriaOperator;
+	/** Is 'argument' the id of a global state or a pure value */
+	bool argumentIsAnId;
+};
+
+/** What happens when Puzzle criteria are met */
+enum ResultAction {
+	ADD,
+	ANIM_PLAY,
+	ANIM_PRELOAD,
+	ANIM_UNLOAD,
+	ATTENUATE,
+	ASSIGN,
+	CHANGE_LOCATION,
+	CROSSFADE,
+	DEBUG,
+	DELAY_RENDER,
+	DISABLE_CONTROL,
+	DISABLE_VENUS,
+	DISPLAY_MESSAGE,
+	DISSOLVE,
+	DISTORT,
+	ENABLE_CONTROL,
+	FLUSH_MOUSE_EVENTS,
+	INVENTORY,
+	KILL,
+	MENU_BAR_ENABLE,
+	MUSIC,
+	PAN_TRACK,
+	PLAY_PRELOAD,
+	PREFERENCES,
+	QUIT,
+	RANDOM,
+	REGION,
+	RESTORE_GAME,
+	ROTATE_TO,
+	SAVE_GAME,
+	SET_PARTIAL_SCREEN,
+	SET_SCREEN,
+	SET_VENUS,
+	STOP,
+	STREAM_VIDEO,
+	SYNC_SOUND,
+	TIMER,
+	TTY_TEXT,
+	UNIVERSE_MUSIC,
+};
+
+/** What happens when Puzzle criteria are met */
+struct Result {
+	ResultAction action;
+	Common::List<Object> arguments;
+};
+
+enum StateFlags : byte {
+	ONCE_PER_INST = 0x01,
+	DO_ME_NOW = 0x02,
+	DISABLED = 0x04
+};
+
+struct Puzzle {
+	uint32 id;
+	Common::List<Criteria> criteriaList;
+	Common::List<Result> resultList;
+	byte flags;
+};
+
+}
+
+#endif


Commit: 8243263b33fe7aaf4e1144104f1189cd03636ff0
    https://github.com/scummvm/scummvm/commit/8243263b33fe7aaf4e1144104f1189cd03636ff0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:45-07:00

Commit Message:
ZVISION: Add documentation to utility functions and add a glorified trim function

Changed paths:
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 15f9490..0777ba9 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -29,7 +29,14 @@
 
 namespace ZVision {
 
-void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile) {
+/**
+ * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
+ * contents to destFile. destFile is created in the working directory
+ *
+ * @param sourceFile	The 'file' you want the contents of
+ * @param destFile		The name of the file where the content will be written to
+ */
+void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) {
 	Common::File f;
 	f.open(sourceFile);
 	byte* buffer = new byte[f.size()];
@@ -45,6 +52,23 @@ void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile)
 	delete[] buffer;
 }
 
+/**
+ * Removes any line comments using '#' as a sequence start.
+ * Then removes any trailing and leading 'whitespace'.
+ * Uses isspace() to determine what is whitespace and what is not.
+ *
+ * @param string	The string to modify. It is modified in place
+ */
+void trimCommentsAndWhiteSpace(Common::String &string) {
+	for (int i = string.size(); i >= 0; --i) {
+		if (string[i] == '#') {
+			string.erase(i);
+		}
+	}
+
+	string.trim();
+}
+
 } // End namespace ZVision
 
 #endif


Commit: 75e513c46ca086a7047e906af7d4e9bd5d52c5c7
    https://github.com/scummvm/scummvm/commit/75e513c46ca086a7047e906af7d4e9bd5d52c5c7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:46-07:00

Commit Message:
ZVISION: Create base puzzle parsing.

Changed paths:
  A engines/zvision/scrFileHandling.cpp
    engines/zvision/scriptManager.h



diff --git a/engines/zvision/scrFileHandling.cpp b/engines/zvision/scrFileHandling.cpp
new file mode 100644
index 0000000..f4b5bab
--- /dev/null
+++ b/engines/zvision/scrFileHandling.cpp
@@ -0,0 +1,325 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include <stdio.h>
+
+#include "zvision/scriptManager.h"
+#include "zvision/utility.h"
+
+#include "common/textconsole.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+
+namespace ZVision {
+
+
+void ScriptManager::parseScrFile(Common::String fileName) {
+	Common::File file;
+	if (!file.open(fileName))
+		return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
+
+	char buffer[1024];
+	while(!file.eos()) {
+		Common::String line = file.readLine();
+		if (file.err()) {
+			warning("Error parsing scr file: %s", fileName);
+			return;
+		}
+
+		trimCommentsAndWhiteSpace(line);
+		if (line.empty())
+			continue;
+
+		if (line.matchString("puzzle:*", true)) {
+			Puzzle *puzzle = new Puzzle();
+			sscanf(line.c_str(),"puzzle:%u",&(puzzle->id));
+
+			parsePuzzle(puzzle, file);
+		} else if (line.matchString("control:*", true)) {
+			Control *control = new Control();
+			sscanf(line.c_str(),"control:%u",&(control->id));
+
+			parseControl(control, file);
+		}
+	}
+}
+
+void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("criteria {", true))
+			puzzle->criteriaList.push_back(parseCriteria(stream));
+		else if (line.matchString("results {", true))
+			puzzle->resultList.push_back(parseResult(stream));
+		else if (line.matchString("flags {", true))
+			puzzle->flags = parseFlags(stream);
+	}
+
+}
+
+Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const {
+	Criteria criteria;
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		// Split the string into tokens using ' ' as a delimiter
+		Common::StringTokenizer tokenizer(line);
+		Common::String token;
+
+		// Parse the id out of the first token
+		token = tokenizer.nextToken();
+		sscanf(token.c_str(), "[%u]", &(criteria.id));
+
+		// Parse the operator out of the second token
+		token = tokenizer.nextToken();
+		if (token.c_str()[0] == '=')
+			criteria.criteriaOperator = EQUAL_TO;
+		else if (token.c_str()[0] == '!')
+			criteria.criteriaOperator = NOT_EQUAL_TO;
+		else if (token.c_str()[0] == '>')
+			criteria.criteriaOperator = GREATER_THAN;
+		else if (token.c_str()[0] == '<')
+			criteria.criteriaOperator = LESS_THAN;
+
+		// First determine if the last token is an id or a value
+		// Then parse it into 'argument'
+		token = tokenizer.nextToken();
+		if (token.contains('[')) {
+			sscanf(token.c_str(), "[%u]", &(criteria.argument));
+			criteria.argumentIsAnId = true;
+		} else {
+			sscanf(token.c_str(), "%u", &(criteria.argument));
+			criteria.argumentIsAnId = false;
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(line);
+	}
+
+	return criteria;
+}
+
+Result ScriptManager::parseResult(Common::SeekableReadStream &stream) const {
+	Result result;
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		Common::StringTokenizer tokenizer(line, " :(),");
+		// We don't care about the first token
+		tokenizer.nextToken();
+		Common::String token = tokenizer.nextToken();
+
+		// The second token defines the action
+		// Use it to set the action enum and then to parse the arguments
+		if (token.matchString("add", true)) {
+			result.action = ADD;
+			ObjectType argTypes[] = { UINT32, UINT32 };
+			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
+		} else if (token.matchString("animplay", true)) {
+			result.action = ANIM_PLAY;
+
+		} else if (token.matchString("animpreload", true)) {
+			result.action = ANIM_PRELOAD;
+
+		} else if (token.matchString("animunload", true)) {
+			result.action = ANIM_UNLOAD;
+
+		} else if (token.matchString("attenuate", true)) {
+			result.action = ATTENUATE;
+
+		} else if (token.matchString("assign", true)) {
+			result.action = ASSIGN;
+			ObjectType argTypes[] = { UINT32, UINT32 };
+			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
+		} else if (token.matchString("change_location", true)) {
+			result.action = CHANGE_LOCATION;
+			ObjectType argTypes[] = { STRING, STRING, STRING, UINT32 };
+			parseResultArguments(result, argTypes, 4, tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken());
+		} else if (token.matchString("crossfade", true)) {
+			result.action = CROSSFADE;
+
+		} else if (token.matchString("debug", true)) {
+			result.action = DEBUG;
+
+		} else if (token.matchString("delay_render", true)) {
+			result.action = DELAY_RENDER;
+
+		} else if (token.matchString("disable_control", true)) {
+			result.action = DISABLE_CONTROL;
+
+		} else if (token.matchString("disable_venus", true)) {
+			result.action = DISABLE_VENUS;
+
+		} else if (token.matchString("display_message", true)) {
+			result.action = DISPLAY_MESSAGE;
+
+		} else if (token.matchString("dissolve", true)) {
+			result.action = DISSOLVE;
+		} else if (token.matchString("distort", true)) {
+			result.action = DISTORT;
+
+		} else if (token.matchString("enable_control", true)) {
+			result.action = ENABLE_CONTROL;
+
+		} else if (token.matchString("flush_mouse_events", true)) {
+			result.action = FLUSH_MOUSE_EVENTS;
+
+		} else if (token.matchString("inventory", true)) {
+			result.action = INVENTORY;
+
+		} else if (token.matchString("kill", true)) {
+			result.action = KILL;
+
+		} else if (token.matchString("menu_bar_enable", true)) {
+			result.action = MENU_BAR_ENABLE;
+
+		} else if (token.matchString("music", true)) {
+			result.action = MUSIC;
+			ObjectType argTypes[] = { UINT32, UINT32, STRING, UINT32, UINT32 };
+			parseResultArguments(result, argTypes, 5,
+								 tokenizer.nextToken(), tokenizer.nextToken(),
+								 tokenizer.nextToken(), tokenizer.nextToken(),
+								 tokenizer.nextToken());
+		} else if (token.matchString("pan_track", true)) {
+			result.action = PAN_TRACK;
+
+		} else if (token.matchString("playpreload", true)) {
+			result.action = PLAY_PRELOAD;
+
+		} else if (token.matchString("preferences", true)) {
+			result.action = PREFERENCES;
+
+		} else if (token.matchString("quit", true)) {
+			result.action = QUIT;
+
+		} else if (token.matchString("random", true)) {
+			result.action = RANDOM;
+			ObjectType argTypes[] = { UINT32, UINT32 };
+			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
+		} else if (token.matchString("region", true)) {
+			result.action = REGION;
+
+		} else if (token.matchString("restore_game", true)) {
+			result.action = RESTORE_GAME;
+
+		} else if (token.matchString("rotate_to", true)) {
+			result.action = ROTATE_TO;
+
+		} else if (token.matchString("save_game", true)) {
+			result.action = SAVE_GAME;
+
+		} else if (token.matchString("set_partial_screen", true)) {
+			result.action = SET_PARTIAL_SCREEN;
+
+		} else if (token.matchString("set_screen", true)) {
+			result.action = SET_SCREEN;
+
+		} else if (token.matchString("set_venus", true)) {
+			result.action = SET_VENUS;
+
+		} else if (token.matchString("stop", true)) {
+			result.action = STOP;
+			ObjectType argTypes[] = { UINT32 };
+			parseResultArguments(result, argTypes, 1, tokenizer.nextToken());
+		} else if (token.matchString("streamvideo", true)) {
+			result.action = STREAM_VIDEO;
+
+		} else if (token.matchString("syncsound", true)) {
+			result.action = SYNC_SOUND;
+
+		} else if (token.matchString("timer", true)) {
+			result.action = TIMER;
+			ObjectType argTypes[] = { UINT32, UINT32 };
+			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
+		} else if (token.matchString("ttytext", true)) {
+			result.action = TTY_TEXT;
+
+		} else if (token.matchString("universe_music", true)) {
+			result.action = UNIVERSE_MUSIC;
+
+		} else {
+			warning("Unhandled result action type: ", token);
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(line);
+	}
+
+	return result;
+}
+
+void ScriptManager::parseResultArguments(Result &result, const ObjectType *types, int numberOfArgs, ...) const {
+	va_list argptr;
+	va_start(argptr, numberOfArgs);
+
+	for (int i = 0; i < numberOfArgs; i++) {
+		if (types[i] == UINT32) {
+			Common::String arg = va_arg(argptr, Common::String);
+			Object argObject(UINT32);
+			sscanf(arg.c_str(), "%u", &argObject);
+			result.arguments.push_back(argObject);
+			break;
+		} else {
+			Common::String arg = va_arg(argptr, Common::String);
+			result.arguments.push_back(Object(arg));
+			break;
+		}
+	}
+
+	va_end(argptr);
+}
+
+byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
+	byte flags;
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("ONCE_PER_INST", true)) {
+			flags |= ONCE_PER_INST;
+		} else if (line.matchString("DO_ME_NOW", true)) {
+			flags |= DO_ME_NOW;
+		} else if (line.matchString("DISABLED", true)) {
+			flags |= DISABLED;
+		}
+	}
+
+	return flags;
+}
+
+void ScriptManager::parseControl(Control *control, Common::SeekableReadStream &stream) {
+
+}
+
+} // End namespace ZVision
diff --git a/engines/zvision/scriptManager.h b/engines/zvision/scriptManager.h
index a6c9f2b..7f6cc25 100644
--- a/engines/zvision/scriptManager.h
+++ b/engines/zvision/scriptManager.h
@@ -23,8 +23,13 @@
 #ifndef ZVISION_SCRIPT_MANAGER_H
 #define ZVISION_SCRIPT_MANAGER_H
 
+#include "common/str.h"
+#include "common/stream.h"
 #include "common/hashmap.h"
 
+#include "zvision/puzzle.h"
+#include "zvision/control.h"
+
 namespace ZVision {
 
 class ScriptManager {
@@ -34,6 +39,63 @@ public:
 
 private:
 	Common::HashMap<uint32, byte> _globalState;
+
+	/**
+	 * Parses a script file into triggers and events
+	 *
+	 * @param fileName		Name of the .scr file
+	 */
+	void parseScrFile(Common::String fileName);
+
+	/**
+	 * Helper method for parseScrFile. Parses the stream into a Puzzle object
+	 *
+	 * @param puzzle	The object to store what is parsed
+	 * @param stream	Scr file stream
+	 */
+	void parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream);
+
+	/**
+	 * Helper method for parsePuzzle. Parses the stream into a Criteria object
+	 *
+	 * @param stream	Scr file stream
+	 * @return			Created Criteria object
+	 */
+	Criteria parseCriteria(Common::SeekableReadStream &stream) const;
+
+	/**
+	 * Helper method for parsePuzzle. Parses the stream into a Results object
+	 *
+	 * @param stream	Scr file stream
+	 * @return			Created Results object
+	 */
+	Result parseResult(Common::SeekableReadStream &stream) const;
+
+	/**
+	 * Helper method for parseResults. Parses a number of strings into Object types.
+	 *
+	 * @param result			Results object to store the arguments in
+	 * @param types				The type of the each of the arguments. IE. BOOL, UINT32, etc.
+	 * @param numberOfArgs		The number of arguments. This has to equal the length of 'types' AND the number of optional arguments passed.
+	 * @param 					String arguments wanting to be parsed
+	 */
+	void parseResultArguments(Result &result, const ObjectType *types, int numberOfArgs, ...) const;
+
+	/**
+	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
+	 *
+	 * @param stream	Scr file stream
+	 * @return			Bitwise or of all the flags set within the puzzle
+	 */
+	byte parseFlags(Common::SeekableReadStream &stream) const;
+
+	/**
+	 * Helper method for parseScrFile. Parses the stream into a Control object
+	 *
+	 * @param control	The object to store what is parsed
+	 * @param stream	Scr file stream
+	 */
+	void parseControl(Control *control, Common::SeekableReadStream &stream);
 };
 
 


Commit: cf7c04a001d99081d73e4340acb8065ad593030a
    https://github.com/scummvm/scummvm/commit/cf7c04a001d99081d73e4340acb8065ad593030a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:46-07:00

Commit Message:
ZVISION: Fix code formatting to follow the convention

Changed paths:
    engines/zvision/control.h
    engines/zvision/graphics.cpp
    engines/zvision/object.cpp
    engines/zvision/object.h
    engines/zvision/puzzle.h
    engines/zvision/scrFileHandling.cpp
    engines/zvision/scriptManager.h
    engines/zvision/scripts.cpp
    engines/zvision/utility.h
    engines/zvision/zfsArchive.cpp
    engines/zvision/zfsArchive.h
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 46a7211..df01544 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -32,6 +32,6 @@ struct Control {
 
 };
 
-} // End namespace ZVision
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/graphics.cpp b/engines/zvision/graphics.cpp
index 17e7a4f..7d1201c 100644
--- a/engines/zvision/graphics.cpp
+++ b/engines/zvision/graphics.cpp
@@ -34,4 +34,4 @@ void ZVision::updateAnimations(uint32 detaTimeMillis) {
 
 }
 
-} // End namespace ZVision
+} // End of namespace ZVision
diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
index 253eaf7..6bc8c0f 100644
--- a/engines/zvision/object.cpp
+++ b/engines/zvision/object.cpp
@@ -97,7 +97,7 @@ Object::Object(Common::String value) : _objectType(BYTE) {
 	_value.stringVal = new Common::String(value);
 }
 
-Object::Object(const Object& other) {
+Object::Object(const Object &other) {
 	_objectType = other._objectType;
 
 	switch (_objectType) {
@@ -138,7 +138,7 @@ Object::~Object() {
 void Object::deleteValue() {
 	// Call delete on the correct part of the union.
 	// Even though they all point to the same memory and will all be cast 
-	// to a void *, compiler optimizations could cause undefined behavior.
+	// to a void *, this can still cause undefined behavior.
 	switch (_objectType) {
 	case BOOL:
 		delete _value.boolVal;
@@ -171,7 +171,7 @@ void Object::deleteValue() {
 }
 
 
-Object& Object::operator=(const bool& rhs) {
+Object &Object::operator=(const bool &rhs) {
 	if (_objectType == BOOL)
 		*_value.boolVal = rhs;
 	else {
@@ -183,7 +183,7 @@ Object& Object::operator=(const bool& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const byte& rhs) {
+Object &Object::operator=(const byte &rhs) {
 	if (_objectType == BYTE)
 		*_value.byteVal = rhs;
 	else {
@@ -195,7 +195,7 @@ Object& Object::operator=(const byte& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const int16& rhs) {
+Object &Object::operator=(const int16 &rhs) {
 	if (_objectType == INT16)
 		*_value.int16Val = rhs;
 	else {
@@ -207,7 +207,7 @@ Object& Object::operator=(const int16& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const uint16& rhs) {
+Object &Object::operator=(const uint16 &rhs) {
 	if (_objectType == UINT16)
 		*_value.uint16Val = rhs;
 	else {
@@ -219,7 +219,7 @@ Object& Object::operator=(const uint16& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const int32& rhs) {
+Object &Object::operator=(const int32 &rhs) {
 	if (_objectType == INT32)
 		*_value.int32Val = rhs;
 	else {
@@ -231,7 +231,7 @@ Object& Object::operator=(const int32& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const uint32& rhs) {
+Object &Object::operator=(const uint32 &rhs) {
 	if (_objectType == UINT32)
 		*_value.uint32Val = rhs;
 	else {
@@ -243,7 +243,7 @@ Object& Object::operator=(const uint32& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const float& rhs) {
+Object &Object::operator=(const float &rhs) {
 	if (_objectType == FLOAT)
 		*_value.floatVal = rhs;
 	else {
@@ -255,7 +255,7 @@ Object& Object::operator=(const float& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const double& rhs) {
+Object &Object::operator=(const double &rhs) {
 	if (_objectType == DOUBLE)
 		*_value.doubleVal = rhs;
 	else {
@@ -267,7 +267,7 @@ Object& Object::operator=(const double& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const Common::String& rhs) {
+Object &Object::operator=(const Common::String &rhs) {
 	if (_objectType == STRING)
 		*_value.stringVal = rhs;
 	else {
@@ -279,7 +279,7 @@ Object& Object::operator=(const Common::String& rhs) {
 	return *this;
 }
 
-Object& Object::operator=(const Object& rhs) {
+Object &Object::operator=(const Object &rhs) {
 	switch (_objectType) {
 	case BOOL:
 		return operator=(*rhs._value.boolVal);
@@ -368,4 +368,4 @@ Object::operator Common::String() {
 	return *_value.stringVal;
 }
 
-} // End namespace ZVision
+} // End of namespace ZVision
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index 02ca962..b98b381 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -27,19 +27,6 @@
 
 namespace ZVision {
 
-
-enum ObjectType {
-	BOOL,
-	BYTE,
-	INT16,
-	UINT16,
-	INT32,
-	UINT32,
-	FLOAT,
-	DOUBLE,
-	STRING,
-};
-
 /**
  * A generic single value storage class. It is useful for storing different 
  * value types in a single List, Hashmap, etc.
@@ -52,6 +39,18 @@ enum ObjectType {
  */
 class Object {
 public:
+	enum ObjectType {
+		BOOL,
+		BYTE,
+		INT16,
+		UINT16,
+		INT32,
+		UINT32,
+		FLOAT,
+		DOUBLE,
+		STRING,
+	};
+
 	// Constructors
 	Object(ObjectType type);
 	Object(bool value);
@@ -86,17 +85,17 @@ private:
 	} _value;
 
 public:
-	Object& operator=(const bool& rhs);
-	Object& operator=(const byte& rhs);
-	Object& operator=(const int16& rhs);
-	Object& operator=(const uint16& rhs);
-	Object& operator=(const int32& rhs);
-	Object& operator=(const uint32& rhs);
-	Object& operator=(const float& rhs);
-	Object& operator=(const double& rhs);
-	Object& operator=(const Common::String& rhs);
-
-	Object& operator=(const Object& rhs);
+	Object &operator=(const bool &rhs);
+	Object &operator=(const byte &rhs);
+	Object &operator=(const int16 &rhs);
+	Object &operator=(const uint16 &rhs);
+	Object &operator=(const int32 &rhs);
+	Object &operator=(const uint32 &rhs);
+	Object &operator=(const float &rhs);
+	Object &operator=(const double &rhs);
+	Object &operator=(const Common::String &rhs);
+
+	Object& operator=(const Object &rhs);
 
 	operator bool();
 	operator byte();
@@ -116,6 +115,6 @@ private:
 	void deleteValue();
 };
 
-} // End namespace ZVision
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index cb44a44..6961fde 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -114,6 +114,6 @@ struct Puzzle {
 	byte flags;
 };
 
-}
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/scrFileHandling.cpp b/engines/zvision/scrFileHandling.cpp
index f4b5bab..a0d4ceb 100644
--- a/engines/zvision/scrFileHandling.cpp
+++ b/engines/zvision/scrFileHandling.cpp
@@ -322,4 +322,4 @@ void ScriptManager::parseControl(Control *control, Common::SeekableReadStream &s
 
 }
 
-} // End namespace ZVision
+} // End of namespace ZVision
diff --git a/engines/zvision/scriptManager.h b/engines/zvision/scriptManager.h
index 7f6cc25..0bae919 100644
--- a/engines/zvision/scriptManager.h
+++ b/engines/zvision/scriptManager.h
@@ -99,6 +99,6 @@ private:
 };
 
 
-} // End namespace ZVision
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/scripts.cpp b/engines/zvision/scripts.cpp
index 40bad8f..b6deb1b 100644
--- a/engines/zvision/scripts.cpp
+++ b/engines/zvision/scripts.cpp
@@ -28,4 +28,4 @@ namespace ZVision {
 
 
 
-} // End namespace ZVision
+} // End of namespace ZVision
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 0777ba9..f9f9916 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -69,6 +69,6 @@ void trimCommentsAndWhiteSpace(Common::String &string) {
 	string.trim();
 }
 
-} // End namespace ZVision
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/zfsArchive.cpp b/engines/zvision/zfsArchive.cpp
index 93a026e..e65d0df 100644
--- a/engines/zvision/zfsArchive.cpp
+++ b/engines/zvision/zfsArchive.cpp
@@ -150,6 +150,6 @@ void ZfsArchive::unXor(byte *buffer, int length, const byte *xorKey) const {
 		buffer[i] ^= xorKey[i % 4];
 }
 
-} // End namespace ZVision
+} // End of namespace ZVision
 
 
diff --git a/engines/zvision/zfsArchive.h b/engines/zvision/zfsArchive.h
index 718b26c..60292f8 100644
--- a/engines/zvision/zfsArchive.h
+++ b/engines/zvision/zfsArchive.h
@@ -115,6 +115,6 @@ private:
 	void unXor(byte *buffer, int length, const byte *xorKey) const;
 };
 
-} // End of namespace Common
+} // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 3c37f92..e008741 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -185,4 +185,4 @@ Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
 	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);

 }

 

-} // End of namespace Audio

+} // End of namespace ZVision

diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index a8f8ce0..3a93802 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -62,6 +62,6 @@ Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream
                                    int rate,

                                    DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

 

-} // End of namespace Audio

+} // End of namespace ZVision

 

 #endif



Commit: 8cc678e2eeda0df0b80fd19b03712a626b0b7bd2
    https://github.com/scummvm/scummvm/commit/8cc678e2eeda0df0b80fd19b03712a626b0b7bd2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:47-07:00

Commit Message:
ZVISION: Convert 'Object' implicit conversion operators to accessors

Implicit conversion, while simple can cause problems and doesn't
show exactly how to get the value.

Changed paths:
    engines/zvision/object.cpp
    engines/zvision/object.h



diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
index 6bc8c0f..322d7f2 100644
--- a/engines/zvision/object.cpp
+++ b/engines/zvision/object.cpp
@@ -305,67 +305,78 @@ Object &Object::operator=(const Object &rhs) {
 }
 
 
-Object::operator bool() {
-	if (_objectType !=  BOOL)
-		warning("'Object' not of type bool. Bad cast");
+bool Object::getBoolValue(bool *returnValue) const {
+	if (_objectType !=  BOOL) {
+		warning("'Object' not of type bool.");
+		return false;
+	}
 
-	return *_value.boolVal;
+	*returnValue = *_value.boolVal;
+	return true;
 }
 
-Object::operator byte() {
+bool Object::getByteValue(byte *returnValue) const {
 	if (_objectType !=  BYTE)
-		warning("'Object' not of type byte. Bad cast");
+		warning("'Object' not of type byte.");
 
-	return *_value.byteVal;
+	*returnValue = *_value.byteVal;
+	return true;
 }
 
-Object::operator int16() {
+bool Object::getInt16Value(int16 *returnValue) const {
 	if (_objectType !=  INT16)
-		warning("'Object' not of type int16. Bad cast");
+		warning("'Object' not of type int16.");
 
-	return *_value.int16Val;
+	*returnValue = *_value.int16Val;
+	return true;
 }
 
-Object::operator uint16() {
+bool Object::getUInt16Value(uint16 *returnValue) const {
 	if (_objectType !=  UINT16)
-		warning("'Object' not of type uint16. Bad cast");
+		warning("'Object' not of type uint16.");
 
-	return *_value.uint16Val;
+	*returnValue = *_value.uint16Val;
+	return true;
 }
 
-Object::operator int32() {
+bool Object::getInt32Value(int32 *returnValue) const {
 	if (_objectType !=  INT32)
-		warning("'Object' not of type int32. Bad cast");
+		warning("'Object' not of type int32.");
 
-	return *_value.int32Val;
+	*returnValue = *_value.int32Val;
+	return true;
 }
 
-Object::operator uint32() {
+bool Object::getUInt32Value(uint32 *returnValue) const {
 	if (_objectType !=  UINT32)
-		warning("'Object' not of type uint32. Bad cast");
+		warning("'Object' not of type uint32.");
 
-	return *_value.uint32Val;
+	*returnValue = *_value.uint32Val;
+	return true;
 }
 
-Object::operator float() {
+bool Object::getFloatValue(float *returnValue) const {
 	if (_objectType !=  FLOAT)
-		warning("'Object' not of type float. Bad cast");
+		warning("'Object' not of type float.");
 
-	return *_value.floatVal;
+	*returnValue = *_value.floatVal;
+	return true;
 }
 
-Object::operator double() {
+bool Object::getDoubleValue(double *returnValue) const {
 	if (_objectType !=  DOUBLE)
-		warning("'Object' not of type double. Bad cast");
+		warning("'Object' not of type double.");
 
-	return *_value.doubleVal;
+	*returnValue = *_value.doubleVal;
+	return true;
 }
 
-Object::operator Common::String() {
+bool Object::getStringValue(Common::String *returnValue) const {
 	if (_objectType !=  STRING)
-		warning("'Object' not of type Common::String. Bad cast");
+		warning("'Object' not of type Common::String.");
 
-	return *_value.stringVal;
+	*returnValue = *_value.stringVal;
+	return true;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index b98b381..4df572c 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -97,15 +97,15 @@ public:
 
 	Object& operator=(const Object &rhs);
 
-	operator bool();
-	operator byte();
-	operator int16();
-	operator uint16();
-	operator int32();
-	operator uint32();
-	operator float();
-	operator double();
-	operator Common::String();
+	bool getBoolValue(bool *returnValue) const;
+	bool getByteValue(byte *returnValue) const;
+	bool getInt16Value(int16 *returnValue) const;
+	bool getUInt16Value(uint16 *returnValue) const;
+	bool getInt32Value(int32 *returnValue) const;
+	bool getUInt32Value(uint32 *returnValue) const;
+	bool getFloatValue(float *returnValue) const;
+	bool getDoubleValue(double *returnValue) const;
+	bool getStringValue(Common::String *returnValue) const;
 
 private:
 	/**


Commit: 7803c9fddf5fecd7d9adb6741f08e37fb92c0224
    https://github.com/scummvm/scummvm/commit/7803c9fddf5fecd7d9adb6741f08e37fb92c0224
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:47-07:00

Commit Message:
ZVISION: Force 'Object' constructors to be explicit.

Changed paths:
    engines/zvision/object.h



diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index 4df572c..6e4b98a 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -52,19 +52,19 @@ public:
 	};
 
 	// Constructors
-	Object(ObjectType type);
-	Object(bool value);
-	Object(byte value);
-	Object(int16 value);
-	Object(uint16 value);
-	Object(int32 value);
-	Object(uint32 value);
-	Object(float value);
-	Object(double value);
-	Object(Common::String value);
+	explicit Object(ObjectType type);
+	explicit Object(bool value);
+	explicit Object(byte value);
+	explicit Object(int16 value);
+	explicit Object(uint16 value);
+	explicit Object(int32 value);
+	explicit Object(uint32 value);
+	explicit Object(float value);
+	explicit Object(double value);
+	explicit Object(Common::String value);
 
 	// Copy constructor
-	Object(const Object& other);
+	explicit Object(const Object& other);
 
 	// Destructor
 	~Object();


Commit: 3283176f6d000cbb66208a0b5d4b3337004461fd
    https://github.com/scummvm/scummvm/commit/3283176f6d000cbb66208a0b5d4b3337004461fd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:48-07:00

Commit Message:
ZVISION: Move initialization code from run() and into its own method

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



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 2cc0b47..452ed00 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -73,7 +73,7 @@ ZVision::~ZVision() {
 	DebugMan.clearAllDebugChannels();

 }

 

-Common::Error ZVision::run() {

+void ZVision::initialize() {

 	// Find zfs archive files

 	Common::ArchiveMemberList list;

 	SearchMan.listMatchingMembers(list, "*.zfs");

@@ -92,6 +92,12 @@ Common::Error ZVision::run() {
 

 	// Create debugger console. It requires GFX to be initialized

 	_console = new Console(this);

+}

+

+Common::Error ZVision::run() {

+	initialize();

+

+	tests();

 

 	// Main loop

 	uint32 currentTime = _system->getMillis();

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index b4664d0..c5ddb8a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -67,6 +67,8 @@ public:
 	virtual Common::Error run();

  

 private:

+	void initialize();

+

 	void processEvents();

 	void onMouseDown(const Common::Point &pos);
 	void onMouseMove(const Common::Point &pos);


Commit: d5fa6612ed8f48ce33dd9f3576c450fe80a7526d
    https://github.com/scummvm/scummvm/commit/d5fa6612ed8f48ce33dd9f3576c450fe80a7526d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:48-07:00

Commit Message:
ZVISION: Modify utility and puzzle comments to make them more clear

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/utility.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 6961fde..1133ada 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -48,8 +48,8 @@ struct Criteria {
 	uint32 argument;
 	/** How to do the comparison */
 	CriteriaOperator criteriaOperator;
-	/** Is 'argument' the id of a global state or a pure value */
-	bool argumentIsAnId;
+	/** Whether 'argument' is the id of a global state (true) or a pure value (false) */
+	bool isArgumentAnId;
 };
 
 /** What happens when Puzzle criteria are met */
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index f9f9916..9fade10 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -54,8 +54,8 @@ void writeFileContentsToFile(Common::String sourceFile, Common::String destFile)
 
 /**
  * Removes any line comments using '#' as a sequence start.
- * Then removes any trailing and leading 'whitespace'.
- * Uses isspace() to determine what is whitespace and what is not.
+ * Then removes any trailing and leading 'whitespace' using String::trim()
+ * Note: String::trim uses isspace() to determine what is whitespace and what is not.
  *
  * @param string	The string to modify. It is modified in place
  */


Commit: 5fef80994101046801500f3350f85ca368d50aa6
    https://github.com/scummvm/scummvm/commit/5fef80994101046801500f3350f85ca368d50aa6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:49-07:00

Commit Message:
ZVISION: Convert union of pointers to union of values except for String.

Instead of storing everything on the heap, only store Strings on the heap.
For Strings, store a char array pointer instead of an actual String object
since String objects are fairly large.

Changed paths:
    engines/zvision/object.cpp
    engines/zvision/object.h



diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
index 322d7f2..b272320 100644
--- a/engines/zvision/object.cpp
+++ b/engines/zvision/object.cpp
@@ -27,74 +27,43 @@
 
 namespace ZVision {
 
-Object::Object(ObjectType type) {
-	_objectType = type;
-
-	switch (type) {
-	case BOOL:
-		_value.boolVal = new bool;
-		break;
-	case BYTE:
-		_value.byteVal = new byte;
-		break;
-	case INT16:
-		_value.int16Val = new int16;
-		break;
-	case UINT16:
-		_value.uint16Val = new uint16;
-		break;
-	case INT32:
-		_value.int32Val = new int32;
-		break;
-	case UINT32:
-		_value.uint32Val = new uint32;
-		break;
-	case FLOAT:
-		_value.floatVal = new float;
-		break;
-	case DOUBLE:
-		_value.doubleVal = new double;
-		break;
-	case STRING:
-		_value.stringVal = new Common::String;
-		break;
-	}
-}
+Object::Object(ObjectType type) : _objectType(type) { }
 
 Object::Object(bool value) : _objectType(BOOL) {
-	_value.boolVal = new bool(value);
+	_value.boolVal = value;
 }
 
 Object::Object(byte value) : _objectType(BYTE) {
-	_value.byteVal = new byte(value);
+	_value.byteVal = value;
 }
 
 Object::Object(int16 value) : _objectType(INT16) {
-	_value.int16Val = new int16(value);
+	_value.int16Val = value;
 }
 
 Object::Object(uint16 value) : _objectType(UINT16) {
-	_value.uint16Val = new uint16(value);
+	_value.uint16Val = value;
 }
 
 Object::Object(int32 value) : _objectType(INT32) {
-	_value.int32Val = new int32(value);
+	_value.int32Val = value;
 }
 
 Object::Object(uint32 value) : _objectType(UINT32) {
-	_value.uint32Val = new uint32(value);
+	_value.uint32Val = value;
 }
 
 Object::Object(float value) : _objectType(FLOAT) {
-	_value.floatVal = new float(value);
+	_value.floatVal = value;
 }
 
 Object::Object(double value) : _objectType(DOUBLE) {
-	_value.doubleVal = new double(value);
+	_value.doubleVal = value;
 }
 
 Object::Object(Common::String value) : _objectType(BYTE) {
-	_value.stringVal = new Common::String(value);
+	_value.stringVal = new char[value.size() + 1];
+	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
 }
 
 Object::Object(const Object &other) {
@@ -102,178 +71,167 @@ Object::Object(const Object &other) {
 
 	switch (_objectType) {
 	case BOOL:
-		_value.boolVal = new bool(*other._value.boolVal);
+		_value.boolVal = other._value.boolVal;
 		break;
 	case BYTE:
-		_value.byteVal = new byte(*other._value.byteVal);
+		_value.byteVal = other._value.byteVal;
 		break;
 	case INT16:
-		_value.int16Val = new int16(*other._value.int16Val);
+		_value.int16Val = other._value.int16Val;
 		break;
 	case UINT16:
-		_value.uint16Val = new uint16(*other._value.uint16Val);
+		_value.uint16Val = other._value.uint16Val;
 		break;
 	case INT32:
-		_value.int32Val = new int32(*other._value.int32Val);
+		_value.int32Val = other._value.int32Val;
 		break;
 	case UINT32:
-		_value.uint32Val = new uint32(*other._value.uint32Val);
+		_value.uint32Val = other._value.uint32Val;
 		break;
 	case FLOAT:
-		_value.floatVal = new float(*other._value.floatVal);
+		_value.floatVal = other._value.floatVal;
 		break;
 	case DOUBLE:
-		_value.doubleVal = new double(*other._value.doubleVal);
+		_value.doubleVal = other._value.doubleVal;
 		break;
 	case STRING:
-		_value.stringVal = new Common::String(*other._value.stringVal);
+		uint32 length = strlen(other._value.stringVal);
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, other._value.stringVal, length + 1);
 		break;
 	}
 }
 
 Object::~Object() {
-	deleteValue();
+	deleteCharPointer();
 }
 
-void Object::deleteValue() {
-	// Call delete on the correct part of the union.
-	// Even though they all point to the same memory and will all be cast 
-	// to a void *, this can still cause undefined behavior.
-	switch (_objectType) {
-	case BOOL:
-		delete _value.boolVal;
-		break;
-	case BYTE:
-		delete _value.byteVal;
-		break;
-	case INT16:
-		delete _value.int16Val;
-		break;
-	case UINT16:
-		delete _value.uint16Val;
-		break;
-	case INT32:
-		delete _value.int32Val;
-		break;
-	case UINT32:
-		delete _value.uint32Val;
-		break;
-	case FLOAT:
-		delete _value.floatVal;
-		break;
-	case DOUBLE:
-		delete _value.doubleVal;
-		break;
-	case STRING:
-		delete _value.stringVal;
-		break;
-	}
+void Object::deleteCharPointer() {
+	if (_objectType == STRING)
+		delete[] _value.stringVal;
 }
 
 
 Object &Object::operator=(const bool &rhs) {
-	if (_objectType == BOOL)
-		*_value.boolVal = rhs;
-	else {
-		deleteValue();
-		_objectType = BOOL;
-		_value.boolVal = new bool(rhs);
+	if (_objectType == BOOL) {
+		_value.boolVal = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = BOOL;
+	_value.boolVal = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const byte &rhs) {
-	if (_objectType == BYTE)
-		*_value.byteVal = rhs;
-	else {
-		deleteValue();
-		_objectType = BYTE;
-		_value.byteVal = new byte(rhs);
+	if (_objectType == BYTE) {
+		_value.byteVal = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = BYTE;
+	_value.byteVal = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const int16 &rhs) {
-	if (_objectType == INT16)
-		*_value.int16Val = rhs;
-	else {
-		deleteValue();
-		_objectType = INT16;
-		_value.int16Val = new int16(rhs);
+	if (_objectType == INT16) {
+		_value.int16Val = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = INT16;
+	_value.int16Val = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const uint16 &rhs) {
-	if (_objectType == UINT16)
-		*_value.uint16Val = rhs;
-	else {
-		deleteValue();
-		_objectType = UINT16;
-		_value.uint16Val = new uint16(rhs);
+	if (_objectType == UINT16) {
+		_value.uint16Val = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = UINT16;
+	_value.uint16Val = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const int32 &rhs) {
-	if (_objectType == INT32)
-		*_value.int32Val = rhs;
-	else {
-		deleteValue();
-		_objectType = INT32;
-		_value.int32Val = new int32(rhs);
+	if (_objectType == INT32) {
+		_value.int32Val = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = INT32;
+	_value.int32Val = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const uint32 &rhs) {
-	if (_objectType == UINT32)
-		*_value.uint32Val = rhs;
-	else {
-		deleteValue();
-		_objectType = UINT32;
-		_value.uint32Val = new uint32(rhs);
+	if (_objectType == UINT32) {
+		_value.uint32Val = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = UINT32;
+	_value.uint32Val = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const float &rhs) {
-	if (_objectType == FLOAT)
-		*_value.floatVal = rhs;
-	else {
-		deleteValue();
-		_objectType = FLOAT;
-		_value.floatVal = new float(rhs);
+	if (_objectType == FLOAT) {
+		_value.floatVal = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = FLOAT;
+	_value.floatVal = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const double &rhs) {
-	if (_objectType == DOUBLE)
-		*_value.doubleVal = rhs;
-	else {
-		deleteValue();
-		_objectType = DOUBLE;
-		_value.doubleVal = new double(rhs);
+	if (_objectType == DOUBLE) {
+		_value.doubleVal = rhs;
+		return *this;
 	}
 
+	deleteCharPointer();
+	_objectType = DOUBLE;
+	_value.doubleVal = rhs;
+
 	return *this;
 }
 
 Object &Object::operator=(const Common::String &rhs) {
-	if (_objectType == STRING)
-		*_value.stringVal = rhs;
-	else {
-		deleteValue();
+	if (_objectType != STRING) {
 		_objectType = STRING;
-		_value.stringVal = new Common::String(rhs);
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+
+		return *this;
+	}
+
+	uint32 length = strlen(_value.stringVal);
+	if (length <= rhs.size() + 1) {
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+	} else {
+		delete[] _value.stringVal;
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
 	}
 
 	return *this;
@@ -282,23 +240,28 @@ Object &Object::operator=(const Common::String &rhs) {
 Object &Object::operator=(const Object &rhs) {
 	switch (_objectType) {
 	case BOOL:
-		return operator=(*rhs._value.boolVal);
+		return operator=(rhs._value.boolVal);
 	case BYTE:
-		return operator=(*rhs._value.byteVal);
+		return operator=(rhs._value.byteVal);
 	case INT16:
-		return operator=(*rhs._value.int16Val);
+		return operator=(rhs._value.int16Val);
 	case UINT16:
-		return operator=(*rhs._value.uint16Val);
+		return operator=(rhs._value.uint16Val);
 	case INT32:
-		return operator=(*rhs._value.int32Val);
+		return operator=(rhs._value.int32Val);
 	case UINT32:
-		return operator=(*rhs._value.uint32Val);
+		return operator=(rhs._value.uint32Val);
 	case FLOAT:
-		return operator=(*rhs._value.floatVal);
+		return operator=(rhs._value.floatVal);
 	case DOUBLE:
-		return operator=(*rhs._value.doubleVal);
+		return operator=(rhs._value.doubleVal);
 	case STRING:
-		return operator=(*rhs._value.stringVal);
+		uint32 length = strlen(rhs._value.stringVal);
+
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
+
+		return *this;
 	}
 
 	return *this;
@@ -307,75 +270,75 @@ Object &Object::operator=(const Object &rhs) {
 
 bool Object::getBoolValue(bool *returnValue) const {
 	if (_objectType !=  BOOL) {
-		warning("'Object' not of type bool.");
+		warning("'Object' is not storing a bool.");
 		return false;
 	}
 
-	*returnValue = *_value.boolVal;
+	*returnValue = _value.boolVal;
 	return true;
 }
 
 bool Object::getByteValue(byte *returnValue) const {
 	if (_objectType !=  BYTE)
-		warning("'Object' not of type byte.");
+		warning("'Object' is not storing a byte.");
 
-	*returnValue = *_value.byteVal;
+	*returnValue = _value.byteVal;
 	return true;
 }
 
 bool Object::getInt16Value(int16 *returnValue) const {
 	if (_objectType !=  INT16)
-		warning("'Object' not of type int16.");
+		warning("'Object' is not storing an int16.");
 
-	*returnValue = *_value.int16Val;
+	*returnValue = _value.int16Val;
 	return true;
 }
 
 bool Object::getUInt16Value(uint16 *returnValue) const {
 	if (_objectType !=  UINT16)
-		warning("'Object' not of type uint16.");
+		warning("'Object' is not storing a uint16.");
 
-	*returnValue = *_value.uint16Val;
+	*returnValue = _value.uint16Val;
 	return true;
 }
 
 bool Object::getInt32Value(int32 *returnValue) const {
 	if (_objectType !=  INT32)
-		warning("'Object' not of type int32.");
+		warning("'Object' is not storing an int32.");
 
-	*returnValue = *_value.int32Val;
+	*returnValue = _value.int32Val;
 	return true;
 }
 
 bool Object::getUInt32Value(uint32 *returnValue) const {
 	if (_objectType !=  UINT32)
-		warning("'Object' not of type uint32.");
+		warning("'Object' is not storing a uint32.");
 
-	*returnValue = *_value.uint32Val;
+	*returnValue = _value.uint32Val;
 	return true;
 }
 
 bool Object::getFloatValue(float *returnValue) const {
 	if (_objectType !=  FLOAT)
-		warning("'Object' not of type float.");
+		warning("'Object' is not storing a float.");
 
-	*returnValue = *_value.floatVal;
+	*returnValue = _value.floatVal;
 	return true;
 }
 
 bool Object::getDoubleValue(double *returnValue) const {
 	if (_objectType !=  DOUBLE)
-		warning("'Object' not of type double.");
+		warning("'Object' is not storing a double.");
 
-	*returnValue = *_value.doubleVal;
+	*returnValue = _value.doubleVal;
 	return true;
 }
 
 bool Object::getStringValue(Common::String *returnValue) const {
 	if (_objectType !=  STRING)
-		warning("'Object' not of type Common::String.");
+		warning("'Object' is not storing a Common::String.");
 
-	*returnValue = *_value.stringVal;
+	*returnValue = _value.stringVal;
 	return true;
 }
 
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index 6e4b98a..dc5905b 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -73,15 +73,15 @@ private:
 	ObjectType _objectType;
 
 	union {
-		bool *boolVal;
-		byte *byteVal;
-		int16 *int16Val;
-		uint16 *uint16Val;
-		int32 *int32Val;
-		uint32 *uint32Val;
-		float *floatVal;
-		double *doubleVal;
-		Common::String *stringVal;
+		bool boolVal;
+		byte byteVal;
+		int16 int16Val;
+		uint16 uint16Val;
+		int32 int32Val;
+		uint32 uint32Val;
+		float floatVal;
+		double doubleVal;
+		char *stringVal;
 	} _value;
 
 public:


Commit: 30208f7f2b0e47b5684d7d1860541f4dd56f43ce
    https://github.com/scummvm/scummvm/commit/30208f7f2b0e47b5684d7d1860541f4dd56f43ce
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:49-07:00

Commit Message:
ZVISION: Add documentation to 'Object' accessors

Changed paths:
    engines/zvision/object.h



diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index dc5905b..f7e08c4 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -97,22 +97,89 @@ public:
 
 	Object& operator=(const Object &rhs);
 
+	/**
+	 * Retrieve a bool from the container. If the container is not storing a 
+	 * bool, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getBoolValue(bool *returnValue) const;
+	/**
+	 * Retrieve a byte from the container. If the container is not storing a 
+	 * byte, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getByteValue(byte *returnValue) const;
+	/**
+	 * Retrieve an int16 from the container. If the container is not storing an 
+	 * int16, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getInt16Value(int16 *returnValue) const;
+	/**
+	 * Retrieve a uint16 from the container. If the container is not storing a 
+	 * uint16, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getUInt16Value(uint16 *returnValue) const;
+	/**
+	 * Retrieve an int32 from the container. If the container is not storing an 
+	 * int32, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getInt32Value(int32 *returnValue) const;
+	/**
+	 * Retrieve a uint32 from the container. If the container is not storing a 
+	 * uint32, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getUInt32Value(uint32 *returnValue) const;
+	/**
+	 * Retrieve a float from the container. If the container is not storing a 
+	 * float, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getFloatValue(float *returnValue) const;
+	/**
+	 * Retrieve a double from the container. If the container is not storing a 
+	 * double, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getDoubleValue(double *returnValue) const;
+	/**
+	 * Retrieve a String from the container. If the container is not storing a 
+	 * string, this will return false and display a warning().
+	 * 
+	 * Caution: Strings are internally stored as char[]. getStringValue uses
+	 * Common::String::operator=(char *) to do the assigment, which uses both
+	 * strlen() AND memmove().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
 	bool getStringValue(Common::String *returnValue) const;
 
 private:
 	/**
-	 * Helper method for destruction and assignment. Calls delete on
-	 * the currently used data pointer			
+	 * Helper method for destruction and assignment. It checks to see
+	 * if the char pointer is being used, and if so calls delete on it
 	 */
-	void deleteValue();
+	void deleteCharPointer();
 };
 
 } // End of namespace ZVision


Commit: c3c75669628e93c66d08a175142ad72b8f9b00a7
    https://github.com/scummvm/scummvm/commit/c3c75669628e93c66d08a175142ad72b8f9b00a7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:50-07:00

Commit Message:
ZVISION: Rename 'Object' class to 'SingleValueContainer'

Changed paths:
    engines/zvision/object.cpp
    engines/zvision/object.h



diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
index b272320..6a3d4e0 100644
--- a/engines/zvision/object.cpp
+++ b/engines/zvision/object.cpp
@@ -27,46 +27,46 @@
 
 namespace ZVision {
 
-Object::Object(ObjectType type) : _objectType(type) { }
+SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
 
-Object::Object(bool value) : _objectType(BOOL) {
+SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
 	_value.boolVal = value;
 }
 
-Object::Object(byte value) : _objectType(BYTE) {
+SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
 	_value.byteVal = value;
 }
 
-Object::Object(int16 value) : _objectType(INT16) {
+SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
 	_value.int16Val = value;
 }
 
-Object::Object(uint16 value) : _objectType(UINT16) {
+SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
 	_value.uint16Val = value;
 }
 
-Object::Object(int32 value) : _objectType(INT32) {
+SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
 	_value.int32Val = value;
 }
 
-Object::Object(uint32 value) : _objectType(UINT32) {
+SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
 	_value.uint32Val = value;
 }
 
-Object::Object(float value) : _objectType(FLOAT) {
+SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
 	_value.floatVal = value;
 }
 
-Object::Object(double value) : _objectType(DOUBLE) {
+SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
 	_value.doubleVal = value;
 }
 
-Object::Object(Common::String value) : _objectType(BYTE) {
+SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
 	_value.stringVal = new char[value.size() + 1];
 	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
 }
 
-Object::Object(const Object &other) {
+SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
 	_objectType = other._objectType;
 
 	switch (_objectType) {
@@ -102,17 +102,17 @@ Object::Object(const Object &other) {
 	}
 }
 
-Object::~Object() {
+SingleValueContainer::~SingleValueContainer() {
 	deleteCharPointer();
 }
 
-void Object::deleteCharPointer() {
+void SingleValueContainer::deleteCharPointer() {
 	if (_objectType == STRING)
 		delete[] _value.stringVal;
 }
 
 
-Object &Object::operator=(const bool &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
 	if (_objectType == BOOL) {
 		_value.boolVal = rhs;
 		return *this;
@@ -125,7 +125,7 @@ Object &Object::operator=(const bool &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const byte &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
 	if (_objectType == BYTE) {
 		_value.byteVal = rhs;
 		return *this;
@@ -138,7 +138,7 @@ Object &Object::operator=(const byte &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const int16 &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
 	if (_objectType == INT16) {
 		_value.int16Val = rhs;
 		return *this;
@@ -151,7 +151,7 @@ Object &Object::operator=(const int16 &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const uint16 &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
 	if (_objectType == UINT16) {
 		_value.uint16Val = rhs;
 		return *this;
@@ -164,7 +164,7 @@ Object &Object::operator=(const uint16 &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const int32 &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
 	if (_objectType == INT32) {
 		_value.int32Val = rhs;
 		return *this;
@@ -177,7 +177,7 @@ Object &Object::operator=(const int32 &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const uint32 &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
 	if (_objectType == UINT32) {
 		_value.uint32Val = rhs;
 		return *this;
@@ -190,7 +190,7 @@ Object &Object::operator=(const uint32 &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const float &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
 	if (_objectType == FLOAT) {
 		_value.floatVal = rhs;
 		return *this;
@@ -203,7 +203,7 @@ Object &Object::operator=(const float &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const double &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
 	if (_objectType == DOUBLE) {
 		_value.doubleVal = rhs;
 		return *this;
@@ -216,7 +216,7 @@ Object &Object::operator=(const double &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const Common::String &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
 	if (_objectType != STRING) {
 		_objectType = STRING;
 		_value.stringVal = new char[rhs.size() + 1];
@@ -237,7 +237,7 @@ Object &Object::operator=(const Common::String &rhs) {
 	return *this;
 }
 
-Object &Object::operator=(const Object &rhs) {
+SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
 	switch (_objectType) {
 	case BOOL:
 		return operator=(rhs._value.boolVal);
@@ -268,7 +268,7 @@ Object &Object::operator=(const Object &rhs) {
 }
 
 
-bool Object::getBoolValue(bool *returnValue) const {
+bool SingleValueContainer::getBoolValue(bool *returnValue) const {
 	if (_objectType !=  BOOL) {
 		warning("'Object' is not storing a bool.");
 		return false;
@@ -278,7 +278,7 @@ bool Object::getBoolValue(bool *returnValue) const {
 	return true;
 }
 
-bool Object::getByteValue(byte *returnValue) const {
+bool SingleValueContainer::getByteValue(byte *returnValue) const {
 	if (_objectType !=  BYTE)
 		warning("'Object' is not storing a byte.");
 
@@ -286,7 +286,7 @@ bool Object::getByteValue(byte *returnValue) const {
 	return true;
 }
 
-bool Object::getInt16Value(int16 *returnValue) const {
+bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
 	if (_objectType !=  INT16)
 		warning("'Object' is not storing an int16.");
 
@@ -294,7 +294,7 @@ bool Object::getInt16Value(int16 *returnValue) const {
 	return true;
 }
 
-bool Object::getUInt16Value(uint16 *returnValue) const {
+bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
 	if (_objectType !=  UINT16)
 		warning("'Object' is not storing a uint16.");
 
@@ -302,7 +302,7 @@ bool Object::getUInt16Value(uint16 *returnValue) const {
 	return true;
 }
 
-bool Object::getInt32Value(int32 *returnValue) const {
+bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
 	if (_objectType !=  INT32)
 		warning("'Object' is not storing an int32.");
 
@@ -310,7 +310,7 @@ bool Object::getInt32Value(int32 *returnValue) const {
 	return true;
 }
 
-bool Object::getUInt32Value(uint32 *returnValue) const {
+bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
 	if (_objectType !=  UINT32)
 		warning("'Object' is not storing a uint32.");
 
@@ -318,7 +318,7 @@ bool Object::getUInt32Value(uint32 *returnValue) const {
 	return true;
 }
 
-bool Object::getFloatValue(float *returnValue) const {
+bool SingleValueContainer::getFloatValue(float *returnValue) const {
 	if (_objectType !=  FLOAT)
 		warning("'Object' is not storing a float.");
 
@@ -326,7 +326,7 @@ bool Object::getFloatValue(float *returnValue) const {
 	return true;
 }
 
-bool Object::getDoubleValue(double *returnValue) const {
+bool SingleValueContainer::getDoubleValue(double *returnValue) const {
 	if (_objectType !=  DOUBLE)
 		warning("'Object' is not storing a double.");
 
@@ -334,7 +334,7 @@ bool Object::getDoubleValue(double *returnValue) const {
 	return true;
 }
 
-bool Object::getStringValue(Common::String *returnValue) const {
+bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
 	if (_objectType !=  STRING)
 		warning("'Object' is not storing a Common::String.");
 
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
index f7e08c4..3c24cc0 100644
--- a/engines/zvision/object.h
+++ b/engines/zvision/object.h
@@ -30,16 +30,10 @@ namespace ZVision {
 /**
  * A generic single value storage class. It is useful for storing different 
  * value types in a single List, Hashmap, etc.
- *
- * Mimics C#'s Object class
- *
- * Caution: The actual value is stored on the heap, so be careful creating
- * many objects of this class. Also, when re-using 'Object', try to assign
- * a value of the same type as before, as this will prevent an extra memory allocation.
  */
-class Object {
+class SingleValueContainer {
 public:
-	enum ObjectType {
+	enum ValueType {
 		BOOL,
 		BYTE,
 		INT16,
@@ -52,25 +46,25 @@ public:
 	};
 
 	// Constructors
-	explicit Object(ObjectType type);
-	explicit Object(bool value);
-	explicit Object(byte value);
-	explicit Object(int16 value);
-	explicit Object(uint16 value);
-	explicit Object(int32 value);
-	explicit Object(uint32 value);
-	explicit Object(float value);
-	explicit Object(double value);
-	explicit Object(Common::String value);
+	explicit SingleValueContainer(ValueType type);
+	explicit SingleValueContainer(bool value);
+	explicit SingleValueContainer(byte value);
+	explicit SingleValueContainer(int16 value);
+	explicit SingleValueContainer(uint16 value);
+	explicit SingleValueContainer(int32 value);
+	explicit SingleValueContainer(uint32 value);
+	explicit SingleValueContainer(float value);
+	explicit SingleValueContainer(double value);
+	explicit SingleValueContainer(Common::String value);
 
 	// Copy constructor
-	explicit Object(const Object& other);
+	explicit SingleValueContainer(const SingleValueContainer& other);
 
 	// Destructor
-	~Object();
+	~SingleValueContainer();
 
 private:
-	ObjectType _objectType;
+	ValueType _objectType;
 
 	union {
 		bool boolVal;
@@ -85,17 +79,17 @@ private:
 	} _value;
 
 public:
-	Object &operator=(const bool &rhs);
-	Object &operator=(const byte &rhs);
-	Object &operator=(const int16 &rhs);
-	Object &operator=(const uint16 &rhs);
-	Object &operator=(const int32 &rhs);
-	Object &operator=(const uint32 &rhs);
-	Object &operator=(const float &rhs);
-	Object &operator=(const double &rhs);
-	Object &operator=(const Common::String &rhs);
-
-	Object& operator=(const Object &rhs);
+	SingleValueContainer &operator=(const bool &rhs);
+	SingleValueContainer &operator=(const byte &rhs);
+	SingleValueContainer &operator=(const int16 &rhs);
+	SingleValueContainer &operator=(const uint16 &rhs);
+	SingleValueContainer &operator=(const int32 &rhs);
+	SingleValueContainer &operator=(const uint32 &rhs);
+	SingleValueContainer &operator=(const float &rhs);
+	SingleValueContainer &operator=(const double &rhs);
+	SingleValueContainer &operator=(const Common::String &rhs);
+
+	SingleValueContainer& operator=(const SingleValueContainer &rhs);
 
 	/**
 	 * Retrieve a bool from the container. If the container is not storing a 


Commit: 063d6c34008cf61a19ce8ae135b44091371ac728
    https://github.com/scummvm/scummvm/commit/063d6c34008cf61a19ce8ae135b44091371ac728
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:50-07:00

Commit Message:
ZVISION: Rename object.h and object.cpp to fit the new class name

Changed paths:
  A engines/zvision/singleValueContainer.cpp
  A engines/zvision/singleValueContainer.h
  R engines/zvision/object.cpp
  R engines/zvision/object.h



diff --git a/engines/zvision/object.cpp b/engines/zvision/object.cpp
deleted file mode 100644
index 6a3d4e0..0000000
--- a/engines/zvision/object.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-#include "common/textconsole.h"
-
-#include "zvision/object.h"
-
-namespace ZVision {
-
-SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
-
-SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
-	_value.boolVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
-	_value.byteVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
-	_value.int16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
-	_value.uint16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
-	_value.int32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
-	_value.uint32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
-	_value.floatVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
-	_value.doubleVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
-	_value.stringVal = new char[value.size() + 1];
-	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
-}
-
-SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
-	_objectType = other._objectType;
-
-	switch (_objectType) {
-	case BOOL:
-		_value.boolVal = other._value.boolVal;
-		break;
-	case BYTE:
-		_value.byteVal = other._value.byteVal;
-		break;
-	case INT16:
-		_value.int16Val = other._value.int16Val;
-		break;
-	case UINT16:
-		_value.uint16Val = other._value.uint16Val;
-		break;
-	case INT32:
-		_value.int32Val = other._value.int32Val;
-		break;
-	case UINT32:
-		_value.uint32Val = other._value.uint32Val;
-		break;
-	case FLOAT:
-		_value.floatVal = other._value.floatVal;
-		break;
-	case DOUBLE:
-		_value.doubleVal = other._value.doubleVal;
-		break;
-	case STRING:
-		uint32 length = strlen(other._value.stringVal);
-		_value.stringVal = new char[length + 1];
-		memcpy(_value.stringVal, other._value.stringVal, length + 1);
-		break;
-	}
-}
-
-SingleValueContainer::~SingleValueContainer() {
-	deleteCharPointer();
-}
-
-void SingleValueContainer::deleteCharPointer() {
-	if (_objectType == STRING)
-		delete[] _value.stringVal;
-}
-
-
-SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
-	if (_objectType == BOOL) {
-		_value.boolVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = BOOL;
-	_value.boolVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
-	if (_objectType == BYTE) {
-		_value.byteVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = BYTE;
-	_value.byteVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
-	if (_objectType == INT16) {
-		_value.int16Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = INT16;
-	_value.int16Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
-	if (_objectType == UINT16) {
-		_value.uint16Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = UINT16;
-	_value.uint16Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
-	if (_objectType == INT32) {
-		_value.int32Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = INT32;
-	_value.int32Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
-	if (_objectType == UINT32) {
-		_value.uint32Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = UINT32;
-	_value.uint32Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
-	if (_objectType == FLOAT) {
-		_value.floatVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = FLOAT;
-	_value.floatVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
-	if (_objectType == DOUBLE) {
-		_value.doubleVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = DOUBLE;
-	_value.doubleVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
-	if (_objectType != STRING) {
-		_objectType = STRING;
-		_value.stringVal = new char[rhs.size() + 1];
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-
-		return *this;
-	}
-
-	uint32 length = strlen(_value.stringVal);
-	if (length <= rhs.size() + 1) {
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-	} else {
-		delete[] _value.stringVal;
-		_value.stringVal = new char[rhs.size() + 1];
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-	}
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
-	switch (_objectType) {
-	case BOOL:
-		return operator=(rhs._value.boolVal);
-	case BYTE:
-		return operator=(rhs._value.byteVal);
-	case INT16:
-		return operator=(rhs._value.int16Val);
-	case UINT16:
-		return operator=(rhs._value.uint16Val);
-	case INT32:
-		return operator=(rhs._value.int32Val);
-	case UINT32:
-		return operator=(rhs._value.uint32Val);
-	case FLOAT:
-		return operator=(rhs._value.floatVal);
-	case DOUBLE:
-		return operator=(rhs._value.doubleVal);
-	case STRING:
-		uint32 length = strlen(rhs._value.stringVal);
-
-		_value.stringVal = new char[length + 1];
-		memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
-
-		return *this;
-	}
-
-	return *this;
-}
-
-
-bool SingleValueContainer::getBoolValue(bool *returnValue) const {
-	if (_objectType !=  BOOL) {
-		warning("'Object' is not storing a bool.");
-		return false;
-	}
-
-	*returnValue = _value.boolVal;
-	return true;
-}
-
-bool SingleValueContainer::getByteValue(byte *returnValue) const {
-	if (_objectType !=  BYTE)
-		warning("'Object' is not storing a byte.");
-
-	*returnValue = _value.byteVal;
-	return true;
-}
-
-bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
-	if (_objectType !=  INT16)
-		warning("'Object' is not storing an int16.");
-
-	*returnValue = _value.int16Val;
-	return true;
-}
-
-bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
-	if (_objectType !=  UINT16)
-		warning("'Object' is not storing a uint16.");
-
-	*returnValue = _value.uint16Val;
-	return true;
-}
-
-bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
-	if (_objectType !=  INT32)
-		warning("'Object' is not storing an int32.");
-
-	*returnValue = _value.int32Val;
-	return true;
-}
-
-bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
-	if (_objectType !=  UINT32)
-		warning("'Object' is not storing a uint32.");
-
-	*returnValue = _value.uint32Val;
-	return true;
-}
-
-bool SingleValueContainer::getFloatValue(float *returnValue) const {
-	if (_objectType !=  FLOAT)
-		warning("'Object' is not storing a float.");
-
-	*returnValue = _value.floatVal;
-	return true;
-}
-
-bool SingleValueContainer::getDoubleValue(double *returnValue) const {
-	if (_objectType !=  DOUBLE)
-		warning("'Object' is not storing a double.");
-
-	*returnValue = _value.doubleVal;
-	return true;
-}
-
-bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
-	if (_objectType !=  STRING)
-		warning("'Object' is not storing a Common::String.");
-
-	*returnValue = _value.stringVal;
-	return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/object.h b/engines/zvision/object.h
deleted file mode 100644
index 3c24cc0..0000000
--- a/engines/zvision/object.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_OBJECT_H
-#define ZVISION_OBJECT_H
-
-#include "common/str.h"
-
-namespace ZVision {
-
-/**
- * A generic single value storage class. It is useful for storing different 
- * value types in a single List, Hashmap, etc.
- */
-class SingleValueContainer {
-public:
-	enum ValueType {
-		BOOL,
-		BYTE,
-		INT16,
-		UINT16,
-		INT32,
-		UINT32,
-		FLOAT,
-		DOUBLE,
-		STRING,
-	};
-
-	// Constructors
-	explicit SingleValueContainer(ValueType type);
-	explicit SingleValueContainer(bool value);
-	explicit SingleValueContainer(byte value);
-	explicit SingleValueContainer(int16 value);
-	explicit SingleValueContainer(uint16 value);
-	explicit SingleValueContainer(int32 value);
-	explicit SingleValueContainer(uint32 value);
-	explicit SingleValueContainer(float value);
-	explicit SingleValueContainer(double value);
-	explicit SingleValueContainer(Common::String value);
-
-	// Copy constructor
-	explicit SingleValueContainer(const SingleValueContainer& other);
-
-	// Destructor
-	~SingleValueContainer();
-
-private:
-	ValueType _objectType;
-
-	union {
-		bool boolVal;
-		byte byteVal;
-		int16 int16Val;
-		uint16 uint16Val;
-		int32 int32Val;
-		uint32 uint32Val;
-		float floatVal;
-		double doubleVal;
-		char *stringVal;
-	} _value;
-
-public:
-	SingleValueContainer &operator=(const bool &rhs);
-	SingleValueContainer &operator=(const byte &rhs);
-	SingleValueContainer &operator=(const int16 &rhs);
-	SingleValueContainer &operator=(const uint16 &rhs);
-	SingleValueContainer &operator=(const int32 &rhs);
-	SingleValueContainer &operator=(const uint32 &rhs);
-	SingleValueContainer &operator=(const float &rhs);
-	SingleValueContainer &operator=(const double &rhs);
-	SingleValueContainer &operator=(const Common::String &rhs);
-
-	SingleValueContainer& operator=(const SingleValueContainer &rhs);
-
-	/**
-	 * Retrieve a bool from the container. If the container is not storing a 
-	 * bool, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getBoolValue(bool *returnValue) const;
-	/**
-	 * Retrieve a byte from the container. If the container is not storing a 
-	 * byte, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getByteValue(byte *returnValue) const;
-	/**
-	 * Retrieve an int16 from the container. If the container is not storing an 
-	 * int16, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getInt16Value(int16 *returnValue) const;
-	/**
-	 * Retrieve a uint16 from the container. If the container is not storing a 
-	 * uint16, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getUInt16Value(uint16 *returnValue) const;
-	/**
-	 * Retrieve an int32 from the container. If the container is not storing an 
-	 * int32, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getInt32Value(int32 *returnValue) const;
-	/**
-	 * Retrieve a uint32 from the container. If the container is not storing a 
-	 * uint32, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getUInt32Value(uint32 *returnValue) const;
-	/**
-	 * Retrieve a float from the container. If the container is not storing a 
-	 * float, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getFloatValue(float *returnValue) const;
-	/**
-	 * Retrieve a double from the container. If the container is not storing a 
-	 * double, this will return false and display a warning().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getDoubleValue(double *returnValue) const;
-	/**
-	 * Retrieve a String from the container. If the container is not storing a 
-	 * string, this will return false and display a warning().
-	 * 
-	 * Caution: Strings are internally stored as char[]. getStringValue uses
-	 * Common::String::operator=(char *) to do the assigment, which uses both
-	 * strlen() AND memmove().
-	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
-	 */
-	bool getStringValue(Common::String *returnValue) const;
-
-private:
-	/**
-	 * Helper method for destruction and assignment. It checks to see
-	 * if the char pointer is being used, and if so calls delete on it
-	 */
-	void deleteCharPointer();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/singleValueContainer.cpp b/engines/zvision/singleValueContainer.cpp
new file mode 100644
index 0000000..6a3d4e0
--- /dev/null
+++ b/engines/zvision/singleValueContainer.cpp
@@ -0,0 +1,345 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/textconsole.h"
+
+#include "zvision/object.h"
+
+namespace ZVision {
+
+SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
+
+SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
+	_value.boolVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
+	_value.byteVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
+	_value.int16Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
+	_value.uint16Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
+	_value.int32Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
+	_value.uint32Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
+	_value.floatVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
+	_value.doubleVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
+	_value.stringVal = new char[value.size() + 1];
+	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
+}
+
+SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
+	_objectType = other._objectType;
+
+	switch (_objectType) {
+	case BOOL:
+		_value.boolVal = other._value.boolVal;
+		break;
+	case BYTE:
+		_value.byteVal = other._value.byteVal;
+		break;
+	case INT16:
+		_value.int16Val = other._value.int16Val;
+		break;
+	case UINT16:
+		_value.uint16Val = other._value.uint16Val;
+		break;
+	case INT32:
+		_value.int32Val = other._value.int32Val;
+		break;
+	case UINT32:
+		_value.uint32Val = other._value.uint32Val;
+		break;
+	case FLOAT:
+		_value.floatVal = other._value.floatVal;
+		break;
+	case DOUBLE:
+		_value.doubleVal = other._value.doubleVal;
+		break;
+	case STRING:
+		uint32 length = strlen(other._value.stringVal);
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, other._value.stringVal, length + 1);
+		break;
+	}
+}
+
+SingleValueContainer::~SingleValueContainer() {
+	deleteCharPointer();
+}
+
+void SingleValueContainer::deleteCharPointer() {
+	if (_objectType == STRING)
+		delete[] _value.stringVal;
+}
+
+
+SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
+	if (_objectType == BOOL) {
+		_value.boolVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = BOOL;
+	_value.boolVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
+	if (_objectType == BYTE) {
+		_value.byteVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = BYTE;
+	_value.byteVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
+	if (_objectType == INT16) {
+		_value.int16Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = INT16;
+	_value.int16Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
+	if (_objectType == UINT16) {
+		_value.uint16Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = UINT16;
+	_value.uint16Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
+	if (_objectType == INT32) {
+		_value.int32Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = INT32;
+	_value.int32Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
+	if (_objectType == UINT32) {
+		_value.uint32Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = UINT32;
+	_value.uint32Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
+	if (_objectType == FLOAT) {
+		_value.floatVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = FLOAT;
+	_value.floatVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
+	if (_objectType == DOUBLE) {
+		_value.doubleVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = DOUBLE;
+	_value.doubleVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
+	if (_objectType != STRING) {
+		_objectType = STRING;
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+
+		return *this;
+	}
+
+	uint32 length = strlen(_value.stringVal);
+	if (length <= rhs.size() + 1) {
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+	} else {
+		delete[] _value.stringVal;
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+	}
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
+	switch (_objectType) {
+	case BOOL:
+		return operator=(rhs._value.boolVal);
+	case BYTE:
+		return operator=(rhs._value.byteVal);
+	case INT16:
+		return operator=(rhs._value.int16Val);
+	case UINT16:
+		return operator=(rhs._value.uint16Val);
+	case INT32:
+		return operator=(rhs._value.int32Val);
+	case UINT32:
+		return operator=(rhs._value.uint32Val);
+	case FLOAT:
+		return operator=(rhs._value.floatVal);
+	case DOUBLE:
+		return operator=(rhs._value.doubleVal);
+	case STRING:
+		uint32 length = strlen(rhs._value.stringVal);
+
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
+
+		return *this;
+	}
+
+	return *this;
+}
+
+
+bool SingleValueContainer::getBoolValue(bool *returnValue) const {
+	if (_objectType !=  BOOL) {
+		warning("'Object' is not storing a bool.");
+		return false;
+	}
+
+	*returnValue = _value.boolVal;
+	return true;
+}
+
+bool SingleValueContainer::getByteValue(byte *returnValue) const {
+	if (_objectType !=  BYTE)
+		warning("'Object' is not storing a byte.");
+
+	*returnValue = _value.byteVal;
+	return true;
+}
+
+bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
+	if (_objectType !=  INT16)
+		warning("'Object' is not storing an int16.");
+
+	*returnValue = _value.int16Val;
+	return true;
+}
+
+bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
+	if (_objectType !=  UINT16)
+		warning("'Object' is not storing a uint16.");
+
+	*returnValue = _value.uint16Val;
+	return true;
+}
+
+bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
+	if (_objectType !=  INT32)
+		warning("'Object' is not storing an int32.");
+
+	*returnValue = _value.int32Val;
+	return true;
+}
+
+bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
+	if (_objectType !=  UINT32)
+		warning("'Object' is not storing a uint32.");
+
+	*returnValue = _value.uint32Val;
+	return true;
+}
+
+bool SingleValueContainer::getFloatValue(float *returnValue) const {
+	if (_objectType !=  FLOAT)
+		warning("'Object' is not storing a float.");
+
+	*returnValue = _value.floatVal;
+	return true;
+}
+
+bool SingleValueContainer::getDoubleValue(double *returnValue) const {
+	if (_objectType !=  DOUBLE)
+		warning("'Object' is not storing a double.");
+
+	*returnValue = _value.doubleVal;
+	return true;
+}
+
+bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
+	if (_objectType !=  STRING)
+		warning("'Object' is not storing a Common::String.");
+
+	*returnValue = _value.stringVal;
+	return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/singleValueContainer.h b/engines/zvision/singleValueContainer.h
new file mode 100644
index 0000000..3c24cc0
--- /dev/null
+++ b/engines/zvision/singleValueContainer.h
@@ -0,0 +1,181 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_OBJECT_H
+#define ZVISION_OBJECT_H
+
+#include "common/str.h"
+
+namespace ZVision {
+
+/**
+ * A generic single value storage class. It is useful for storing different 
+ * value types in a single List, Hashmap, etc.
+ */
+class SingleValueContainer {
+public:
+	enum ValueType {
+		BOOL,
+		BYTE,
+		INT16,
+		UINT16,
+		INT32,
+		UINT32,
+		FLOAT,
+		DOUBLE,
+		STRING,
+	};
+
+	// Constructors
+	explicit SingleValueContainer(ValueType type);
+	explicit SingleValueContainer(bool value);
+	explicit SingleValueContainer(byte value);
+	explicit SingleValueContainer(int16 value);
+	explicit SingleValueContainer(uint16 value);
+	explicit SingleValueContainer(int32 value);
+	explicit SingleValueContainer(uint32 value);
+	explicit SingleValueContainer(float value);
+	explicit SingleValueContainer(double value);
+	explicit SingleValueContainer(Common::String value);
+
+	// Copy constructor
+	explicit SingleValueContainer(const SingleValueContainer& other);
+
+	// Destructor
+	~SingleValueContainer();
+
+private:
+	ValueType _objectType;
+
+	union {
+		bool boolVal;
+		byte byteVal;
+		int16 int16Val;
+		uint16 uint16Val;
+		int32 int32Val;
+		uint32 uint32Val;
+		float floatVal;
+		double doubleVal;
+		char *stringVal;
+	} _value;
+
+public:
+	SingleValueContainer &operator=(const bool &rhs);
+	SingleValueContainer &operator=(const byte &rhs);
+	SingleValueContainer &operator=(const int16 &rhs);
+	SingleValueContainer &operator=(const uint16 &rhs);
+	SingleValueContainer &operator=(const int32 &rhs);
+	SingleValueContainer &operator=(const uint32 &rhs);
+	SingleValueContainer &operator=(const float &rhs);
+	SingleValueContainer &operator=(const double &rhs);
+	SingleValueContainer &operator=(const Common::String &rhs);
+
+	SingleValueContainer& operator=(const SingleValueContainer &rhs);
+
+	/**
+	 * Retrieve a bool from the container. If the container is not storing a 
+	 * bool, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getBoolValue(bool *returnValue) const;
+	/**
+	 * Retrieve a byte from the container. If the container is not storing a 
+	 * byte, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getByteValue(byte *returnValue) const;
+	/**
+	 * Retrieve an int16 from the container. If the container is not storing an 
+	 * int16, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getInt16Value(int16 *returnValue) const;
+	/**
+	 * Retrieve a uint16 from the container. If the container is not storing a 
+	 * uint16, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getUInt16Value(uint16 *returnValue) const;
+	/**
+	 * Retrieve an int32 from the container. If the container is not storing an 
+	 * int32, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getInt32Value(int32 *returnValue) const;
+	/**
+	 * Retrieve a uint32 from the container. If the container is not storing a 
+	 * uint32, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getUInt32Value(uint32 *returnValue) const;
+	/**
+	 * Retrieve a float from the container. If the container is not storing a 
+	 * float, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getFloatValue(float *returnValue) const;
+	/**
+	 * Retrieve a double from the container. If the container is not storing a 
+	 * double, this will return false and display a warning().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getDoubleValue(double *returnValue) const;
+	/**
+	 * Retrieve a String from the container. If the container is not storing a 
+	 * string, this will return false and display a warning().
+	 * 
+	 * Caution: Strings are internally stored as char[]. getStringValue uses
+	 * Common::String::operator=(char *) to do the assigment, which uses both
+	 * strlen() AND memmove().
+	 *
+	 * @param returnValue	Pointer to where you want the value stored
+	 * @return				Value indicating whether the value assignment was successful
+	 */
+	bool getStringValue(Common::String *returnValue) const;
+
+private:
+	/**
+	 * Helper method for destruction and assignment. It checks to see
+	 * if the char pointer is being used, and if so calls delete on it
+	 */
+	void deleteCharPointer();
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: 526c1dc4650948125334cedc32c9fdfb70219dce
    https://github.com/scummvm/scummvm/commit/526c1dc4650948125334cedc32c9fdfb70219dce
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:51-07:00

Commit Message:
ZVISION: Use spaces in doxygen comments for alignement instead of tabs

Changed paths:
    engines/zvision/singleValueContainer.h
    engines/zvision/utility.h
    engines/zvision/zfsArchive.h



diff --git a/engines/zvision/singleValueContainer.h b/engines/zvision/singleValueContainer.h
index 3c24cc0..49c7267 100644
--- a/engines/zvision/singleValueContainer.h
+++ b/engines/zvision/singleValueContainer.h
@@ -95,64 +95,64 @@ public:
 	 * Retrieve a bool from the container. If the container is not storing a 
 	 * bool, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getBoolValue(bool *returnValue) const;
 	/**
 	 * Retrieve a byte from the container. If the container is not storing a 
 	 * byte, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getByteValue(byte *returnValue) const;
 	/**
 	 * Retrieve an int16 from the container. If the container is not storing an 
 	 * int16, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getInt16Value(int16 *returnValue) const;
 	/**
 	 * Retrieve a uint16 from the container. If the container is not storing a 
 	 * uint16, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getUInt16Value(uint16 *returnValue) const;
 	/**
 	 * Retrieve an int32 from the container. If the container is not storing an 
 	 * int32, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getInt32Value(int32 *returnValue) const;
 	/**
 	 * Retrieve a uint32 from the container. If the container is not storing a 
 	 * uint32, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getUInt32Value(uint32 *returnValue) const;
 	/**
 	 * Retrieve a float from the container. If the container is not storing a 
 	 * float, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getFloatValue(float *returnValue) const;
 	/**
 	 * Retrieve a double from the container. If the container is not storing a 
 	 * double, this will return false and display a warning().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getDoubleValue(double *returnValue) const;
 	/**
@@ -163,8 +163,8 @@ public:
 	 * Common::String::operator=(char *) to do the assigment, which uses both
 	 * strlen() AND memmove().
 	 *
-	 * @param returnValue	Pointer to where you want the value stored
-	 * @return				Value indicating whether the value assignment was successful
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
 	 */
 	bool getStringValue(Common::String *returnValue) const;
 
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 9fade10..4d12450 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -33,8 +33,8 @@ namespace ZVision {
  * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
  * contents to destFile. destFile is created in the working directory
  *
- * @param sourceFile	The 'file' you want the contents of
- * @param destFile		The name of the file where the content will be written to
+ * @param sourceFile    The 'file' you want the contents of
+ * @param destFile      The name of the file where the content will be written to
  */
 void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) {
 	Common::File f;
@@ -57,7 +57,7 @@ void writeFileContentsToFile(Common::String sourceFile, Common::String destFile)
  * Then removes any trailing and leading 'whitespace' using String::trim()
  * Note: String::trim uses isspace() to determine what is whitespace and what is not.
  *
- * @param string	The string to modify. It is modified in place
+ * @param string    The string to modify. It is modified in place
  */
 void trimCommentsAndWhiteSpace(Common::String &string) {
 	for (int i = string.size(); i >= 0; --i) {
diff --git a/engines/zvision/zfsArchive.h b/engines/zvision/zfsArchive.h
index 60292f8..ccdf192 100644
--- a/engines/zvision/zfsArchive.h
+++ b/engines/zvision/zfsArchive.h
@@ -67,7 +67,7 @@ public:
 	 * Add all members of the Archive to list.
 	 * Must only append to list, and not remove elements from it.
 	 *
-	 * @return the number of names added to list
+	 * @return    The number of names added to list
 	 */
 	int listMembers(Common::ArchiveMemberList &list) const;
 
@@ -79,7 +79,8 @@ public:
 	/**
 	 * Create a stream bound to a member with the specified name in the
 	 * archive. If no member with this name exists, 0 is returned.
-	 * @return the newly created input stream
+	 *
+	 * @return    The newly created input stream
 	 */
 	Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
 
@@ -92,7 +93,7 @@ private:
 	 * Parses the zfs file into file entry headers that can be used later
 	 * to get the entry data.
 	 *
-	 * @param stream	The contents of the zfs file
+	 * @param stream    The contents of the zfs file
 	 */
 	void readHeaders(Common::SeekableReadStream *stream);
 
@@ -100,8 +101,8 @@ private:
 	 * Entry names are contained within a 16 byte block. This reads the block
 	 * and converts it the name to a Common::String
 	 *
-	 * @param stream	The zfs file stream
-	 * @return			The entry file name
+	 * @param stream    The zfs file stream
+	 * @return          The entry file name
 	 */
 	Common::String readEntryName(Common::SeekableReadStream *stream) const;
 
@@ -109,8 +110,8 @@ private:
 	 * ZFS file entries can be encrypted using XOR encoding. This method
 	 * decodes the buffer in place using the supplied xorKey.
 	 *
-	 * @param buffer	The data to decode
-	 * @param length	Length of buffer
+	 * @param buffer    The data to decode
+	 * @param length    Length of buffer
 	 */
 	void unXor(byte *buffer, int length, const byte *xorKey) const;
 };


Commit: ac96b943fa90270e1b5c1536f3b0d49bb6c3b161
    https://github.com/scummvm/scummvm/commit/ac96b943fa90270e1b5c1536f3b0d49bb6c3b161
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:51-07:00

Commit Message:
ZVISION: Create an instance of ScriptManager inside ZVision

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



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 452ed00..2009ccd 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -32,10 +32,13 @@
 #include "engines/util.h"

  

 #include "zvision/zvision.h"

+#include "zvision/scriptManager.h"

 #include "zvision/zfsArchive.h"

 

 #include "graphics/decoders/tga.h"

 

+#include "zvision/tests.h"

+

 namespace ZVision {

  

 ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {

@@ -59,7 +62,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine
  

 	// Don't forget to register your random source

 	_rnd = new Common::RandomSource("zvision");

- 

+

 	debug("ZVision::ZVision");

 }

  

@@ -90,6 +93,8 @@ void ZVision::initialize() {
 	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555

 	initGraphics(640, 480, true, &format);

 

+	_scriptManager.initialize();

+

 	// Create debugger console. It requires GFX to be initialized

 	_console = new Console(this);

 }

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index c5ddb8a..b57ce20 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -29,6 +29,8 @@
 

 #include "engines/engine.h"

 

+#include "zvision/scriptManager.h"

+

 #include "gui/debugger.h"

  

 namespace ZVision {

@@ -56,6 +58,8 @@ private:
 	// We need random numbers

 	Common::RandomSource *_rnd;

 

+	ScriptManager _scriptManager;

+

 	// To prevent allocation every time we process events

 	Common::Event _event;

 



Commit: b3b7bd29b1fe2dcb2e2c13bbd68c907dc4990552
    https://github.com/scummvm/scummvm/commit/b3b7bd29b1fe2dcb2e2c13bbd68c907dc4990552
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:52-07:00

Commit Message:
ZVISION: Create ResultAction base class and ActionAdd child class

Changed paths:
  A engines/zvision/resultAction.cpp
  A engines/zvision/resultAction.h



diff --git a/engines/zvision/resultAction.cpp b/engines/zvision/resultAction.cpp
new file mode 100644
index 0000000..d14438d
--- /dev/null
+++ b/engines/zvision/resultAction.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/resultAction.h"
+
+namespace ZVision {
+
+ActionAdd::ActionAdd(Common::String line) {
+	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
+}
+
+bool ActionAdd::execute(ZVision *zVision) {
+	zVision->getScriptManager()->addToStateValue(_key, _value);
+	return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/resultAction.h b/engines/zvision/resultAction.h
new file mode 100644
index 0000000..4fd589d
--- /dev/null
+++ b/engines/zvision/resultAction.h
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_RESULT_ACTION_H
+#define ZVISION_RESULT_ACTION_H
+
+#include "common/scummsys.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ResultAction {
+public:
+	virtual ~ResultAction() {}
+	virtual bool execute(ZVision *zVision) = 0;
+};
+
+
+// The different types of actions
+// ADD,
+// ANIM_PLAY,
+// ANIM_PRELOAD,
+// ANIM_UNLOAD,
+// ATTENUATE,
+// ASSIGN,
+// CHANGE_LOCATION,
+// CROSSFADE,
+// DEBUG,
+// DELAY_RENDER,
+// DISABLE_CONTROL,
+// DISABLE_VENUS,
+// DISPLAY_MESSAGE,
+// DISSOLVE,
+// DISTORT,
+// ENABLE_CONTROL,
+// FLUSH_MOUSE_EVENTS,
+// INVENTORY,
+// KILL,
+// MENU_BAR_ENABLE,
+// MUSIC,
+// PAN_TRACK,
+// PLAY_PRELOAD,
+// PREFERENCES,
+// QUIT,
+// RANDOM,
+// REGION,
+// RESTORE_GAME,
+// ROTATE_TO,
+// SAVE_GAME,
+// SET_PARTIAL_SCREEN,
+// SET_SCREEN,
+// SET_VENUS,
+// STOP,
+// STREAM_VIDEO,
+// SYNC_SOUND,
+// TIMER,
+// TTY_TEXT,
+// UNIVERSE_MUSIC,
+
+class ActionAdd : public ResultAction {
+public:
+	ActionAdd(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: 464cc44a8204134681aadbe68645fd4efe6d04d4
    https://github.com/scummvm/scummvm/commit/464cc44a8204134681aadbe68645fd4efe6d04d4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:52-07:00

Commit Message:
ZVISION: Convert ScriptManager methods to use ResultAction classes logic

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/scrFileHandling.cpp



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 1133ada..1a456ef 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -25,7 +25,7 @@
 
 #include "common/list.h"
 
-#include "zvision/object.h"
+#include "zvision/resultAction.h"
 
 namespace ZVision {
 
@@ -39,11 +39,11 @@ enum CriteriaOperator {
 
 /** Criteria for a Puzzle result to be fired */
 struct Criteria {
-	/** The id of a global state */
-	uint32 id;
+	/** The key of a global state */
+	uint32 key;
 	/**  
 	 * What we're comparing the value of the global state against
-	 * This can either be a pure value or it can be the id of another global state
+	 * This can either be a pure value or it can be the key of another global state
 	 */
 	uint32 argument;
 	/** How to do the comparison */
@@ -52,55 +52,6 @@ struct Criteria {
 	bool isArgumentAnId;
 };
 
-/** What happens when Puzzle criteria are met */
-enum ResultAction {
-	ADD,
-	ANIM_PLAY,
-	ANIM_PRELOAD,
-	ANIM_UNLOAD,
-	ATTENUATE,
-	ASSIGN,
-	CHANGE_LOCATION,
-	CROSSFADE,
-	DEBUG,
-	DELAY_RENDER,
-	DISABLE_CONTROL,
-	DISABLE_VENUS,
-	DISPLAY_MESSAGE,
-	DISSOLVE,
-	DISTORT,
-	ENABLE_CONTROL,
-	FLUSH_MOUSE_EVENTS,
-	INVENTORY,
-	KILL,
-	MENU_BAR_ENABLE,
-	MUSIC,
-	PAN_TRACK,
-	PLAY_PRELOAD,
-	PREFERENCES,
-	QUIT,
-	RANDOM,
-	REGION,
-	RESTORE_GAME,
-	ROTATE_TO,
-	SAVE_GAME,
-	SET_PARTIAL_SCREEN,
-	SET_SCREEN,
-	SET_VENUS,
-	STOP,
-	STREAM_VIDEO,
-	SYNC_SOUND,
-	TIMER,
-	TTY_TEXT,
-	UNIVERSE_MUSIC,
-};
-
-/** What happens when Puzzle criteria are met */
-struct Result {
-	ResultAction action;
-	Common::List<Object> arguments;
-};
-
 enum StateFlags : byte {
 	ONCE_PER_INST = 0x01,
 	DO_ME_NOW = 0x02,
@@ -108,9 +59,9 @@ enum StateFlags : byte {
 };
 
 struct Puzzle {
-	uint32 id;
+	uint32 key;
 	Common::List<Criteria> criteriaList;
-	Common::List<Result> resultList;
+	Common::List<ResultAction> resultActions;
 	byte flags;
 };
 
diff --git a/engines/zvision/scrFileHandling.cpp b/engines/zvision/scrFileHandling.cpp
index a0d4ceb..c511a2e 100644
--- a/engines/zvision/scrFileHandling.cpp
+++ b/engines/zvision/scrFileHandling.cpp
@@ -26,6 +26,7 @@
 
 #include "zvision/scriptManager.h"
 #include "zvision/utility.h"
+#include "zvision/puzzle.h"
 
 #include "common/textconsole.h"
 #include "common/file.h"
@@ -33,13 +34,11 @@
 
 namespace ZVision {
 
-
 void ScriptManager::parseScrFile(Common::String fileName) {
 	Common::File file;
 	if (!file.open(fileName))
 		return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
 
-	char buffer[1024];
 	while(!file.eos()) {
 		Common::String line = file.readLine();
 		if (file.err()) {
@@ -52,32 +51,34 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 			continue;
 
 		if (line.matchString("puzzle:*", true)) {
-			Puzzle *puzzle = new Puzzle();
-			sscanf(line.c_str(),"puzzle:%u",&(puzzle->id));
+			Puzzle puzzle;
+			sscanf(line.c_str(),"puzzle:%u",&(puzzle.id));
 
 			parsePuzzle(puzzle, file);
+			_puzzles.push_back(puzzle);
 		} else if (line.matchString("control:*", true)) {
-			Control *control = new Control();
-			sscanf(line.c_str(),"control:%u",&(control->id));
+			Control control;
+			char controlType[20];
+			sscanf(line.c_str(),"control:%u %s",&(control.id), controlType);
 
 			parseControl(control, file);
+			_controls.push_back(control);
 		}
 	}
 }
 
-void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
+void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(line);
 
 	while (!line.contains('}')) {
 		if (line.matchString("criteria {", true))
-			puzzle->criteriaList.push_back(parseCriteria(stream));
+			puzzle.criteriaList.push_back(parseCriteria(stream));
 		else if (line.matchString("results {", true))
-			puzzle->resultList.push_back(parseResult(stream));
+			parseResult(stream, puzzle.resultActions);
 		else if (line.matchString("flags {", true))
-			puzzle->flags = parseFlags(stream);
+			puzzle.flags = parseFlags(stream);
 	}
-
 }
 
 Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const {
@@ -125,177 +126,138 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 	return criteria;
 }
 
-Result ScriptManager::parseResult(Common::SeekableReadStream &stream) const {
-	Result result;
-
+void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(line);
 
 	while (!line.contains('}')) {
-		Common::StringTokenizer tokenizer(line, " :(),");
-		// We don't care about the first token
-		tokenizer.nextToken();
-		Common::String token = tokenizer.nextToken();
-
-		// The second token defines the action
-		// Use it to set the action enum and then to parse the arguments
-		if (token.matchString("add", true)) {
-			result.action = ADD;
-			ObjectType argTypes[] = { UINT32, UINT32 };
-			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
-		} else if (token.matchString("animplay", true)) {
-			result.action = ANIM_PLAY;
+		// Parse for the action type
+		if (line.matchString("*:add*", true)) {
+			actionList.push_back(ActionAdd(line));
+		} else if (line.matchString("*:animplay*", true)) {
+			
 
-		} else if (token.matchString("animpreload", true)) {
-			result.action = ANIM_PRELOAD;
-
-		} else if (token.matchString("animunload", true)) {
-			result.action = ANIM_UNLOAD;
-
-		} else if (token.matchString("attenuate", true)) {
-			result.action = ATTENUATE;
+		} else if (line.matchString("*:animpreload*", true)) {
+			
 
-		} else if (token.matchString("assign", true)) {
-			result.action = ASSIGN;
-			ObjectType argTypes[] = { UINT32, UINT32 };
-			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
-		} else if (token.matchString("change_location", true)) {
-			result.action = CHANGE_LOCATION;
-			ObjectType argTypes[] = { STRING, STRING, STRING, UINT32 };
-			parseResultArguments(result, argTypes, 4, tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken());
-		} else if (token.matchString("crossfade", true)) {
-			result.action = CROSSFADE;
-
-		} else if (token.matchString("debug", true)) {
-			result.action = DEBUG;
-
-		} else if (token.matchString("delay_render", true)) {
-			result.action = DELAY_RENDER;
-
-		} else if (token.matchString("disable_control", true)) {
-			result.action = DISABLE_CONTROL;
-
-		} else if (token.matchString("disable_venus", true)) {
-			result.action = DISABLE_VENUS;
-
-		} else if (token.matchString("display_message", true)) {
-			result.action = DISPLAY_MESSAGE;
-
-		} else if (token.matchString("dissolve", true)) {
-			result.action = DISSOLVE;
-		} else if (token.matchString("distort", true)) {
-			result.action = DISTORT;
-
-		} else if (token.matchString("enable_control", true)) {
-			result.action = ENABLE_CONTROL;
-
-		} else if (token.matchString("flush_mouse_events", true)) {
-			result.action = FLUSH_MOUSE_EVENTS;
-
-		} else if (token.matchString("inventory", true)) {
-			result.action = INVENTORY;
-
-		} else if (token.matchString("kill", true)) {
-			result.action = KILL;
-
-		} else if (token.matchString("menu_bar_enable", true)) {
-			result.action = MENU_BAR_ENABLE;
-
-		} else if (token.matchString("music", true)) {
-			result.action = MUSIC;
-			ObjectType argTypes[] = { UINT32, UINT32, STRING, UINT32, UINT32 };
-			parseResultArguments(result, argTypes, 5,
-								 tokenizer.nextToken(), tokenizer.nextToken(),
-								 tokenizer.nextToken(), tokenizer.nextToken(),
-								 tokenizer.nextToken());
-		} else if (token.matchString("pan_track", true)) {
-			result.action = PAN_TRACK;
-
-		} else if (token.matchString("playpreload", true)) {
-			result.action = PLAY_PRELOAD;
-
-		} else if (token.matchString("preferences", true)) {
-			result.action = PREFERENCES;
-
-		} else if (token.matchString("quit", true)) {
-			result.action = QUIT;
-
-		} else if (token.matchString("random", true)) {
-			result.action = RANDOM;
-			ObjectType argTypes[] = { UINT32, UINT32 };
-			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
-		} else if (token.matchString("region", true)) {
-			result.action = REGION;
-
-		} else if (token.matchString("restore_game", true)) {
-			result.action = RESTORE_GAME;
-
-		} else if (token.matchString("rotate_to", true)) {
-			result.action = ROTATE_TO;
-
-		} else if (token.matchString("save_game", true)) {
-			result.action = SAVE_GAME;
+		} else if (line.matchString("*:animunload*", true)) {
+			
 
-		} else if (token.matchString("set_partial_screen", true)) {
-			result.action = SET_PARTIAL_SCREEN;
+		} else if (line.matchString("*:attenuate*", true)) {
+			
 
-		} else if (token.matchString("set_screen", true)) {
-			result.action = SET_SCREEN;
+		} else if (line.matchString("*:assign*", true)) {
+			
 
-		} else if (token.matchString("set_venus", true)) {
-			result.action = SET_VENUS;
+		} else if (line.matchString("*:change_location*", true)) {
+			
 
-		} else if (token.matchString("stop", true)) {
-			result.action = STOP;
-			ObjectType argTypes[] = { UINT32 };
-			parseResultArguments(result, argTypes, 1, tokenizer.nextToken());
-		} else if (token.matchString("streamvideo", true)) {
-			result.action = STREAM_VIDEO;
+		} else if (line.matchString("*:crossfade*", true)) {
+			
 
-		} else if (token.matchString("syncsound", true)) {
-			result.action = SYNC_SOUND;
+		} else if (line.matchString("*:debug*", true)) {
+			
 
-		} else if (token.matchString("timer", true)) {
-			result.action = TIMER;
-			ObjectType argTypes[] = { UINT32, UINT32 };
-			parseResultArguments(result, argTypes, 2, tokenizer.nextToken(), tokenizer.nextToken());
-		} else if (token.matchString("ttytext", true)) {
-			result.action = TTY_TEXT;
+		} else if (line.matchString("*:delay_render*", true)) {
+			
 
-		} else if (token.matchString("universe_music", true)) {
-			result.action = UNIVERSE_MUSIC;
+		} else if (line.matchString("*:disable_control*", true)) {
+			
 
-		} else {
-			warning("Unhandled result action type: ", token);
-		}
+		} else if (line.matchString("*:disable_venus*", true)) {
+			
 
-		line = stream.readLine();
-		trimCommentsAndWhiteSpace(line);
-	}
+		} else if (line.matchString("*:display_message*", true)) {
+			
 
-	return result;
-}
+		} else if (line.matchString("*:dissolve*", true)) {
+			
+
+		} else if (line.matchString("*:distort*", true)) {
+			
+
+		} else if (line.matchString("*:enable_control*", true)) {
+			
+
+		} else if (line.matchString("*:flush_mouse_events*", true)) {
+			
+
+		} else if (line.matchString("*:inventory*", true)) {
+			
+
+		} else if (line.matchString("*:kill*", true)) {
+			
+
+		} else if (line.matchString("*:menu_bar_enable*", true)) {
+			
+
+		} else if (line.matchString("*:music*", true)) {
+			
+
+		} else if (line.matchString("*:pan_track*", true)) {
+			
+
+		} else if (line.matchString("*:playpreload*", true)) {
+			
+
+		} else if (line.matchString("*:preferences*", true)) {
+			
+
+		} else if (line.matchString("*:quit*", true)) {
+			
+
+		} else if (line.matchString("*:random*", true)) {
+			
+
+		} else if (line.matchString("*:region*", true)) {
+			
+
+		} else if (line.matchString("*:restore_game*", true)) {
+			
+
+		} else if (line.matchString("*:rotate_to*", true)) {
+			
+
+		} else if (line.matchString("*:save_game*", true)) {
+			
+
+		} else if (line.matchString("*:set_partial_screen*", true)) {
+			
+
+		} else if (line.matchString("*:set_screen*", true)) {
+			
+
+		} else if (line.matchString("*:set_venus*", true)) {
+			
+
+		} else if (line.matchString("*:stop*", true)) {
+			
+
+		} else if (line.matchString("*:streamvideo*", true)) {
+			
+
+		} else if (line.matchString("*:syncsound*", true)) {
+			
+
+		} else if (line.matchString("*:timer*", true)) {
+			
+
+		} else if (line.matchString("*:ttytext*", true)) {
+			
+
+		} else if (line.matchString("*:universe_music*", true)) {
+			
 
-void ScriptManager::parseResultArguments(Result &result, const ObjectType *types, int numberOfArgs, ...) const {
-	va_list argptr;
-	va_start(argptr, numberOfArgs);
-
-	for (int i = 0; i < numberOfArgs; i++) {
-		if (types[i] == UINT32) {
-			Common::String arg = va_arg(argptr, Common::String);
-			Object argObject(UINT32);
-			sscanf(arg.c_str(), "%u", &argObject);
-			result.arguments.push_back(argObject);
-			break;
 		} else {
-			Common::String arg = va_arg(argptr, Common::String);
-			result.arguments.push_back(Object(arg));
-			break;
+			warning("Unhandled result action type: ", line);
 		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(line);
 	}
 
-	va_end(argptr);
+	return;
 }
 
 byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
@@ -318,7 +280,7 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
 	return flags;
 }
 
-void ScriptManager::parseControl(Control *control, Common::SeekableReadStream &stream) {
+void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) {
 
 }
 


Commit: b70f85b9a0775212f47c25f5218e63b117d0c696
    https://github.com/scummvm/scummvm/commit/b70f85b9a0775212f47c25f5218e63b117d0c696
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:53-07:00

Commit Message:
ZVISION: Comment clarification for ScriptManager methods and helper structs

Changed paths:
    engines/zvision/scrFileHandling.cpp
    engines/zvision/scriptManager.h



diff --git a/engines/zvision/scrFileHandling.cpp b/engines/zvision/scrFileHandling.cpp
index c511a2e..61feb12 100644
--- a/engines/zvision/scrFileHandling.cpp
+++ b/engines/zvision/scrFileHandling.cpp
@@ -113,10 +113,10 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 		token = tokenizer.nextToken();
 		if (token.contains('[')) {
 			sscanf(token.c_str(), "[%u]", &(criteria.argument));
-			criteria.argumentIsAnId = true;
+			criteria.isArgumentAnId = true;
 		} else {
 			sscanf(token.c_str(), "%u", &(criteria.argument));
-			criteria.argumentIsAnId = false;
+			criteria.isArgumentAnId = false;
 		}
 
 		line = stream.readLine();
diff --git a/engines/zvision/scriptManager.h b/engines/zvision/scriptManager.h
index 0bae919..563a010 100644
--- a/engines/zvision/scriptManager.h
+++ b/engines/zvision/scriptManager.h
@@ -29,17 +29,27 @@
 
 #include "zvision/puzzle.h"
 #include "zvision/control.h"
+#include "zvision/singleValueContainer.h"
 
 namespace ZVision {
 
 class ScriptManager {
-public:
-	ScriptManager();
-	~ScriptManager();
-
 private:
+	/** Holds the global state variables. Optimize for fast random access */
 	Common::HashMap<uint32, byte> _globalState;
+	/** Holds the currently active puzzles. Optimize for fast iteration */
+	Common::List<Puzzle> _puzzles;
+	/** Holds the currently active controls. Optimize for fast iteration */
+	Common::List<Control> _controls;
 
+public:
+	
+	void initialize();
+	byte getStateValue(uint32 key);
+	void setStateValue(uint32 key, byte value);
+	void addToStateValue(uint32 key, byte valueToAdd);
+
+private:
 	/**
 	 * Parses a script file into triggers and events
 	 *
@@ -48,54 +58,47 @@ private:
 	void parseScrFile(Common::String fileName);
 
 	/**
-	 * Helper method for parseScrFile. Parses the stream into a Puzzle object
+	 * Parses the stream into a Puzzle object
+	 * Helper method for parseScrFile. 
 	 *
-	 * @param puzzle	The object to store what is parsed
-	 * @param stream	Scr file stream
+	 * @param puzzle    The object to store what is parsed
+	 * @param stream    Scr file stream
 	 */
-	void parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream);
+	void parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream);
 
 	/**
-	 * Helper method for parsePuzzle. Parses the stream into a Criteria object
+	 * Parses the stream into a Criteria object
+	 * Helper method for parsePuzzle. 
 	 *
-	 * @param stream	Scr file stream
-	 * @return			Created Criteria object
+	 * @param stream    Scr file stream
+	 * @return          Created Criteria object
 	 */
 	Criteria parseCriteria(Common::SeekableReadStream &stream) const;
 
 	/**
-	 * Helper method for parsePuzzle. Parses the stream into a Results object
-	 *
-	 * @param stream	Scr file stream
-	 * @return			Created Results object
-	 */
-	Result parseResult(Common::SeekableReadStream &stream) const;
-
-	/**
-	 * Helper method for parseResults. Parses a number of strings into Object types.
+	 * Parses the stream into a Results object
+	 * Helper method for parsePuzzle. 
 	 *
-	 * @param result			Results object to store the arguments in
-	 * @param types				The type of the each of the arguments. IE. BOOL, UINT32, etc.
-	 * @param numberOfArgs		The number of arguments. This has to equal the length of 'types' AND the number of optional arguments passed.
-	 * @param 					String arguments wanting to be parsed
+	 * @param stream    Scr file stream
+	 * @return          Created Results object
 	 */
-	void parseResultArguments(Result &result, const ObjectType *types, int numberOfArgs, ...) const;
+	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const;
 
 	/**
 	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
 	 *
-	 * @param stream	Scr file stream
-	 * @return			Bitwise or of all the flags set within the puzzle
+	 * @param stream    Scr file stream
+	 * @return          Bitwise or of all the flags set within the puzzle
 	 */
 	byte parseFlags(Common::SeekableReadStream &stream) const;
 
 	/**
 	 * Helper method for parseScrFile. Parses the stream into a Control object
 	 *
-	 * @param control	The object to store what is parsed
-	 * @param stream	Scr file stream
+	 * @param control    The object to store what is parsed
+	 * @param stream     Scr file stream
 	 */
-	void parseControl(Control *control, Common::SeekableReadStream &stream);
+	void parseControl(Control &control, Common::SeekableReadStream &stream);
 };
 
 


Commit: dec34c174bd34f1fd1354985e7c70336270dd9e6
    https://github.com/scummvm/scummvm/commit/dec34c174bd34f1fd1354985e7c70336270dd9e6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:53-07:00

Commit Message:
ZVISION: Create global state accessor/mutator methods for ScriptManager

Changed paths:
  A engines/zvision/scriptManager.cpp



diff --git a/engines/zvision/scriptManager.cpp b/engines/zvision/scriptManager.cpp
new file mode 100644
index 0000000..5317bf6
--- /dev/null
+++ b/engines/zvision/scriptManager.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/scriptManager.h"
+
+namespace ZVision {
+
+// TODO: Actually do something in the initialize or remove it
+void ScriptManager::initialize() {
+	
+}
+
+byte ScriptManager::getStateValue(uint32 key) {
+	return _globalState[key];
+}
+
+void ScriptManager::setStateValue(uint32 key, byte value) {
+	_globalState[key] = value;
+}
+
+void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
+	_globalState[key] += valueToAdd;
+}
+
+} // End of namespace ZVision


Commit: 8d9f90bf12c758ac4845f19ae8584c0c5ee264c8
    https://github.com/scummvm/scummvm/commit/8d9f90bf12c758ac4845f19ae8584c0c5ee264c8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:54-07:00

Commit Message:
ZVISION: Create ScriptManager accessor for ZVision

Having the ScriptManager as a member variable forced it to be const,
which prevented any non cont methods to be used. Thus, ScriptManager is
created on the heap and disposed after use.

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



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 2009ccd..33b2a80 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -60,19 +60,23 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine
 	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");

 	//DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");

  

-	// Don't forget to register your random source

+	// Register random source

 	_rnd = new Common::RandomSource("zvision");

 

+	// Create managers

+	_scriptManager = new ScriptManager();

+

 	debug("ZVision::ZVision");

 }

  

 ZVision::~ZVision() {

 	debug("ZVision::~ZVision");

  

-	// Dispose your resources here

+	// Dispose of resources

+	delete _scriptManager;

 	delete _rnd;

  

-	// Remove all of our debug levels here

+	// Remove all of our debug levels

 	DebugMan.clearAllDebugChannels();

 }

 

@@ -93,7 +97,7 @@ void ZVision::initialize() {
 	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555

 	initGraphics(640, 480, true, &format);

 

-	_scriptManager.initialize();

+	_scriptManager->initialize();

 

 	// Create debugger console. It requires GFX to be initialized

 	_console = new Console(this);

@@ -134,4 +138,8 @@ Common::Error ZVision::run() {
 	return Common::kNoError;

 }

 

+ScriptManager *ZVision::getScriptManager() const {

+	return _scriptManager;

+}

+

 } // End of namespace ZVision

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index b57ce20..b0cd1ae 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -58,7 +58,7 @@ private:
 	// We need random numbers

 	Common::RandomSource *_rnd;

 

-	ScriptManager _scriptManager;

+	ScriptManager *_scriptManager;

 

 	// To prevent allocation every time we process events

 	Common::Event _event;

@@ -69,7 +69,8 @@ public:
 	uint32 getFeatures() const;

 	Common::Language getLanguage() const;

 	virtual Common::Error run();

- 

+	ScriptManager *getScriptManager() const;

+

 private:

 	void initialize();

 



Commit: 7bc0097ddef3bbbb38bf854a2ed8685c92fd3312
    https://github.com/scummvm/scummvm/commit/7bc0097ddef3bbbb38bf854a2ed8685c92fd3312
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:54-07:00

Commit Message:
ZVISION: Fix include for singleValueContainer.cpp

Changed paths:
    engines/zvision/singleValueContainer.cpp



diff --git a/engines/zvision/singleValueContainer.cpp b/engines/zvision/singleValueContainer.cpp
index 6a3d4e0..bd91c44 100644
--- a/engines/zvision/singleValueContainer.cpp
+++ b/engines/zvision/singleValueContainer.cpp
@@ -23,7 +23,7 @@
 #include "common/scummsys.h"
 #include "common/textconsole.h"
 
-#include "zvision/object.h"
+#include "zvision/singleValueContainer.h"
 
 namespace ZVision {
 


Commit: daa2c4b67060ba8c86b11f60a59f1b59fec5037f
    https://github.com/scummvm/scummvm/commit/daa2c4b67060ba8c86b11f60a59f1b59fec5037f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:55-07:00

Commit Message:
ZVISION: Move test functions out of video.cpp and into their own file

The file only exist to hold the code. The actual tests will be
moved to an appropriate location later.

Changed paths:
  A engines/zvision/tests.h
    engines/zvision/video.cpp



diff --git a/engines/zvision/tests.h b/engines/zvision/tests.h
new file mode 100644
index 0000000..14f80ed
--- /dev/null
+++ b/engines/zvision/tests.h
@@ -0,0 +1,54 @@
+
+namespace ZVision {
+
+void tests() {
+#if 0
+	// Video test
+	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
+	if (videoDecoder && videoDecoder->loadFile("zassets/temple/t000a11c.avi")) {
+		Common::List<Graphics::PixelFormat> formats;
+		formats.push_back(videoDecoder->getPixelFormat());
+		//initGraphics(640, 480, true, formats);
+
+		playVideo(videoDecoder);
+	}
+#endif
+
+	Common::File f;
+
+#if 1
+	// Image test
+
+	//initGraphics(640, 480, true, &format);
+
+	if (f.open(" zassets/global/GJDEB11C.TGA")) {
+		Graphics::TGADecoder tga;
+		if (!tga.loadStream(f))
+			error("Error while reading TGA image");
+		f.close();
+
+		const Graphics::Surface *tgaSurface = tga.getSurface();
+
+		Graphics::Surface *screen = g_system->lockScreen();
+		for (uint16 y = 0; y < tgaSurface->h; y++)
+			memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);
+		g_system->unlockScreen();
+
+		tga.destroy();
+	}
+
+
+#endif
+
+#if 0
+	// Sound test
+	if (f.open("zassets/castle/c000h9tc.raw")) {
+		Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);
+		Audio::SoundHandle handle;
+		g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
+	}
+
+#endif
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index ce68683..4e5fe82 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -132,54 +132,4 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
 	delete videoDecoder;
 }
 
-void tests() {
-#if 0
-	// Video test
-	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
-	if (videoDecoder && videoDecoder->loadFile("zassets/temple/t000a11c.avi")) {
-		Common::List<Graphics::PixelFormat> formats;
-		formats.push_back(videoDecoder->getPixelFormat());
-		//initGraphics(640, 480, true, formats);
-
-		playVideo(videoDecoder);
-	}
-#endif
-
-	Common::File f;
-
-#if 0
-	// Image test
-
-	//initGraphics(640, 480, true, &format);
-
-	if (f.open("zassets/castle/cb8eb11c.tga")) {
-		Graphics::TGADecoder tga;
-		if (!tga.loadStream(f))
-			error("Error while reading TGA image");
-		f.close();
-
-		const Graphics::Surface *tgaSurface = tga.getSurface();
-
-		Graphics::Surface *screen = g_system->lockScreen();
-		for (uint16 y = 0; y < tgaSurface->h; y++)
-			memcpy(screen->getBasePtr(0, y), tgaSurface->getBasePtr(0, y), tgaSurface->pitch);
-		g_system->unlockScreen();
-
-		tga.destroy();
-	}
-
-
-#endif
-
-#if 0
-	// Sound test
-	if (f.open("zassets/castle/c000h9tc.raw")) {
-		Audio::SeekableAudioStream *audioStream = makeRawZorkStream(&f, 22050, DisposeAfterUse::YES);
-		Audio::SoundHandle handle;
-		g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
-	}
-
-#endif
-}
-
 } // End of namespace ZVision


Commit: f99d613dcb1022a6c30b0c299ffada11fb7eba6b
    https://github.com/scummvm/scummvm/commit/f99d613dcb1022a6c30b0c299ffada11fb7eba6b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:55-07:00

Commit Message:
ZVISION: Rename files to use underscores instead of camelCase

Changed paths:
  A engines/zvision/result_action.cpp
  A engines/zvision/result_action.h
  A engines/zvision/scr_file_handling.cpp
  A engines/zvision/script_manager.cpp
  A engines/zvision/script_manager.h
  A engines/zvision/single_value_container.cpp
  A engines/zvision/single_value_container.h
  A engines/zvision/zfs_archive.cpp
  A engines/zvision/zfs_archive.h
  R engines/zvision/resultAction.cpp
  R engines/zvision/resultAction.h
  R engines/zvision/scrFileHandling.cpp
  R engines/zvision/scriptManager.cpp
  R engines/zvision/scriptManager.h
  R engines/zvision/singleValueContainer.cpp
  R engines/zvision/singleValueContainer.h
  R engines/zvision/zfsArchive.cpp
  R engines/zvision/zfsArchive.h



diff --git a/engines/zvision/resultAction.cpp b/engines/zvision/resultAction.cpp
deleted file mode 100644
index d14438d..0000000
--- a/engines/zvision/resultAction.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/resultAction.h"
-
-namespace ZVision {
-
-ActionAdd::ActionAdd(Common::String line) {
-	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
-}
-
-bool ActionAdd::execute(ZVision *zVision) {
-	zVision->getScriptManager()->addToStateValue(_key, _value);
-	return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/resultAction.h b/engines/zvision/resultAction.h
deleted file mode 100644
index 4fd589d..0000000
--- a/engines/zvision/resultAction.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_RESULT_ACTION_H
-#define ZVISION_RESULT_ACTION_H
-
-#include "common/scummsys.h"
-
-#include "zvision/zvision.h"
-
-namespace ZVision {
-
-class ResultAction {
-public:
-	virtual ~ResultAction() {}
-	virtual bool execute(ZVision *zVision) = 0;
-};
-
-
-// The different types of actions
-// ADD,
-// ANIM_PLAY,
-// ANIM_PRELOAD,
-// ANIM_UNLOAD,
-// ATTENUATE,
-// ASSIGN,
-// CHANGE_LOCATION,
-// CROSSFADE,
-// DEBUG,
-// DELAY_RENDER,
-// DISABLE_CONTROL,
-// DISABLE_VENUS,
-// DISPLAY_MESSAGE,
-// DISSOLVE,
-// DISTORT,
-// ENABLE_CONTROL,
-// FLUSH_MOUSE_EVENTS,
-// INVENTORY,
-// KILL,
-// MENU_BAR_ENABLE,
-// MUSIC,
-// PAN_TRACK,
-// PLAY_PRELOAD,
-// PREFERENCES,
-// QUIT,
-// RANDOM,
-// REGION,
-// RESTORE_GAME,
-// ROTATE_TO,
-// SAVE_GAME,
-// SET_PARTIAL_SCREEN,
-// SET_SCREEN,
-// SET_VENUS,
-// STOP,
-// STREAM_VIDEO,
-// SYNC_SOUND,
-// TIMER,
-// TTY_TEXT,
-// UNIVERSE_MUSIC,
-
-class ActionAdd : public ResultAction {
-public:
-	ActionAdd(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	byte _value;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
new file mode 100644
index 0000000..d14438d
--- /dev/null
+++ b/engines/zvision/result_action.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/resultAction.h"
+
+namespace ZVision {
+
+ActionAdd::ActionAdd(Common::String line) {
+	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
+}
+
+bool ActionAdd::execute(ZVision *zVision) {
+	zVision->getScriptManager()->addToStateValue(_key, _value);
+	return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h
new file mode 100644
index 0000000..4fd589d
--- /dev/null
+++ b/engines/zvision/result_action.h
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_RESULT_ACTION_H
+#define ZVISION_RESULT_ACTION_H
+
+#include "common/scummsys.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ResultAction {
+public:
+	virtual ~ResultAction() {}
+	virtual bool execute(ZVision *zVision) = 0;
+};
+
+
+// The different types of actions
+// ADD,
+// ANIM_PLAY,
+// ANIM_PRELOAD,
+// ANIM_UNLOAD,
+// ATTENUATE,
+// ASSIGN,
+// CHANGE_LOCATION,
+// CROSSFADE,
+// DEBUG,
+// DELAY_RENDER,
+// DISABLE_CONTROL,
+// DISABLE_VENUS,
+// DISPLAY_MESSAGE,
+// DISSOLVE,
+// DISTORT,
+// ENABLE_CONTROL,
+// FLUSH_MOUSE_EVENTS,
+// INVENTORY,
+// KILL,
+// MENU_BAR_ENABLE,
+// MUSIC,
+// PAN_TRACK,
+// PLAY_PRELOAD,
+// PREFERENCES,
+// QUIT,
+// RANDOM,
+// REGION,
+// RESTORE_GAME,
+// ROTATE_TO,
+// SAVE_GAME,
+// SET_PARTIAL_SCREEN,
+// SET_SCREEN,
+// SET_VENUS,
+// STOP,
+// STREAM_VIDEO,
+// SYNC_SOUND,
+// TIMER,
+// TTY_TEXT,
+// UNIVERSE_MUSIC,
+
+class ActionAdd : public ResultAction {
+public:
+	ActionAdd(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scrFileHandling.cpp b/engines/zvision/scrFileHandling.cpp
deleted file mode 100644
index 61feb12..0000000
--- a/engines/zvision/scrFileHandling.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include <stdio.h>
-
-#include "zvision/scriptManager.h"
-#include "zvision/utility.h"
-#include "zvision/puzzle.h"
-
-#include "common/textconsole.h"
-#include "common/file.h"
-#include "common/tokenizer.h"
-
-namespace ZVision {
-
-void ScriptManager::parseScrFile(Common::String fileName) {
-	Common::File file;
-	if (!file.open(fileName))
-		return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
-
-	while(!file.eos()) {
-		Common::String line = file.readLine();
-		if (file.err()) {
-			warning("Error parsing scr file: %s", fileName);
-			return;
-		}
-
-		trimCommentsAndWhiteSpace(line);
-		if (line.empty())
-			continue;
-
-		if (line.matchString("puzzle:*", true)) {
-			Puzzle puzzle;
-			sscanf(line.c_str(),"puzzle:%u",&(puzzle.id));
-
-			parsePuzzle(puzzle, file);
-			_puzzles.push_back(puzzle);
-		} else if (line.matchString("control:*", true)) {
-			Control control;
-			char controlType[20];
-			sscanf(line.c_str(),"control:%u %s",&(control.id), controlType);
-
-			parseControl(control, file);
-			_controls.push_back(control);
-		}
-	}
-}
-
-void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
-	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
-
-	while (!line.contains('}')) {
-		if (line.matchString("criteria {", true))
-			puzzle.criteriaList.push_back(parseCriteria(stream));
-		else if (line.matchString("results {", true))
-			parseResult(stream, puzzle.resultActions);
-		else if (line.matchString("flags {", true))
-			puzzle.flags = parseFlags(stream);
-	}
-}
-
-Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const {
-	Criteria criteria;
-
-	// Loop until we find the closing brace
-	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
-
-	while (!line.contains('}')) {
-		// Split the string into tokens using ' ' as a delimiter
-		Common::StringTokenizer tokenizer(line);
-		Common::String token;
-
-		// Parse the id out of the first token
-		token = tokenizer.nextToken();
-		sscanf(token.c_str(), "[%u]", &(criteria.id));
-
-		// Parse the operator out of the second token
-		token = tokenizer.nextToken();
-		if (token.c_str()[0] == '=')
-			criteria.criteriaOperator = EQUAL_TO;
-		else if (token.c_str()[0] == '!')
-			criteria.criteriaOperator = NOT_EQUAL_TO;
-		else if (token.c_str()[0] == '>')
-			criteria.criteriaOperator = GREATER_THAN;
-		else if (token.c_str()[0] == '<')
-			criteria.criteriaOperator = LESS_THAN;
-
-		// First determine if the last token is an id or a value
-		// Then parse it into 'argument'
-		token = tokenizer.nextToken();
-		if (token.contains('[')) {
-			sscanf(token.c_str(), "[%u]", &(criteria.argument));
-			criteria.isArgumentAnId = true;
-		} else {
-			sscanf(token.c_str(), "%u", &(criteria.argument));
-			criteria.isArgumentAnId = false;
-		}
-
-		line = stream.readLine();
-		trimCommentsAndWhiteSpace(line);
-	}
-
-	return criteria;
-}
-
-void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const {
-	// Loop until we find the closing brace
-	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
-
-	while (!line.contains('}')) {
-		// Parse for the action type
-		if (line.matchString("*:add*", true)) {
-			actionList.push_back(ActionAdd(line));
-		} else if (line.matchString("*:animplay*", true)) {
-			
-
-		} else if (line.matchString("*:animpreload*", true)) {
-			
-
-		} else if (line.matchString("*:animunload*", true)) {
-			
-
-		} else if (line.matchString("*:attenuate*", true)) {
-			
-
-		} else if (line.matchString("*:assign*", true)) {
-			
-
-		} else if (line.matchString("*:change_location*", true)) {
-			
-
-		} else if (line.matchString("*:crossfade*", true)) {
-			
-
-		} else if (line.matchString("*:debug*", true)) {
-			
-
-		} else if (line.matchString("*:delay_render*", true)) {
-			
-
-		} else if (line.matchString("*:disable_control*", true)) {
-			
-
-		} else if (line.matchString("*:disable_venus*", true)) {
-			
-
-		} else if (line.matchString("*:display_message*", true)) {
-			
-
-		} else if (line.matchString("*:dissolve*", true)) {
-			
-
-		} else if (line.matchString("*:distort*", true)) {
-			
-
-		} else if (line.matchString("*:enable_control*", true)) {
-			
-
-		} else if (line.matchString("*:flush_mouse_events*", true)) {
-			
-
-		} else if (line.matchString("*:inventory*", true)) {
-			
-
-		} else if (line.matchString("*:kill*", true)) {
-			
-
-		} else if (line.matchString("*:menu_bar_enable*", true)) {
-			
-
-		} else if (line.matchString("*:music*", true)) {
-			
-
-		} else if (line.matchString("*:pan_track*", true)) {
-			
-
-		} else if (line.matchString("*:playpreload*", true)) {
-			
-
-		} else if (line.matchString("*:preferences*", true)) {
-			
-
-		} else if (line.matchString("*:quit*", true)) {
-			
-
-		} else if (line.matchString("*:random*", true)) {
-			
-
-		} else if (line.matchString("*:region*", true)) {
-			
-
-		} else if (line.matchString("*:restore_game*", true)) {
-			
-
-		} else if (line.matchString("*:rotate_to*", true)) {
-			
-
-		} else if (line.matchString("*:save_game*", true)) {
-			
-
-		} else if (line.matchString("*:set_partial_screen*", true)) {
-			
-
-		} else if (line.matchString("*:set_screen*", true)) {
-			
-
-		} else if (line.matchString("*:set_venus*", true)) {
-			
-
-		} else if (line.matchString("*:stop*", true)) {
-			
-
-		} else if (line.matchString("*:streamvideo*", true)) {
-			
-
-		} else if (line.matchString("*:syncsound*", true)) {
-			
-
-		} else if (line.matchString("*:timer*", true)) {
-			
-
-		} else if (line.matchString("*:ttytext*", true)) {
-			
-
-		} else if (line.matchString("*:universe_music*", true)) {
-			
-
-		} else {
-			warning("Unhandled result action type: ", line);
-		}
-
-		line = stream.readLine();
-		trimCommentsAndWhiteSpace(line);
-	}
-
-	return;
-}
-
-byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
-	byte flags;
-
-	// Loop until we find the closing brace
-	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
-
-	while (!line.contains('}')) {
-		if (line.matchString("ONCE_PER_INST", true)) {
-			flags |= ONCE_PER_INST;
-		} else if (line.matchString("DO_ME_NOW", true)) {
-			flags |= DO_ME_NOW;
-		} else if (line.matchString("DISABLED", true)) {
-			flags |= DISABLED;
-		}
-	}
-
-	return flags;
-}
-
-void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) {
-
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
new file mode 100644
index 0000000..61feb12
--- /dev/null
+++ b/engines/zvision/scr_file_handling.cpp
@@ -0,0 +1,287 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include <stdio.h>
+
+#include "zvision/scriptManager.h"
+#include "zvision/utility.h"
+#include "zvision/puzzle.h"
+
+#include "common/textconsole.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+
+namespace ZVision {
+
+void ScriptManager::parseScrFile(Common::String fileName) {
+	Common::File file;
+	if (!file.open(fileName))
+		return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
+
+	while(!file.eos()) {
+		Common::String line = file.readLine();
+		if (file.err()) {
+			warning("Error parsing scr file: %s", fileName);
+			return;
+		}
+
+		trimCommentsAndWhiteSpace(line);
+		if (line.empty())
+			continue;
+
+		if (line.matchString("puzzle:*", true)) {
+			Puzzle puzzle;
+			sscanf(line.c_str(),"puzzle:%u",&(puzzle.id));
+
+			parsePuzzle(puzzle, file);
+			_puzzles.push_back(puzzle);
+		} else if (line.matchString("control:*", true)) {
+			Control control;
+			char controlType[20];
+			sscanf(line.c_str(),"control:%u %s",&(control.id), controlType);
+
+			parseControl(control, file);
+			_controls.push_back(control);
+		}
+	}
+}
+
+void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("criteria {", true))
+			puzzle.criteriaList.push_back(parseCriteria(stream));
+		else if (line.matchString("results {", true))
+			parseResult(stream, puzzle.resultActions);
+		else if (line.matchString("flags {", true))
+			puzzle.flags = parseFlags(stream);
+	}
+}
+
+Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const {
+	Criteria criteria;
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		// Split the string into tokens using ' ' as a delimiter
+		Common::StringTokenizer tokenizer(line);
+		Common::String token;
+
+		// Parse the id out of the first token
+		token = tokenizer.nextToken();
+		sscanf(token.c_str(), "[%u]", &(criteria.id));
+
+		// Parse the operator out of the second token
+		token = tokenizer.nextToken();
+		if (token.c_str()[0] == '=')
+			criteria.criteriaOperator = EQUAL_TO;
+		else if (token.c_str()[0] == '!')
+			criteria.criteriaOperator = NOT_EQUAL_TO;
+		else if (token.c_str()[0] == '>')
+			criteria.criteriaOperator = GREATER_THAN;
+		else if (token.c_str()[0] == '<')
+			criteria.criteriaOperator = LESS_THAN;
+
+		// First determine if the last token is an id or a value
+		// Then parse it into 'argument'
+		token = tokenizer.nextToken();
+		if (token.contains('[')) {
+			sscanf(token.c_str(), "[%u]", &(criteria.argument));
+			criteria.isArgumentAnId = true;
+		} else {
+			sscanf(token.c_str(), "%u", &(criteria.argument));
+			criteria.isArgumentAnId = false;
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(line);
+	}
+
+	return criteria;
+}
+
+void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const {
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		// Parse for the action type
+		if (line.matchString("*:add*", true)) {
+			actionList.push_back(ActionAdd(line));
+		} else if (line.matchString("*:animplay*", true)) {
+			
+
+		} else if (line.matchString("*:animpreload*", true)) {
+			
+
+		} else if (line.matchString("*:animunload*", true)) {
+			
+
+		} else if (line.matchString("*:attenuate*", true)) {
+			
+
+		} else if (line.matchString("*:assign*", true)) {
+			
+
+		} else if (line.matchString("*:change_location*", true)) {
+			
+
+		} else if (line.matchString("*:crossfade*", true)) {
+			
+
+		} else if (line.matchString("*:debug*", true)) {
+			
+
+		} else if (line.matchString("*:delay_render*", true)) {
+			
+
+		} else if (line.matchString("*:disable_control*", true)) {
+			
+
+		} else if (line.matchString("*:disable_venus*", true)) {
+			
+
+		} else if (line.matchString("*:display_message*", true)) {
+			
+
+		} else if (line.matchString("*:dissolve*", true)) {
+			
+
+		} else if (line.matchString("*:distort*", true)) {
+			
+
+		} else if (line.matchString("*:enable_control*", true)) {
+			
+
+		} else if (line.matchString("*:flush_mouse_events*", true)) {
+			
+
+		} else if (line.matchString("*:inventory*", true)) {
+			
+
+		} else if (line.matchString("*:kill*", true)) {
+			
+
+		} else if (line.matchString("*:menu_bar_enable*", true)) {
+			
+
+		} else if (line.matchString("*:music*", true)) {
+			
+
+		} else if (line.matchString("*:pan_track*", true)) {
+			
+
+		} else if (line.matchString("*:playpreload*", true)) {
+			
+
+		} else if (line.matchString("*:preferences*", true)) {
+			
+
+		} else if (line.matchString("*:quit*", true)) {
+			
+
+		} else if (line.matchString("*:random*", true)) {
+			
+
+		} else if (line.matchString("*:region*", true)) {
+			
+
+		} else if (line.matchString("*:restore_game*", true)) {
+			
+
+		} else if (line.matchString("*:rotate_to*", true)) {
+			
+
+		} else if (line.matchString("*:save_game*", true)) {
+			
+
+		} else if (line.matchString("*:set_partial_screen*", true)) {
+			
+
+		} else if (line.matchString("*:set_screen*", true)) {
+			
+
+		} else if (line.matchString("*:set_venus*", true)) {
+			
+
+		} else if (line.matchString("*:stop*", true)) {
+			
+
+		} else if (line.matchString("*:streamvideo*", true)) {
+			
+
+		} else if (line.matchString("*:syncsound*", true)) {
+			
+
+		} else if (line.matchString("*:timer*", true)) {
+			
+
+		} else if (line.matchString("*:ttytext*", true)) {
+			
+
+		} else if (line.matchString("*:universe_music*", true)) {
+			
+
+		} else {
+			warning("Unhandled result action type: ", line);
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(line);
+	}
+
+	return;
+}
+
+byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
+	byte flags;
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("ONCE_PER_INST", true)) {
+			flags |= ONCE_PER_INST;
+		} else if (line.matchString("DO_ME_NOW", true)) {
+			flags |= DO_ME_NOW;
+		} else if (line.matchString("DISABLED", true)) {
+			flags |= DISABLED;
+		}
+	}
+
+	return flags;
+}
+
+void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) {
+
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scriptManager.cpp b/engines/zvision/scriptManager.cpp
deleted file mode 100644
index 5317bf6..0000000
--- a/engines/zvision/scriptManager.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
-
-#include "common/scummsys.h"
-
-#include "zvision/scriptManager.h"
-
-namespace ZVision {
-
-// TODO: Actually do something in the initialize or remove it
-void ScriptManager::initialize() {
-	
-}
-
-byte ScriptManager::getStateValue(uint32 key) {
-	return _globalState[key];
-}
-
-void ScriptManager::setStateValue(uint32 key, byte value) {
-	_globalState[key] = value;
-}
-
-void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
-	_globalState[key] += valueToAdd;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scriptManager.h b/engines/zvision/scriptManager.h
deleted file mode 100644
index 563a010..0000000
--- a/engines/zvision/scriptManager.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public 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 ZVISION_SCRIPT_MANAGER_H
-#define ZVISION_SCRIPT_MANAGER_H
-
-#include "common/str.h"
-#include "common/stream.h"
-#include "common/hashmap.h"
-
-#include "zvision/puzzle.h"
-#include "zvision/control.h"
-#include "zvision/singleValueContainer.h"
-
-namespace ZVision {
-
-class ScriptManager {
-private:
-	/** Holds the global state variables. Optimize for fast random access */
-	Common::HashMap<uint32, byte> _globalState;
-	/** Holds the currently active puzzles. Optimize for fast iteration */
-	Common::List<Puzzle> _puzzles;
-	/** Holds the currently active controls. Optimize for fast iteration */
-	Common::List<Control> _controls;
-
-public:
-	
-	void initialize();
-	byte getStateValue(uint32 key);
-	void setStateValue(uint32 key, byte value);
-	void addToStateValue(uint32 key, byte valueToAdd);
-
-private:
-	/**
-	 * Parses a script file into triggers and events
-	 *
-	 * @param fileName		Name of the .scr file
-	 */
-	void parseScrFile(Common::String fileName);
-
-	/**
-	 * Parses the stream into a Puzzle object
-	 * Helper method for parseScrFile. 
-	 *
-	 * @param puzzle    The object to store what is parsed
-	 * @param stream    Scr file stream
-	 */
-	void parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream);
-
-	/**
-	 * Parses the stream into a Criteria object
-	 * Helper method for parsePuzzle. 
-	 *
-	 * @param stream    Scr file stream
-	 * @return          Created Criteria object
-	 */
-	Criteria parseCriteria(Common::SeekableReadStream &stream) const;
-
-	/**
-	 * Parses the stream into a Results object
-	 * Helper method for parsePuzzle. 
-	 *
-	 * @param stream    Scr file stream
-	 * @return          Created Results object
-	 */
-	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const;
-
-	/**
-	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
-	 *
-	 * @param stream    Scr file stream
-	 * @return          Bitwise or of all the flags set within the puzzle
-	 */
-	byte parseFlags(Common::SeekableReadStream &stream) const;
-
-	/**
-	 * Helper method for parseScrFile. Parses the stream into a Control object
-	 *
-	 * @param control    The object to store what is parsed
-	 * @param stream     Scr file stream
-	 */
-	void parseControl(Control &control, Common::SeekableReadStream &stream);
-};
-
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
new file mode 100644
index 0000000..5317bf6
--- /dev/null
+++ b/engines/zvision/script_manager.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/scriptManager.h"
+
+namespace ZVision {
+
+// TODO: Actually do something in the initialize or remove it
+void ScriptManager::initialize() {
+	
+}
+
+byte ScriptManager::getStateValue(uint32 key) {
+	return _globalState[key];
+}
+
+void ScriptManager::setStateValue(uint32 key, byte value) {
+	_globalState[key] = value;
+}
+
+void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
+	_globalState[key] += valueToAdd;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
new file mode 100644
index 0000000..563a010
--- /dev/null
+++ b/engines/zvision/script_manager.h
@@ -0,0 +1,107 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_SCRIPT_MANAGER_H
+#define ZVISION_SCRIPT_MANAGER_H
+
+#include "common/str.h"
+#include "common/stream.h"
+#include "common/hashmap.h"
+
+#include "zvision/puzzle.h"
+#include "zvision/control.h"
+#include "zvision/singleValueContainer.h"
+
+namespace ZVision {
+
+class ScriptManager {
+private:
+	/** Holds the global state variables. Optimize for fast random access */
+	Common::HashMap<uint32, byte> _globalState;
+	/** Holds the currently active puzzles. Optimize for fast iteration */
+	Common::List<Puzzle> _puzzles;
+	/** Holds the currently active controls. Optimize for fast iteration */
+	Common::List<Control> _controls;
+
+public:
+	
+	void initialize();
+	byte getStateValue(uint32 key);
+	void setStateValue(uint32 key, byte value);
+	void addToStateValue(uint32 key, byte valueToAdd);
+
+private:
+	/**
+	 * Parses a script file into triggers and events
+	 *
+	 * @param fileName		Name of the .scr file
+	 */
+	void parseScrFile(Common::String fileName);
+
+	/**
+	 * Parses the stream into a Puzzle object
+	 * Helper method for parseScrFile. 
+	 *
+	 * @param puzzle    The object to store what is parsed
+	 * @param stream    Scr file stream
+	 */
+	void parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream);
+
+	/**
+	 * Parses the stream into a Criteria object
+	 * Helper method for parsePuzzle. 
+	 *
+	 * @param stream    Scr file stream
+	 * @return          Created Criteria object
+	 */
+	Criteria parseCriteria(Common::SeekableReadStream &stream) const;
+
+	/**
+	 * Parses the stream into a Results object
+	 * Helper method for parsePuzzle. 
+	 *
+	 * @param stream    Scr file stream
+	 * @return          Created Results object
+	 */
+	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const;
+
+	/**
+	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
+	 *
+	 * @param stream    Scr file stream
+	 * @return          Bitwise or of all the flags set within the puzzle
+	 */
+	byte parseFlags(Common::SeekableReadStream &stream) const;
+
+	/**
+	 * Helper method for parseScrFile. Parses the stream into a Control object
+	 *
+	 * @param control    The object to store what is parsed
+	 * @param stream     Scr file stream
+	 */
+	void parseControl(Control &control, Common::SeekableReadStream &stream);
+};
+
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/singleValueContainer.cpp b/engines/zvision/singleValueContainer.cpp
deleted file mode 100644
index bd91c44..0000000
--- a/engines/zvision/singleValueContainer.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-#include "common/textconsole.h"
-
-#include "zvision/singleValueContainer.h"
-
-namespace ZVision {
-
-SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
-
-SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
-	_value.boolVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
-	_value.byteVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
-	_value.int16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
-	_value.uint16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
-	_value.int32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
-	_value.uint32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
-	_value.floatVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
-	_value.doubleVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
-	_value.stringVal = new char[value.size() + 1];
-	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
-}
-
-SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
-	_objectType = other._objectType;
-
-	switch (_objectType) {
-	case BOOL:
-		_value.boolVal = other._value.boolVal;
-		break;
-	case BYTE:
-		_value.byteVal = other._value.byteVal;
-		break;
-	case INT16:
-		_value.int16Val = other._value.int16Val;
-		break;
-	case UINT16:
-		_value.uint16Val = other._value.uint16Val;
-		break;
-	case INT32:
-		_value.int32Val = other._value.int32Val;
-		break;
-	case UINT32:
-		_value.uint32Val = other._value.uint32Val;
-		break;
-	case FLOAT:
-		_value.floatVal = other._value.floatVal;
-		break;
-	case DOUBLE:
-		_value.doubleVal = other._value.doubleVal;
-		break;
-	case STRING:
-		uint32 length = strlen(other._value.stringVal);
-		_value.stringVal = new char[length + 1];
-		memcpy(_value.stringVal, other._value.stringVal, length + 1);
-		break;
-	}
-}
-
-SingleValueContainer::~SingleValueContainer() {
-	deleteCharPointer();
-}
-
-void SingleValueContainer::deleteCharPointer() {
-	if (_objectType == STRING)
-		delete[] _value.stringVal;
-}
-
-
-SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
-	if (_objectType == BOOL) {
-		_value.boolVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = BOOL;
-	_value.boolVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
-	if (_objectType == BYTE) {
-		_value.byteVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = BYTE;
-	_value.byteVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
-	if (_objectType == INT16) {
-		_value.int16Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = INT16;
-	_value.int16Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
-	if (_objectType == UINT16) {
-		_value.uint16Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = UINT16;
-	_value.uint16Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
-	if (_objectType == INT32) {
-		_value.int32Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = INT32;
-	_value.int32Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
-	if (_objectType == UINT32) {
-		_value.uint32Val = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = UINT32;
-	_value.uint32Val = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
-	if (_objectType == FLOAT) {
-		_value.floatVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = FLOAT;
-	_value.floatVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
-	if (_objectType == DOUBLE) {
-		_value.doubleVal = rhs;
-		return *this;
-	}
-
-	deleteCharPointer();
-	_objectType = DOUBLE;
-	_value.doubleVal = rhs;
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
-	if (_objectType != STRING) {
-		_objectType = STRING;
-		_value.stringVal = new char[rhs.size() + 1];
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-
-		return *this;
-	}
-
-	uint32 length = strlen(_value.stringVal);
-	if (length <= rhs.size() + 1) {
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-	} else {
-		delete[] _value.stringVal;
-		_value.stringVal = new char[rhs.size() + 1];
-		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-	}
-
-	return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
-	switch (_objectType) {
-	case BOOL:
-		return operator=(rhs._value.boolVal);
-	case BYTE:
-		return operator=(rhs._value.byteVal);
-	case INT16:
-		return operator=(rhs._value.int16Val);
-	case UINT16:
-		return operator=(rhs._value.uint16Val);
-	case INT32:
-		return operator=(rhs._value.int32Val);
-	case UINT32:
-		return operator=(rhs._value.uint32Val);
-	case FLOAT:
-		return operator=(rhs._value.floatVal);
-	case DOUBLE:
-		return operator=(rhs._value.doubleVal);
-	case STRING:
-		uint32 length = strlen(rhs._value.stringVal);
-
-		_value.stringVal = new char[length + 1];
-		memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
-
-		return *this;
-	}
-
-	return *this;
-}
-
-
-bool SingleValueContainer::getBoolValue(bool *returnValue) const {
-	if (_objectType !=  BOOL) {
-		warning("'Object' is not storing a bool.");
-		return false;
-	}
-
-	*returnValue = _value.boolVal;
-	return true;
-}
-
-bool SingleValueContainer::getByteValue(byte *returnValue) const {
-	if (_objectType !=  BYTE)
-		warning("'Object' is not storing a byte.");
-
-	*returnValue = _value.byteVal;
-	return true;
-}
-
-bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
-	if (_objectType !=  INT16)
-		warning("'Object' is not storing an int16.");
-
-	*returnValue = _value.int16Val;
-	return true;
-}
-
-bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
-	if (_objectType !=  UINT16)
-		warning("'Object' is not storing a uint16.");
-
-	*returnValue = _value.uint16Val;
-	return true;
-}
-
-bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
-	if (_objectType !=  INT32)
-		warning("'Object' is not storing an int32.");
-
-	*returnValue = _value.int32Val;
-	return true;
-}
-
-bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
-	if (_objectType !=  UINT32)
-		warning("'Object' is not storing a uint32.");
-
-	*returnValue = _value.uint32Val;
-	return true;
-}
-
-bool SingleValueContainer::getFloatValue(float *returnValue) const {
-	if (_objectType !=  FLOAT)
-		warning("'Object' is not storing a float.");
-
-	*returnValue = _value.floatVal;
-	return true;
-}
-
-bool SingleValueContainer::getDoubleValue(double *returnValue) const {
-	if (_objectType !=  DOUBLE)
-		warning("'Object' is not storing a double.");
-
-	*returnValue = _value.doubleVal;
-	return true;
-}
-
-bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
-	if (_objectType !=  STRING)
-		warning("'Object' is not storing a Common::String.");
-
-	*returnValue = _value.stringVal;
-	return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/singleValueContainer.h b/engines/zvision/singleValueContainer.h
deleted file mode 100644
index 49c7267..0000000
--- a/engines/zvision/singleValueContainer.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_OBJECT_H
-#define ZVISION_OBJECT_H
-
-#include "common/str.h"
-
-namespace ZVision {
-
-/**
- * A generic single value storage class. It is useful for storing different 
- * value types in a single List, Hashmap, etc.
- */
-class SingleValueContainer {
-public:
-	enum ValueType {
-		BOOL,
-		BYTE,
-		INT16,
-		UINT16,
-		INT32,
-		UINT32,
-		FLOAT,
-		DOUBLE,
-		STRING,
-	};
-
-	// Constructors
-	explicit SingleValueContainer(ValueType type);
-	explicit SingleValueContainer(bool value);
-	explicit SingleValueContainer(byte value);
-	explicit SingleValueContainer(int16 value);
-	explicit SingleValueContainer(uint16 value);
-	explicit SingleValueContainer(int32 value);
-	explicit SingleValueContainer(uint32 value);
-	explicit SingleValueContainer(float value);
-	explicit SingleValueContainer(double value);
-	explicit SingleValueContainer(Common::String value);
-
-	// Copy constructor
-	explicit SingleValueContainer(const SingleValueContainer& other);
-
-	// Destructor
-	~SingleValueContainer();
-
-private:
-	ValueType _objectType;
-
-	union {
-		bool boolVal;
-		byte byteVal;
-		int16 int16Val;
-		uint16 uint16Val;
-		int32 int32Val;
-		uint32 uint32Val;
-		float floatVal;
-		double doubleVal;
-		char *stringVal;
-	} _value;
-
-public:
-	SingleValueContainer &operator=(const bool &rhs);
-	SingleValueContainer &operator=(const byte &rhs);
-	SingleValueContainer &operator=(const int16 &rhs);
-	SingleValueContainer &operator=(const uint16 &rhs);
-	SingleValueContainer &operator=(const int32 &rhs);
-	SingleValueContainer &operator=(const uint32 &rhs);
-	SingleValueContainer &operator=(const float &rhs);
-	SingleValueContainer &operator=(const double &rhs);
-	SingleValueContainer &operator=(const Common::String &rhs);
-
-	SingleValueContainer& operator=(const SingleValueContainer &rhs);
-
-	/**
-	 * Retrieve a bool from the container. If the container is not storing a 
-	 * bool, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getBoolValue(bool *returnValue) const;
-	/**
-	 * Retrieve a byte from the container. If the container is not storing a 
-	 * byte, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getByteValue(byte *returnValue) const;
-	/**
-	 * Retrieve an int16 from the container. If the container is not storing an 
-	 * int16, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getInt16Value(int16 *returnValue) const;
-	/**
-	 * Retrieve a uint16 from the container. If the container is not storing a 
-	 * uint16, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getUInt16Value(uint16 *returnValue) const;
-	/**
-	 * Retrieve an int32 from the container. If the container is not storing an 
-	 * int32, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getInt32Value(int32 *returnValue) const;
-	/**
-	 * Retrieve a uint32 from the container. If the container is not storing a 
-	 * uint32, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getUInt32Value(uint32 *returnValue) const;
-	/**
-	 * Retrieve a float from the container. If the container is not storing a 
-	 * float, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getFloatValue(float *returnValue) const;
-	/**
-	 * Retrieve a double from the container. If the container is not storing a 
-	 * double, this will return false and display a warning().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getDoubleValue(double *returnValue) const;
-	/**
-	 * Retrieve a String from the container. If the container is not storing a 
-	 * string, this will return false and display a warning().
-	 * 
-	 * Caution: Strings are internally stored as char[]. getStringValue uses
-	 * Common::String::operator=(char *) to do the assigment, which uses both
-	 * strlen() AND memmove().
-	 *
-	 * @param returnValue    Pointer to where you want the value stored
-	 * @return               Value indicating whether the value assignment was successful
-	 */
-	bool getStringValue(Common::String *returnValue) const;
-
-private:
-	/**
-	 * Helper method for destruction and assignment. It checks to see
-	 * if the char pointer is being used, and if so calls delete on it
-	 */
-	void deleteCharPointer();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/single_value_container.cpp b/engines/zvision/single_value_container.cpp
new file mode 100644
index 0000000..bd91c44
--- /dev/null
+++ b/engines/zvision/single_value_container.cpp
@@ -0,0 +1,345 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/textconsole.h"
+
+#include "zvision/singleValueContainer.h"
+
+namespace ZVision {
+
+SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
+
+SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
+	_value.boolVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
+	_value.byteVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
+	_value.int16Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
+	_value.uint16Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
+	_value.int32Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
+	_value.uint32Val = value;
+}
+
+SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
+	_value.floatVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
+	_value.doubleVal = value;
+}
+
+SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
+	_value.stringVal = new char[value.size() + 1];
+	memcpy(_value.stringVal, value.c_str(), value.size() + 1);
+}
+
+SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
+	_objectType = other._objectType;
+
+	switch (_objectType) {
+	case BOOL:
+		_value.boolVal = other._value.boolVal;
+		break;
+	case BYTE:
+		_value.byteVal = other._value.byteVal;
+		break;
+	case INT16:
+		_value.int16Val = other._value.int16Val;
+		break;
+	case UINT16:
+		_value.uint16Val = other._value.uint16Val;
+		break;
+	case INT32:
+		_value.int32Val = other._value.int32Val;
+		break;
+	case UINT32:
+		_value.uint32Val = other._value.uint32Val;
+		break;
+	case FLOAT:
+		_value.floatVal = other._value.floatVal;
+		break;
+	case DOUBLE:
+		_value.doubleVal = other._value.doubleVal;
+		break;
+	case STRING:
+		uint32 length = strlen(other._value.stringVal);
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, other._value.stringVal, length + 1);
+		break;
+	}
+}
+
+SingleValueContainer::~SingleValueContainer() {
+	deleteCharPointer();
+}
+
+void SingleValueContainer::deleteCharPointer() {
+	if (_objectType == STRING)
+		delete[] _value.stringVal;
+}
+
+
+SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
+	if (_objectType == BOOL) {
+		_value.boolVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = BOOL;
+	_value.boolVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
+	if (_objectType == BYTE) {
+		_value.byteVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = BYTE;
+	_value.byteVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
+	if (_objectType == INT16) {
+		_value.int16Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = INT16;
+	_value.int16Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
+	if (_objectType == UINT16) {
+		_value.uint16Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = UINT16;
+	_value.uint16Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
+	if (_objectType == INT32) {
+		_value.int32Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = INT32;
+	_value.int32Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
+	if (_objectType == UINT32) {
+		_value.uint32Val = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = UINT32;
+	_value.uint32Val = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
+	if (_objectType == FLOAT) {
+		_value.floatVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = FLOAT;
+	_value.floatVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
+	if (_objectType == DOUBLE) {
+		_value.doubleVal = rhs;
+		return *this;
+	}
+
+	deleteCharPointer();
+	_objectType = DOUBLE;
+	_value.doubleVal = rhs;
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
+	if (_objectType != STRING) {
+		_objectType = STRING;
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+
+		return *this;
+	}
+
+	uint32 length = strlen(_value.stringVal);
+	if (length <= rhs.size() + 1) {
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+	} else {
+		delete[] _value.stringVal;
+		_value.stringVal = new char[rhs.size() + 1];
+		memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
+	}
+
+	return *this;
+}
+
+SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
+	switch (_objectType) {
+	case BOOL:
+		return operator=(rhs._value.boolVal);
+	case BYTE:
+		return operator=(rhs._value.byteVal);
+	case INT16:
+		return operator=(rhs._value.int16Val);
+	case UINT16:
+		return operator=(rhs._value.uint16Val);
+	case INT32:
+		return operator=(rhs._value.int32Val);
+	case UINT32:
+		return operator=(rhs._value.uint32Val);
+	case FLOAT:
+		return operator=(rhs._value.floatVal);
+	case DOUBLE:
+		return operator=(rhs._value.doubleVal);
+	case STRING:
+		uint32 length = strlen(rhs._value.stringVal);
+
+		_value.stringVal = new char[length + 1];
+		memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
+
+		return *this;
+	}
+
+	return *this;
+}
+
+
+bool SingleValueContainer::getBoolValue(bool *returnValue) const {
+	if (_objectType !=  BOOL) {
+		warning("'Object' is not storing a bool.");
+		return false;
+	}
+
+	*returnValue = _value.boolVal;
+	return true;
+}
+
+bool SingleValueContainer::getByteValue(byte *returnValue) const {
+	if (_objectType !=  BYTE)
+		warning("'Object' is not storing a byte.");
+
+	*returnValue = _value.byteVal;
+	return true;
+}
+
+bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
+	if (_objectType !=  INT16)
+		warning("'Object' is not storing an int16.");
+
+	*returnValue = _value.int16Val;
+	return true;
+}
+
+bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
+	if (_objectType !=  UINT16)
+		warning("'Object' is not storing a uint16.");
+
+	*returnValue = _value.uint16Val;
+	return true;
+}
+
+bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
+	if (_objectType !=  INT32)
+		warning("'Object' is not storing an int32.");
+
+	*returnValue = _value.int32Val;
+	return true;
+}
+
+bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
+	if (_objectType !=  UINT32)
+		warning("'Object' is not storing a uint32.");
+
+	*returnValue = _value.uint32Val;
+	return true;
+}
+
+bool SingleValueContainer::getFloatValue(float *returnValue) const {
+	if (_objectType !=  FLOAT)
+		warning("'Object' is not storing a float.");
+
+	*returnValue = _value.floatVal;
+	return true;
+}
+
+bool SingleValueContainer::getDoubleValue(double *returnValue) const {
+	if (_objectType !=  DOUBLE)
+		warning("'Object' is not storing a double.");
+
+	*returnValue = _value.doubleVal;
+	return true;
+}
+
+bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
+	if (_objectType !=  STRING)
+		warning("'Object' is not storing a Common::String.");
+
+	*returnValue = _value.stringVal;
+	return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
new file mode 100644
index 0000000..49c7267
--- /dev/null
+++ b/engines/zvision/single_value_container.h
@@ -0,0 +1,181 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_OBJECT_H
+#define ZVISION_OBJECT_H
+
+#include "common/str.h"
+
+namespace ZVision {
+
+/**
+ * A generic single value storage class. It is useful for storing different 
+ * value types in a single List, Hashmap, etc.
+ */
+class SingleValueContainer {
+public:
+	enum ValueType {
+		BOOL,
+		BYTE,
+		INT16,
+		UINT16,
+		INT32,
+		UINT32,
+		FLOAT,
+		DOUBLE,
+		STRING,
+	};
+
+	// Constructors
+	explicit SingleValueContainer(ValueType type);
+	explicit SingleValueContainer(bool value);
+	explicit SingleValueContainer(byte value);
+	explicit SingleValueContainer(int16 value);
+	explicit SingleValueContainer(uint16 value);
+	explicit SingleValueContainer(int32 value);
+	explicit SingleValueContainer(uint32 value);
+	explicit SingleValueContainer(float value);
+	explicit SingleValueContainer(double value);
+	explicit SingleValueContainer(Common::String value);
+
+	// Copy constructor
+	explicit SingleValueContainer(const SingleValueContainer& other);
+
+	// Destructor
+	~SingleValueContainer();
+
+private:
+	ValueType _objectType;
+
+	union {
+		bool boolVal;
+		byte byteVal;
+		int16 int16Val;
+		uint16 uint16Val;
+		int32 int32Val;
+		uint32 uint32Val;
+		float floatVal;
+		double doubleVal;
+		char *stringVal;
+	} _value;
+
+public:
+	SingleValueContainer &operator=(const bool &rhs);
+	SingleValueContainer &operator=(const byte &rhs);
+	SingleValueContainer &operator=(const int16 &rhs);
+	SingleValueContainer &operator=(const uint16 &rhs);
+	SingleValueContainer &operator=(const int32 &rhs);
+	SingleValueContainer &operator=(const uint32 &rhs);
+	SingleValueContainer &operator=(const float &rhs);
+	SingleValueContainer &operator=(const double &rhs);
+	SingleValueContainer &operator=(const Common::String &rhs);
+
+	SingleValueContainer& operator=(const SingleValueContainer &rhs);
+
+	/**
+	 * Retrieve a bool from the container. If the container is not storing a 
+	 * bool, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getBoolValue(bool *returnValue) const;
+	/**
+	 * Retrieve a byte from the container. If the container is not storing a 
+	 * byte, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getByteValue(byte *returnValue) const;
+	/**
+	 * Retrieve an int16 from the container. If the container is not storing an 
+	 * int16, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getInt16Value(int16 *returnValue) const;
+	/**
+	 * Retrieve a uint16 from the container. If the container is not storing a 
+	 * uint16, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getUInt16Value(uint16 *returnValue) const;
+	/**
+	 * Retrieve an int32 from the container. If the container is not storing an 
+	 * int32, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getInt32Value(int32 *returnValue) const;
+	/**
+	 * Retrieve a uint32 from the container. If the container is not storing a 
+	 * uint32, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getUInt32Value(uint32 *returnValue) const;
+	/**
+	 * Retrieve a float from the container. If the container is not storing a 
+	 * float, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getFloatValue(float *returnValue) const;
+	/**
+	 * Retrieve a double from the container. If the container is not storing a 
+	 * double, this will return false and display a warning().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getDoubleValue(double *returnValue) const;
+	/**
+	 * Retrieve a String from the container. If the container is not storing a 
+	 * string, this will return false and display a warning().
+	 * 
+	 * Caution: Strings are internally stored as char[]. getStringValue uses
+	 * Common::String::operator=(char *) to do the assigment, which uses both
+	 * strlen() AND memmove().
+	 *
+	 * @param returnValue    Pointer to where you want the value stored
+	 * @return               Value indicating whether the value assignment was successful
+	 */
+	bool getStringValue(Common::String *returnValue) const;
+
+private:
+	/**
+	 * Helper method for destruction and assignment. It checks to see
+	 * if the char pointer is being used, and if so calls delete on it
+	 */
+	void deleteCharPointer();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/zfsArchive.cpp b/engines/zvision/zfsArchive.cpp
deleted file mode 100644
index e65d0df..0000000
--- a/engines/zvision/zfsArchive.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/zfsArchive.h"
-#include "common/hashmap.h"
-#include "common/memstream.h"
-#include "common/debug.h"
-
-namespace ZVision {
-
-ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
-	Common::File zfsFile;
-
-	if (!zfsFile.open(_fileName)) {
-		warning("ZFSArchive::ZFSArchive(): Could not find the archive file");
-		return;
-	}
-
-	readHeaders(&zfsFile);
-
-	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
-}
-
-ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) {
-	readHeaders(stream);
-
-	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
-}
-
-ZfsArchive::~ZfsArchive() {
-	debug(0, "ZfsArchive Destructor Called");
-	ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
-	for ( ; it != _entryHeaders.end(); ++it) {
-		delete it->_value;
-	}
-}
-
-void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
-	// Don't do a straight struct cast since we can't guarantee endianness
-	_header.magic = stream->readUint32LE();
-	_header.unknown1 = stream->readUint32LE();
-	_header.maxNameLength = stream->readUint32LE();
-	_header.filesPerBlock = stream->readUint32LE();
-	_header.fileCount = stream->readUint32LE();
-	_header.xorKey[0] = stream->readByte();
-	_header.xorKey[1] = stream->readByte();
-	_header.xorKey[2] = stream->readByte();
-	_header.xorKey[3] = stream->readByte();
-	_header.fileSectionOffset = stream->readUint32LE();
-
-	uint32 nextOffset;
-
-	do {
-		// Read the offset to the next block
-		nextOffset = stream->readUint32LE();
-
-		// Read in each entry header
-		for (int i = 0; i < _header.filesPerBlock; i++) {
-			ZfsEntryHeader entryHeader;
-			
-			entryHeader.name = readEntryName(stream);
-			entryHeader.offset = stream->readUint32LE();
-			entryHeader.id = stream->readUint32LE();
-			entryHeader.size = stream->readUint32LE();
-			entryHeader.time = stream->readUint32LE();
-			entryHeader.unknown = stream->readUint32LE();
-
-			if (entryHeader.size != 0)
-				_entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader);
-		}
-
-		// Seek to the next block of headers
-		stream->seek(nextOffset);
-	} while (nextOffset != 0);
-}
-
-Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const {
-	// Entry Names are at most 16 bytes and are null padded
-	char buffer[16];
-	stream->read(buffer, 16);
-
-	return Common::String(buffer);
-}
-
-bool ZfsArchive::hasFile(const Common::String &name) const {
-	return _entryHeaders.contains(name);
-}
-
-int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const {
-	int matches = 0;
-
-	for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) {
-		list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this)));
-		matches++;
-	}
-
-	return matches;
-}
-
-const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const {
-	if (!_entryHeaders.contains(name))
-		return Common::ArchiveMemberPtr();
-
-	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
-}
-
-Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const {
-	if (!_entryHeaders.contains(name)) {
-		return 0;
-	}
-
-	ZfsEntryHeader *entryHeader = _entryHeaders[name];
-
-	Common::File zfsArchive;
-	zfsArchive.open(_fileName);
-	zfsArchive.seek(entryHeader->offset);
-
-	byte* buffer = new byte[entryHeader->size];
-	zfsArchive.read(buffer, entryHeader->size);
-	// Decrypt the data in place
-	if (_header.xorKey != 0)
-		unXor(buffer, entryHeader->size, _header.xorKey);
-
-	return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
-}
-
-void ZfsArchive::unXor(byte *buffer, int length, const byte *xorKey) const {
-	for (uint32 i = 0; i < length; i++)
-		buffer[i] ^= xorKey[i % 4];
-}
-
-} // End of namespace ZVision
-
-
diff --git a/engines/zvision/zfsArchive.h b/engines/zvision/zfsArchive.h
deleted file mode 100644
index ccdf192..0000000
--- a/engines/zvision/zfsArchive.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_ZFS_ARCHIVE_H
-#define ZVISION_ZFS_ARCHIVE_H
-
-#include "common/archive.h"
-#include "common/file.h"
-#include "common/fs.h"
-
-namespace ZVision {
-
-struct ZfsHeader {
-	uint32 magic;
-	uint32 unknown1;
-	uint32 maxNameLength;
-	uint32 filesPerBlock;
-	uint32 fileCount;
-	byte xorKey[4];
-	uint32 fileSectionOffset;
-};
-
-struct ZfsEntryHeader {
-	Common::String name;
-	uint32 offset;
-	uint32 id;
-	uint32 size;
-	uint32 time;
-	uint32 unknown;
-};
-
-typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
-
-class ZfsArchive : public Common::Archive {
-public:
-	ZfsArchive(const Common::String &fileName);
-	ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream);
-	~ZfsArchive();
-
-	/**
-	 * Check if a member with the given name is present in the Archive.
-	 * Patterns are not allowed, as this is meant to be a quick File::exists()
-	 * replacement.
-	 */
-	bool hasFile(const Common::String &fileName) const;
-
-	/**
-	 * Add all members of the Archive to list.
-	 * Must only append to list, and not remove elements from it.
-	 *
-	 * @return    The number of names added to list
-	 */
-	int listMembers(Common::ArchiveMemberList &list) const;
-
-	/**
-	 * Returns a ArchiveMember representation of the given file.
-	 */
-	const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
-
-	/**
-	 * Create a stream bound to a member with the specified name in the
-	 * archive. If no member with this name exists, 0 is returned.
-	 *
-	 * @return    The newly created input stream
-	 */
-	Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
-
-private:
-	const Common::String _fileName;
-	ZfsHeader _header;
-	ZfsEntryHeaderMap _entryHeaders;
-
-	/**
-	 * Parses the zfs file into file entry headers that can be used later
-	 * to get the entry data.
-	 *
-	 * @param stream    The contents of the zfs file
-	 */
-	void readHeaders(Common::SeekableReadStream *stream);
-
-	/**
-	 * Entry names are contained within a 16 byte block. This reads the block
-	 * and converts it the name to a Common::String
-	 *
-	 * @param stream    The zfs file stream
-	 * @return          The entry file name
-	 */
-	Common::String readEntryName(Common::SeekableReadStream *stream) const;
-
-	/**
-	 * ZFS file entries can be encrypted using XOR encoding. This method
-	 * decodes the buffer in place using the supplied xorKey.
-	 *
-	 * @param buffer    The data to decode
-	 * @param length    Length of buffer
-	 */
-	void unXor(byte *buffer, int length, const byte *xorKey) const;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
new file mode 100644
index 0000000..e65d0df
--- /dev/null
+++ b/engines/zvision/zfs_archive.cpp
@@ -0,0 +1,155 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/zfsArchive.h"
+#include "common/hashmap.h"
+#include "common/memstream.h"
+#include "common/debug.h"
+
+namespace ZVision {
+
+ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
+	Common::File zfsFile;
+
+	if (!zfsFile.open(_fileName)) {
+		warning("ZFSArchive::ZFSArchive(): Could not find the archive file");
+		return;
+	}
+
+	readHeaders(&zfsFile);
+
+	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+}
+
+ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) {
+	readHeaders(stream);
+
+	debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+}
+
+ZfsArchive::~ZfsArchive() {
+	debug(0, "ZfsArchive Destructor Called");
+	ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
+	for ( ; it != _entryHeaders.end(); ++it) {
+		delete it->_value;
+	}
+}
+
+void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
+	// Don't do a straight struct cast since we can't guarantee endianness
+	_header.magic = stream->readUint32LE();
+	_header.unknown1 = stream->readUint32LE();
+	_header.maxNameLength = stream->readUint32LE();
+	_header.filesPerBlock = stream->readUint32LE();
+	_header.fileCount = stream->readUint32LE();
+	_header.xorKey[0] = stream->readByte();
+	_header.xorKey[1] = stream->readByte();
+	_header.xorKey[2] = stream->readByte();
+	_header.xorKey[3] = stream->readByte();
+	_header.fileSectionOffset = stream->readUint32LE();
+
+	uint32 nextOffset;
+
+	do {
+		// Read the offset to the next block
+		nextOffset = stream->readUint32LE();
+
+		// Read in each entry header
+		for (int i = 0; i < _header.filesPerBlock; i++) {
+			ZfsEntryHeader entryHeader;
+			
+			entryHeader.name = readEntryName(stream);
+			entryHeader.offset = stream->readUint32LE();
+			entryHeader.id = stream->readUint32LE();
+			entryHeader.size = stream->readUint32LE();
+			entryHeader.time = stream->readUint32LE();
+			entryHeader.unknown = stream->readUint32LE();
+
+			if (entryHeader.size != 0)
+				_entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader);
+		}
+
+		// Seek to the next block of headers
+		stream->seek(nextOffset);
+	} while (nextOffset != 0);
+}
+
+Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const {
+	// Entry Names are at most 16 bytes and are null padded
+	char buffer[16];
+	stream->read(buffer, 16);
+
+	return Common::String(buffer);
+}
+
+bool ZfsArchive::hasFile(const Common::String &name) const {
+	return _entryHeaders.contains(name);
+}
+
+int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const {
+	int matches = 0;
+
+	for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) {
+		list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this)));
+		matches++;
+	}
+
+	return matches;
+}
+
+const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const {
+	if (!_entryHeaders.contains(name))
+		return Common::ArchiveMemberPtr();
+
+	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
+}
+
+Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const {
+	if (!_entryHeaders.contains(name)) {
+		return 0;
+	}
+
+	ZfsEntryHeader *entryHeader = _entryHeaders[name];
+
+	Common::File zfsArchive;
+	zfsArchive.open(_fileName);
+	zfsArchive.seek(entryHeader->offset);
+
+	byte* buffer = new byte[entryHeader->size];
+	zfsArchive.read(buffer, entryHeader->size);
+	// Decrypt the data in place
+	if (_header.xorKey != 0)
+		unXor(buffer, entryHeader->size, _header.xorKey);
+
+	return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
+}
+
+void ZfsArchive::unXor(byte *buffer, int length, const byte *xorKey) const {
+	for (uint32 i = 0; i < length; i++)
+		buffer[i] ^= xorKey[i % 4];
+}
+
+} // End of namespace ZVision
+
+
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
new file mode 100644
index 0000000..ccdf192
--- /dev/null
+++ b/engines/zvision/zfs_archive.h
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_ZFS_ARCHIVE_H
+#define ZVISION_ZFS_ARCHIVE_H
+
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+namespace ZVision {
+
+struct ZfsHeader {
+	uint32 magic;
+	uint32 unknown1;
+	uint32 maxNameLength;
+	uint32 filesPerBlock;
+	uint32 fileCount;
+	byte xorKey[4];
+	uint32 fileSectionOffset;
+};
+
+struct ZfsEntryHeader {
+	Common::String name;
+	uint32 offset;
+	uint32 id;
+	uint32 size;
+	uint32 time;
+	uint32 unknown;
+};
+
+typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
+
+class ZfsArchive : public Common::Archive {
+public:
+	ZfsArchive(const Common::String &fileName);
+	ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream);
+	~ZfsArchive();
+
+	/**
+	 * Check if a member with the given name is present in the Archive.
+	 * Patterns are not allowed, as this is meant to be a quick File::exists()
+	 * replacement.
+	 */
+	bool hasFile(const Common::String &fileName) const;
+
+	/**
+	 * Add all members of the Archive to list.
+	 * Must only append to list, and not remove elements from it.
+	 *
+	 * @return    The number of names added to list
+	 */
+	int listMembers(Common::ArchiveMemberList &list) const;
+
+	/**
+	 * Returns a ArchiveMember representation of the given file.
+	 */
+	const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
+
+	/**
+	 * Create a stream bound to a member with the specified name in the
+	 * archive. If no member with this name exists, 0 is returned.
+	 *
+	 * @return    The newly created input stream
+	 */
+	Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
+
+private:
+	const Common::String _fileName;
+	ZfsHeader _header;
+	ZfsEntryHeaderMap _entryHeaders;
+
+	/**
+	 * Parses the zfs file into file entry headers that can be used later
+	 * to get the entry data.
+	 *
+	 * @param stream    The contents of the zfs file
+	 */
+	void readHeaders(Common::SeekableReadStream *stream);
+
+	/**
+	 * Entry names are contained within a 16 byte block. This reads the block
+	 * and converts it the name to a Common::String
+	 *
+	 * @param stream    The zfs file stream
+	 * @return          The entry file name
+	 */
+	Common::String readEntryName(Common::SeekableReadStream *stream) const;
+
+	/**
+	 * ZFS file entries can be encrypted using XOR encoding. This method
+	 * decodes the buffer in place using the supplied xorKey.
+	 *
+	 * @param buffer    The data to decode
+	 * @param length    Length of buffer
+	 */
+	void unXor(byte *buffer, int length, const byte *xorKey) const;
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: 1710468121648d494a393f7176c81027fec573c4
    https://github.com/scummvm/scummvm/commit/1710468121648d494a393f7176c81027fec573c4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:56-07:00

Commit Message:
ZVISION: Fix includes to use new underscore names

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/result_action.cpp
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h
    engines/zvision/zfs_archive.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 1a456ef..75d3dc0 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -25,7 +25,7 @@
 
 #include "common/list.h"
 
-#include "zvision/resultAction.h"
+#include "zvision/result_action.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
index d14438d..375dcd2 100644
--- a/engines/zvision/result_action.cpp
+++ b/engines/zvision/result_action.cpp
@@ -22,7 +22,7 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/resultAction.h"
+#include "zvision/result_action.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 61feb12..d18e042 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -24,7 +24,7 @@
 
 #include <stdio.h>
 
-#include "zvision/scriptManager.h"
+#include "zvision/script_manager.h"
 #include "zvision/utility.h"
 #include "zvision/puzzle.h"
 
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 5317bf6..13438d4 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -22,7 +22,7 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/scriptManager.h"
+#include "zvision/script_manager.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 563a010..7f46bd5 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -29,7 +29,7 @@
 
 #include "zvision/puzzle.h"
 #include "zvision/control.h"
-#include "zvision/singleValueContainer.h"
+#include "zvision/result_action.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index e65d0df..85933b3 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -22,7 +22,7 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/zfsArchive.h"
+#include "zvision/zfs_archive.h"
 #include "common/hashmap.h"
 #include "common/memstream.h"
 #include "common/debug.h"
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 33b2a80..5af1cbb 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -32,8 +32,8 @@
 #include "engines/util.h"

  

 #include "zvision/zvision.h"

-#include "zvision/scriptManager.h"

-#include "zvision/zfsArchive.h"

+#include "zvision/script_manager.h"

+#include "zvision/zfs_archive.h"

 

 #include "graphics/decoders/tga.h"

 

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index b0cd1ae..166d3c0 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -29,7 +29,7 @@
 

 #include "engines/engine.h"

 

-#include "zvision/scriptManager.h"

+#include "zvision/script_manager.h"

 

 #include "gui/debugger.h"

  



Commit: 0b9dce40a08020499aab20d8c9d967f53f7d84ea
    https://github.com/scummvm/scummvm/commit/0b9dce40a08020499aab20d8c9d967f53f7d84ea
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:56-07:00

Commit Message:
ZVISION: Fix usage of Puzzle struct to use 'key' instead of 'id'

Changed paths:
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index d18e042..073d0ea 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -52,7 +52,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 
 		if (line.matchString("puzzle:*", true)) {
 			Puzzle puzzle;
-			sscanf(line.c_str(),"puzzle:%u",&(puzzle.id));
+			sscanf(line.c_str(),"puzzle:%u",&(puzzle.key));
 
 			parsePuzzle(puzzle, file);
 			_puzzles.push_back(puzzle);
@@ -95,7 +95,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 
 		// Parse the id out of the first token
 		token = tokenizer.nextToken();
-		sscanf(token.c_str(), "[%u]", &(criteria.id));
+		sscanf(token.c_str(), "[%u]", &(criteria.key));
 
 		// Parse the operator out of the second token
 		token = tokenizer.nextToken();


Commit: c0c4ee65339285652b7966afa66a48d012d6ea27
    https://github.com/scummvm/scummvm/commit/c0c4ee65339285652b7966afa66a48d012d6ea27
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:57-07:00

Commit Message:
ZVISION: Fix single_value_container.h include to use the new file name

Changed paths:
    engines/zvision/single_value_container.cpp



diff --git a/engines/zvision/single_value_container.cpp b/engines/zvision/single_value_container.cpp
index bd91c44..7e27098 100644
--- a/engines/zvision/single_value_container.cpp
+++ b/engines/zvision/single_value_container.cpp
@@ -23,7 +23,7 @@
 #include "common/scummsys.h"
 #include "common/textconsole.h"
 
-#include "zvision/singleValueContainer.h"
+#include "zvision/single_value_container.h"
 
 namespace ZVision {
 


Commit: 187c119e934fd5887fb26e2dada5e1a4c856e056
    https://github.com/scummvm/scummvm/commit/187c119e934fd5887fb26e2dada5e1a4c856e056
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:57-07:00

Commit Message:
ZVISION: Create ResultAction 's for Add and Random.

Create class templates for PlayAnimation, PreloadAnimation, and Attenuate

Changed paths:
    engines/zvision/result_action.cpp
    engines/zvision/result_action.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
index 375dcd2..de439db 100644
--- a/engines/zvision/result_action.cpp
+++ b/engines/zvision/result_action.cpp
@@ -26,6 +26,9 @@
 
 namespace ZVision {
 
+// ActionAdd
+//////////////////////////////////////////////////////////////////////////////
+
 ActionAdd::ActionAdd(Common::String line) {
 	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
 }
@@ -35,4 +38,31 @@ bool ActionAdd::execute(ZVision *zVision) {
 	return true;
 }
 
+
+// ActionAssign
+//////////////////////////////////////////////////////////////////////////////
+
+ActionAssign::ActionAssign(Common::String line) {
+	sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value);
+}
+
+bool ActionAssign::execute(ZVision *zVision) {
+	zVision->getScriptManager()->setStateValue(_key, _value);
+	return true;
+}
+
+
+// ActionRandom
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRandom::ActionRandom(Common::String line) {
+	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
+}
+
+bool ActionRandom::execute(ZVision *zVision) {
+	uint32 randNumber = zVision->getRandomSource()->getRandomNumber(_max);
+	zVision->getScriptManager()->setStateValue(_key, randNumber);
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h
index 4fd589d..7ab896d 100644
--- a/engines/zvision/result_action.h
+++ b/engines/zvision/result_action.h
@@ -87,6 +87,44 @@ private:
 	byte _value;
 };
 
+class ActionPlayAnimation : public ResultAction {
+public:
+	ActionPlayAnimation(Common::String line);
+	bool execute(ZVision *zVision);
+};
+
+class ActionPreloadAnimation : public ResultAction {
+public:
+	ActionPreloadAnimation(Common::String line);
+	bool execute(ZVision *zVision);
+};
+
+class ActionAttenuate : public ResultAction {
+public:
+	ActionAttenuate(Common::String line);
+	bool execute(ZVision *zVision);
+};
+
+class ActionAssign : public ResultAction {
+public:
+	ActionAssign(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
+};
+
+class ActionRandom : public ResultAction {
+public:
+	ActionRandom(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	uint32 _max;
+};
+
 } // End of namespace ZVision
 
 #endif
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 073d0ea..3171492 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -131,16 +131,15 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(line);
 
+	// TODO: Re-order the if-then statements in order of highest occurrence
 	while (!line.contains('}')) {
 		// Parse for the action type
 		if (line.matchString("*:add*", true)) {
 			actionList.push_back(ActionAdd(line));
 		} else if (line.matchString("*:animplay*", true)) {
-			
-
+			actionList.push_back(ActionPlayAnimation(line));
 		} else if (line.matchString("*:animpreload*", true)) {
-			
-
+			actionList.push_back(ActionPreloadAnimation(line));
 		} else if (line.matchString("*:animunload*", true)) {
 			
 
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 5af1cbb..479bf23 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -142,4 +142,8 @@ ScriptManager *ZVision::getScriptManager() const {
 	return _scriptManager;

 }

 

+Common::RandomSource *ZVision::getRandomSource() const {

+	return _rnd;

+}

+

 } // End of namespace ZVision

diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 166d3c0..ac5796a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -70,6 +70,7 @@ public:
 	Common::Language getLanguage() const;

 	virtual Common::Error run();

 	ScriptManager *getScriptManager() const;

+	Common::RandomSource *getRandomSource() const;

 

 private:

 	void initialize();

@@ -89,7 +90,7 @@ public:
 	Console(ZVision *vm) {}

 	virtual ~Console(void) {}

 };

- 

+

 } // End of namespace ZVision

  

 #endif



Commit: 16cc970c9e1c7ccc06088de732abcd6ac51fa26a
    https://github.com/scummvm/scummvm/commit/16cc970c9e1c7ccc06088de732abcd6ac51fa26a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:58-07:00

Commit Message:
ZVISION: Normalize remaining CRLF to LF for the remote

Changed paths:
    engines/zvision/detection.cpp
    engines/zvision/module.mk
    engines/zvision/zork_avi_decoder.cpp
    engines/zvision/zork_avi_decoder.h
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 62d834a..5488ae5 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -1,256 +1,256 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- *

- */

-

-#include "base/plugins.h"

-

-#include "engines/advancedDetector.h"

-

-#include "common/translation.h"

-#include "common/savefile.h"

-#include "common/str-array.h"

-#include "common/system.h"

-

-#include "zvision/zvision.h"

-

-

-namespace ZVision {

-

-struct ZVisionGameDescription {

-	ADGameDescription desc;

-};

-

-uint32 ZVision::getFeatures() const {

-	return _gameDescription->desc.flags;

-}

-

-Common::Language ZVision::getLanguage() const {

-	return _gameDescription->desc.language;

-}

-

-}

-

-static const PlainGameDescriptor zVisionGames[] = {

-	{"zvision",  "ZVision Game"},

-	{"znemesis", "Zork Nemesis: The Forbidden Lands"},

-	{"zgi",      "Zork: Grand Inquisitor"},

-	{0, 0}

-};

-

-

-namespace ZVision {

-

-static const ZVisionGameDescription gameDescriptions[] = {

-

-	{

-		// Zork Nemesis English version

-		{

-			"znemesis",

-			0,

-			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),

-			Common::EN_ANY,

-			Common::kPlatformDOS,

-			ADGF_NO_FLAGS,

-			GUIO1(GUIO_NONE)

-		},

-	},

-

-	{ AD_TABLE_END_MARKER }

-};

-

-} // End of namespace ZVision

-

-static const char *directoryGlobs[] = {

-	"znemscr",

-	0

-};

-

-static const ExtraGuiOption ZVisionExtraGuiOption = {

-	_s("Use original save/load screens"),

-	_s("Use the original save/load screens, instead of the ScummVM ones"),

-	"originalsaveload",

-	false

-};

-

-class ZVisionMetaEngine : public AdvancedMetaEngine {

-public:

-	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {

-		_maxScanDepth = 2;

-		_directoryGlobs = directoryGlobs;

-		_singleid = "zvision";

-	}

-

-	virtual const char *getName() const {

-		return "ZVision";

-	}

-

-	virtual const char *getOriginalCopyright() const {

-		return "ZVision Activision (C) 1996";

-	}

-

-	virtual bool hasFeature(MetaEngineFeature f) const;

-	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;

-	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {

-	return false;

-		/*

-		(f == kSupportsListSaves) ||

-		(f == kSupportsLoadingDuringStartup) ||

-		(f == kSupportsDeleteSave) ||

-		(f == kSavesSupportMetaInfo) ||

-		(f == kSavesSupportThumbnail) ||

-		(f == kSavesSupportCreationDate) ||

-		(f == kSavesSupportPlayTime);

-		*/

-}

-

-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {

-	return

-		(f == kSupportsRTL) ||

-		(f == kSupportsLoadingDuringRuntime) ||

-		(f == kSupportsSavingDuringRuntime);

-}*/

-

-bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {

-	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;

-	if (gd) {

-		*engine = new ZVision::ZVision(syst, gd);

-	}

-	return gd != 0;

-}

-

-const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {

-	ExtraGuiOptions options;

-	options.push_back(ZVisionExtraGuiOption);

-	return options;

-}

-

-SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {

-	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

-	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {

-					saveList.push_back(SaveStateDescriptor(slotNum, header.description));

-				}

-				delete in;

-			}

-		}

-	}*/

-

-	return saveList;

-}

-

-int ZVisionMetaEngine::getMaximumSaveSlot() const {

-	return 999;

-}

-

-void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {

-	/*

-	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();

-	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);

-		}

-	}

-	*/

-}

-

-SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {

-	/*

-	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);

-	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());

-

-	if (in) {

-		ZVision::ZVision::SaveHeader header;

-		ZVision::ZVision::kReadSaveHeaderError error;

-

-		error = ZVision::ZVision::readSaveHeader(in, true, header);

-		delete in;

-

-		if (error == ZVision::ZVision::kRSHENoError) {

-			SaveStateDescriptor desc(slot, header.description);

-

-			desc.setThumbnail(header.thumbnail);

-

-			if (header.version > 0) {

-				int day = (header.saveDate >> 24) & 0xFF;

-				int month = (header.saveDate >> 16) & 0xFF;

-				int year = header.saveDate & 0xFFFF;

-

-				desc.setSaveDate(year, month, day);

-

-				int hour = (header.saveTime >> 16) & 0xFF;

-				int minutes = (header.saveTime >> 8) & 0xFF;

-

-				desc.setSaveTime(hour, minutes);

-

-				desc.setPlayTime(header.playTime * 1000);

-			}

-

-			return desc;

-		}

-	}

-	*/

-

-	return SaveStateDescriptor();

-}

-

-#if PLUGIN_ENABLED_DYNAMIC(ZVISION)

-	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

-#else

-	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);

-#endif

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+
+#include "common/translation.h"
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/system.h"
+
+#include "zvision/zvision.h"
+
+
+namespace ZVision {
+
+struct ZVisionGameDescription {
+	ADGameDescription desc;
+};
+
+uint32 ZVision::getFeatures() const {
+	return _gameDescription->desc.flags;
+}
+
+Common::Language ZVision::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
+}
+
+static const PlainGameDescriptor zVisionGames[] = {
+	{"zvision",  "ZVision Game"},
+	{"znemesis", "Zork Nemesis: The Forbidden Lands"},
+	{"zgi",      "Zork: Grand Inquisitor"},
+	{0, 0}
+};
+
+
+namespace ZVision {
+
+static const ZVisionGameDescription gameDescriptions[] = {
+
+	{
+		// Zork Nemesis English version
+		{
+			"znemesis",
+			0,
+			AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+	},
+
+	{ AD_TABLE_END_MARKER }
+};
+
+} // End of namespace ZVision
+
+static const char *directoryGlobs[] = {
+	"znemscr",
+	0
+};
+
+static const ExtraGuiOption ZVisionExtraGuiOption = {
+	_s("Use original save/load screens"),
+	_s("Use the original save/load screens, instead of the ScummVM ones"),
+	"originalsaveload",
+	false
+};
+
+class ZVisionMetaEngine : public AdvancedMetaEngine {
+public:
+	ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
+		_maxScanDepth = 2;
+		_directoryGlobs = directoryGlobs;
+		_singleid = "zvision";
+	}
+
+	virtual const char *getName() const {
+		return "ZVision";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "ZVision Activision (C) 1996";
+	}
+
+	virtual bool hasFeature(MetaEngineFeature f) const;
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+	virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) 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 ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return false;
+		/*
+		(f == kSupportsListSaves) ||
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsDeleteSave) ||
+		(f == kSavesSupportMetaInfo) ||
+		(f == kSavesSupportThumbnail) ||
+		(f == kSavesSupportCreationDate) ||
+		(f == kSavesSupportPlayTime);
+		*/
+}
+
+/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsLoadingDuringRuntime) ||
+		(f == kSupportsSavingDuringRuntime);
+}*/
+
+bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
+	if (gd) {
+		*engine = new ZVision::ZVision(syst, gd);
+	}
+	return gd != 0;
+}
+
+const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
+	ExtraGuiOptions options;
+	options.push_back(ZVisionExtraGuiOption);
+	return options;
+}
+
+SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
+	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	/*ZVision::ZVision::SaveHeader 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 (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
+					saveList.push_back(SaveStateDescriptor(slotNum, header.description));
+				}
+				delete in;
+			}
+		}
+	}*/
+
+	return saveList;
+}
+
+int ZVisionMetaEngine::getMaximumSaveSlot() const {
+	return 999;
+}
+
+void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
+	/*
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::String filename = ZVision::ZVision::getSavegameFilename(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 = ZVision::ZVision::getSavegameFilename(target, ++slot);
+		}
+	}
+	*/
+}
+
+SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	/*
+	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+	if (in) {
+		ZVision::ZVision::SaveHeader header;
+		ZVision::ZVision::kReadSaveHeaderError error;
+
+		error = ZVision::ZVision::readSaveHeader(in, true, header);
+		delete in;
+
+		if (error == ZVision::ZVision::kRSHENoError) {
+			SaveStateDescriptor desc(slot, header.description);
+
+			desc.setThumbnail(header.thumbnail);
+
+			if (header.version > 0) {
+				int day = (header.saveDate >> 24) & 0xFF;
+				int month = (header.saveDate >> 16) & 0xFF;
+				int year = header.saveDate & 0xFFFF;
+
+				desc.setSaveDate(year, month, day);
+
+				int hour = (header.saveTime >> 16) & 0xFF;
+				int minutes = (header.saveTime >> 8) & 0xFF;
+
+				desc.setSaveTime(hour, minutes);
+
+				desc.setPlayTime(header.playTime * 1000);
+			}
+
+			return desc;
+		}
+	}
+	*/
+
+	return SaveStateDescriptor();
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
+	REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 854ee03..3dd17a2 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,18 +1,18 @@
-MODULE := engines/zvision

- 

-MODULE_OBJS := \

-	detection.o \

-	zvision.o \

-	zork_avi_decoder.o \

-	zork_raw.o

- 

-MODULE_DIRS += \

-	engines/zvision

- 

-# This module can be built as a plugin

-ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN)

-PLUGIN := 1

-endif

- 

-# Include common rules 

+MODULE := engines/zvision
+ 
+MODULE_OBJS := \
+	detection.o \
+	zvision.o \
+	zork_avi_decoder.o \
+	zork_raw.o
+ 
+MODULE_DIRS += \
+	engines/zvision
+ 
+# This module can be built as a plugin
+ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+ 
+# Include common rules 
 include $(srcdir)/rules.mk
\ No newline at end of file
diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index 2da5246..4ceff48 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -1,50 +1,50 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- *

- */

-

-#include "common/scummsys.h"

-

-#include "common/stream.h"

-#include "audio/audiostream.h"

-

-#include "engines/zvision/zork_avi_decoder.h"

-#include "engines/zvision/zork_raw.h"

-

-namespace ZVision {

-

-Video::AVIDecoder::AVIAudioTrack *ZVision::ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {

-	ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);

-	return (Video::AVIDecoder::AVIAudioTrack *)audioTrack;

-}

-

-void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {

-	if (_audStream) {

-		if (_wvInfo.tag == kWaveFormatZorkPCM) {

-			assert(_wvInfo.size == 8);

-			_audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES);

-		}

-	} else {

-		delete stream;

-	}

-}

-

-} // End of namespace ZVision

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/stream.h"
+#include "audio/audiostream.h"
+
+#include "engines/zvision/zork_avi_decoder.h"
+#include "engines/zvision/zork_raw.h"
+
+namespace ZVision {
+
+Video::AVIDecoder::AVIAudioTrack *ZVision::ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {
+	ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);
+	return (Video::AVIDecoder::AVIAudioTrack *)audioTrack;
+}
+
+void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {
+	if (_audStream) {
+		if (_wvInfo.tag == kWaveFormatZorkPCM) {
+			assert(_wvInfo.size == 8);
+			_audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES);
+		}
+	} else {
+		delete stream;
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index 5530d92..1dff304 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -1,59 +1,59 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public 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 ZORK_AVI_DECODER_H

-#define ZORK_AVI_DECODER_H

-

-#include "video/avi_decoder.h"

- 

-namespace ZVision {

-

-class ZorkAVIDecoder : public Video::AVIDecoder {

-public:

-	ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :

-	  Video::AVIDecoder(soundType) {}

-

-	  virtual ~ZorkAVIDecoder() {}

-

-private:

-	class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {

-	public:

-		ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :

-			Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {}

-		virtual ~ZorkAVIAudioTrack() {}

-

-		void queueSound(Common::SeekableReadStream *stream);

-	};

-

-	Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);

-

-	private:

-		// Audio Codecs

-		enum {

-			kWaveFormatZorkPCM = 17	// special Zork PCM audio format (clashes with MS IMA ADPCM)

-		};

-};

-

-} // End of namespace ZVision

- 

-#endif

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZORK_AVI_DECODER_H
+#define ZORK_AVI_DECODER_H
+
+#include "video/avi_decoder.h"
+ 
+namespace ZVision {
+
+class ZorkAVIDecoder : public Video::AVIDecoder {
+public:
+	ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :
+	  Video::AVIDecoder(soundType) {}
+
+	  virtual ~ZorkAVIDecoder() {}
+
+private:
+	class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {
+	public:
+		ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :
+			Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {}
+		virtual ~ZorkAVIAudioTrack() {}
+
+		void queueSound(Common::SeekableReadStream *stream);
+	};
+
+	Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);
+
+	private:
+		// Audio Codecs
+		enum {
+			kWaveFormatZorkPCM = 17	// special Zork PCM audio format (clashes with MS IMA ADPCM)
+		};
+};
+
+} // End of namespace ZVision
+ 
+#endif
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index e008741..d920550 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -1,188 +1,188 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- */

-

-#include "common/scummsys.h"

-

-#include "common/endian.h"

-#include "common/memstream.h"

-#include "common/textconsole.h"

-#include "common/util.h"

-

-#include "audio/audiostream.h"

-

-#include "engines/zvision/zork_raw.h"

-

-namespace ZVision {

-

-#pragma mark -

-#pragma mark --- RawZorkStream ---

-#pragma mark -

-

-/**

- * This is a stream, which allows for playing raw PCM data from a stream.

- */

-class RawZorkStream : public Audio::SeekableAudioStream {

-public:

-	RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)

-		: _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) {

-		// Setup our buffer for readBuffer

-		_buffer = new byte[kSampleBufferLength];

-		assert(_buffer);

-

-		// Calculate the total playtime of the stream

-		_playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate);

-	}

-

-	~RawZorkStream() {

-		delete[] _buffer;

-	}

-

-	int readBuffer(int16 *buffer, const int numSamples);

-

-	bool isStereo() const  { return true; }

-	bool endOfData() const { return _endOfData; }

-

-	int getRate() const         { return _rate; }

-	Audio::Timestamp getLength() const { return _playtime; }

-

-	bool seek(const Audio::Timestamp &where);

-private:

-	const int _rate;                                           ///< Sample rate of stream

-	Audio::Timestamp _playtime;                                       ///< Calculated total play time

-	Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from

-	bool _endOfData;                                           ///< Whether the stream end has been reached

-

-	byte *_buffer;                                             ///< Buffer used in readBuffer

-	enum {

-		/**

-		 * How many samples we can buffer at once.

-		 *

-		 * TODO: Check whether this size suffices

-		 * for systems with slow disk I/O.

-		 */

-		kSampleBufferLength = 2048

-	};

-

-	/**

-	 * Fill the temporary sample buffer used in readBuffer.

-	 *

-	 * @param maxSamples Maximum samples to read.

-	 * @return actual count of samples read.

-	 */

-	int fillBuffer(int maxSamples);

-};

-

-int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {

-	int samplesLeft = numSamples;

-

-	while (samplesLeft > 0) {

-		// Try to read up to "samplesLeft" samples.

-		int len = fillBuffer(samplesLeft);

-

-		// In case we were not able to read any samples

-		// we will stop reading here.

-		if (!len)

-			break;

-

-		// Adjust the samples left to read.

-		samplesLeft -= len;

-

-		// Copy the data to the caller's buffer.

-		const byte *src = _buffer;

-		while (len-- > 0) {

-			if (*src < 128)

-				*buffer++ = ((128 - *src) << 8) ^ 0x8000;

-			else

-				*buffer++ = (*src << 8) ^ 0x8000;

-			src++;

-		}

-	}

-

-	return numSamples - samplesLeft;

-}

-

-int RawZorkStream::fillBuffer(int maxSamples) {

-	int bufferedSamples = 0;

-	byte *dst = _buffer;

-

-	// We can only read up to "kSampleBufferLength" samples

-	// so we take this into consideration, when trying to

-	// read up to maxSamples.

-	maxSamples = MIN<int>(kSampleBufferLength, maxSamples);

-

-	// We will only read up to maxSamples

-	while (maxSamples > 0 && !endOfData()) {

-		// Try to read all the sample data and update the

-		// destination pointer.

-		const int bytesRead = _stream->read(dst, maxSamples);

-		dst += bytesRead;

-

-		// Calculate how many samples we actually read.

-		const int samplesRead = bytesRead;

-

-		// Update all status variables

-		bufferedSamples += samplesRead;

-		maxSamples -= samplesRead;

-

-		// We stop stream playback, when we reached the end of the data stream.

-		// We also stop playback when an error occures.

-		if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos())

-			_endOfData = true;

-	}

-

-	return bufferedSamples;

-}

-

-bool RawZorkStream::seek(const Audio::Timestamp &where) {

-	_endOfData = true;

-

-	if (where > _playtime)

-		return false;

-

-	const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames();

-	_stream->seek(seekSample, SEEK_SET);

-

-	// In case of an error we will not continue stream playback.

-	if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size())

-		_endOfData = false;

-

-	return true;

-}

-

-#pragma mark -

-#pragma mark --- Raw stream factories ---

-#pragma mark -

-

-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,

-                                   int rate,

-                                   DisposeAfterUse::Flag disposeAfterUse) {

-	assert(stream->size() % 2 == 0);

-	return new RawZorkStream(rate, disposeAfterUse, stream);

-}

-

-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,

-                                   int rate,

-                                   DisposeAfterUse::Flag disposeAfterUse) {

-	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);

-}

-

-} // End of namespace ZVision

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/endian.h"
+#include "common/memstream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+
+#include "audio/audiostream.h"
+
+#include "engines/zvision/zork_raw.h"
+
+namespace ZVision {
+
+#pragma mark -
+#pragma mark --- RawZorkStream ---
+#pragma mark -
+
+/**
+ * This is a stream, which allows for playing raw PCM data from a stream.
+ */
+class RawZorkStream : public Audio::SeekableAudioStream {
+public:
+	RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+		: _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) {
+		// Setup our buffer for readBuffer
+		_buffer = new byte[kSampleBufferLength];
+		assert(_buffer);
+
+		// Calculate the total playtime of the stream
+		_playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate);
+	}
+
+	~RawZorkStream() {
+		delete[] _buffer;
+	}
+
+	int readBuffer(int16 *buffer, const int numSamples);
+
+	bool isStereo() const  { return true; }
+	bool endOfData() const { return _endOfData; }
+
+	int getRate() const         { return _rate; }
+	Audio::Timestamp getLength() const { return _playtime; }
+
+	bool seek(const Audio::Timestamp &where);
+private:
+	const int _rate;                                           ///< Sample rate of stream
+	Audio::Timestamp _playtime;                                       ///< Calculated total play time
+	Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from
+	bool _endOfData;                                           ///< Whether the stream end has been reached
+
+	byte *_buffer;                                             ///< Buffer used in readBuffer
+	enum {
+		/**
+		 * How many samples we can buffer at once.
+		 *
+		 * TODO: Check whether this size suffices
+		 * for systems with slow disk I/O.
+		 */
+		kSampleBufferLength = 2048
+	};
+
+	/**
+	 * Fill the temporary sample buffer used in readBuffer.
+	 *
+	 * @param maxSamples Maximum samples to read.
+	 * @return actual count of samples read.
+	 */
+	int fillBuffer(int maxSamples);
+};
+
+int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
+	int samplesLeft = numSamples;
+
+	while (samplesLeft > 0) {
+		// Try to read up to "samplesLeft" samples.
+		int len = fillBuffer(samplesLeft);
+
+		// In case we were not able to read any samples
+		// we will stop reading here.
+		if (!len)
+			break;
+
+		// Adjust the samples left to read.
+		samplesLeft -= len;
+
+		// Copy the data to the caller's buffer.
+		const byte *src = _buffer;
+		while (len-- > 0) {
+			if (*src < 128)
+				*buffer++ = ((128 - *src) << 8) ^ 0x8000;
+			else
+				*buffer++ = (*src << 8) ^ 0x8000;
+			src++;
+		}
+	}
+
+	return numSamples - samplesLeft;
+}
+
+int RawZorkStream::fillBuffer(int maxSamples) {
+	int bufferedSamples = 0;
+	byte *dst = _buffer;
+
+	// We can only read up to "kSampleBufferLength" samples
+	// so we take this into consideration, when trying to
+	// read up to maxSamples.
+	maxSamples = MIN<int>(kSampleBufferLength, maxSamples);
+
+	// We will only read up to maxSamples
+	while (maxSamples > 0 && !endOfData()) {
+		// Try to read all the sample data and update the
+		// destination pointer.
+		const int bytesRead = _stream->read(dst, maxSamples);
+		dst += bytesRead;
+
+		// Calculate how many samples we actually read.
+		const int samplesRead = bytesRead;
+
+		// Update all status variables
+		bufferedSamples += samplesRead;
+		maxSamples -= samplesRead;
+
+		// We stop stream playback, when we reached the end of the data stream.
+		// We also stop playback when an error occures.
+		if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos())
+			_endOfData = true;
+	}
+
+	return bufferedSamples;
+}
+
+bool RawZorkStream::seek(const Audio::Timestamp &where) {
+	_endOfData = true;
+
+	if (where > _playtime)
+		return false;
+
+	const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames();
+	_stream->seek(seekSample, SEEK_SET);
+
+	// In case of an error we will not continue stream playback.
+	if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size())
+		_endOfData = false;
+
+	return true;
+}
+
+#pragma mark -
+#pragma mark --- Raw stream factories ---
+#pragma mark -
+
+Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
+                                   int rate,
+                                   DisposeAfterUse::Flag disposeAfterUse) {
+	assert(stream->size() % 2 == 0);
+	return new RawZorkStream(rate, disposeAfterUse, stream);
+}
+
+Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
+                                   int rate,
+                                   DisposeAfterUse::Flag disposeAfterUse) {
+	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 3a93802..1de3b57 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -1,67 +1,67 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public 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 ZVISION_ZORK_RAW_H

-#define ZVISION_ZORK_RAW_H

-

-#include "common/scummsys.h"

-#include "common/types.h"

-

-#include "common/list.h"

-

-

-namespace Common {

-class SeekableReadStream;

-}

-

-namespace ZVision {

-

-class SeekableAudioStream;

-

-/**

- * Creates an audio stream, which plays from the given buffer.

- *

- * @param buffer Buffer to play from.

- * @param size   Size of the buffer in bytes.

- * @param rate   Rate of the sound data.

- * @param disposeAfterUse Whether to free the buffer after use (with free!).

- * @return The new SeekableAudioStream (or 0 on failure).

- */

-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,

-                                   int rate,

-                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

-

-/**

- * Creates an audio stream, which plays from the given stream.

- *

- * @param stream Stream object to play from.

- * @param rate   Rate of the sound data.

- * @param disposeAfterUse Whether to delete the stream after use.

- * @return The new SeekableAudioStream (or 0 on failure).

- */

-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,

-                                   int rate,

-                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

-

-} // End of namespace ZVision

-

-#endif

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_ZORK_RAW_H
+#define ZVISION_ZORK_RAW_H
+
+#include "common/scummsys.h"
+#include "common/types.h"
+
+#include "common/list.h"
+
+
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace ZVision {
+
+class SeekableAudioStream;
+
+/**
+ * Creates an audio stream, which plays from the given buffer.
+ *
+ * @param buffer Buffer to play from.
+ * @param size   Size of the buffer in bytes.
+ * @param rate   Rate of the sound data.
+ * @param disposeAfterUse Whether to free the buffer after use (with free!).
+ * @return The new SeekableAudioStream (or 0 on failure).
+ */
+Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
+                                   int rate,
+                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+
+/**
+ * Creates an audio stream, which plays from the given stream.
+ *
+ * @param stream Stream object to play from.
+ * @param rate   Rate of the sound data.
+ * @param disposeAfterUse Whether to delete the stream after use.
+ * @return The new SeekableAudioStream (or 0 on failure).
+ */
+Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
+                                   int rate,
+                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 479bf23..5e83c47 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -1,149 +1,149 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- */

-

-#include "common/scummsys.h"

-

-#include "common/config-manager.h"

-#include "common/debug.h"

-#include "common/debug-channels.h"

-#include "common/error.h"

-#include "common/system.h"

-#include "common/file.h"

-

-#include "engines/util.h"

- 

-#include "zvision/zvision.h"

-#include "zvision/script_manager.h"

-#include "zvision/zfs_archive.h"

-

-#include "graphics/decoders/tga.h"

-

-#include "zvision/tests.h"

-

-namespace ZVision {

- 

-ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {

-	// Put your engine in a sane state, but do nothing big yet;

-	// in particular, do not load data from files; rather, if you

-	// need to do such things, do them from run().

- 

-	// Do not initialize graphics here

- 

-	// However this is the place to specify all default directories

-	const Common::FSNode gameDataDir(ConfMan.get("path"));

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4);

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4);

-	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4);

-	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");

-	SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");

- 

-	// Here is the right place to set up the engine specific debug channels

-	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");

-	//DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");

- 

-	// Register random source

-	_rnd = new Common::RandomSource("zvision");

-

-	// Create managers

-	_scriptManager = new ScriptManager();

-

-	debug("ZVision::ZVision");

-}

- 

-ZVision::~ZVision() {

-	debug("ZVision::~ZVision");

- 

-	// Dispose of resources

-	delete _scriptManager;

-	delete _rnd;

- 

-	// Remove all of our debug levels

-	DebugMan.clearAllDebugChannels();

-}

-

-void ZVision::initialize() {

-	// Find zfs archive files

-	Common::ArchiveMemberList list;

-	SearchMan.listMatchingMembers(list, "*.zfs");

-

-	// Register the file entries within the zfs archives with the SearchMan

-	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {

-		Common::String name = (*iter)->getName();

-		ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream());

-

-		SearchMan.add(name, archive);

-	}

-

-	//Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);	// ARGB8888

-	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555

-	initGraphics(640, 480, true, &format);

-

-	_scriptManager->initialize();

-

-	// Create debugger console. It requires GFX to be initialized

-	_console = new Console(this);

-}

-

-Common::Error ZVision::run() {

-	initialize();

-

-	tests();

-

-	// Main loop

-	uint32 currentTime = _system->getMillis();

-	uint32 lastTime = currentTime;

-	const uint32 desiredFrameTime = 33; // ~30 fps

-

-	while (!shouldQuit()) {

-		processEvents();

-		

-		currentTime = _system->getMillis();

-		uint32 deltaTime = currentTime - lastTime;

-		lastTime = currentTime;

-		

-		updateScripts();

-		updateAnimations(deltaTime);

-

-		if (_needsScreenUpdate)

-		{

-			_system->updateScreen();

-		}

-		

-		// Calculate the frame delay based off a desired frame rate

-		int delay = desiredFrameTime - (currentTime - _system->getMillis());

-		// Ensure non-negative

-		delay = delay < 0 ? 0 : delay;

-		_system->delayMillis(delay);

-	}

-

-	return Common::kNoError;

-}

-

-ScriptManager *ZVision::getScriptManager() const {

-	return _scriptManager;

-}

-

-Common::RandomSource *ZVision::getRandomSource() const {

-	return _rnd;

-}

-

-} // End of namespace ZVision

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/error.h"
+#include "common/system.h"
+#include "common/file.h"
+
+#include "engines/util.h"
+ 
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/zfs_archive.h"
+
+#include "graphics/decoders/tga.h"
+
+#include "zvision/tests.h"
+
+namespace ZVision {
+ 
+ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+	// Put your engine in a sane state, but do nothing big yet;
+	// in particular, do not load data from files; rather, if you
+	// need to do such things, do them from run().
+ 
+	// Do not initialize graphics here
+ 
+	// However this is the place to specify all default directories
+	const Common::FSNode gameDataDir(ConfMan.get("path"));
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");
+	SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");
+ 
+	// Here is the right place to set up the engine specific debug channels
+	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");
+	//DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");
+ 
+	// Register random source
+	_rnd = new Common::RandomSource("zvision");
+
+	// Create managers
+	_scriptManager = new ScriptManager();
+
+	debug("ZVision::ZVision");
+}
+ 
+ZVision::~ZVision() {
+	debug("ZVision::~ZVision");
+ 
+	// Dispose of resources
+	delete _scriptManager;
+	delete _rnd;
+ 
+	// Remove all of our debug levels
+	DebugMan.clearAllDebugChannels();
+}
+
+void ZVision::initialize() {
+	// Find zfs archive files
+	Common::ArchiveMemberList list;
+	SearchMan.listMatchingMembers(list, "*.zfs");
+
+	// Register the file entries within the zfs archives with the SearchMan
+	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+		Common::String name = (*iter)->getName();
+		ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream());
+
+		SearchMan.add(name, archive);
+	}
+
+	//Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);	// ARGB8888
+	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555
+	initGraphics(640, 480, true, &format);
+
+	_scriptManager->initialize();
+
+	// Create debugger console. It requires GFX to be initialized
+	_console = new Console(this);
+}
+
+Common::Error ZVision::run() {
+	initialize();
+
+	tests();
+
+	// Main loop
+	uint32 currentTime = _system->getMillis();
+	uint32 lastTime = currentTime;
+	const uint32 desiredFrameTime = 33; // ~30 fps
+
+	while (!shouldQuit()) {
+		processEvents();
+		
+		currentTime = _system->getMillis();
+		uint32 deltaTime = currentTime - lastTime;
+		lastTime = currentTime;
+		
+		updateScripts();
+		updateAnimations(deltaTime);
+
+		if (_needsScreenUpdate)
+		{
+			_system->updateScreen();
+		}
+		
+		// Calculate the frame delay based off a desired frame rate
+		int delay = desiredFrameTime - (currentTime - _system->getMillis());
+		// Ensure non-negative
+		delay = delay < 0 ? 0 : delay;
+		_system->delayMillis(delay);
+	}
+
+	return Common::kNoError;
+}
+
+ScriptManager *ZVision::getScriptManager() const {
+	return _scriptManager;
+}
+
+Common::RandomSource *ZVision::getRandomSource() const {
+	return _rnd;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index ac5796a..0053fe5 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -1,96 +1,96 @@
-/* ScummVM - Graphic Adventure Engine

- *

- * ScummVM is the legal property of its developers, whose names

- * are too numerous to list here. Please refer to the COPYRIGHT

- * file distributed with this source distribution.

- *

- * This program is free software; you can redistribute it and/or

- * modify it under the terms of the GNU General Public License

- * as published by the Free Software Foundation; either version 2

- * of the License, or (at your option) any later version.

-

- * This program is distributed in the hope that it will be useful,

- * but WITHOUT ANY WARRANTY; without even the implied warranty of

- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

- * GNU General Public License for more details.

-

- * You should have received a copy of the GNU General Public License

- * along with this program; if not, write to the Free Software

- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

- *

- *

- */

-

-#ifndef ZVISION_H

-#define ZVISION_H

-

-#include "common/random.h"

-#include "common/events.h"

-

-#include "engines/engine.h"

-

-#include "zvision/script_manager.h"

-

-#include "gui/debugger.h"

- 

-namespace ZVision {

-

-struct ZVisionGameDescription;

-class Console;

- 

-// our engine debug channels

-enum {

-	kZDebugExample = 1 << 0,

-	kZDebugExample2 = 1 << 1

-	// next new channel must be 1 << 2 (4)

-	// the current limitation is 32 debug channels (1 << 31 is the last one)

-};

- 

-class ZVision : public Engine {

-public:

-	ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);

-	~ZVision();

-

-private:

-	Console *_console;

-	const ZVisionGameDescription *_gameDescription;

-

-	// We need random numbers

-	Common::RandomSource *_rnd;

-

-	ScriptManager *_scriptManager;

-

-	// To prevent allocation every time we process events

-	Common::Event _event;

-

-	bool _needsScreenUpdate;

-

-public:

-	uint32 getFeatures() const;

-	Common::Language getLanguage() const;

-	virtual Common::Error run();

-	ScriptManager *getScriptManager() const;

-	Common::RandomSource *getRandomSource() const;

-

-private:

-	void initialize();

-

-	void processEvents();

+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 ZVISION_H
+#define ZVISION_H
+
+#include "common/random.h"
+#include "common/events.h"
+
+#include "engines/engine.h"
+
+#include "zvision/script_manager.h"
+
+#include "gui/debugger.h"
+ 
+namespace ZVision {
+
+struct ZVisionGameDescription;
+class Console;
+ 
+// our engine debug channels
+enum {
+	kZDebugExample = 1 << 0,
+	kZDebugExample2 = 1 << 1
+	// next new channel must be 1 << 2 (4)
+	// the current limitation is 32 debug channels (1 << 31 is the last one)
+};
+ 
+class ZVision : public Engine {
+public:
+	ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
+	~ZVision();
+
+private:
+	Console *_console;
+	const ZVisionGameDescription *_gameDescription;
+
+	// We need random numbers
+	Common::RandomSource *_rnd;
+
+	ScriptManager *_scriptManager;
+
+	// To prevent allocation every time we process events
+	Common::Event _event;
+
+	bool _needsScreenUpdate;
+
+public:
+	uint32 getFeatures() const;
+	Common::Language getLanguage() const;
+	virtual Common::Error run();
+	ScriptManager *getScriptManager() const;
+	Common::RandomSource *getRandomSource() const;
+
+private:
+	void initialize();
+
+	void processEvents();
 	void onMouseDown(const Common::Point &pos);
 	void onMouseMove(const Common::Point &pos);
-	void onKeyDown(uint16 keyCode);

-

-	void updateScripts();

-	void updateAnimations(uint32 detaTimeMillis);

-};

- 

-// Example console class

-class Console : public GUI::Debugger {

-public:

-	Console(ZVision *vm) {}

-	virtual ~Console(void) {}

-};

-

-} // End of namespace ZVision

- 

-#endif

+	void onKeyDown(uint16 keyCode);
+
+	void updateScripts();
+	void updateAnimations(uint32 detaTimeMillis);
+};
+ 
+// Example console class
+class Console : public GUI::Debugger {
+public:
+	Console(ZVision *vm) {}
+	virtual ~Console(void) {}
+};
+
+} // End of namespace ZVision
+ 
+#endif


Commit: 0ba9ca8fa0614287bf4b7e666a07126fa8e1faad
    https://github.com/scummvm/scummvm/commit/0ba9ca8fa0614287bf4b7e666a07126fa8e1faad
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:58-07:00

Commit Message:
ZVISION: Forward declare ZVision in result_action.h

result_action.h is #included before ZVision is declared, causing not declared compiler errors

Changed paths:
    engines/zvision/result_action.cpp
    engines/zvision/result_action.h



diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
index de439db..4721c5b 100644
--- a/engines/zvision/result_action.cpp
+++ b/engines/zvision/result_action.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 
 #include "zvision/result_action.h"
+#include "zvision/zvision.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h
index 7ab896d..fbf8e7f 100644
--- a/engines/zvision/result_action.h
+++ b/engines/zvision/result_action.h
@@ -25,10 +25,13 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/zvision.h"
+#include "common/str.h"
 
 namespace ZVision {
 
+// Forward declaration of ZVision. This file is included before ZVision is declared
+class ZVision;
+
 class ResultAction {
 public:
 	virtual ~ResultAction() {}


Commit: 3822de2aec0d41df7c2beeb5a1269577e9c3df84
    https://github.com/scummvm/scummvm/commit/3822de2aec0d41df7c2beeb5a1269577e9c3df84
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:59-07:00

Commit Message:
ZVISION: Change Puzzle::resultActions to a List of pointers instead of ResultAction objects

ResultAction is abstract, therefore, it can't be directly stored in the list

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 75d3dc0..fd9c61e 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -61,7 +61,8 @@ enum StateFlags : byte {
 struct Puzzle {
 	uint32 key;
 	Common::List<Criteria> criteriaList;
-	Common::List<ResultAction> resultActions;
+	// This has to be list of pointers because ResultAction is abstract
+	Common::List<ResultAction *> resultActions;
 	byte flags;
 };
 
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 3171492..eb867fa 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -126,7 +126,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 	return criteria;
 }
 
-void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const {
+void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(line);
@@ -135,11 +135,11 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
 	while (!line.contains('}')) {
 		// Parse for the action type
 		if (line.matchString("*:add*", true)) {
-			actionList.push_back(ActionAdd(line));
+			actionList.push_back(new ActionAdd(line));
 		} else if (line.matchString("*:animplay*", true)) {
-			actionList.push_back(ActionPlayAnimation(line));
+			actionList.push_back(new ActionPlayAnimation(line));
 		} else if (line.matchString("*:animpreload*", true)) {
-			actionList.push_back(ActionPreloadAnimation(line));
+			actionList.push_back(new ActionPreloadAnimation(line));
 		} else if (line.matchString("*:animunload*", true)) {
 			
 
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 7f46bd5..173705e 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -82,7 +82,7 @@ private:
 	 * @param stream    Scr file stream
 	 * @return          Created Results object
 	 */
-	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction> &actionList) const;
+	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const;
 
 	/**
 	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum


Commit: 3f93f7d27fe58690a4b94c22247bb00a9af2c92e
    https://github.com/scummvm/scummvm/commit/3f93f7d27fe58690a4b94c22247bb00a9af2c92e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:31:59-07:00

Commit Message:
ZVISION: Change trimCommentsAndWhiteSpace to use a pointer instead of a reference.

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/utility.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index eb867fa..285e635 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -46,7 +46,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 			return;
 		}
 
-		trimCommentsAndWhiteSpace(line);
+		trimCommentsAndWhiteSpace(&line);
 		if (line.empty())
 			continue;
 
@@ -69,7 +69,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 
 void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
 	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
+	trimCommentsAndWhiteSpace(&line);
 
 	while (!line.contains('}')) {
 		if (line.matchString("criteria {", true))
@@ -86,7 +86,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
+	trimCommentsAndWhiteSpace(&line);
 
 	while (!line.contains('}')) {
 		// Split the string into tokens using ' ' as a delimiter
@@ -120,7 +120,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 		}
 
 		line = stream.readLine();
-		trimCommentsAndWhiteSpace(line);
+		trimCommentsAndWhiteSpace(&line);
 	}
 
 	return criteria;
@@ -129,7 +129,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
+	trimCommentsAndWhiteSpace(&line);
 
 	// TODO: Re-order the if-then statements in order of highest occurrence
 	while (!line.contains('}')) {
@@ -253,7 +253,7 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
 		}
 
 		line = stream.readLine();
-		trimCommentsAndWhiteSpace(line);
+		trimCommentsAndWhiteSpace(&line);
 	}
 
 	return;
@@ -264,7 +264,7 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
 
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
-	trimCommentsAndWhiteSpace(line);
+	trimCommentsAndWhiteSpace(&line);
 
 	while (!line.contains('}')) {
 		if (line.matchString("ONCE_PER_INST", true)) {
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 4d12450..511b3c1 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -59,14 +59,15 @@ void writeFileContentsToFile(Common::String sourceFile, Common::String destFile)
  *
  * @param string    The string to modify. It is modified in place
  */
-void trimCommentsAndWhiteSpace(Common::String &string) {
-	for (int i = string.size(); i >= 0; --i) {
-		if (string[i] == '#') {
-			string.erase(i);
+void trimCommentsAndWhiteSpace(Common::String *string) {
+	for (int i = string->size() - 1; i >= 0; i--) {
+		if ((*string)[i] == '#') {
+			string->erase(i);
 		}
 	}
 
-	string.trim();
+	string->trim();
+}
 }
 
 } // End of namespace ZVision


Commit: ebb546c46850475485753346594376cf62465765
    https://github.com/scummvm/scummvm/commit/ebb546c46850475485753346594376cf62465765
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:00-07:00

Commit Message:
ZVISION: Create utility method to dump result action signatures from various .scr files

Changed paths:
    engines/zvision/utility.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 511b3c1..0b2ef2b 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -36,7 +36,7 @@ namespace ZVision {
  * @param sourceFile    The 'file' you want the contents of
  * @param destFile      The name of the file where the content will be written to
  */
-void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) {
+void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
 	Common::File f;
 	f.open(sourceFile);
 	byte* buffer = new byte[f.size()];
@@ -68,6 +68,138 @@ void trimCommentsAndWhiteSpace(Common::String *string) {
 
 	string->trim();
 }
+
+void tryToDumpLine(const Common::String &key,
+	Common::String &line,
+	Common::HashMap<Common::String, byte> *count,
+	Common::HashMap<Common::String, bool> *fileAlreadyUsed,
+	Common::DumpFile &output) {
+		const byte numberOfExamplesPerType = 8;
+
+		if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
+			output.writeString(line);
+			output.writeByte('\n');
+			(*count)[key]++;
+			(*fileAlreadyUsed)[key] = true;
+		}
+}
+
+/**
+ * Searches through all the .scr files and dumps 'numberOfExamplesPerType' examples of each type of ResultAction
+ * ZVision::initialize() must have been called before this function can be used.
+ *
+ * @param destFile    Where to write the examples
+ */
+void dumpEveryResultAction(const Common::String &destFile) {
+	
+
+	Common::HashMap<Common::String, byte> count;
+	Common::HashMap<Common::String, bool> fileAlreadyUsed;
+
+	Common::DumpFile output;
+	output.open(destFile);
+
+	// Find scr files
+	Common::ArchiveMemberList list;
+	SearchMan.listMatchingMembers(list, "*.scr");
+
+	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+		Common::SeekableReadStream *stream = (*iter)->createReadStream();
+
+		Common::String line = stream->readLine();
+		trimCommentsAndWhiteSpace(&line);
+
+		while (!stream->eos()) {
+			if (line.matchString("*:add*", true)) {
+				tryToDumpLine("add", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animplay*", true)) {
+				tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animpreload*", true)) {
+				tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animunload*", true)) {
+				tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:attenuate*", true)) {
+				tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:assign*", true)) {
+				tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:change_location*", true)) {
+				tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) {
+				tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:debug*", true)) {
+				tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:delay_render*", true)) {
+				tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:disable_control*", true)) {
+				tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:disable_venus*", true)) {
+				tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:display_message*", true)) {
+				tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:dissolve*", true)) {
+				tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:distort*", true)) {
+				tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:enable_control*", true)) {
+				tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:flush_mouse_events*", true)) {
+				tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:inventory*", true)) {
+				tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:kill*", true)) {
+				tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:menu_bar_enable*", true)) {
+				tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:music*", true)) {
+				tryToDumpLine("music", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:pan_track*", true)) {
+				tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:playpreload*", true)) {
+				tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:preferences*", true)) {
+				tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:quit*", true)) {
+				tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:random*", true)) {
+				tryToDumpLine("random", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:region*", true)) {
+				tryToDumpLine("region", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:restore_game*", true)) {
+				tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:rotate_to*", true)) {
+				tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:save_game*", true)) {
+				tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_partial_screen*", true)) {
+				tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_screen*", true)) {
+				tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_venus*", true)) {
+				tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:stop*", true)) {
+				tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:streamvideo*", true)) {
+				tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:syncsound*", true)) {
+				tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:timer*", true)) {
+				tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:ttytext*", true)) {
+				tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:universe_music*", true)) {
+				tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output);
+			}
+
+			line = stream->readLine();
+			trimCommentsAndWhiteSpace(&line);
+		}
+
+		for (Common::HashMap<Common::String, bool>::iterator iter = fileAlreadyUsed.begin(); iter != fileAlreadyUsed.end(); ++iter) {
+			(*iter)._value = false;
+		}
+	}
+
+	output.close();
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 5e83c47..6fb94f8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -37,7 +37,7 @@
 
 #include "graphics/decoders/tga.h"
 
-#include "zvision/tests.h"
+#include "zvision/utility.h"
 
 namespace ZVision {
  
@@ -106,7 +106,8 @@ void ZVision::initialize() {
 Common::Error ZVision::run() {
 	initialize();
 
-	tests();
+	dumpEveryResultAction("resultActions.txt");
+	debug("dump finished");
 
 	// Main loop
 	uint32 currentTime = _system->getMillis();


Commit: a77ae2163b460c081f969d764bcdb6ad001396a5
    https://github.com/scummvm/scummvm/commit/a77ae2163b460c081f969d764bcdb6ad001396a5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:00-07:00

Commit Message:
ZVISION: Add definitions for more ResultActions

Changed paths:
    engines/zvision/result_action.cpp
    engines/zvision/result_action.h



diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
index 4721c5b..c61fcca 100644
--- a/engines/zvision/result_action.cpp
+++ b/engines/zvision/result_action.cpp
@@ -27,6 +27,7 @@
 
 namespace ZVision {
 
+//////////////////////////////////////////////////////////////////////////////
 // ActionAdd
 //////////////////////////////////////////////////////////////////////////////
 
@@ -40,6 +41,7 @@ bool ActionAdd::execute(ZVision *zVision) {
 }
 
 
+//////////////////////////////////////////////////////////////////////////////
 // ActionAssign
 //////////////////////////////////////////////////////////////////////////////
 
@@ -53,6 +55,83 @@ bool ActionAssign::execute(ZVision *zVision) {
 }
 
 
+//////////////////////////////////////////////////////////////////////////////
+// ActionAttenuate
+//////////////////////////////////////////////////////////////////////////////
+
+ActionAttenuate::ActionAttenuate(Common::String line) {
+	sscanf(line.c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
+}
+
+bool ActionAttenuate::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionChangeLocation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionChangeLocation::ActionChangeLocation(Common::String line) {
+	sscanf(line.c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
+}
+
+bool ActionChangeLocation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionCrossfade
+//////////////////////////////////////////////////////////////////////////////
+
+ActionCrossfade::ActionCrossfade(Common::String line) {
+	sscanf(line.c_str(), 
+           ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
+           &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+}
+
+bool ActionCrossfade::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionPreloadAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPreloadAnimation::ActionPreloadAnimation(Common::String line) {
+	// The two %*hhu are always 0 and dont seem to have a use
+	sscanf(line.c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
+}
+
+bool ActionPreloadAnimation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionPlayAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPlayAnimation::ActionPlayAnimation(Common::String line) {
+	// The two %*hhu are always 0 and dont seem to have a use
+	sscanf(line.c_str(), 
+           ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
+           &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
+}
+
+bool ActionPlayAnimation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
 // ActionRandom
 //////////////////////////////////////////////////////////////////////////////
 
@@ -66,4 +145,18 @@ bool ActionRandom::execute(ZVision *zVision) {
 	return true;
 }
 
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionTimer
+//////////////////////////////////////////////////////////////////////////////
+
+ActionTimer::ActionTimer(Common::String line) {
+	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
+}
+
+bool ActionTimer::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h
index fbf8e7f..a58ef68 100644
--- a/engines/zvision/result_action.h
+++ b/engines/zvision/result_action.h
@@ -40,13 +40,6 @@ public:
 
 
 // The different types of actions
-// ADD,
-// ANIM_PLAY,
-// ANIM_PRELOAD,
-// ANIM_UNLOAD,
-// ATTENUATE,
-// ASSIGN,
-// CHANGE_LOCATION,
 // CROSSFADE,
 // DEBUG,
 // DELAY_RENDER,
@@ -76,7 +69,6 @@ public:
 // STOP,
 // STREAM_VIDEO,
 // SYNC_SOUND,
-// TIMER,
 // TTY_TEXT,
 // UNIVERSE_MUSIC,
 
@@ -90,34 +82,91 @@ private:
 	byte _value;
 };
 
-class ActionPlayAnimation : public ResultAction {
+class ActionAssign : public ResultAction {
 public:
-	ActionPlayAnimation(Common::String line);
+	ActionAssign(Common::String line);
 	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
 };
 
-class ActionPreloadAnimation : public ResultAction {
+class ActionAttenuate : public ResultAction {
 public:
-	ActionPreloadAnimation(Common::String line);
+	ActionAttenuate(Common::String line);
 	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	int16 _attenuation;
 };
 
-class ActionAttenuate : public ResultAction {
+class ActionChangeLocation : public ResultAction {
 public:
-	ActionAttenuate(Common::String line);
+	ActionChangeLocation(Common::String line);
 	bool execute(ZVision *zVision);
+
+private:
+	char _world;
+	char _room;
+	char _nodeview[2];
+	int16 _x;
 };
 
-class ActionAssign : public ResultAction {
+class ActionCrossfade : public ResultAction {
 public:
-	ActionAssign(Common::String line);
+	ActionCrossfade(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _keyOne;
+	uint32 _keyTwo;
+	byte _oneStartVolume;
+	byte _twoStartVolume;
+	byte _oneEndVolume;
+	byte _twoEndVolume;
+	uint16 _timeInMillis;
+};
+
+class ActionPlayAnimation : public ResultAction {
+public:
+	ActionPlayAnimation(Common::String line);
 	bool execute(ZVision *zVision);
 
 private:
 	uint32 _key;
-	byte _value;
+	Common::String _fileName;
+	uint32 _x;
+	uint32 _y;
+	uint32 _width;
+	uint32 _height;
+	uint32 _start;
+	uint32 _end;
+	uint32 _mask;
+	byte _framerate;
+	bool _loop;
 };
 
+class ActionPreloadAnimation : public ResultAction {
+public:
+	ActionPreloadAnimation(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	Common::String _fileName;
+	uint32 _mask;
+	byte _framerate;
+};
+
+// TODO: See if this exists in ZGI. It doesn't in ZNem
+//class ActionUnloadAnimation : public ResultAction {
+//public:
+//	ActionUnloadAnimation(Common::String line);
+//	bool execute(ZVision *zVision);
+//};
+
 class ActionRandom : public ResultAction {
 public:
 	ActionRandom(Common::String line);
@@ -128,6 +177,16 @@ private:
 	uint32 _max;
 };
 
+class ActionTimer : public ResultAction {
+public:
+	ActionTimer(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	uint32 _time;
+};
+
 } // End of namespace ZVision
 
 #endif


Commit: 42092369948af8499b980b320b09911b53c10b3d
    https://github.com/scummvm/scummvm/commit/42092369948af8499b980b320b09911b53c10b3d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:01-07:00

Commit Message:
ZVISION: Create debug console and apply console logic to main loop

Changed paths:
  A engines/zvision/console.cpp
  A engines/zvision/console.h
    engines/zvision/events.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
new file mode 100644
index 0000000..a26dba9
--- /dev/null
+++ b/engines/zvision/console.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "gui/debugger.h"
+
+#include "zvision/console.h"
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+	Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
+	}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
new file mode 100644
index 0000000..c91b362
--- /dev/null
+++ b/engines/zvision/console.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#ifndef ZVISION_CONSOLE_H
+#define ZVISION_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace ZVision {
+
+	class ZVision;
+
+	class Console : public GUI::Debugger {
+	public:
+		Console(ZVision *engine);
+		virtual ~Console() {}
+
+	private:
+		ZVision *_engine;
+	};
+
+} // End of namespace ZVision
+#endif
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 8d10485..cb1ef53 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -22,7 +22,8 @@
 
 #include "common/scummsys.h"
 
-#include "zvision.h"
+#include "zvision/zvision.h"
+#include "zvision/console.h"
 #include "common/EventRecorder.h"
 
 
@@ -50,8 +51,8 @@ void ZVision::processEvents() {
 			case Common::KEYCODE_d:
 				if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
 					// Start the debugger
-					getDebugger()->attach();
-					getDebugger()->onFrame();
+					_console->attach();
+					_console->onFrame();
 				}
 				break;
 
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 6fb94f8..7a07b59 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -25,6 +25,7 @@
 #include "common/config-manager.h"
 #include "common/debug.h"
 #include "common/debug-channels.h"
+#include "common/textconsole.h"
 #include "common/error.h"
 #include "common/system.h"
 #include "common/file.h"
@@ -32,11 +33,10 @@
 #include "engines/util.h"
  
 #include "zvision/zvision.h"
+#include "zvision/console.h"
 #include "zvision/script_manager.h"
 #include "zvision/zfs_archive.h"
 
-#include "graphics/decoders/tga.h"
-
 #include "zvision/utility.h"
 
 namespace ZVision {
@@ -73,6 +73,7 @@ ZVision::~ZVision() {
 	debug("ZVision::~ZVision");
  
 	// Dispose of resources
+	delete _console;
 	delete _scriptManager;
 	delete _rnd;
  
@@ -124,9 +125,11 @@ Common::Error ZVision::run() {
 		updateScripts();
 		updateAnimations(deltaTime);
 
-		if (_needsScreenUpdate)
-		{
+		
+
+		if (_needsScreenUpdate || _console->isActive()) {
 			_system->updateScreen();
+			_needsScreenUpdate = false;
 		}
 		
 		// Calculate the frame delay based off a desired frame rate
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 0053fe5..9dd3666 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -83,13 +83,6 @@ private:
 	void updateScripts();
 	void updateAnimations(uint32 detaTimeMillis);
 };
- 
-// Example console class
-class Console : public GUI::Debugger {
-public:
-	Console(ZVision *vm) {}
-	virtual ~Console(void) {}
-};
 
 } // End of namespace ZVision
  


Commit: 46865dc39414a6e8123c41faa287c03270d7a6da
    https://github.com/scummvm/scummvm/commit/46865dc39414a6e8123c41faa287c03270d7a6da
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:01-07:00

Commit Message:
ZVISION: Create renderImageToScreen method and add a console command for it

Changed paths:
  A engines/zvision/image.cpp
    engines/zvision/console.cpp
    engines/zvision/console.h
    engines/zvision/zvision.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index a26dba9..d9d4182 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -30,6 +30,17 @@
 namespace ZVision {
 
 	Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
+		DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage));
+	}
+
+	bool Console::cmdLoadImage(int argc, const char **argv) {
+		if (argc != 6) {
+			DebugPrintf("Use loadimage <fileName> <x> <y> <width> <height> to load an image to the screen");
+			return false;
+		}
+		_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
+
+		return true;
 	}
 
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index c91b362..c341b8d 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -36,6 +36,8 @@ namespace ZVision {
 
 	private:
 		ZVision *_engine;
+
+		bool cmdLoadImage(int argc, const char **argv);
 	};
 
 } // End of namespace ZVision
diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
new file mode 100644
index 0000000..95fed0c
--- /dev/null
+++ b/engines/zvision/image.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/decoders/tga.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y, uint32 width, uint32 height) {
+	Common::File file;
+
+	if (file.open(fileName)) {
+		Graphics::TGADecoder tga;
+		if (!tga.loadStream(file))
+			error("Error while reading TGA image");
+		file.close();
+
+		const Graphics::Surface *tgaSurface = tga.getSurface();
+
+		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, width, height);
+
+		tga.destroy();
+
+		_needsScreenUpdate = true;
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 9dd3666..7ff03ca 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -71,6 +71,7 @@ public:
 	virtual Common::Error run();
 	ScriptManager *getScriptManager() const;
 	Common::RandomSource *getRandomSource() const;
+	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y, uint32 width, uint32 height);
 
 private:
 	void initialize();


Commit: 540dde67db3dcf00f336ea772c0c51701675ece8
    https://github.com/scummvm/scummvm/commit/540dde67db3dcf00f336ea772c0c51701675ece8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:02-07:00

Commit Message:
ZVISION: Cleanup dump method from run()

Changed paths:
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 7a07b59..4653b30 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -107,9 +107,6 @@ void ZVision::initialize() {
 Common::Error ZVision::run() {
 	initialize();
 
-	dumpEveryResultAction("resultActions.txt");
-	debug("dump finished");
-
 	// Main loop
 	uint32 currentTime = _system->getMillis();
 	uint32 lastTime = currentTime;
@@ -125,8 +122,6 @@ Common::Error ZVision::run() {
 		updateScripts();
 		updateAnimations(deltaTime);
 
-		
-
 		if (_needsScreenUpdate || _console->isActive()) {
 			_system->updateScreen();
 			_needsScreenUpdate = false;


Commit: c882f796950c4ada93b5ea85c69b62f2613b0aea
    https://github.com/scummvm/scummvm/commit/c882f796950c4ada93b5ea85c69b62f2613b0aea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-04T11:32:02-07:00

Commit Message:
ZVISION: Remove direct inclusion of stdio.h

Changed paths:
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 285e635..a0ecf6b 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -22,8 +22,6 @@
 
 #include "common/scummsys.h"
 
-#include <stdio.h>
-
 #include "zvision/script_manager.h"
 #include "zvision/utility.h"
 #include "zvision/puzzle.h"


Commit: 258ecb0aebc21d84c2e81b9b82e9c49a24e6d41b
    https://github.com/scummvm/scummvm/commit/258ecb0aebc21d84c2e81b9b82e9c49a24e6d41b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-04T11:32:03-07:00

Commit Message:
ZVISION: Remove nonstandard C type declaration from the StateFlags enum

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index fd9c61e..d3b7536 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -52,7 +52,7 @@ struct Criteria {
 	bool isArgumentAnId;
 };
 
-enum StateFlags : byte {
+enum StateFlags {
 	ONCE_PER_INST = 0x01,
 	DO_ME_NOW = 0x02,
 	DISABLED = 0x04


Commit: a8e5e1e2dbd8a3fcf438966383172866a90b835e
    https://github.com/scummvm/scummvm/commit/a8e5e1e2dbd8a3fcf438966383172866a90b835e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:03-07:00

Commit Message:
ZVISION: Rename result_action.h/.cpp files to actions.h/.cpp

Changed paths:
  A engines/zvision/actions.cpp
  A engines/zvision/actions.h
  R engines/zvision/result_action.cpp
  R engines/zvision/result_action.h
    engines/zvision/puzzle.h
    engines/zvision/script_manager.h



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
new file mode 100644
index 0000000..23f7f16
--- /dev/null
+++ b/engines/zvision/actions.cpp
@@ -0,0 +1,162 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/actions.h"
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionAdd
+//////////////////////////////////////////////////////////////////////////////
+
+ActionAdd::ActionAdd(Common::String line) {
+	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
+}
+
+bool ActionAdd::execute(ZVision *zVision) {
+	zVision->getScriptManager()->addToStateValue(_key, _value);
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionAssign
+//////////////////////////////////////////////////////////////////////////////
+
+ActionAssign::ActionAssign(Common::String line) {
+	sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value);
+}
+
+bool ActionAssign::execute(ZVision *zVision) {
+	zVision->getScriptManager()->setStateValue(_key, _value);
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionAttenuate
+//////////////////////////////////////////////////////////////////////////////
+
+ActionAttenuate::ActionAttenuate(Common::String line) {
+	sscanf(line.c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
+}
+
+bool ActionAttenuate::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionChangeLocation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionChangeLocation::ActionChangeLocation(Common::String line) {
+	sscanf(line.c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
+}
+
+bool ActionChangeLocation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionCrossfade
+//////////////////////////////////////////////////////////////////////////////
+
+ActionCrossfade::ActionCrossfade(Common::String line) {
+	sscanf(line.c_str(), 
+           ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
+           &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+}
+
+bool ActionCrossfade::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionPreloadAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPreloadAnimation::ActionPreloadAnimation(Common::String line) {
+	// The two %*hhu are always 0 and dont seem to have a use
+	sscanf(line.c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
+}
+
+bool ActionPreloadAnimation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionPlayAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPlayAnimation::ActionPlayAnimation(Common::String line) {
+	// The two %*hhu are always 0 and dont seem to have a use
+	sscanf(line.c_str(), 
+           ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
+           &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
+}
+
+bool ActionPlayAnimation::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionRandom
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRandom::ActionRandom(Common::String line) {
+	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
+}
+
+bool ActionRandom::execute(ZVision *zVision) {
+	uint32 randNumber = zVision->getRandomSource()->getRandomNumber(_max);
+	zVision->getScriptManager()->setStateValue(_key, randNumber);
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionTimer
+//////////////////////////////////////////////////////////////////////////////
+
+ActionTimer::ActionTimer(Common::String line) {
+	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
+}
+
+bool ActionTimer::execute(ZVision *zVision) {
+	// TODO: Implement
+	return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
new file mode 100644
index 0000000..a58ef68
--- /dev/null
+++ b/engines/zvision/actions.h
@@ -0,0 +1,192 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_RESULT_ACTION_H
+#define ZVISION_RESULT_ACTION_H
+
+#include "common/scummsys.h"
+
+#include "common/str.h"
+
+namespace ZVision {
+
+// Forward declaration of ZVision. This file is included before ZVision is declared
+class ZVision;
+
+class ResultAction {
+public:
+	virtual ~ResultAction() {}
+	virtual bool execute(ZVision *zVision) = 0;
+};
+
+
+// The different types of actions
+// CROSSFADE,
+// DEBUG,
+// DELAY_RENDER,
+// DISABLE_CONTROL,
+// DISABLE_VENUS,
+// DISPLAY_MESSAGE,
+// DISSOLVE,
+// DISTORT,
+// ENABLE_CONTROL,
+// FLUSH_MOUSE_EVENTS,
+// INVENTORY,
+// KILL,
+// MENU_BAR_ENABLE,
+// MUSIC,
+// PAN_TRACK,
+// PLAY_PRELOAD,
+// PREFERENCES,
+// QUIT,
+// RANDOM,
+// REGION,
+// RESTORE_GAME,
+// ROTATE_TO,
+// SAVE_GAME,
+// SET_PARTIAL_SCREEN,
+// SET_SCREEN,
+// SET_VENUS,
+// STOP,
+// STREAM_VIDEO,
+// SYNC_SOUND,
+// TTY_TEXT,
+// UNIVERSE_MUSIC,
+
+class ActionAdd : public ResultAction {
+public:
+	ActionAdd(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
+};
+
+class ActionAssign : public ResultAction {
+public:
+	ActionAssign(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	byte _value;
+};
+
+class ActionAttenuate : public ResultAction {
+public:
+	ActionAttenuate(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	int16 _attenuation;
+};
+
+class ActionChangeLocation : public ResultAction {
+public:
+	ActionChangeLocation(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	char _world;
+	char _room;
+	char _nodeview[2];
+	int16 _x;
+};
+
+class ActionCrossfade : public ResultAction {
+public:
+	ActionCrossfade(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _keyOne;
+	uint32 _keyTwo;
+	byte _oneStartVolume;
+	byte _twoStartVolume;
+	byte _oneEndVolume;
+	byte _twoEndVolume;
+	uint16 _timeInMillis;
+};
+
+class ActionPlayAnimation : public ResultAction {
+public:
+	ActionPlayAnimation(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	Common::String _fileName;
+	uint32 _x;
+	uint32 _y;
+	uint32 _width;
+	uint32 _height;
+	uint32 _start;
+	uint32 _end;
+	uint32 _mask;
+	byte _framerate;
+	bool _loop;
+};
+
+class ActionPreloadAnimation : public ResultAction {
+public:
+	ActionPreloadAnimation(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	Common::String _fileName;
+	uint32 _mask;
+	byte _framerate;
+};
+
+// TODO: See if this exists in ZGI. It doesn't in ZNem
+//class ActionUnloadAnimation : public ResultAction {
+//public:
+//	ActionUnloadAnimation(Common::String line);
+//	bool execute(ZVision *zVision);
+//};
+
+class ActionRandom : public ResultAction {
+public:
+	ActionRandom(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	uint32 _max;
+};
+
+class ActionTimer : public ResultAction {
+public:
+	ActionTimer(Common::String line);
+	bool execute(ZVision *zVision);
+
+private:
+	uint32 _key;
+	uint32 _time;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index d3b7536..9dab606 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -25,7 +25,7 @@
 
 #include "common/list.h"
 
-#include "zvision/result_action.h"
+#include "zvision/actions.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp
deleted file mode 100644
index c61fcca..0000000
--- a/engines/zvision/result_action.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/result_action.h"
-#include "zvision/zvision.h"
-
-namespace ZVision {
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionAdd
-//////////////////////////////////////////////////////////////////////////////
-
-ActionAdd::ActionAdd(Common::String line) {
-	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
-}
-
-bool ActionAdd::execute(ZVision *zVision) {
-	zVision->getScriptManager()->addToStateValue(_key, _value);
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionAssign
-//////////////////////////////////////////////////////////////////////////////
-
-ActionAssign::ActionAssign(Common::String line) {
-	sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value);
-}
-
-bool ActionAssign::execute(ZVision *zVision) {
-	zVision->getScriptManager()->setStateValue(_key, _value);
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionAttenuate
-//////////////////////////////////////////////////////////////////////////////
-
-ActionAttenuate::ActionAttenuate(Common::String line) {
-	sscanf(line.c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
-}
-
-bool ActionAttenuate::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionChangeLocation
-//////////////////////////////////////////////////////////////////////////////
-
-ActionChangeLocation::ActionChangeLocation(Common::String line) {
-	sscanf(line.c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
-}
-
-bool ActionChangeLocation::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionCrossfade
-//////////////////////////////////////////////////////////////////////////////
-
-ActionCrossfade::ActionCrossfade(Common::String line) {
-	sscanf(line.c_str(), 
-           ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
-           &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
-}
-
-bool ActionCrossfade::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionPreloadAnimation
-//////////////////////////////////////////////////////////////////////////////
-
-ActionPreloadAnimation::ActionPreloadAnimation(Common::String line) {
-	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line.c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
-}
-
-bool ActionPreloadAnimation::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionPlayAnimation
-//////////////////////////////////////////////////////////////////////////////
-
-ActionPlayAnimation::ActionPlayAnimation(Common::String line) {
-	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line.c_str(), 
-           ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
-           &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
-}
-
-bool ActionPlayAnimation::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionRandom
-//////////////////////////////////////////////////////////////////////////////
-
-ActionRandom::ActionRandom(Common::String line) {
-	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
-}
-
-bool ActionRandom::execute(ZVision *zVision) {
-	uint32 randNumber = zVision->getRandomSource()->getRandomNumber(_max);
-	zVision->getScriptManager()->setStateValue(_key, randNumber);
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// ActionTimer
-//////////////////////////////////////////////////////////////////////////////
-
-ActionTimer::ActionTimer(Common::String line) {
-	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
-}
-
-bool ActionTimer::execute(ZVision *zVision) {
-	// TODO: Implement
-	return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h
deleted file mode 100644
index a58ef68..0000000
--- a/engines/zvision/result_action.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_RESULT_ACTION_H
-#define ZVISION_RESULT_ACTION_H
-
-#include "common/scummsys.h"
-
-#include "common/str.h"
-
-namespace ZVision {
-
-// Forward declaration of ZVision. This file is included before ZVision is declared
-class ZVision;
-
-class ResultAction {
-public:
-	virtual ~ResultAction() {}
-	virtual bool execute(ZVision *zVision) = 0;
-};
-
-
-// The different types of actions
-// CROSSFADE,
-// DEBUG,
-// DELAY_RENDER,
-// DISABLE_CONTROL,
-// DISABLE_VENUS,
-// DISPLAY_MESSAGE,
-// DISSOLVE,
-// DISTORT,
-// ENABLE_CONTROL,
-// FLUSH_MOUSE_EVENTS,
-// INVENTORY,
-// KILL,
-// MENU_BAR_ENABLE,
-// MUSIC,
-// PAN_TRACK,
-// PLAY_PRELOAD,
-// PREFERENCES,
-// QUIT,
-// RANDOM,
-// REGION,
-// RESTORE_GAME,
-// ROTATE_TO,
-// SAVE_GAME,
-// SET_PARTIAL_SCREEN,
-// SET_SCREEN,
-// SET_VENUS,
-// STOP,
-// STREAM_VIDEO,
-// SYNC_SOUND,
-// TTY_TEXT,
-// UNIVERSE_MUSIC,
-
-class ActionAdd : public ResultAction {
-public:
-	ActionAdd(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	byte _value;
-};
-
-class ActionAssign : public ResultAction {
-public:
-	ActionAssign(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	byte _value;
-};
-
-class ActionAttenuate : public ResultAction {
-public:
-	ActionAttenuate(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	int16 _attenuation;
-};
-
-class ActionChangeLocation : public ResultAction {
-public:
-	ActionChangeLocation(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	char _world;
-	char _room;
-	char _nodeview[2];
-	int16 _x;
-};
-
-class ActionCrossfade : public ResultAction {
-public:
-	ActionCrossfade(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _keyOne;
-	uint32 _keyTwo;
-	byte _oneStartVolume;
-	byte _twoStartVolume;
-	byte _oneEndVolume;
-	byte _twoEndVolume;
-	uint16 _timeInMillis;
-};
-
-class ActionPlayAnimation : public ResultAction {
-public:
-	ActionPlayAnimation(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	Common::String _fileName;
-	uint32 _x;
-	uint32 _y;
-	uint32 _width;
-	uint32 _height;
-	uint32 _start;
-	uint32 _end;
-	uint32 _mask;
-	byte _framerate;
-	bool _loop;
-};
-
-class ActionPreloadAnimation : public ResultAction {
-public:
-	ActionPreloadAnimation(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	Common::String _fileName;
-	uint32 _mask;
-	byte _framerate;
-};
-
-// TODO: See if this exists in ZGI. It doesn't in ZNem
-//class ActionUnloadAnimation : public ResultAction {
-//public:
-//	ActionUnloadAnimation(Common::String line);
-//	bool execute(ZVision *zVision);
-//};
-
-class ActionRandom : public ResultAction {
-public:
-	ActionRandom(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	uint32 _max;
-};
-
-class ActionTimer : public ResultAction {
-public:
-	ActionTimer(Common::String line);
-	bool execute(ZVision *zVision);
-
-private:
-	uint32 _key;
-	uint32 _time;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 173705e..f02073b 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -29,7 +29,7 @@
 
 #include "zvision/puzzle.h"
 #include "zvision/control.h"
-#include "zvision/result_action.h"
+#include "zvision/actions.h"
 
 namespace ZVision {
 


Commit: fa365dffce5036a6f82e8a4df212a9a424f522bd
    https://github.com/scummvm/scummvm/commit/fa365dffce5036a6f82e8a4df212a9a424f522bd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:04-07:00

Commit Message:
ZVISION: Change #include scummsys.h to types.h

Changed paths:
    engines/zvision/control.h



diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index df01544..1f59478 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -23,7 +23,7 @@
 #ifndef ZVISION_CONTROL_H
 #define ZVISION_CONTROL_H
 
-#include "common/scummsys.h"
+#include "common/types.h"
 
 namespace ZVision {
 


Commit: 89693d4074091bfb998fc6fbdbfe585f53a6ad13
    https://github.com/scummvm/scummvm/commit/89693d4074091bfb998fc6fbdbfe585f53a6ad13
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:04-07:00

Commit Message:
ZVISION: Create class for decompressing and reading LZSS

Changed paths:
  A engines/zvision/lzss_read_stream.cpp
  A engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
new file mode 100644
index 0000000..69b49c5
--- /dev/null
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/lzss_read_stream.h"
+
+namespace ZVision {
+
+LzssReadStream::LzssReadStream(Common::SeekableReadStream *source, bool stream, uint32 decompressedSize)
+		: _source(source),
+		  // It's convention to set the starting cursor position to blockSize - 16
+		  _windowCursor(0x0FEE),
+		  _readCursor(0) {
+	// Clear the window to null
+	memset(_window, 0, blockSize);
+
+	// Reserve space in the destination buffer
+	// TODO: Make a better guess
+	if (decompressedSize == npos) {
+		decompressedSize = source->size();
+	}
+	_destination.reserve(decompressedSize);
+
+	if (stream)
+		decompressBytes(blockSize);
+	else
+		decompressAll();
+}
+
+void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
+	uint32 bytesRead = 0;
+
+	while (!_source->eos() && bytesRead <= numberOfBytes) {
+		byte flagbyte = _source->readByte();
+		byte mask = 1;
+
+		for (uint32 i = 0; i < 8; i++) {
+			if (!_source->eos()) {
+				if ((flagbyte & mask) == mask)
+				{
+					byte data = _source->readByte();
+					bytesRead++;
+					if (_source->eos())
+						break;
+
+					_window[_windowCursor] = data;
+					_destination.push_back(data);
+
+					// Increment and wrap the window cursor
+					_windowCursor = (_windowCursor + 1) & 0xFFF;
+				}
+				else
+				{
+					byte low = _source->readByte();
+					bytesRead++;
+					if (_source->eos())
+						break;
+
+					byte high = _source->readByte();
+					bytesRead++;
+					if (_source->eos())
+						break;
+
+					uint16 length = (high & 0xF) + 2;
+					uint16 offset = low | ((high & 0xF0)<<4);
+
+					for(byte j = 0; j <= length; j++)
+					{
+						byte temp = _window[(offset + j) & 0xFFF];
+						_window[_windowCursor] = temp;
+						_destination.push_back(temp);
+						_windowCursor = (_windowCursor + 1) & 0xFFF;
+					}
+				};
+
+				mask = mask << 1;
+			}
+		}
+	}
+}
+
+void LzssReadStream::decompressAll() {
+	decompressBytes(_source->size());
+}
+
+bool LzssReadStream::eos() const {
+	// Make sure that we've read all of the source
+	return _readCursor >= _destination.size() && _source->eos();
+}
+
+uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) {
+	// Check if there are enough bytes available
+	// If not, keep decompressing until we have enough bytes or until we reach EOS
+	while (dataSize > _destination.size() - _readCursor) {
+		// Check if we can read any more data from source
+		if (_source->eos()) {
+			dataSize = _destination.size() - _readCursor;
+			break;
+		}
+
+		decompressBytes(blockSize);
+	}
+
+	memcpy(dataPtr, _destination.begin() + _readCursor, dataSize);
+	_readCursor += dataSize;
+
+	return dataSize;
+}
+
+uint32 LzssReadStream::currentSize() const {
+	return _destination.size();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
new file mode 100644
index 0000000..7e6511a
--- /dev/null
+++ b/engines/zvision/lzss_read_stream.h
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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 ZVISION_LZSS_STREAM_H
+#define ZVISION_LZSS_STREAM_H
+
+#include "common/types.h"
+#include "common/stream.h"
+#include "common/memstream.h"
+#include "common/array.h"
+
+namespace ZVision {
+
+class LzssReadStream : public Common::ReadStream {
+public:
+	/**
+	 * A class that decompresses LZSS data and implements ReadStream for easy access 
+	 * to the decompiled data. It can either decompress all the data in the beginning 
+	 * or decompress as needed by read().
+	 *
+	 * @param source              The source data
+	 * @param stream			  Decompress the data as needed (true) or all at once (false)
+	 * @param decompressedSize    The size of the decompressed data. If npos, the class will choose a size and grow as needed
+	 */
+	LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = npos);
+
+public:
+	static const uint32 npos = 0xFFFFFFFFu;
+	static const uint16 blockSize = 0x1000u;
+
+private:
+	Common::SeekableReadStream *_source;
+	Common::Array<char> _destination;
+	char _window[blockSize];
+	uint16 _windowCursor;
+	uint32 _readCursor;
+
+public:
+	bool eos() const;
+	uint32 read(void *dataPtr, uint32 dataSize);
+	uint32 currentSize() const;
+
+private:
+	/**
+	 * Decompress the next <numberOfBytes> from the source stream. Or until EOS
+	 *
+	 * @param numberOfBytes    How many bytes to decompress. This is a count of source bytes, not destination bytes
+	 */
+	void decompressBytes(uint32 numberOfBytes);
+	/** Decompress all of the source stream. */
+	void decompressAll();
+};
+
+}
+
+#endif


Commit: 399e512be232746f956b6be52b8387b52114d35b
    https://github.com/scummvm/scummvm/commit/399e512be232746f956b6be52b8387b52114d35b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:05-07:00

Commit Message:
ZVISION: Update renderImageToScreen to handle TGZ image files

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/image.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index d9d4182..3af6740 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -34,11 +34,11 @@ namespace ZVision {
 	}
 
 	bool Console::cmdLoadImage(int argc, const char **argv) {
-		if (argc != 6) {
-			DebugPrintf("Use loadimage <fileName> <x> <y> <width> <height> to load an image to the screen");
+		if (argc != 4) {
+			DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen");
 			return false;
 		}
-		_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
+		_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
 
 		return true;
 	}
diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index 95fed0c..1463401 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -28,25 +28,55 @@
 #include "graphics/decoders/tga.h"
 
 #include "zvision/zvision.h"
+#include "zvision/lzss_read_stream.h"
 
 namespace ZVision {
 
-void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y, uint32 width, uint32 height) {
+void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
 	Common::File file;
 
 	if (file.open(fileName)) {
-		Graphics::TGADecoder tga;
-		if (!tga.loadStream(file))
-			error("Error while reading TGA image");
-		file.close();
+		// Read the magic number
+		// Some files are true TGA, while others are TGZ
+		char fileType[4];
+		file.read(fileType, 4);
 
-		const Graphics::Surface *tgaSurface = tga.getSurface();
+		// Check for true TGA files
+		if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'A' && fileType[3] == '\0') {
+			// Reset the cursor
+			file.seek(0);
 
-		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, width, height);
+			// Decode
+			Graphics::TGADecoder tga;
+			if (!tga.loadStream(file))
+				error("Error while reading TGA image");
+			file.close();
 
-		tga.destroy();
+			const Graphics::Surface *tgaSurface = tga.getSurface();
+
+			_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
+
+			tga.destroy();
+		} else {
+			// TGZ files have a header and then Bitmap data that is compressed with LZSS
+			uint32 decompressedSize = file.readSint32LE();
+			uint32 width = file.readSint32LE();
+			uint32 height = file.readSint32LE();
+
+			LzssReadStream stream(&file, false, decompressedSize);
+			byte *buffer = new byte[stream.currentSize()];
+			stream.read(buffer, stream.currentSize());
+
+			//Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0);
+			// Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0);
+
+			_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
+		}
+		
 
 		_needsScreenUpdate = true;
+	} else {
+		error("Could not open file %s", fileName.c_str());
 	}
 }
 
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 7ff03ca..31c65a8 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -71,7 +71,7 @@ public:
 	virtual Common::Error run();
 	ScriptManager *getScriptManager() const;
 	Common::RandomSource *getRandomSource() const;
-	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y, uint32 width, uint32 height);
+	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
 
 private:
 	void initialize();


Commit: ca89f7679881aeb2ce056592f5d38531db2465fd
    https://github.com/scummvm/scummvm/commit/ca89f7679881aeb2ce056592f5d38531db2465fd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:05-07:00

Commit Message:
ZVISION: Move early break out above the for loop. LzssReadStream::decompressBytes()

The other code would go through each of the for loops and do nothing due to EOS.

Changed paths:
    engines/zvision/lzss_read_stream.cpp



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 69b49c5..61b5b16 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -52,49 +52,49 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
 
 	while (!_source->eos() && bytesRead <= numberOfBytes) {
 		byte flagbyte = _source->readByte();
+		if (_source->eos())
+			break;
 		byte mask = 1;
 
 		for (uint32 i = 0; i < 8; i++) {
-			if (!_source->eos()) {
-				if ((flagbyte & mask) == mask)
+			if ((flagbyte & mask) == mask)
+			{
+				byte data = _source->readByte();
+				bytesRead++;
+				if (_source->eos())
+					break;
+
+				_window[_windowCursor] = data;
+				_destination.push_back(data);
+
+				// Increment and wrap the window cursor
+				_windowCursor = (_windowCursor + 1) & 0xFFF;
+			}
+			else
+			{
+				byte low = _source->readByte();
+				bytesRead++;
+				if (_source->eos())
+					break;
+
+				byte high = _source->readByte();
+				bytesRead++;
+				if (_source->eos())
+					break;
+
+				uint16 length = (high & 0xF) + 2;
+				uint16 offset = low | ((high & 0xF0)<<4);
+
+				for(byte j = 0; j <= length; j++)
 				{
-					byte data = _source->readByte();
-					bytesRead++;
-					if (_source->eos())
-						break;
-
-					_window[_windowCursor] = data;
-					_destination.push_back(data);
-
-					// Increment and wrap the window cursor
+					byte temp = _window[(offset + j) & 0xFFF];
+					_window[_windowCursor] = temp;
+					_destination.push_back(temp);
 					_windowCursor = (_windowCursor + 1) & 0xFFF;
 				}
-				else
-				{
-					byte low = _source->readByte();
-					bytesRead++;
-					if (_source->eos())
-						break;
-
-					byte high = _source->readByte();
-					bytesRead++;
-					if (_source->eos())
-						break;
-
-					uint16 length = (high & 0xF) + 2;
-					uint16 offset = low | ((high & 0xF0)<<4);
-
-					for(byte j = 0; j <= length; j++)
-					{
-						byte temp = _window[(offset + j) & 0xFFF];
-						_window[_windowCursor] = temp;
-						_destination.push_back(temp);
-						_windowCursor = (_windowCursor + 1) & 0xFFF;
-					}
-				};
-
-				mask = mask << 1;
-			}
+			};
+
+			mask = mask << 1;
 		}
 	}
 }


Commit: 00c028476513c5f41d5ac9941a7315163eeae307
    https://github.com/scummvm/scummvm/commit/00c028476513c5f41d5ac9941a7315163eeae307
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:05-07:00

Commit Message:
ZVISION: Conform to new eventRecorder code

Changed paths:
    engines/zvision/events.cpp
    engines/zvision/video.cpp



diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index cb1ef53..984d59e 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -24,7 +24,7 @@
 
 #include "zvision/zvision.h"
 #include "zvision/console.h"
-#include "common/EventRecorder.h"
+#include "common/events.h"
 
 
 namespace ZVision {
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 4e5fe82..8f77554 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -29,7 +29,7 @@
 #include "zvision/zork_avi_decoder.h"
 #include "zvision/zork_raw.h"
 
-#include "common/EventRecorder.h"
+#include "common/events.h"
 #include "common/file.h"
 
 namespace ZVision {


Commit: ec7915bcb9d507979fa51d76de736f10b8060255
    https://github.com/scummvm/scummvm/commit/ec7915bcb9d507979fa51d76de736f10b8060255
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:06-07:00

Commit Message:
ZVISION: Fix eos checking in LzssReadStream

Changed paths:
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 61b5b16..a7cdcd9 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -30,7 +30,8 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source, bool stream,
 		: _source(source),
 		  // It's convention to set the starting cursor position to blockSize - 16
 		  _windowCursor(0x0FEE),
-		  _readCursor(0) {
+		  _readCursor(0),
+		  _eosFlag(false) {
 	// Clear the window to null
 	memset(_window, 0, blockSize);
 
@@ -104,8 +105,7 @@ void LzssReadStream::decompressAll() {
 }
 
 bool LzssReadStream::eos() const {
-	// Make sure that we've read all of the source
-	return _readCursor >= _destination.size() && _source->eos();
+	return _eosFlag;
 }
 
 uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) {
@@ -114,15 +114,19 @@ uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) {
 	while (dataSize > _destination.size() - _readCursor) {
 		// Check if we can read any more data from source
 		if (_source->eos()) {
+			// Shorten the dataSize to what we have left and flag that we're at EOS
 			dataSize = _destination.size() - _readCursor;
+			_eosFlag = true;
 			break;
 		}
 
 		decompressBytes(blockSize);
 	}
 
-	memcpy(dataPtr, _destination.begin() + _readCursor, dataSize);
-	_readCursor += dataSize;
+	if (dataSize > 0) {
+		memcpy(dataPtr, _destination.begin() + _readCursor, dataSize);
+		_readCursor += dataSize;
+	}
 
 	return dataSize;
 }
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 7e6511a..9ef1d6d 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -53,6 +53,7 @@ private:
 	char _window[blockSize];
 	uint16 _windowCursor;
 	uint32 _readCursor;
+	bool _eosFlag;
 
 public:
 	bool eos() const;


Commit: 811ea394862a35faacd2e87c68ef57a501f67f3c
    https://github.com/scummvm/scummvm/commit/811ea394862a35faacd2e87c68ef57a501f67f3c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:06-07:00

Commit Message:
ZVISION: Update module.mk with current objs

Changed paths:
    engines/zvision/module.mk



diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 3dd17a2..3d672d9 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,8 +1,20 @@
 MODULE := engines/zvision
  
 MODULE_OBJS := \
+	actions.o \
+	console.o \
 	detection.o \
+	events.o \
+	graphics.o \
+	image.o \
+	lzss_read_stream.o \
+	scr_file_handling.o \
+	script_manager.o \
+	scripts.o \
+	single_value_container.o \
+	video.o \
 	zvision.o \
+	zfs_archive.o \
 	zork_avi_decoder.o \
 	zork_raw.o
  


Commit: 4c7db7f5de574833b360653e423d8240d7af8fa9
    https://github.com/scummvm/scummvm/commit/4c7db7f5de574833b360653e423d8240d7af8fa9
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:07-07:00

Commit Message:
ZVISION: renderImageToScreen: Check for TGZ first instead of TGA

TGA's aren't required to have a magic number in the header, but TGZ are.
Therefore it's easier to identify TGZ files.

Changed paths:
    engines/zvision/image.cpp



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index 1463401..35ec9b3 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -35,49 +35,49 @@ namespace ZVision {
 void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
 	Common::File file;
 
-	if (file.open(fileName)) {
-		// Read the magic number
-		// Some files are true TGA, while others are TGZ
-		char fileType[4];
-		file.read(fileType, 4);
-
-		// Check for true TGA files
-		if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'A' && fileType[3] == '\0') {
-			// Reset the cursor
-			file.seek(0);
-
-			// Decode
-			Graphics::TGADecoder tga;
-			if (!tga.loadStream(file))
-				error("Error while reading TGA image");
-			file.close();
-
-			const Graphics::Surface *tgaSurface = tga.getSurface();
-
-			_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
-
-			tga.destroy();
-		} else {
-			// TGZ files have a header and then Bitmap data that is compressed with LZSS
-			uint32 decompressedSize = file.readSint32LE();
-			uint32 width = file.readSint32LE();
-			uint32 height = file.readSint32LE();
-
-			LzssReadStream stream(&file, false, decompressedSize);
-			byte *buffer = new byte[stream.currentSize()];
-			stream.read(buffer, stream.currentSize());
-
-			//Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0);
-			// Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0);
-
-			_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
-		}
-		
-
-		_needsScreenUpdate = true;
-	} else {
+	if (!file.open(fileName)) {
 		error("Could not open file %s", fileName.c_str());
+		return;
 	}
+
+	// Read the magic number
+	// Some files are true TGA, while others are TGZ
+	char fileType[4];
+	file.read(fileType, 4);
+
+	// Check for TGZ files
+	if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'Z' && fileType[3] == '\0') {
+		// TGZ files have a header and then Bitmap data that is compressed with LZSS
+		uint32 decompressedSize = file.readSint32LE();
+		uint32 width = file.readSint32LE();
+		uint32 height = file.readSint32LE();
+
+		LzssReadStream stream(&file, false, decompressedSize);
+		byte *buffer = new byte[stream.currentSize()];
+		stream.read(buffer, stream.currentSize());
+
+		//Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0);
+		// Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0);
+
+		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
+	} else {
+		// Reset the cursor
+		file.seek(0);
+
+		// Decode
+		Graphics::TGADecoder tga;
+		if (!tga.loadStream(file))
+			error("Error while reading TGA image");
+		file.close();
+
+		const Graphics::Surface *tgaSurface = tga.getSurface();
+
+		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
+
+		tga.destroy();
+	}
+
+	_needsScreenUpdate = true;
 }
 
 } // End of namespace ZVision


Commit: afbcca2187c7a07e6e0853bd0befdc1e9a67dce2
    https://github.com/scummvm/scummvm/commit/afbcca2187c7a07e6e0853bd0befdc1e9a67dce2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:08-07:00

Commit Message:
ZVISION: Move engine width, height, and pixelFormat to const member variables

Changed paths:
    engines/zvision/image.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index 35ec9b3..981308f 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -56,9 +56,6 @@ void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint
 		byte *buffer = new byte[stream.currentSize()];
 		stream.read(buffer, stream.currentSize());
 
-		//Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0);
-		// Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0);
-
 		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
 	} else {
 		// Reset the cursor
@@ -71,7 +68,6 @@ void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint
 		file.close();
 
 		const Graphics::Surface *tgaSurface = tga.getSurface();
-
 		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
 
 		tga.destroy();
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 4653b30..ac810d8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -41,7 +41,13 @@
 
 namespace ZVision {
  
-ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
+		: Engine(syst),
+		  _gameDescription(gameDesc),
+		  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
+		  _currentVideo(0),
+		  _width(640),
+		  _height(480) {
 	// Put your engine in a sane state, but do nothing big yet;
 	// in particular, do not load data from files; rather, if you
 	// need to do such things, do them from run().
@@ -94,9 +100,7 @@ void ZVision::initialize() {
 		SearchMan.add(name, archive);
 	}
 
-	//Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);	// ARGB8888
-	Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);	// RGB555
-	initGraphics(640, 480, true, &format);
+	initGraphics(_width, _height, true, &_pixelFormat);
 
 	_scriptManager->initialize();
 
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 31c65a8..d18319a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -54,12 +54,14 @@ public:
 private:
 	Console *_console;
 	const ZVisionGameDescription *_gameDescription;
+	const Graphics::PixelFormat _pixelFormat;
+	const int _width;
+	const int _height;
 
 	// We need random numbers
 	Common::RandomSource *_rnd;
-
+	// Managers
 	ScriptManager *_scriptManager;
-
 	// To prevent allocation every time we process events
 	Common::Event _event;
 


Commit: 76b2aa33ca129b1c7a626f1a043e5d828e72af57
    https://github.com/scummvm/scummvm/commit/76b2aa33ca129b1c7a626f1a043e5d828e72af57
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:08-07:00

Commit Message:
ZVISION: Create/refactor methods for playing video.

The pixel format for videos is not the same as for the rest of the game.
(Game: RGB 555, Video: RGB 565)

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



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 8f77554..5e27e3a 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -21,16 +21,14 @@
  */
 
 #include "common/scummsys.h"
+
 #include "common/system.h"
+#include "engines/util.h"
 
-#include "engines/engine.h"
-#include "graphics/decoders/tga.h"
+#include "graphics/surface.h"
 
-#include "zvision/zork_avi_decoder.h"
-#include "zvision/zork_raw.h"
+#include "zvision/zvision.h"
 
-#include "common/events.h"
-#include "common/file.h"
 
 namespace ZVision {
 
@@ -73,63 +71,50 @@ void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte b
 	}
 }
 
-void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
+void ZVision::startVideo(Video::VideoDecoder *videoDecoder) {
 	if (!videoDecoder)
 		return;
 
-	videoDecoder->start();
+	_currentVideo = videoDecoder;
 
-	byte *scaleBuffer = 0;
-	byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;
-	uint16 width = videoDecoder->getWidth();
-	uint16 height = videoDecoder->getHeight();
-	uint16 pitch = videoDecoder->getWidth() * bytesPerPixel;
-	uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();
-	uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();
+	Common::List<Graphics::PixelFormat> formats;
+	formats.push_back(videoDecoder->getPixelFormat());
+	initGraphics(640, 480, true, formats);
+	_currentVideo->start();
 
-	bool zoom2x = true;
+	continueVideo();
+}
 
-	if (zoom2x) {
-		width *= 2;
-		height *= 2;
-		pitch *= 2;
-		scaleBuffer = new byte[width * height * bytesPerPixel];
+void ZVision::continueVideo() {
+	if (_currentVideo == 0) {
+		warning("No video loaded. Nothing to continue");
+		return;
 	}
 
-	uint16 x, y;
-
-	x = (screenWidth - width) / 2;
-	y = (screenHeight - height) / 2;
+	byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel;
+	uint16 width = _currentVideo->getWidth();
+	uint16 height = _currentVideo->getHeight();
+	uint16 pitch = _currentVideo->getWidth() * bytesPerPixel;
 
-	bool skipVideo = false;
+	uint16 x = (_system->getWidth() - width) / 2;
+	uint16 y = (_system->getWidth() - height) / 2;
 
-	while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
-		if (videoDecoder->needsUpdate()) {
-			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+	if (!_currentVideo->endOfVideo()) {
+		if (_currentVideo->needsUpdate()) {
+			const Graphics::Surface *frame = _currentVideo->decodeNextFrame();
 
 			if (frame) {
-				if (scaleBuffer) {
-					scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
-					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
-				} else {
-					g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);
-				}
-
-				g_system->updateScreen();
-			}
-		}
+				_system->copyRectToScreen(frame->pixels, pitch, x, y, width, height);
 
-		Common::Event event;
-		while (g_system->getEventManager()->pollEvent(event)) {
-			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
-				skipVideo = true;
+				_needsScreenUpdate = true;
+			}
 		}
-
-		g_system->delayMillis(10);
+	} else {
+		initGraphics(_width, _height, true, &_pixelFormat);
+		delete _currentVideo;
+		_currentVideo = 0;
 	}
 
-	delete[] scaleBuffer;
-	delete videoDecoder;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index ac810d8..de1730f 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -122,9 +122,13 @@ Common::Error ZVision::run() {
 		currentTime = _system->getMillis();
 		uint32 deltaTime = currentTime - lastTime;
 		lastTime = currentTime;
-		
-		updateScripts();
-		updateAnimations(deltaTime);
+
+		if (_currentVideo != 0)
+			continueVideo();
+		else {
+			updateScripts();
+			updateAnimations(deltaTime);
+		}
 
 		if (_needsScreenUpdate || _console->isActive()) {
 			_system->updateScreen();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index d18319a..ffda12a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -27,6 +27,8 @@
 #include "common/random.h"
 #include "common/events.h"
 
+#include "video/video_decoder.h"
+
 #include "engines/engine.h"
 
 #include "zvision/script_manager.h"
@@ -67,6 +69,7 @@ private:
 
 	bool _needsScreenUpdate;
 
+	Video::VideoDecoder *_currentVideo;
 public:
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;
@@ -74,6 +77,8 @@ public:
 	ScriptManager *getScriptManager() const;
 	Common::RandomSource *getRandomSource() const;
 	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
+	void startVideo(Video::VideoDecoder *videoDecoder);
+	void continueVideo();
 
 private:
 	void initialize();


Commit: 4398c04a7b20c5ccb5033d04430479c795f9dff8
    https://github.com/scummvm/scummvm/commit/4398c04a7b20c5ccb5033d04430479c795f9dff8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:09-07:00

Commit Message:
ZVISION: Create console command for loading a video

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/console.h
    engines/zvision/video.cpp



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 3af6740..3721c94 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -26,21 +26,37 @@
 
 #include "zvision/console.h"
 #include "zvision/zvision.h"
+#include "zvision/zork_avi_decoder.h"
 
 namespace ZVision {
 
-	Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
-		DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage));
+Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
+	DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage));
+	DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
+}
+
+bool Console::cmdLoadImage(int argc, const char **argv) {
+	if (argc != 4) {
+		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen");
+		return false;
 	}
+	_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+
+	return true;
+}
 
-	bool Console::cmdLoadImage(int argc, const char **argv) {
-		if (argc != 4) {
-			DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen");
-			return false;
-		}
-		_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+bool Console::cmdLoadVideo(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Use loadvideo <fileName> to load a video to the screen");
+		return false;
+	}
 
-		return true;
+	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
+	if (videoDecoder && videoDecoder->loadFile(argv[1])) {
+		_engine->startVideo(videoDecoder);
 	}
 
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index c341b8d..6603798 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -38,6 +38,7 @@ namespace ZVision {
 		ZVision *_engine;
 
 		bool cmdLoadImage(int argc, const char **argv);
+		bool cmdLoadVideo(int argc, const char **argv);
 	};
 
 } // End of namespace ZVision
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 5e27e3a..b5e9fa0 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -82,6 +82,7 @@ void ZVision::startVideo(Video::VideoDecoder *videoDecoder) {
 	initGraphics(640, 480, true, formats);
 	_currentVideo->start();
 
+	// Load the first frame
 	continueVideo();
 }
 


Commit: 0451503ecc415a7f871652040fc23e221d3e4d63
    https://github.com/scummvm/scummvm/commit/0451503ecc415a7f871652040fc23e221d3e4d63
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:09-07:00

Commit Message:
ZVISION: Remove implicit cast between integer types

Changed paths:
    engines/zvision/zfs_archive.cpp
    engines/zvision/zfs_archive.h



diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index 85933b3..fbfe3d3 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -76,7 +76,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
 		nextOffset = stream->readUint32LE();
 
 		// Read in each entry header
-		for (int i = 0; i < _header.filesPerBlock; i++) {
+		for (uint32 i = 0; i < _header.filesPerBlock; i++) {
 			ZfsEntryHeader entryHeader;
 			
 			entryHeader.name = readEntryName(stream);
@@ -145,7 +145,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
 	return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
 }
 
-void ZfsArchive::unXor(byte *buffer, int length, const byte *xorKey) const {
+void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const {
 	for (uint32 i = 0; i < length; i++)
 		buffer[i] ^= xorKey[i % 4];
 }
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
index ccdf192..cb371f2 100644
--- a/engines/zvision/zfs_archive.h
+++ b/engines/zvision/zfs_archive.h
@@ -113,7 +113,7 @@ private:
 	 * @param buffer    The data to decode
 	 * @param length    Length of buffer
 	 */
-	void unXor(byte *buffer, int length, const byte *xorKey) const;
+	void unXor(byte *buffer, uint32 length, const byte *xorKey) const;
 };
 
 } // End of namespace ZVision


Commit: 61a2fffafd708828dd6cef4dff4dc971e8541654
    https://github.com/scummvm/scummvm/commit/61a2fffafd708828dd6cef4dff4dc971e8541654
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:10-07:00

Commit Message:
ZVISION: Standardize naming conventions to fit the rest of the code base

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 23f7f16..9bdc6aa 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -35,8 +35,8 @@ ActionAdd::ActionAdd(Common::String line) {
 	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
 }
 
-bool ActionAdd::execute(ZVision *zVision) {
-	zVision->getScriptManager()->addToStateValue(_key, _value);
+bool ActionAdd::execute(ZVision *engine) {
+	engine->getScriptManager()->addToStateValue(_key, _value);
 	return true;
 }
 
@@ -49,8 +49,8 @@ ActionAssign::ActionAssign(Common::String line) {
 	sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value);
 }
 
-bool ActionAssign::execute(ZVision *zVision) {
-	zVision->getScriptManager()->setStateValue(_key, _value);
+bool ActionAssign::execute(ZVision *engine) {
+	engine->getScriptManager()->setStateValue(_key, _value);
 	return true;
 }
 
@@ -63,7 +63,7 @@ ActionAttenuate::ActionAttenuate(Common::String line) {
 	sscanf(line.c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
 }
 
-bool ActionAttenuate::execute(ZVision *zVision) {
+bool ActionAttenuate::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
 }
@@ -77,7 +77,7 @@ ActionChangeLocation::ActionChangeLocation(Common::String line) {
 	sscanf(line.c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
 }
 
-bool ActionChangeLocation::execute(ZVision *zVision) {
+bool ActionChangeLocation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
 }
@@ -93,7 +93,7 @@ ActionCrossfade::ActionCrossfade(Common::String line) {
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
-bool ActionCrossfade::execute(ZVision *zVision) {
+bool ActionCrossfade::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
 }
@@ -108,7 +108,7 @@ ActionPreloadAnimation::ActionPreloadAnimation(Common::String line) {
 	sscanf(line.c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
 }
 
-bool ActionPreloadAnimation::execute(ZVision *zVision) {
+bool ActionPreloadAnimation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
 }
@@ -125,7 +125,7 @@ ActionPlayAnimation::ActionPlayAnimation(Common::String line) {
            &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 }
 
-bool ActionPlayAnimation::execute(ZVision *zVision) {
+bool ActionPlayAnimation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
 }
@@ -139,9 +139,9 @@ ActionRandom::ActionRandom(Common::String line) {
 	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
 }
 
-bool ActionRandom::execute(ZVision *zVision) {
-	uint32 randNumber = zVision->getRandomSource()->getRandomNumber(_max);
-	zVision->getScriptManager()->setStateValue(_key, randNumber);
+bool ActionRandom::execute(ZVision *engine) {
+	uint32 randNumber = engine->getRandomSource()->getRandomNumber(_max);
+	engine->getScriptManager()->setStateValue(_key, randNumber);
 	return true;
 }
 
@@ -154,8 +154,8 @@ ActionTimer::ActionTimer(Common::String line) {
 	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
 }
 
-bool ActionTimer::execute(ZVision *zVision) {
 	// TODO: Implement
+bool ActionTimer::execute(ZVision *engine) {
 	return true;
 }
 
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index a58ef68..aed8483 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -35,7 +35,7 @@ class ZVision;
 class ResultAction {
 public:
 	virtual ~ResultAction() {}
-	virtual bool execute(ZVision *zVision) = 0;
+	virtual bool execute(ZVision *engine) = 0;
 };
 
 
@@ -75,7 +75,7 @@ public:
 class ActionAdd : public ResultAction {
 public:
 	ActionAdd(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -85,7 +85,7 @@ private:
 class ActionAssign : public ResultAction {
 public:
 	ActionAssign(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -95,7 +95,7 @@ private:
 class ActionAttenuate : public ResultAction {
 public:
 	ActionAttenuate(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -105,7 +105,7 @@ private:
 class ActionChangeLocation : public ResultAction {
 public:
 	ActionChangeLocation(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	char _world;
@@ -117,7 +117,7 @@ private:
 class ActionCrossfade : public ResultAction {
 public:
 	ActionCrossfade(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _keyOne;
@@ -132,7 +132,7 @@ private:
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -151,7 +151,7 @@ private:
 class ActionPreloadAnimation : public ResultAction {
 public:
 	ActionPreloadAnimation(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -164,13 +164,13 @@ private:
 //class ActionUnloadAnimation : public ResultAction {
 //public:
 //	ActionUnloadAnimation(Common::String line);
-//	bool execute(ZVision *zVision);
+//	bool execute(ZVision *engine);
 //};
 
 class ActionRandom : public ResultAction {
 public:
 	ActionRandom(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;
@@ -180,7 +180,7 @@ private:
 class ActionTimer : public ResultAction {
 public:
 	ActionTimer(Common::String line);
-	bool execute(ZVision *zVision);
+	bool execute(ZVision *engine);
 
 private:
 	uint32 _key;


Commit: 4e55d7ba9476cd47a3118ecdeb0d0618e6d32211
    https://github.com/scummvm/scummvm/commit/4e55d7ba9476cd47a3118ecdeb0d0618e6d32211
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:10-07:00

Commit Message:
ZVISION: Clean up includes

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 9dab606..7a2755f 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -25,10 +25,10 @@
 
 #include "common/list.h"
 
-#include "zvision/actions.h"
-
 namespace ZVision {
 
+class ResultAction;
+
 /** How criteria should be decided */
 enum CriteriaOperator {
 	EQUAL_TO,
@@ -48,8 +48,8 @@ struct Criteria {
 	uint32 argument;
 	/** How to do the comparison */
 	CriteriaOperator criteriaOperator;
-	/** Whether 'argument' is the id of a global state (true) or a pure value (false) */
-	bool isArgumentAnId;
+	/** Whether 'argument' is the key of a global state (true) or a pure value (false) */
+	bool argumentIsAKey;
 };
 
 enum StateFlags {
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index a0ecf6b..6bf7373 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -111,10 +111,10 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 		token = tokenizer.nextToken();
 		if (token.contains('[')) {
 			sscanf(token.c_str(), "[%u]", &(criteria.argument));
-			criteria.isArgumentAnId = true;
+			criteria.argumentIsAKey = true;
 		} else {
 			sscanf(token.c_str(), "%u", &(criteria.argument));
-			criteria.isArgumentAnId = false;
+			criteria.argumentIsAKey = false;
 		}
 
 		line = stream.readLine();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index ffda12a..bec8827 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -31,14 +31,13 @@
 
 #include "engines/engine.h"
 
-#include "zvision/script_manager.h"
-
 #include "gui/debugger.h"
  
 namespace ZVision {
 
 struct ZVisionGameDescription;
 class Console;
+class ScriptManager;
  
 // our engine debug channels
 enum {


Commit: 9d478206f85769e5cbe7f1eda0ec8b9ac390dbc0
    https://github.com/scummvm/scummvm/commit/9d478206f85769e5cbe7f1eda0ec8b9ac390dbc0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:11-07:00

Commit Message:
ZVISION: Move utility functions to a cpp file with declarations in a header file

Changed paths:
  A engines/zvision/utility.cpp
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
new file mode 100644
index 0000000..41b589d
--- /dev/null
+++ b/engines/zvision/utility.cpp
@@ -0,0 +1,180 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/utility.h"
+
+namespace ZVision {
+
+void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
+	Common::File f;
+	f.open(sourceFile);
+	byte* buffer = new byte[f.size()];
+	f.read(buffer, f.size());
+
+	Common::DumpFile dumpFile;
+	dumpFile.open(destFile);
+
+	dumpFile.write(buffer, f.size());
+	dumpFile.flush();
+	dumpFile.close();
+
+	delete[] buffer;
+}
+
+void trimCommentsAndWhiteSpace(Common::String *string) {
+	for (int i = string->size() - 1; i >= 0; i--) {
+		if ((*string)[i] == '#') {
+			string->erase(i);
+		}
+	}
+
+	string->trim();
+}
+
+void tryToDumpLine(const Common::String &key,
+				   Common::String &line,
+				   Common::HashMap<Common::String, byte> *count,
+				   Common::HashMap<Common::String, bool> *fileAlreadyUsed,
+				   Common::DumpFile &output) {
+	const byte numberOfExamplesPerType = 8;
+
+	if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
+		output.writeString(line);
+		output.writeByte('\n');
+		(*count)[key]++;
+		(*fileAlreadyUsed)[key] = true;
+	}
+}
+
+void dumpEveryResultAction(const Common::String &destFile) {
+	Common::HashMap<Common::String, byte> count;
+	Common::HashMap<Common::String, bool> fileAlreadyUsed;
+
+	Common::DumpFile output;
+	output.open(destFile);
+
+	// Find scr files
+	Common::ArchiveMemberList list;
+	SearchMan.listMatchingMembers(list, "*.scr");
+
+	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+		Common::SeekableReadStream *stream = (*iter)->createReadStream();
+
+		Common::String line = stream->readLine();
+		trimCommentsAndWhiteSpace(&line);
+
+		while (!stream->eos()) {
+			if (line.matchString("*:add*", true)) {
+				tryToDumpLine("add", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animplay*", true)) {
+				tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animpreload*", true)) {
+				tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:animunload*", true)) {
+				tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:attenuate*", true)) {
+				tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:assign*", true)) {
+				tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:change_location*", true)) {
+				tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) {
+				tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:debug*", true)) {
+				tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:delay_render*", true)) {
+				tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:disable_control*", true)) {
+				tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:disable_venus*", true)) {
+				tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:display_message*", true)) {
+				tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:dissolve*", true)) {
+				tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:distort*", true)) {
+				tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:enable_control*", true)) {
+				tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:flush_mouse_events*", true)) {
+				tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:inventory*", true)) {
+				tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:kill*", true)) {
+				tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:menu_bar_enable*", true)) {
+				tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:music*", true)) {
+				tryToDumpLine("music", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:pan_track*", true)) {
+				tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:playpreload*", true)) {
+				tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:preferences*", true)) {
+				tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:quit*", true)) {
+				tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:random*", true)) {
+				tryToDumpLine("random", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:region*", true)) {
+				tryToDumpLine("region", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:restore_game*", true)) {
+				tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:rotate_to*", true)) {
+				tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:save_game*", true)) {
+				tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_partial_screen*", true)) {
+				tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_screen*", true)) {
+				tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:set_venus*", true)) {
+				tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:stop*", true)) {
+				tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:streamvideo*", true)) {
+				tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:syncsound*", true)) {
+				tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:timer*", true)) {
+				tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:ttytext*", true)) {
+				tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output);
+			} else if (line.matchString("*:universe_music*", true)) {
+				tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output);
+			}
+
+			line = stream->readLine();
+			trimCommentsAndWhiteSpace(&line);
+		}
+
+		for (Common::HashMap<Common::String, bool>::iterator iter = fileAlreadyUsed.begin(); iter != fileAlreadyUsed.end(); ++iter) {
+			iter->_value = false;
+		}
+	}
+
+	output.close();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 0b2ef2b..43d28df 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -26,6 +26,7 @@
 
 #include "common/str.h"
 #include "common/file.h"
+#include "common/array.h"
 
 namespace ZVision {
 
@@ -36,21 +37,7 @@ namespace ZVision {
  * @param sourceFile    The 'file' you want the contents of
  * @param destFile      The name of the file where the content will be written to
  */
-void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
-	Common::File f;
-	f.open(sourceFile);
-	byte* buffer = new byte[f.size()];
-	f.read(buffer, f.size());
-
-	Common::DumpFile dumpFile;
-	dumpFile.open(destFile);
-
-	uint32 writtenBytes = dumpFile.write(buffer, f.size());
-	dumpFile.flush();
-	dumpFile.close();
-
-	delete[] buffer;
-}
+void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile);
 
 /**
  * Removes any line comments using '#' as a sequence start.
@@ -59,30 +46,7 @@ void writeFileContentsToFile(const Common::String &sourceFile, const Common::Str
  *
  * @param string    The string to modify. It is modified in place
  */
-void trimCommentsAndWhiteSpace(Common::String *string) {
-	for (int i = string->size() - 1; i >= 0; i--) {
-		if ((*string)[i] == '#') {
-			string->erase(i);
-		}
-	}
-
-	string->trim();
-}
-
-void tryToDumpLine(const Common::String &key,
-	Common::String &line,
-	Common::HashMap<Common::String, byte> *count,
-	Common::HashMap<Common::String, bool> *fileAlreadyUsed,
-	Common::DumpFile &output) {
-		const byte numberOfExamplesPerType = 8;
-
-		if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
-			output.writeString(line);
-			output.writeByte('\n');
-			(*count)[key]++;
-			(*fileAlreadyUsed)[key] = true;
-		}
-}
+void trimCommentsAndWhiteSpace(Common::String *string);
 
 /**
  * Searches through all the .scr files and dumps 'numberOfExamplesPerType' examples of each type of ResultAction
@@ -90,116 +54,11 @@ void tryToDumpLine(const Common::String &key,
  *
  * @param destFile    Where to write the examples
  */
-void dumpEveryResultAction(const Common::String &destFile) {
-	
-
-	Common::HashMap<Common::String, byte> count;
-	Common::HashMap<Common::String, bool> fileAlreadyUsed;
-
-	Common::DumpFile output;
-	output.open(destFile);
-
-	// Find scr files
-	Common::ArchiveMemberList list;
-	SearchMan.listMatchingMembers(list, "*.scr");
+void dumpEveryResultAction(const Common::String &destFile);
 
-	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
-		Common::SeekableReadStream *stream = (*iter)->createReadStream();
 
-		Common::String line = stream->readLine();
-		trimCommentsAndWhiteSpace(&line);
-
-		while (!stream->eos()) {
-			if (line.matchString("*:add*", true)) {
-				tryToDumpLine("add", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:animplay*", true)) {
-				tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:animpreload*", true)) {
-				tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:animunload*", true)) {
-				tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:attenuate*", true)) {
-				tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:assign*", true)) {
-				tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:change_location*", true)) {
-				tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) {
-				tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:debug*", true)) {
-				tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:delay_render*", true)) {
-				tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:disable_control*", true)) {
-				tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:disable_venus*", true)) {
-				tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:display_message*", true)) {
-				tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:dissolve*", true)) {
-				tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:distort*", true)) {
-				tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:enable_control*", true)) {
-				tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:flush_mouse_events*", true)) {
-				tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:inventory*", true)) {
-				tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:kill*", true)) {
-				tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:menu_bar_enable*", true)) {
-				tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:music*", true)) {
-				tryToDumpLine("music", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:pan_track*", true)) {
-				tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:playpreload*", true)) {
-				tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:preferences*", true)) {
-				tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:quit*", true)) {
-				tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:random*", true)) {
-				tryToDumpLine("random", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:region*", true)) {
-				tryToDumpLine("region", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:restore_game*", true)) {
-				tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:rotate_to*", true)) {
-				tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:save_game*", true)) {
-				tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:set_partial_screen*", true)) {
-				tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:set_screen*", true)) {
-				tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:set_venus*", true)) {
-				tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:stop*", true)) {
-				tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:streamvideo*", true)) {
-				tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:syncsound*", true)) {
-				tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:timer*", true)) {
-				tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:ttytext*", true)) {
-				tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output);
-			} else if (line.matchString("*:universe_music*", true)) {
-				tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output);
-			}
-
-			line = stream->readLine();
-			trimCommentsAndWhiteSpace(&line);
-		}
-
-		for (Common::HashMap<Common::String, bool>::iterator iter = fileAlreadyUsed.begin(); iter != fileAlreadyUsed.end(); ++iter) {
-			(*iter)._value = false;
 		}
 	}
-
-	output.close();
 }
 
 } // End of namespace ZVision


Commit: d672c2c44093269ce1c0bd8107346d05f4c1b225
    https://github.com/scummvm/scummvm/commit/d672c2c44093269ce1c0bd8107346d05f4c1b225
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:12-07:00

Commit Message:
ZVISION: Remove unused methods from ZVision class

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



diff --git a/engines/zvision/graphics.cpp b/engines/zvision/graphics.cpp
index 7d1201c..610960d 100644
--- a/engines/zvision/graphics.cpp
+++ b/engines/zvision/graphics.cpp
@@ -26,12 +26,4 @@
 
 namespace ZVision {
 
-void ZVision::updateScripts() {
-
-}
-
-void ZVision::updateAnimations(uint32 detaTimeMillis) {
-
-}
-
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index bec8827..7f5b8e3 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -86,9 +86,6 @@ private:
 	void onMouseDown(const Common::Point &pos);
 	void onMouseMove(const Common::Point &pos);
 	void onKeyDown(uint16 keyCode);
-
-	void updateScripts();
-	void updateAnimations(uint32 detaTimeMillis);
 };
 
 } // End of namespace ZVision


Commit: 3397edb4f55d2e3f0973f4ffea6668d8f5b4dbb4
    https://github.com/scummvm/scummvm/commit/3397edb4f55d2e3f0973f4ffea6668d8f5b4dbb4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:12-07:00

Commit Message:
ZVISION: Add ActionNode class

This class encases actions that happen over time (timer, animations, etc)
Each frame, the engine calls process() on each active ActionNode

Changed paths:
  A engines/zvision/action_node.cpp
  A engines/zvision/action_node.h



diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
new file mode 100644
index 0000000..dec52d9
--- /dev/null
+++ b/engines/zvision/action_node.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/action_node.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+
+namespace ZVision {
+
+NodeTimer::NodeTimer(uint32 key, uint32 timeInSeconds) 
+	: _key(key), _timeLeft(timeInSeconds * 1000) {}
+
+bool NodeTimer::process(ZVision *engine, uint32 deltaTimeInMillis) {
+	_timeLeft -= deltaTimeInMillis;
+
+	if (_timeLeft <= 0) {
+		engine->getScriptManager()->setStateValue(_key, 0);
+		return true;
+	}
+
+	return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
new file mode 100644
index 0000000..cd5c9f3
--- /dev/null
+++ b/engines/zvision/action_node.h
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_ACTION_NODE_H
+#define ZVISION_ACTION_NODE_H
+
+#include "common/types.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class ActionNode {
+public:
+	virtual ~ActionNode() {}
+	virtual bool process(ZVision *engine, uint32 deltaTimeInMillis);
+};
+
+class NodeTimer : public ActionNode {
+public:
+	NodeTimer(uint32 key, uint32 timeInSeconds);
+	/**
+	 * Decrement the timer by the delta time. If the timer is finished, set the status
+	 * in _globalState and let this node be deleted
+	 *
+	 * @param engine               Pointer to the ZVision instance
+	 * @param deltaTimeInMillis    Amount of time that has passed since the last frame
+	 * @return    Node should be deleted after this (true) or kept (false)
+	 */
+	bool process(ZVision *engine, uint32 deltaTimeInMillis);
+
+private:
+	uint32 _key;
+	uint32 _timeLeft;
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: ba22c838613912238196d8488a9f781f07416c77
    https://github.com/scummvm/scummvm/commit/ba22c838613912238196d8488a9f781f07416c77
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:13-07:00

Commit Message:
ZVISION: Implement ActionTimer::execute()

Changed paths:
    engines/zvision/actions.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 9bdc6aa..a5b1e95 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -24,6 +24,8 @@
 
 #include "zvision/actions.h"
 #include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/action_node.h"
 
 namespace ZVision {
 
@@ -154,8 +156,8 @@ ActionTimer::ActionTimer(Common::String line) {
 	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
 }
 
-	// TODO: Implement
 bool ActionTimer::execute(ZVision *engine) {
+	engine->getScriptManager()->addActionNode(new NodeTimer(_key, _time));
 	return true;
 }
 


Commit: 78daaeb583a371edddd67b5399cbc14201fe7ee1
    https://github.com/scummvm/scummvm/commit/78daaeb583a371edddd67b5399cbc14201fe7ee1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:13-07:00

Commit Message:
ZVISION: Create main containers in ScriptManager

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 6bf7373..2371c35 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -25,6 +25,7 @@
 #include "zvision/script_manager.h"
 #include "zvision/utility.h"
 #include "zvision/puzzle.h"
+#include "zvision/actions.h"
 
 #include "common/textconsole.h"
 #include "common/file.h"
@@ -53,14 +54,15 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 			sscanf(line.c_str(),"puzzle:%u",&(puzzle.key));
 
 			parsePuzzle(puzzle, file);
-			_puzzles.push_back(puzzle);
+			_activePuzzles.push_back(puzzle);
 		} else if (line.matchString("control:*", true)) {
 			Control control;
 			char controlType[20];
 			sscanf(line.c_str(),"control:%u %s",&(control.id), controlType);
 
 			parseControl(control, file);
-			_controls.push_back(control);
+			/** Holds the currently active puzzles */
+			_activeControls.push_back(control);
 		}
 	}
 }
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index f02073b..5be4c17 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -26,21 +26,33 @@
 #include "common/str.h"
 #include "common/stream.h"
 #include "common/hashmap.h"
+#include "common/stack.h"
 
 #include "zvision/puzzle.h"
 #include "zvision/control.h"
-#include "zvision/actions.h"
 
 namespace ZVision {
 
+class ActionNode;
+
 class ScriptManager {
 private:
-	/** Holds the global state variables. Optimize for fast random access */
+	/** 
+	 * Holds the global state variable. Do NOT directly modify this. Use the accessors and 
+	 * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a 
+	 * particular state key are checked after the key is modified.
+	 */
 	Common::HashMap<uint32, byte> _globalState;
-	/** Holds the currently active puzzles. Optimize for fast iteration */
-	Common::List<Puzzle> _puzzles;
-	/** Holds the currently active controls. Optimize for fast iteration */
-	Common::List<Control> _controls;
+	/** Holds the currently active ActionNodes */
+	Common::List<ActionNode *> _activeNodes;
+	/** References _globalState keys to Puzzles */
+	Common::HashMap<uint32, Common::Array<Puzzle *>> _referenceTable;
+	/** Holds the Puzzles that should be checked this frame */
+	Common::Stack<Puzzle *> _puzzlesToCheck;
+	/** Holds the currently active puzzles */
+	Common::List<Puzzle> _activePuzzles;
+	/** Holds the currently active controls */
+	Common::List<Control> _activeControls;
 
 public:
 	


Commit: 9c7203c4b922845d63b00236a78e48e4f55bd633
    https://github.com/scummvm/scummvm/commit/9c7203c4b922845d63b00236a78e48e4f55bd633
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:14-07:00

Commit Message:
ZVISION: Create utility method to remove duplicate entries from a Common::Array

Changed paths:
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 43d28df..e5713fc 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -56,7 +56,19 @@ void trimCommentsAndWhiteSpace(Common::String *string);
  */
 void dumpEveryResultAction(const Common::String &destFile);
 
+/**
+ * Removes all duplicate entries from container.
+ *
+ * @param container        
+ * @return                
+ */
+template<class T>
+void removeDuplicateEntries(Common::Array<T> *container) {
+	Common::sort(container->front(), container->back());
 
+	for (int i = 0; i < container->size(); i++) {
+		while (container[i] == container[i +1]) {
+			container->remove_at(i + 1);
 		}
 	}
 }


Commit: 24dc3e1793749269daa30350a5923f51d7892efd
    https://github.com/scummvm/scummvm/commit/24dc3e1793749269daa30350a5923f51d7892efd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:14-07:00

Commit Message:
ZVISION: Create ScriptManager state handling logic

Changed paths:
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 13438d4..b4ad1cc 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -22,19 +22,103 @@
 
 #include "common/scummsys.h"
 
+#include "common/algorithm.h"
+#include "common/hashmap.h"
+
 #include "zvision/script_manager.h"
+#include "zvision/actions.h"
+#include "zvision/action_node.h"
+#include "zvision/utility.h"
 
 namespace ZVision {
 
+ScriptManager::ScriptManager(ZVision *engine) : _engine(engine) {}
+
 // TODO: Actually do something in the initialize or remove it
 void ScriptManager::initialize() {
 	
 }
 
+void ScriptManager::createReferenceTable() {
+	// Iterate through each Puzzle
+	for (Common::List<Puzzle>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
+		Puzzle *puzzlePtr = &(*activePuzzleIter);
+
+		// Iterate through each Criteria and add a reference from the criteria key to the Puzzle
+		for (Common::List<Criteria>::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
+			_referenceTable[criteriaIter->key].push_back(puzzlePtr);
+
+			// If the argument is a key, add a reference to it as well
+			if (criteriaIter->argument)
+				_referenceTable[criteriaIter->argument].push_back(puzzlePtr);
+		}
+	}
+
+	// Remove duplicate entries
+	for (Common::HashMap<uint32, Common::Array<Puzzle *>>::iterator referenceTableIter; referenceTableIter != _referenceTable.end(); referenceTableIter++) {
+		removeDuplicateEntries(&(referenceTableIter->_value));
+	}
+}
+
+void ScriptManager::updateNodes(uint32 deltaTimeMillis) {
+	// If process() returns true, it means the node can be deleted
+	for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
+		if ((*iter)->process(_engine, deltaTimeMillis)) {
+			// Remove the node from _activeNodes, then delete it
+			ActionNode *node = *iter;
+			iter = _activeNodes.erase(iter);
+			delete node;
+		} else {
+			iter++;
+		}
+	}
+}
+
+void ScriptManager::checkPuzzleCriteria() {
+	while (!_puzzlesToCheck.empty()) {
+		Puzzle *puzzle = _puzzlesToCheck.pop();
+		// Check each Criteria
+		for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
+			bool criteriaMet = false;
+
+			// Get the value to compare against
+			byte argumentValue;
+			if ((*iter).argument)
+				argumentValue = getStateValue(iter->argument);
+			else
+				argumentValue = iter->argument;
+
+			// Do the comparison
+			switch ((*iter).criteriaOperator) {
+			case EQUAL_TO:
+				criteriaMet = getStateValue(iter->key) == argumentValue;
+				break;
+			case NOT_EQUAL_TO:
+				criteriaMet = getStateValue(iter->key) != argumentValue;
+				break;
+			case GREATER_THAN:
+				criteriaMet = getStateValue(iter->key) > argumentValue;
+				break;
+			case LESS_THAN:
+				criteriaMet = getStateValue(iter->key) < argumentValue;
+				break;
+			}
+
+			// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
+			if (criteriaMet) {
+				for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+					(*resultIter)->execute(_engine);
+				}
+			}
+		}
+	}
+}
+
 byte ScriptManager::getStateValue(uint32 key) {
 	return _globalState[key];
 }
 
+// TODO: Add logic to check _referenceTable and add to _puzzlesToCheck if necessary
 void ScriptManager::setStateValue(uint32 key, byte value) {
 	_globalState[key] = value;
 }
@@ -43,4 +127,8 @@ void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
 	_globalState[key] += valueToAdd;
 }
 
+void ScriptManager::addActionNode(ActionNode *node) {
+	_activeNodes.push_back(node);
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 5be4c17..42f4bba 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -33,10 +33,15 @@
 
 namespace ZVision {
 
+class ZVision;
 class ActionNode;
 
 class ScriptManager {
+public:
+	ScriptManager(ZVision *engine);
+
 private:
+	ZVision *_engine;
 	/** 
 	 * Holds the global state variable. Do NOT directly modify this. Use the accessors and 
 	 * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a 
@@ -57,11 +62,18 @@ private:
 public:
 	
 	void initialize();
+	void updateNodes(uint32 deltaTimeMillis);
+	void checkPuzzleCriteria();
+
 	byte getStateValue(uint32 key);
 	void setStateValue(uint32 key, byte value);
 	void addToStateValue(uint32 key, byte valueToAdd);
 
+	void addActionNode(ActionNode *node);
+
 private:
+	void createReferenceTable();
+
 	/**
 	 * Parses a script file into triggers and events
 	 *
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index de1730f..c126a9a 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -70,7 +70,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 	_rnd = new Common::RandomSource("zvision");
 
 	// Create managers
-	_scriptManager = new ScriptManager();
+	_scriptManager = new ScriptManager(this);
 
 	debug("ZVision::ZVision");
 }
@@ -126,8 +126,8 @@ Common::Error ZVision::run() {
 		if (_currentVideo != 0)
 			continueVideo();
 		else {
-			updateScripts();
-			updateAnimations(deltaTime);
+			_scriptManager->updateNodes(deltaTime);
+			_scriptManager->checkPuzzleCriteria();
 		}
 
 		if (_needsScreenUpdate || _console->isActive()) {


Commit: 29061acd4ebeef2686b2ee2ff9c97d6ee4f11e91
    https://github.com/scummvm/scummvm/commit/29061acd4ebeef2686b2ee2ff9c97d6ee4f11e91
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:15-07:00

Commit Message:
ZVISION: Add operator< to the Puzzle struct

ScriptManager does a unique-fication of a container of Puzzles using
a sort with some other logic. The sort uses operator<

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 7a2755f..b3831d4 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -64,6 +64,13 @@ struct Puzzle {
 	// This has to be list of pointers because ResultAction is abstract
 	Common::List<ResultAction *> resultActions;
 	byte flags;
+
+	// Used by the ScriptManager to allow unique-ification of _referenceTable
+	// The unique-ification is done by sorting, then iterating and removing duplicates
+	// The sort uses operator<
+	const bool operator<(const Puzzle &other) const {
+		return key < other.key;
+	}
 };
 
 } // End of namespace ZVision


Commit: ae84e9508e846e7cfd39652f74c0816b399409e7
    https://github.com/scummvm/scummvm/commit/ae84e9508e846e7cfd39652f74c0816b399409e7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:15-07:00

Commit Message:
ZVISION: Add 2x scaling to videos

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



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index b5e9fa0..0cca486 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -79,7 +79,10 @@ void ZVision::startVideo(Video::VideoDecoder *videoDecoder) {
 
 	Common::List<Graphics::PixelFormat> formats;
 	formats.push_back(videoDecoder->getPixelFormat());
-	initGraphics(640, 480, true, formats);
+	initGraphics(_width, _height, true, formats);
+	
+	_scaledVideoFrameBuffer = new byte[_currentVideo->getWidth() * _currentVideo->getHeight() * _currentVideo->getPixelFormat().bytesPerPixel * 4];
+
 	_currentVideo->start();
 
 	// Load the first frame
@@ -95,17 +98,18 @@ void ZVision::continueVideo() {
 	byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel;
 	uint16 width = _currentVideo->getWidth();
 	uint16 height = _currentVideo->getHeight();
-	uint16 pitch = _currentVideo->getWidth() * bytesPerPixel;
+	uint16 pitch = width * bytesPerPixel;
 
-	uint16 x = (_system->getWidth() - width) / 2;
-	uint16 y = (_system->getWidth() - height) / 2;
+	uint16 x = (_system->getWidth() - (width * 2)) / 2;
+	uint16 y = (_system->getHeight() - (height * 2)) / 2;
 
 	if (!_currentVideo->endOfVideo()) {
 		if (_currentVideo->needsUpdate()) {
 			const Graphics::Surface *frame = _currentVideo->decodeNextFrame();
 
-			if (frame) {
-				_system->copyRectToScreen(frame->pixels, pitch, x, y, width, height);
+			if (frame) {		
+				scale2x(static_cast<byte *>(frame->pixels), _scaledVideoFrameBuffer, width, height, bytesPerPixel);
+				_system->copyRectToScreen(_scaledVideoFrameBuffer, pitch * 2, x, y, width * 2, height * 2);
 
 				_needsScreenUpdate = true;
 			}
@@ -114,6 +118,8 @@ void ZVision::continueVideo() {
 		initGraphics(_width, _height, true, &_pixelFormat);
 		delete _currentVideo;
 		_currentVideo = 0;
+		delete _scaledVideoFrameBuffer;
+		_scaledVideoFrameBuffer = 0;
 	}
 
 }
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index c126a9a..475a453 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -46,6 +46,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 		  _gameDescription(gameDesc),
 		  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
 		  _currentVideo(0),
+		  _scaledVideoFrameBuffer(0),
 		  _width(640),
 		  _height(480) {
 	// Put your engine in a sane state, but do nothing big yet;
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 7f5b8e3..50394a6 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -69,6 +69,7 @@ private:
 	bool _needsScreenUpdate;
 
 	Video::VideoDecoder *_currentVideo;
+	byte *_scaledVideoFrameBuffer;
 public:
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;


Commit: 09358141de42a2ecb4ad487145dc52345814f8a1
    https://github.com/scummvm/scummvm/commit/09358141de42a2ecb4ad487145dc52345814f8a1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:16-07:00

Commit Message:
ZVISION: Allow the console to stay open when errors occur

Changed paths:
    engines/zvision/console.cpp



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 3721c94..f038af1 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -38,7 +38,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 bool Console::cmdLoadImage(int argc, const char **argv) {
 	if (argc != 4) {
 		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen");
-		return false;
+		return true;
 	}
 	_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
 
@@ -48,7 +48,7 @@ bool Console::cmdLoadImage(int argc, const char **argv) {
 bool Console::cmdLoadVideo(int argc, const char **argv) {
 	if (argc != 2) {
 		DebugPrintf("Use loadvideo <fileName> to load a video to the screen");
-		return false;
+		return true;
 	}
 
 	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();


Commit: 8d2bef2936f555cbc675248838079dfe06ff562a
    https://github.com/scummvm/scummvm/commit/8d2bef2936f555cbc675248838079dfe06ff562a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:16-07:00

Commit Message:
ZVISION: Create console command for loading sounds

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index f038af1..c3be4ba 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -23,16 +23,21 @@
 #include "common/scummsys.h"
 
 #include "gui/debugger.h"
+#include "common/file.h"
+#include "common/bufferedstream.h"
+#include "audio/mixer.h"
 
 #include "zvision/console.h"
 #include "zvision/zvision.h"
 #include "zvision/zork_avi_decoder.h"
+#include "zvision/zork_raw.h"
 
 namespace ZVision {
 
 Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage));
 	DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
+	DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -59,4 +64,23 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdLoadSound(int argc, const char **argv) {
+	if (argc != 3) {
+		DebugPrintf("Use loadsound <fileName> <rate> to load a video to the screen");
+		return true;
+	}
+
+	Common::File *file = new Common::File();
+	if (!file->open(argv[1])) {
+		DebugPrintf("File does not exist");
+		return true;
+	}
+
+	Audio::AudioStream *soundStream = makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), atoi(argv[2]), DisposeAfterUse::YES);
+	Audio::SoundHandle handle;
+	_engine->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
+
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 6603798..354051d 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -39,6 +39,7 @@ namespace ZVision {
 
 		bool cmdLoadImage(int argc, const char **argv);
 		bool cmdLoadVideo(int argc, const char **argv);
+		bool cmdLoadSound(int argc, const char **argv);
 	};
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 475a453..ba08122 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -154,4 +154,8 @@ Common::RandomSource *ZVision::getRandomSource() const {
 	return _rnd;
 }
 
+Audio::Mixer *ZVision::getMixer() const {
+	return _mixer;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 50394a6..11773a3 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -76,6 +76,8 @@ public:
 	virtual Common::Error run();
 	ScriptManager *getScriptManager() const;
 	Common::RandomSource *getRandomSource() const;
+	Audio::Mixer *getMixer() const;
+
 	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
 	void startVideo(Video::VideoDecoder *videoDecoder);
 	void continueVideo();


Commit: 535d6a2a405118ee1e94198f8231532ec2b08bad
    https://github.com/scummvm/scummvm/commit/535d6a2a405118ee1e94198f8231532ec2b08bad
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:17-07:00

Commit Message:
ZVISION: Modify RawZorkStream to use a modified ADPCM codec

Changed paths:
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index d920550..69d8edd 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -22,164 +22,113 @@
 
 #include "common/scummsys.h"
 
-#include "common/endian.h"
+#include "common/stream.h"
 #include "common/memstream.h"
-#include "common/textconsole.h"
 #include "common/util.h"
-
 #include "audio/audiostream.h"
 
 #include "engines/zvision/zork_raw.h"
 
 namespace ZVision {
 
-#pragma mark -
-#pragma mark --- RawZorkStream ---
-#pragma mark -
-
-/**
- * This is a stream, which allows for playing raw PCM data from a stream.
- */
-class RawZorkStream : public Audio::SeekableAudioStream {
-public:
-	RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
-		: _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) {
-		// Setup our buffer for readBuffer
-		_buffer = new byte[kSampleBufferLength];
-		assert(_buffer);
-
-		// Calculate the total playtime of the stream
-		_playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate);
-	}
-
-	~RawZorkStream() {
-		delete[] _buffer;
-	}
-
-	int readBuffer(int16 *buffer, const int numSamples);
-
-	bool isStereo() const  { return true; }
-	bool endOfData() const { return _endOfData; }
-
-	int getRate() const         { return _rate; }
-	Audio::Timestamp getLength() const { return _playtime; }
-
-	bool seek(const Audio::Timestamp &where);
-private:
-	const int _rate;                                           ///< Sample rate of stream
-	Audio::Timestamp _playtime;                                       ///< Calculated total play time
-	Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from
-	bool _endOfData;                                           ///< Whether the stream end has been reached
-
-	byte *_buffer;                                             ///< Buffer used in readBuffer
-	enum {
-		/**
-		 * How many samples we can buffer at once.
-		 *
-		 * TODO: Check whether this size suffices
-		 * for systems with slow disk I/O.
-		 */
-		kSampleBufferLength = 2048
-	};
-
-	/**
-	 * Fill the temporary sample buffer used in readBuffer.
-	 *
-	 * @param maxSamples Maximum samples to read.
-	 * @return actual count of samples read.
-	 */
-	int fillBuffer(int maxSamples);
-};
-
-int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
-	int samplesLeft = numSamples;
-
-	while (samplesLeft > 0) {
-		// Try to read up to "samplesLeft" samples.
-		int len = fillBuffer(samplesLeft);
-
-		// In case we were not able to read any samples
-		// we will stop reading here.
-		if (!len)
-			break;
-
-		// Adjust the samples left to read.
-		samplesLeft -= len;
-
-		// Copy the data to the caller's buffer.
-		const byte *src = _buffer;
-		while (len-- > 0) {
-			if (*src < 128)
-				*buffer++ = ((128 - *src) << 8) ^ 0x8000;
-			else
-				*buffer++ = (*src << 8) ^ 0x8000;
-			src++;
-		}
-	}
-
-	return numSamples - samplesLeft;
+const int16 RawZorkStream::stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12};
+
+const int32 RawZorkStream::amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
+                                                       0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
+                                                       0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
+                                                       0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
+                                                       0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, 
+                                                       0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292,
+                                                       0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, 
+                                                       0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0,
+                                                       0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, 
+                                                       0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
+                                                       0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
+
+RawZorkStream::RawZorkStream(uint32 rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+		: _rate(rate),
+		  _stream(stream, disposeStream),
+		  _endOfData(false) {
+	_lastSample[0] = {0, 0};
+	_lastSample[1] = {0, 0};
+
+	// Calculate the total playtime of the stream
+	_playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
 }
 
-int RawZorkStream::fillBuffer(int maxSamples) {
-	int bufferedSamples = 0;
-	byte *dst = _buffer;
-
-	// We can only read up to "kSampleBufferLength" samples
-	// so we take this into consideration, when trying to
-	// read up to maxSamples.
-	maxSamples = MIN<int>(kSampleBufferLength, maxSamples);
-
-	// We will only read up to maxSamples
-	while (maxSamples > 0 && !endOfData()) {
-		// Try to read all the sample data and update the
-		// destination pointer.
-		const int bytesRead = _stream->read(dst, maxSamples);
-		dst += bytesRead;
+int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
+	uint16 bytesRead = 0;
 
-		// Calculate how many samples we actually read.
-		const int samplesRead = bytesRead;
+	// 0: Left, 1: Right
+	byte channel = 0;
 
-		// Update all status variables
-		bufferedSamples += samplesRead;
-		maxSamples -= samplesRead;
+	while (bytesRead < numSamples) {
+		byte encodedSample = _stream->readByte();
+		bytesRead++;
 
-		// We stop stream playback, when we reached the end of the data stream.
-		// We also stop playback when an error occures.
-		if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos())
+		if (_stream->eos()) {
 			_endOfData = true;
+			return bytesRead;
+		}
+
+		uint16 index = _lastSample[channel].index;
+		uint32 lookUpSample = amplitudeLookupTable[index];
+
+		int32 sample = 0;
+
+		if (encodedSample & 0x40)
+			sample += lookUpSample;
+		if (encodedSample & 0x20)
+			sample += lookUpSample >> 1;
+		if (encodedSample & 0x10)
+			sample += lookUpSample >> 2;
+		if (encodedSample & 8)
+			sample += lookUpSample >> 3;
+		if (encodedSample & 4)
+			sample += lookUpSample >> 4;
+		if (encodedSample & 2)
+			sample += lookUpSample >> 5;
+		if (encodedSample & 1)
+			sample += lookUpSample >> 6;
+		if (encodedSample & 0x80)
+			sample = -sample;
+
+		sample += _lastSample[channel].sample;
+		sample = CLIP(sample, -32768, 32767);
+
+		buffer[bytesRead - 1] = (int16)sample;
+
+		index += stepAdjustmentTable[(encodedSample >> 4) & 7];
+		index = CLIP<uint16>(index, 0, 88);
+
+		_lastSample[channel].sample = sample;
+		_lastSample[channel].index = index;
+
+		// Increment and wrap the channel
+		channel = (channel + 1) & 1;
 	}
 
-	return bufferedSamples;
+	return bytesRead;
 }
 
-bool RawZorkStream::seek(const Audio::Timestamp &where) {
-	_endOfData = true;
-
-	if (where > _playtime)
-		return false;
-
-	const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames();
-	_stream->seek(seekSample, SEEK_SET);
-
-	// In case of an error we will not continue stream playback.
-	if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size())
-		_endOfData = false;
+bool RawZorkStream::rewind() {
+	_stream->seek(0, 0);
+	_stream->clearErr();
+	_endOfData = false;
+	_lastSample[0] = {0, 0};
+	_lastSample[1] = {0, 0};
 
 	return true;
 }
 
-#pragma mark -
-#pragma mark --- Raw stream factories ---
-#pragma mark -
-
-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
+Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                    int rate,
                                    DisposeAfterUse::Flag disposeAfterUse) {
 	assert(stream->size() % 2 == 0);
 	return new RawZorkStream(rate, disposeAfterUse, stream);
 }
 
-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
+Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                    int rate,
                                    DisposeAfterUse::Flag disposeAfterUse) {
 	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 1de3b57..43cf4d8 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -23,19 +23,64 @@
 #ifndef ZVISION_ZORK_RAW_H
 #define ZVISION_ZORK_RAW_H
 
-#include "common/scummsys.h"
 #include "common/types.h"
-
-#include "common/list.h"
-
+#include "audio/audiostream.h"
 
 namespace Common {
 class SeekableReadStream;
 }
 
 namespace ZVision {
+/**
+ * This is a stream, which allows for playing raw ADPCM data from a stream.
+ */
+class RawZorkStream : public Audio::RewindableAudioStream {
+public:
+	RawZorkStream(uint32 rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+
+	~RawZorkStream() {
+	}
+
+private:
+	const int _rate;                                           // Sample rate of stream
+	Audio::Timestamp _playtime;                                // Calculated total play time
+	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
+	bool _endOfData;                                           // Whether the stream end has been reached
+
+	/** 
+	 * Holds the frequency and index from the last sample
+	 * 0 holds the left channel, 1 holds the right channel
+	 */
+	struct {
+		int32 sample;
+		int16 index;
+	} _lastSample[2];
+
+	static const int16 stepAdjustmentTable[8];
+
+	static const int32 amplitudeLookupTable[89];
+
+public:
+	int readBuffer(int16 *buffer, const int numSamples);
+
+	bool isStereo() const { return true; }
+	bool endOfData() const { return _endOfData; }
+
+	int getRate() const { return _rate; }
+	Audio::Timestamp getLength() const { return _playtime; }
+
+	bool rewind();
 
-class SeekableAudioStream;
+private:
+	/**
+	 * Fill the temporary sample buffer used in readBuffer.
+	 *
+	 * @param maxSamples Maximum samples to read.
+	 * @return actual count of samples read.
+	 */
+	int fillBuffer(int maxSamples);
+	uint32 processBlock();
+};
 
 /**
  * Creates an audio stream, which plays from the given buffer.
@@ -46,7 +91,7 @@ class SeekableAudioStream;
  * @param disposeAfterUse Whether to free the buffer after use (with free!).
  * @return The new SeekableAudioStream (or 0 on failure).
  */
-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
+Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                    int rate,
                                    DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
@@ -58,7 +103,7 @@ Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
  * @param disposeAfterUse Whether to delete the stream after use.
  * @return The new SeekableAudioStream (or 0 on failure).
  */
-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
+Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                    int rate,
                                    DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 


Commit: f88127104b6b59a336761966e9652412083402b7
    https://github.com/scummvm/scummvm/commit/f88127104b6b59a336761966e9652412083402b7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:17-07:00

Commit Message:
ZVISION: Fix implicit conversion for scanf-type functions

Changed paths:
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 2371c35..6a2e8cf 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -41,7 +41,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 	while(!file.eos()) {
 		Common::String line = file.readLine();
 		if (file.err()) {
-			warning("Error parsing scr file: %s", fileName);
+			warning("Error parsing scr file: %s", fileName.c_str());
 			return;
 		}
 
@@ -249,7 +249,7 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
 			
 
 		} else {
-			warning("Unhandled result action type: ", line);
+			warning("Unhandled result action type: %s", line.c_str());
 		}
 
 		line = stream.readLine();


Commit: c45a13cdd716da04c9b64ba50560d7d89facfccb
    https://github.com/scummvm/scummvm/commit/c45a13cdd716da04c9b64ba50560d7d89facfccb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:18-07:00

Commit Message:
ZVISION: Conform to GCC spacing for template inside template

Changed paths:
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index b4ad1cc..7fcf2f6 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -55,7 +55,7 @@ void ScriptManager::createReferenceTable() {
 	}
 
 	// Remove duplicate entries
-	for (Common::HashMap<uint32, Common::Array<Puzzle *>>::iterator referenceTableIter; referenceTableIter != _referenceTable.end(); referenceTableIter++) {
+	for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter; referenceTableIter != _referenceTable.end(); referenceTableIter++) {
 		removeDuplicateEntries(&(referenceTableIter->_value));
 	}
 }
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 42f4bba..7924eee 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -51,7 +51,7 @@ private:
 	/** Holds the currently active ActionNodes */
 	Common::List<ActionNode *> _activeNodes;
 	/** References _globalState keys to Puzzles */
-	Common::HashMap<uint32, Common::Array<Puzzle *>> _referenceTable;
+	Common::HashMap<uint32, Common::Array<Puzzle *> > _referenceTable;
 	/** Holds the Puzzles that should be checked this frame */
 	Common::Stack<Puzzle *> _puzzlesToCheck;
 	/** Holds the currently active puzzles */


Commit: 644313e8f20fa777325c748a450ca698141c0d97
    https://github.com/scummvm/scummvm/commit/644313e8f20fa777325c748a450ca698141c0d97
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:18-07:00

Commit Message:
ZVISION: Add stereo/mono handling for Zork sound

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index c3be4ba..e0ca37c 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -65,8 +65,8 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
 }
 
 bool Console::cmdLoadSound(int argc, const char **argv) {
-	if (argc != 3) {
-		DebugPrintf("Use loadsound <fileName> <rate> to load a video to the screen");
+	if (argc != 4) {
+		DebugPrintf("Use loadsound <fileName> <rate> <stereo: 0 or 1> to load a video to the screen");
 		return true;
 	}
 
@@ -76,7 +76,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
 		return true;
 	}
 
-	Audio::AudioStream *soundStream = makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), atoi(argv[2]), DisposeAfterUse::YES);
+	Audio::AudioStream *soundStream = makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), atoi(argv[2]), atoi(argv[3]), DisposeAfterUse::YES);
 	Audio::SoundHandle handle;
 	_engine->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
 
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 69d8edd..c4b76d9 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -45,8 +45,9 @@ const int32 RawZorkStream::amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0
                                                        0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
                                                        0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
 
-RawZorkStream::RawZorkStream(uint32 rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
 		: _rate(rate),
+		  _stereo(stereo),
 		  _stream(stream, disposeStream),
 		  _endOfData(false) {
 	_lastSample[0] = {0, 0};
@@ -64,14 +65,13 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
 
 	while (bytesRead < numSamples) {
 		byte encodedSample = _stream->readByte();
-		bytesRead++;
-
 		if (_stream->eos()) {
 			_endOfData = true;
 			return bytesRead;
 		}
+		bytesRead++;
 
-		uint16 index = _lastSample[channel].index;
+		int16 index = _lastSample[channel].index;
 		uint32 lookUpSample = amplitudeLookupTable[index];
 
 		int32 sample = 0;
@@ -105,7 +105,7 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
 		_lastSample[channel].index = index;
 
 		// Increment and wrap the channel
-		channel = (channel + 1) & 1;
+		channel = (channel + 1) & _stereo;
 	}
 
 	return bytesRead;
@@ -122,16 +122,18 @@ bool RawZorkStream::rewind() {
 }
 
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
-                                   int rate,
-                                   DisposeAfterUse::Flag disposeAfterUse) {
+                                                int rate,
+								                bool stereo,
+                                                DisposeAfterUse::Flag disposeAfterUse) {
 	assert(stream->size() % 2 == 0);
-	return new RawZorkStream(rate, disposeAfterUse, stream);
+	return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
 }
 
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
-                                   int rate,
-                                   DisposeAfterUse::Flag disposeAfterUse) {
-	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);
+                                                int rate,
+								                bool stereo,
+                                                DisposeAfterUse::Flag disposeAfterUse) {
+	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 43cf4d8..7386c87 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -36,7 +36,7 @@ namespace ZVision {
  */
 class RawZorkStream : public Audio::RewindableAudioStream {
 public:
-	RawZorkStream(uint32 rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+	RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
 
 	~RawZorkStream() {
 	}
@@ -46,6 +46,7 @@ private:
 	Audio::Timestamp _playtime;                                // Calculated total play time
 	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
 	bool _endOfData;                                           // Whether the stream end has been reached
+	bool _stereo;
 
 	/** 
 	 * Holds the frequency and index from the last sample
@@ -92,8 +93,9 @@ private:
  * @return The new SeekableAudioStream (or 0 on failure).
  */
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
-                                   int rate,
-                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+                                                int rate,
+								                bool stereo,
+                                                DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
 /**
  * Creates an audio stream, which plays from the given stream.
@@ -104,8 +106,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
  * @return The new SeekableAudioStream (or 0 on failure).
  */
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
-                                   int rate,
-                                   DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+                                                int rate,
+								                bool stereo,
+                                                DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
 } // End of namespace ZVision
 


Commit: 8de12fcbd2dbfddd45bd7916e1e90b5b3e4466bc
    https://github.com/scummvm/scummvm/commit/8de12fcbd2dbfddd45bd7916e1e90b5b3e4466bc
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:19-07:00

Commit Message:
ZVISION: Add underscore prefix to public static variable names

Changed paths:
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index a7cdcd9..2d7acdb 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -33,17 +33,17 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source, bool stream,
 		  _readCursor(0),
 		  _eosFlag(false) {
 	// Clear the window to null
-	memset(_window, 0, blockSize);
+	memset(_window, 0, _blockSize);
 
 	// Reserve space in the destination buffer
 	// TODO: Make a better guess
-	if (decompressedSize == npos) {
+	if (decompressedSize == _npos) {
 		decompressedSize = source->size();
 	}
 	_destination.reserve(decompressedSize);
 
 	if (stream)
-		decompressBytes(blockSize);
+		decompressBytes(_blockSize);
 	else
 		decompressAll();
 }
@@ -120,7 +120,7 @@ uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) {
 			break;
 		}
 
-		decompressBytes(blockSize);
+		decompressBytes(_blockSize);
 	}
 
 	if (dataSize > 0) {
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 9ef1d6d..142bf9e 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -41,16 +41,16 @@ public:
 	 * @param stream			  Decompress the data as needed (true) or all at once (false)
 	 * @param decompressedSize    The size of the decompressed data. If npos, the class will choose a size and grow as needed
 	 */
-	LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = npos);
+	LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = _npos);
 
 public:
-	static const uint32 npos = 0xFFFFFFFFu;
-	static const uint16 blockSize = 0x1000u;
+	static const uint32 _npos = 0xFFFFFFFFu;
+	static const uint16 _blockSize = 0x1000u;
 
 private:
 	Common::SeekableReadStream *_source;
 	Common::Array<char> _destination;
-	char _window[blockSize];
+	char _window[_blockSize];
 	uint16 _windowCursor;
 	uint32 _readCursor;
 	bool _eosFlag;


Commit: a30f49b556ef27644d752368c11590cc48c0fccf
    https://github.com/scummvm/scummvm/commit/a30f49b556ef27644d752368c11590cc48c0fccf
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:19-07:00

Commit Message:
ZVISION: Add a game type enum to detection

This is needed for sound file differentiation

Changed paths:
  A engines/zvision/detection.h
    engines/zvision/detection.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 5488ae5..8c87c90 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -23,22 +23,17 @@
 
 #include "base/plugins.h"
 
-#include "engines/advancedDetector.h"
-
 #include "common/translation.h"
 #include "common/savefile.h"
 #include "common/str-array.h"
 #include "common/system.h"
 
 #include "zvision/zvision.h"
+#include "zvision/detection.h"
 
 
 namespace ZVision {
 
-struct ZVisionGameDescription {
-	ADGameDescription desc;
-};
-
 uint32 ZVision::getFeatures() const {
 	return _gameDescription->desc.flags;
 }
@@ -47,7 +42,8 @@ Common::Language ZVision::getLanguage() const {
 	return _gameDescription->desc.language;
 }
 
-}
+} // End of namespace ZVision
+
 
 static const PlainGameDescriptor zVisionGames[] = {
 	{"zvision",  "ZVision Game"},
@@ -72,6 +68,7 @@ static const ZVisionGameDescription gameDescriptions[] = {
 			ADGF_NO_FLAGS,
 			GUIO1(GUIO_NONE)
 		},
+		ZorkNemesis
 	},
 
 	{ AD_TABLE_END_MARKER }
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
new file mode 100644
index 0000000..b1e5dcb
--- /dev/null
+++ b/engines/zvision/detection.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#ifndef ZVISION_DETECTION_H
+#define ZVISION_DETECTION_H
+
+#include "engines/advancedDetector.h"
+
+namespace ZVision {
+
+enum ZVisionGameId {
+	ZorkNemesis,
+	ZorkGrandInquisitor
+};
+
+struct ZVisionGameDescription {
+	ADGameDescription desc;
+	ZVisionGameId gameId;
+};
+
+}
+
+#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index ba08122..4ce775d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -36,6 +36,7 @@
 #include "zvision/console.h"
 #include "zvision/script_manager.h"
 #include "zvision/zfs_archive.h"
+#include "zvision/detection.h"
 
 #include "zvision/utility.h"
 
@@ -154,8 +155,8 @@ Common::RandomSource *ZVision::getRandomSource() const {
 	return _rnd;
 }
 
-Audio::Mixer *ZVision::getMixer() const {
-	return _mixer;
+ZVisionGameId ZVision::getGameId() const {
+	return _gameDescription->gameId;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 11773a3..17a7c02 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -31,6 +31,8 @@
 
 #include "engines/engine.h"
 
+#include "zvision/detection.h"
+
 #include "gui/debugger.h"
  
 namespace ZVision {
@@ -76,7 +78,7 @@ public:
 	virtual Common::Error run();
 	ScriptManager *getScriptManager() const;
 	Common::RandomSource *getRandomSource() const;
-	Audio::Mixer *getMixer() const;
+	ZVisionGameId getGameId() const;
 
 	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
 	void startVideo(Video::VideoDecoder *videoDecoder);


Commit: 9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1
    https://github.com/scummvm/scummvm/commit/9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:20-07:00

Commit Message:
ZVISION: Create utility function to parse fileName from a full/partial path

Changed paths:
    engines/zvision/utility.cpp
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 41b589d..5f69fd7 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -22,6 +22,8 @@
 
 #include "common/scummsys.h"
 
+#include "common/tokenizer.h"
+
 #include "zvision/utility.h"
 
 namespace ZVision {
@@ -177,4 +179,21 @@ void dumpEveryResultAction(const Common::String &destFile) {
 	output.close();
 }
 
+/**
+ * Gets the name of the file (including extension). Forward or back slashes 
+ * are interpreted as directory changes
+ *
+ * @param fullPath    A full or partial path to the file. Ex: folderOne/folderTwo/file.txt
+ * @return            The name of the file without any preceding directories. Ex: file.txt
+ */
+Common::String getFileName(const Common::String &fullPath) {
+	Common::StringTokenizer tokenizer(fullPath, "/\\");
+	Common::String token;
+	while (!tokenizer.empty()) {
+		token = tokenizer.nextToken();
+	}
+
+	return token;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index e5713fc..dba765b 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -73,6 +73,8 @@ void removeDuplicateEntries(Common::Array<T> *container) {
 	}
 }
 
+Common::String getFileName(const Common::String &fullPath);
+
 } // End of namespace ZVision
 
 #endif


Commit: 76f4d2b3d898710f5fefba47aafafc889037968b
    https://github.com/scummvm/scummvm/commit/76f4d2b3d898710f5fefba47aafafc889037968b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:20-07:00

Commit Message:
ZVISION: Create logic to decode sound rate and isStereo from fileName

Changed paths:
    engines/zvision/zork_avi_decoder.cpp
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index 4ceff48..d9b9511 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -26,13 +26,13 @@
 #include "common/stream.h"
 #include "audio/audiostream.h"
 
-#include "engines/zvision/zork_avi_decoder.h"
-#include "engines/zvision/zork_raw.h"
+#include "zvision/zork_avi_decoder.h"
+#include "zvision/zork_raw.h"
 
 namespace ZVision {
 
-Video::AVIDecoder::AVIAudioTrack *ZVision::ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {
-	ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);
+Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {
+	ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);
 	return (Video::AVIDecoder::AVIAudioTrack *)audioTrack;
 }
 
@@ -40,7 +40,7 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s
 	if (_audStream) {
 		if (_wvInfo.tag == kWaveFormatZorkPCM) {
 			assert(_wvInfo.size == 8);
-			_audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES);
+			_audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, _audStream->isStereo(), DisposeAfterUse::YES), DisposeAfterUse::YES);
 		}
 	} else {
 		delete stream;
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index c4b76d9..9f71b76 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -22,18 +22,24 @@
 
 #include "common/scummsys.h"
 
+#include "common/file.h"
+#include "common/str.h"
 #include "common/stream.h"
 #include "common/memstream.h"
+#include "common/bufferedstream.h"
 #include "common/util.h"
 #include "audio/audiostream.h"
 
-#include "engines/zvision/zork_raw.h"
+#include "zvision/zork_raw.h"
+#include "zvision/zvision.h"
+#include "zvision/detection.h"
+#include "zvision/utility.h"
 
 namespace ZVision {
 
-const int16 RawZorkStream::stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12};
+const int16 RawZorkStream::_stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12};
 
-const int32 RawZorkStream::amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
+const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
                                                        0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
                                                        0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
                                                        0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
@@ -45,9 +51,10 @@ const int32 RawZorkStream::amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0
                                                        0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
                                                        0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
 
-RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+RawZorkStream::RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
 		: _rate(rate),
 		  _stereo(stereo),
+		  _packed(packed),
 		  _stream(stream, disposeStream),
 		  _endOfData(false) {
 	_lastSample[0] = {0, 0};
@@ -58,6 +65,18 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
 }
 
 int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
+	if (_packed)
+		return decodeADPCM(buffer, numSamples);
+	else {
+		uint32 bytesRead = _stream->read(buffer, numSamples);
+		if (_stream->eos())
+			_endOfData = true;
+
+		return bytesRead;
+	}
+}
+
+int RawZorkStream::decodeADPCM(int16 *buffer, const int numSamples) {
 	uint16 bytesRead = 0;
 
 	// 0: Left, 1: Right
@@ -72,7 +91,7 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
 		bytesRead++;
 
 		int16 index = _lastSample[channel].index;
-		uint32 lookUpSample = amplitudeLookupTable[index];
+		uint32 lookUpSample = _amplitudeLookupTable[index];
 
 		int32 sample = 0;
 
@@ -98,7 +117,7 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
 
 		buffer[bytesRead - 1] = (int16)sample;
 
-		index += stepAdjustmentTable[(encodedSample >> 4) & 7];
+		index += _stepAdjustmentTable[(encodedSample >> 4) & 7];
 		index = CLIP<uint16>(index, 0, 88);
 
 		_lastSample[channel].sample = sample;
@@ -124,16 +143,43 @@ bool RawZorkStream::rewind() {
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                                 int rate,
 								                bool stereo,
+												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse) {
 	assert(stream->size() % 2 == 0);
-	return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
+	return new RawZorkStream(rate, stereo, packed, disposeAfterUse, stream);
 }
 
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                                 int rate,
 								                bool stereo,
+												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse) {
-	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
+	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, packed, DisposeAfterUse::YES);
+}
+
+Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
+	Common::File *file = new Common::File();
+	assert(file->open(filePath));
+
+	Common::String fileName = getFileName(filePath);
+	fileName.toLowercase();
+
+	SoundParams soundParams;
+
+	if (engine->getGameId() == ZorkNemesis) {
+		for (int i = 0; i < 6; i++) {
+			if (zNemSoundParamLookupTable[i].identifier == (fileName[6]))
+				soundParams = zNemSoundParamLookupTable[i];
+		}
+	}
+	else if (engine->getGameId() == ZorkGrandInquisitor) {
+		for (int i = 0; i < 6; i++) {
+			if (zgiSoundParamLookupTable[i].identifier == (fileName[7]))
+				soundParams = zgiSoundParamLookupTable[i];
+		}
+	}
+
+	return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, soundParams.packed, DisposeAfterUse::YES);
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 7386c87..5efa27a 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -31,22 +31,51 @@ class SeekableReadStream;
 }
 
 namespace ZVision {
+
+class ZVision;
+
+struct SoundParams {
+	char identifier;
+	uint16 rate;
+	bool stereo;
+	bool packed;
+};
+
+const SoundParams zNemSoundParamLookupTable[6] = {{'6', 0x2B11, false, false},
+                                                  {'a', 0x5622, false,  true}, 
+                                                  {'b', 0x5622, true,  true},
+                                                  {'n', 0x2B11, false, true},
+                                                  {'s', 0x5622, false, true},
+                                                  {'t', 0x5622, true, true}
+};
+
+const SoundParams zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false},
+                                                 {'k',0x2B11, true, true},
+                                                 {'p',0x5622, false, true},
+                                                 {'q',0x5622, true, true},
+                                                 {'u',0xAC44, true, true}
+};
+
 /**
  * This is a stream, which allows for playing raw ADPCM data from a stream.
  */
 class RawZorkStream : public Audio::RewindableAudioStream {
 public:
-	RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+	RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+	RawZorkStream(const Common::String &filePath, ZVision *engine);
 
 	~RawZorkStream() {
 	}
 
+public:
+
 private:
 	const int _rate;                                           // Sample rate of stream
 	Audio::Timestamp _playtime;                                // Calculated total play time
 	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
 	bool _endOfData;                                           // Whether the stream end has been reached
 	bool _stereo;
+	bool _packed;
 
 	/** 
 	 * Holds the frequency and index from the last sample
@@ -57,9 +86,8 @@ private:
 		int16 index;
 	} _lastSample[2];
 
-	static const int16 stepAdjustmentTable[8];
-
-	static const int32 amplitudeLookupTable[89];
+	static const int16 _stepAdjustmentTable[8];
+	static const int32 _amplitudeLookupTable[89];
 
 public:
 	int readBuffer(int16 *buffer, const int numSamples);
@@ -73,14 +101,7 @@ public:
 	bool rewind();
 
 private:
-	/**
-	 * Fill the temporary sample buffer used in readBuffer.
-	 *
-	 * @param maxSamples Maximum samples to read.
-	 * @return actual count of samples read.
-	 */
-	int fillBuffer(int maxSamples);
-	uint32 processBlock();
+	int decodeADPCM(int16 *buffer, const int numSamples);
 };
 
 /**
@@ -95,6 +116,7 @@ private:
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                                 int rate,
 								                bool stereo,
+												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
 /**
@@ -108,8 +130,11 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                                 int rate,
 								                bool stereo,
+												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
+Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
+
 } // End of namespace ZVision
 
 #endif


Commit: 92f3de72de273cc4ae3767e5991ff1f7cd85c8ed
    https://github.com/scummvm/scummvm/commit/92f3de72de273cc4ae3767e5991ff1f7cd85c8ed
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:21-07:00

Commit Message:
ZVISION: Convert console sound handling to use new fileName decoding

Changed paths:
    engines/zvision/console.cpp



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index e0ca37c..a18da86 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -42,7 +42,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
 	if (argc != 4) {
-		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen");
+		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen\n");
 		return true;
 	}
 	_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
@@ -52,7 +52,7 @@ bool Console::cmdLoadImage(int argc, const char **argv) {
 
 bool Console::cmdLoadVideo(int argc, const char **argv) {
 	if (argc != 2) {
-		DebugPrintf("Use loadvideo <fileName> to load a video to the screen");
+		DebugPrintf("Use loadvideo <fileName> to load a video to the screen\n");
 		return true;
 	}
 
@@ -65,20 +65,19 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
 }
 
 bool Console::cmdLoadSound(int argc, const char **argv) {
-	if (argc != 4) {
-		DebugPrintf("Use loadsound <fileName> <rate> <stereo: 0 or 1> to load a video to the screen");
+	if (argc != 2) {
+		DebugPrintf("Use loadsound <fileName> to load a sound\n");
 		return true;
 	}
 
-	Common::File *file = new Common::File();
-	if (!file->open(argv[1])) {
-		DebugPrintf("File does not exist");
+	if (!Common::File::exists(argv[1])) {
+		DebugPrintf("File does not exist\n");
 		return true;
 	}
 
-	Audio::AudioStream *soundStream = makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), atoi(argv[2]), atoi(argv[3]), DisposeAfterUse::YES);
+	Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine);
 	Audio::SoundHandle handle;
-	_engine->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
+	_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
 
 	return true;
 }


Commit: 071d9f2241d608753372a027b489ae3027d73480
    https://github.com/scummvm/scummvm/commit/071d9f2241d608753372a027b489ae3027d73480
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:21-07:00

Commit Message:
ZVISION: Add logic to allow the user to break out of videos

Changed paths:
    engines/zvision/events.cpp



diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 984d59e..a3d6b6b 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -25,6 +25,7 @@
 #include "zvision/zvision.h"
 #include "zvision/console.h"
 #include "common/events.h"
+#include "engines/util.h"
 
 
 namespace ZVision {
@@ -55,12 +56,19 @@ void ZVision::processEvents() {
 					_console->onFrame();
 				}
 				break;
-
 			case Common::KEYCODE_q:
 				if (_event.kbd.hasFlags(Common::KBD_CTRL))
 					quitGame();
 				break;
-
+			case Common::KEYCODE_ESCAPE:
+				if (_currentVideo != 0) {
+					initGraphics(_width, _height, true, &_pixelFormat);
+					delete _currentVideo;
+					_currentVideo = 0;
+					delete _scaledVideoFrameBuffer;
+					_scaledVideoFrameBuffer = 0;
+				}
+				break;
 			default:
 				break;
 			}


Commit: c7ce580bbde99c1634a1160a18350ccd51badb39
    https://github.com/scummvm/scummvm/commit/c7ce580bbde99c1634a1160a18350ccd51badb39
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:22-07:00

Commit Message:
ZVISION: Removed 'packed' audio handling from RawZorkStream.

Moved it to the factory method for creating Audio Streams

Changed paths:
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 9f71b76..78913a7 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -29,6 +29,7 @@
 #include "common/bufferedstream.h"
 #include "common/util.h"
 #include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
 
 #include "zvision/zork_raw.h"
 #include "zvision/zvision.h"
@@ -40,21 +41,20 @@ namespace ZVision {
 const int16 RawZorkStream::_stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12};
 
 const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
-                                                       0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
-                                                       0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
-                                                       0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
-                                                       0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, 
-                                                       0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292,
-                                                       0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, 
-                                                       0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0,
-                                                       0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, 
-                                                       0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
-                                                       0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
-
-RawZorkStream::RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+                                                        0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
+                                                        0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
+                                                        0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
+                                                        0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, 
+                                                        0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292,
+                                                        0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, 
+                                                        0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0,
+                                                        0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, 
+                                                        0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
+                                                        0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
+
+RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
 		: _rate(rate),
 		  _stereo(stereo),
-		  _packed(packed),
 		  _stream(stream, disposeStream),
 		  _endOfData(false) {
 	_lastSample[0] = {0, 0};
@@ -65,18 +65,6 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfter
 }
 
 int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
-	if (_packed)
-		return decodeADPCM(buffer, numSamples);
-	else {
-		uint32 bytesRead = _stream->read(buffer, numSamples);
-		if (_stream->eos())
-			_endOfData = true;
-
-		return bytesRead;
-	}
-}
-
-int RawZorkStream::decodeADPCM(int16 *buffer, const int numSamples) {
 	uint16 bytesRead = 0;
 
 	// 0: Left, 1: Right
@@ -143,21 +131,19 @@ bool RawZorkStream::rewind() {
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                                 int rate,
 								                bool stereo,
-												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse) {
 	assert(stream->size() % 2 == 0);
-	return new RawZorkStream(rate, stereo, packed, disposeAfterUse, stream);
+	return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
 }
 
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                                 int rate,
 								                bool stereo,
-												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse) {
-	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, packed, DisposeAfterUse::YES);
+	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
 }
 
-Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
+Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
 	Common::File *file = new Common::File();
 	assert(file->open(filePath));
 
@@ -178,8 +164,15 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
 				soundParams = zgiSoundParamLookupTable[i];
 		}
 	}
-
-	return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, soundParams.packed, DisposeAfterUse::YES);
+	
+	if (soundParams.packed) {
+		byte flags = 0;
+		if (soundParams.stereo)
+			flags |= Audio::FLAG_STEREO;
+		return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
+	}
+	else
+		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 5efa27a..8d4670e 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -61,8 +61,7 @@ const SoundParams zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false},
  */
 class RawZorkStream : public Audio::RewindableAudioStream {
 public:
-	RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
-	RawZorkStream(const Common::String &filePath, ZVision *engine);
+	RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
 
 	~RawZorkStream() {
 	}
@@ -75,7 +74,6 @@ private:
 	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
 	bool _endOfData;                                           // Whether the stream end has been reached
 	bool _stereo;
-	bool _packed;
 
 	/** 
 	 * Holds the frequency and index from the last sample
@@ -99,9 +97,6 @@ public:
 	Audio::Timestamp getLength() const { return _playtime; }
 
 	bool rewind();
-
-private:
-	int decodeADPCM(int16 *buffer, const int numSamples);
 };
 
 /**
@@ -116,7 +111,6 @@ private:
 Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
                                                 int rate,
 								                bool stereo,
-												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
 /**
@@ -130,10 +124,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
 Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
                                                 int rate,
 								                bool stereo,
-												bool packed,
                                                 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
-Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
+Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
 
 } // End of namespace ZVision
 


Commit: d771b615e050ecd13e9da73111230ec16158beb2
    https://github.com/scummvm/scummvm/commit/d771b615e050ecd13e9da73111230ec16158beb2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:22-07:00

Commit Message:
ZVISION: Use individual initialization instead of inline.

Changed paths:
    engines/zvision/zork_raw.cpp



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 78913a7..140e6a5 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -57,8 +57,10 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
 		  _stereo(stereo),
 		  _stream(stream, disposeStream),
 		  _endOfData(false) {
-	_lastSample[0] = {0, 0};
-	_lastSample[1] = {0, 0};
+	_lastSample[0].index = 0;
+	_lastSample[0].sample = 0;
+	_lastSample[1].index = 0;
+	_lastSample[1].sample = 0;
 
 	// Calculate the total playtime of the stream
 	_playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
@@ -122,8 +124,10 @@ bool RawZorkStream::rewind() {
 	_stream->seek(0, 0);
 	_stream->clearErr();
 	_endOfData = false;
-	_lastSample[0] = {0, 0};
-	_lastSample[1] = {0, 0};
+	_lastSample[0].index = 0;
+	_lastSample[0].sample = 0;
+	_lastSample[1].index = 0;
+	_lastSample[1].sample = 0;
 
 	return true;
 }


Commit: 03c871ff3025457067bb504af0799c901498253e
    https://github.com/scummvm/scummvm/commit/03c871ff3025457067bb504af0799c901498253e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:23-07:00

Commit Message:
ZVISION: Convert _stereo to a byte since it is used for a bitwise and

Changed paths:
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 140e6a5..68bb25d 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -54,9 +54,12 @@ const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009,
 
 RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
 		: _rate(rate),
-		  _stereo(stereo),
+		  _stereo(0),
 		  _stream(stream, disposeStream),
 		  _endOfData(false) {
+	if (stereo)
+		_stereo = 1;
+
 	_lastSample[0].index = 0;
 	_lastSample[0].sample = 0;
 	_lastSample[1].index = 0;
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 8d4670e..6d25d19 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -73,7 +73,7 @@ private:
 	Audio::Timestamp _playtime;                                // Calculated total play time
 	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
 	bool _endOfData;                                           // Whether the stream end has been reached
-	bool _stereo;
+	byte _stereo;
 
 	/** 
 	 * Holds the frequency and index from the last sample


Commit: 134f8fda173731d744bd814d68850ce14fa4fd94
    https://github.com/scummvm/scummvm/commit/134f8fda173731d744bd814d68850ce14fa4fd94
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:23-07:00

Commit Message:
ZVISION: Fix incorrect assumptions about a file being stereo

Changed paths:
    engines/zvision/zork_raw.cpp



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 68bb25d..cb031d6 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -66,7 +66,10 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
 	_lastSample[1].sample = 0;
 
 	// Calculate the total playtime of the stream
-	_playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
+	if (stereo)
+		_playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
+	else
+		_playtime = Audio::Timestamp(0, _stream->size(), rate);
 }
 
 int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
@@ -139,7 +142,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
                                                 int rate,
 								                bool stereo,
                                                 DisposeAfterUse::Flag disposeAfterUse) {
-	assert(stream->size() % 2 == 0);
+	if (stereo)
+		assert(stream->size() % 2 == 0);
+
 	return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
 }
 


Commit: e897a1bb2ae444cf812f2c11060585ccd2b48e4c
    https://github.com/scummvm/scummvm/commit/e897a1bb2ae444cf812f2c11060585ccd2b48e4c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:24-07:00

Commit Message:
ZVISION: Fix logic concerning whether a stream is packed or not

It was accidentally returning a raw stream for a ZorkStream and a ZorkStream for a raw

Changed paths:
    engines/zvision/zork_raw.cpp



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index cb031d6..2ffe8eb 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -178,13 +178,14 @@ Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *e
 	}
 	
 	if (soundParams.packed) {
+		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
+	} else {
 		byte flags = 0;
 		if (soundParams.stereo)
 			flags |= Audio::FLAG_STEREO;
+
 		return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
 	}
-	else
-		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
 }
 
 } // End of namespace ZVision


Commit: 7644e00bf3e55c1b6b2ea0d74db89d8539cb9f31
    https://github.com/scummvm/scummvm/commit/7644e00bf3e55c1b6b2ea0d74db89d8539cb9f31
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:24-07:00

Commit Message:
ZVISION: Convert ResultActions to take a String pointer in their constructors

There's no point in copying the String since it's just being parsed

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index a5b1e95..791eda1 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,8 +33,8 @@ namespace ZVision {
 // ActionAdd
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAdd::ActionAdd(Common::String line) {
-	sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value);
+ActionAdd::ActionAdd(Common::String *line) {
+	sscanf(line->c_str(), ":add(%u,%hhu)", &_key, &_value);
 }
 
 bool ActionAdd::execute(ZVision *engine) {
@@ -47,8 +47,8 @@ bool ActionAdd::execute(ZVision *engine) {
 // ActionAssign
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAssign::ActionAssign(Common::String line) {
-	sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value);
+ActionAssign::ActionAssign(Common::String *line) {
+	sscanf(line->c_str(), ":assign(%u, %hhu)", &_key, &_value);
 }
 
 bool ActionAssign::execute(ZVision *engine) {
@@ -61,8 +61,8 @@ bool ActionAssign::execute(ZVision *engine) {
 // ActionAttenuate
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAttenuate::ActionAttenuate(Common::String line) {
-	sscanf(line.c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
+ActionAttenuate::ActionAttenuate(Common::String *line) {
+	sscanf(line->c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
 }
 
 bool ActionAttenuate::execute(ZVision *engine) {
@@ -75,8 +75,8 @@ bool ActionAttenuate::execute(ZVision *engine) {
 // ActionChangeLocation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionChangeLocation::ActionChangeLocation(Common::String line) {
-	sscanf(line.c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
+ActionChangeLocation::ActionChangeLocation(Common::String *line) {
+	sscanf(line->c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
 }
 
 bool ActionChangeLocation::execute(ZVision *engine) {
@@ -89,8 +89,8 @@ bool ActionChangeLocation::execute(ZVision *engine) {
 // ActionCrossfade
 //////////////////////////////////////////////////////////////////////////////
 
-ActionCrossfade::ActionCrossfade(Common::String line) {
-	sscanf(line.c_str(), 
+ActionCrossfade::ActionCrossfade(Common::String *line) {
+	sscanf(line->c_str(), 
            ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
@@ -105,9 +105,9 @@ bool ActionCrossfade::execute(ZVision *engine) {
 // ActionPreloadAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionPreloadAnimation::ActionPreloadAnimation(Common::String line) {
+ActionPreloadAnimation::ActionPreloadAnimation(Common::String *line) {
 	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line.c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
+	sscanf(line->c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
 }
 
 bool ActionPreloadAnimation::execute(ZVision *engine) {
@@ -120,9 +120,9 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
 // ActionPlayAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionPlayAnimation::ActionPlayAnimation(Common::String line) {
+ActionPlayAnimation::ActionPlayAnimation(Common::String *line) {
 	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line.c_str(), 
+	sscanf(line->c_str(), 
            ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
            &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 }
@@ -137,8 +137,8 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
 // ActionRandom
 //////////////////////////////////////////////////////////////////////////////
 
-ActionRandom::ActionRandom(Common::String line) {
-	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
+ActionRandom::ActionRandom(Common::String *line) {
+	sscanf(line->c_str(), ":random:%u, %u)", &_key, &_max);
 }
 
 bool ActionRandom::execute(ZVision *engine) {
@@ -152,8 +152,8 @@ bool ActionRandom::execute(ZVision *engine) {
 // ActionTimer
 //////////////////////////////////////////////////////////////////////////////
 
-ActionTimer::ActionTimer(Common::String line) {
-	sscanf(line.c_str(), ":timer:%u(%hu)", &_key, &_time);
+ActionTimer::ActionTimer(Common::String *line) {
+	sscanf(line->c_str(), ":timer:%u(%hu)", &_key, &_time);
 }
 
 bool ActionTimer::execute(ZVision *engine) {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index aed8483..9b2267d 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -74,7 +74,7 @@ public:
 
 class ActionAdd : public ResultAction {
 public:
-	ActionAdd(Common::String line);
+	ActionAdd(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -84,7 +84,7 @@ private:
 
 class ActionAssign : public ResultAction {
 public:
-	ActionAssign(Common::String line);
+	ActionAssign(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -94,7 +94,7 @@ private:
 
 class ActionAttenuate : public ResultAction {
 public:
-	ActionAttenuate(Common::String line);
+	ActionAttenuate(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -104,7 +104,7 @@ private:
 
 class ActionChangeLocation : public ResultAction {
 public:
-	ActionChangeLocation(Common::String line);
+	ActionChangeLocation(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -116,7 +116,7 @@ private:
 
 class ActionCrossfade : public ResultAction {
 public:
-	ActionCrossfade(Common::String line);
+	ActionCrossfade(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -131,7 +131,7 @@ private:
 
 class ActionPlayAnimation : public ResultAction {
 public:
-	ActionPlayAnimation(Common::String line);
+	ActionPlayAnimation(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -150,7 +150,7 @@ private:
 
 class ActionPreloadAnimation : public ResultAction {
 public:
-	ActionPreloadAnimation(Common::String line);
+	ActionPreloadAnimation(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -163,13 +163,13 @@ private:
 // TODO: See if this exists in ZGI. It doesn't in ZNem
 //class ActionUnloadAnimation : public ResultAction {
 //public:
-//	ActionUnloadAnimation(Common::String line);
+//	ActionUnloadAnimation(Common::String *line);
 //	bool execute(ZVision *engine);
 //};
 
 class ActionRandom : public ResultAction {
 public:
-	ActionRandom(Common::String line);
+	ActionRandom(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
@@ -179,7 +179,7 @@ private:
 
 class ActionTimer : public ResultAction {
 public:
-	ActionTimer(Common::String line);
+	ActionTimer(Common::String *line);
 	bool execute(ZVision *engine);
 
 private:
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 6a2e8cf..168a6d8 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -135,11 +135,11 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
 	while (!line.contains('}')) {
 		// Parse for the action type
 		if (line.matchString("*:add*", true)) {
-			actionList.push_back(new ActionAdd(line));
+			actionList.push_back(new ActionAdd(&line));
 		} else if (line.matchString("*:animplay*", true)) {
-			actionList.push_back(new ActionPlayAnimation(line));
+			actionList.push_back(new ActionPlayAnimation(&line));
 		} else if (line.matchString("*:animpreload*", true)) {
-			actionList.push_back(new ActionPreloadAnimation(line));
+			actionList.push_back(new ActionPreloadAnimation(&line));
 		} else if (line.matchString("*:animunload*", true)) {
 			
 


Commit: 32f88486058c0553ae2c0cd1808ef06fcd09b143
    https://github.com/scummvm/scummvm/commit/32f88486058c0553ae2c0cd1808ef06fcd09b143
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:25-07:00

Commit Message:
ZVISION: Create utility function to convert .RAW to .WAV

Changed paths:
    engines/zvision/utility.cpp
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 5f69fd7..42fadc7 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -25,6 +25,8 @@
 #include "common/tokenizer.h"
 
 #include "zvision/utility.h"
+#include "zvision/zvision.h"
+#include "zvision/zork_raw.h"
 
 namespace ZVision {
 
@@ -179,13 +181,6 @@ void dumpEveryResultAction(const Common::String &destFile) {
 	output.close();
 }
 
-/**
- * Gets the name of the file (including extension). Forward or back slashes 
- * are interpreted as directory changes
- *
- * @param fullPath    A full or partial path to the file. Ex: folderOne/folderTwo/file.txt
- * @return            The name of the file without any preceding directories. Ex: file.txt
- */
 Common::String getFileName(const Common::String &fullPath) {
 	Common::StringTokenizer tokenizer(fullPath, "/\\");
 	Common::String token;
@@ -196,4 +191,39 @@ Common::String getFileName(const Common::String &fullPath) {
 	return token;
 }
 
+void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile) {
+	Common::File file;
+	if (!file.open(inputFile))
+		return;
+
+	Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine);
+	
+	Common::DumpFile output;
+	output.open(outputFile);
+
+	output.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
+	output.writeUint32LE(file.size() * 2 + 36);
+	output.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
+	output.writeUint32BE(MKTAG('f', 'm', 't', ' '));
+	output.writeUint32LE(16);
+	output.writeUint16LE(1);
+	uint16 numChannels;
+	if (audioStream->isStereo()) {
+		numChannels = 2;
+		output.writeUint16LE(2);
+	} else {
+		numChannels = 1;
+		output.writeUint16LE(1);
+	}
+	output.writeUint32LE(audioStream->getRate());
+	output.writeUint32LE(audioStream->getRate() * numChannels * 2);
+	output.writeUint16LE(numChannels * 2);
+	output.writeUint16LE(16);
+	output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
+	output.writeUint32LE(file.size() * 2);
+	int16 *buffer = new int16[file.size()];
+	int readBytes = audioStream->readBuffer(buffer, file.size());
+	output.write(buffer, file.size() * 2);
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index dba765b..46f81ef 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -30,6 +30,8 @@
 
 namespace ZVision {
 
+class ZVision;
+
 /**
  * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
  * contents to destFile. destFile is created in the working directory
@@ -73,8 +75,24 @@ void removeDuplicateEntries(Common::Array<T> *container) {
 	}
 }
 
+/**
+ * Gets the name of the file (including extension). Forward or back slashes 
+ * are interpreted as directory changes
+ *
+ * @param fullPath    A full or partial path to the file. Ex: folderOne/folderTwo/file.txt
+ * @return            The name of the file without any preceding directories. Ex: file.txt
+ */
 Common::String getFileName(const Common::String &fullPath);
 
+/**
+ * Converts a ZVision .RAW file to a .WAV
+ * The .WAV will be created in the working directory and will overwrite any existing file
+ *
+ * @param inputFile     The path to the input .RAW file
+ * @param outputFile    The name of the output .WAV file
+ */
+void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile);
+
 } // End of namespace ZVision
 
 #endif


Commit: 8f32592ab9556c57d459be116863d3bb7ac88c72
    https://github.com/scummvm/scummvm/commit/8f32592ab9556c57d459be116863d3bb7ac88c72
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:25-07:00

Commit Message:
ZVISION: Create console command to use the raw2wav function

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index a18da86..ed244c1 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -31,6 +31,7 @@
 #include "zvision/zvision.h"
 #include "zvision/zork_avi_decoder.h"
 #include "zvision/zork_raw.h"
+#include "zvision/utility.h"
 
 namespace ZVision {
 
@@ -38,6 +39,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage));
 	DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
 	DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound));
+	DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -82,4 +84,13 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdRawToWav(int argc, const char **argv) {
+	if (argc != 3) {
+		DebugPrintf("Use raw2wav <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n");
+		return true;
+	}
+
+	convertRawToWav(argv[1], _engine, argv[2]);
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 354051d..cf22c42 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -40,6 +40,7 @@ namespace ZVision {
 		bool cmdLoadImage(int argc, const char **argv);
 		bool cmdLoadVideo(int argc, const char **argv);
 		bool cmdLoadSound(int argc, const char **argv);
+		bool cmdRawToWav(int argc, const char **argv);
 	};
 
 } // End of namespace ZVision


Commit: 1c44fe7afba706400dd8d3c2132f47da4e07ac1e
    https://github.com/scummvm/scummvm/commit/1c44fe7afba706400dd8d3c2132f47da4e07ac1e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:26-07:00

Commit Message:
ZVISION: Fix the error causing distortions in the sound

Changed paths:
    engines/zvision/zork_raw.cpp



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 2ffe8eb..03a35e0 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -73,7 +73,7 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
 }
 
 int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
-	uint16 bytesRead = 0;
+	uint32 bytesRead = 0;
 
 	// 0: Left, 1: Right
 	byte channel = 0;
@@ -114,7 +114,7 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
 		buffer[bytesRead - 1] = (int16)sample;
 
 		index += _stepAdjustmentTable[(encodedSample >> 4) & 7];
-		index = CLIP<uint16>(index, 0, 88);
+		index = CLIP<int16>(index, 0, 88);
 
 		_lastSample[channel].sample = sample;
 		_lastSample[channel].index = index;


Commit: 125a061a9650297d81a76cc8e77033ca099191b0
    https://github.com/scummvm/scummvm/commit/125a061a9650297d81a76cc8e77033ca099191b0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:26-07:00

Commit Message:
ZVISION: Convert to using MKTAG() instead of checking each char individually

Changed paths:
    engines/zvision/image.cpp



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index 981308f..6e6b802 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -42,11 +42,11 @@ void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint
 
 	// Read the magic number
 	// Some files are true TGA, while others are TGZ
-	char fileType[4];
-	file.read(fileType, 4);
+	uint32 fileType;
+	fileType = file.readUint32BE();
 
 	// Check for TGZ files
-	if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'Z' && fileType[3] == '\0') {
+	if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
 		// TGZ files have a header and then Bitmap data that is compressed with LZSS
 		uint32 decompressedSize = file.readSint32LE();
 		uint32 width = file.readSint32LE();


Commit: 47161ef30d8d7350a92fe28a031437abb338732c
    https://github.com/scummvm/scummvm/commit/47161ef30d8d7350a92fe28a031437abb338732c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:27-07:00

Commit Message:
ZVISION: LZSSReadStream - Decompress directly to the destination buffer instead of an intermediate buffer

Changed paths:
    engines/zvision/image.cpp
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index 6e6b802..cacfec3 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -52,9 +52,9 @@ void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint
 		uint32 width = file.readSint32LE();
 		uint32 height = file.readSint32LE();
 
-		LzssReadStream stream(&file, false, decompressedSize);
-		byte *buffer = new byte[stream.currentSize()];
-		stream.read(buffer, stream.currentSize());
+		LzssReadStream stream(&file);
+		byte *buffer = new byte[decompressedSize];
+		stream.read(buffer, decompressedSize);
 
 		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
 	} else {
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 2d7acdb..35c708a 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -26,7 +26,7 @@
 
 namespace ZVision {
 
-LzssReadStream::LzssReadStream(Common::SeekableReadStream *source, bool stream, uint32 decompressedSize)
+LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
 		: _source(source),
 		  // It's convention to set the starting cursor position to blockSize - 16
 		  _windowCursor(0x0FEE),
@@ -34,24 +34,12 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source, bool stream,
 		  _eosFlag(false) {
 	// Clear the window to null
 	memset(_window, 0, _blockSize);
-
-	// Reserve space in the destination buffer
-	// TODO: Make a better guess
-	if (decompressedSize == _npos) {
-		decompressedSize = source->size();
-	}
-	_destination.reserve(decompressedSize);
-
-	if (stream)
-		decompressBytes(_blockSize);
-	else
-		decompressAll();
 }
 
-void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
-	uint32 bytesRead = 0;
+uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) {
+	uint32 destinationCursor = 0;
 
-	while (!_source->eos() && bytesRead <= numberOfBytes) {
+	while (destinationCursor < numberOfBytes) {
 		byte flagbyte = _source->readByte();
 		if (_source->eos())
 			break;
@@ -61,12 +49,11 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
 			if ((flagbyte & mask) == mask)
 			{
 				byte data = _source->readByte();
-				bytesRead++;
 				if (_source->eos())
-					break;
+					return destinationCursor;
 
 				_window[_windowCursor] = data;
-				_destination.push_back(data);
+				destination[destinationCursor++] = data;
 
 				// Increment and wrap the window cursor
 				_windowCursor = (_windowCursor + 1) & 0xFFF;
@@ -74,14 +61,12 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
 			else
 			{
 				byte low = _source->readByte();
-				bytesRead++;
 				if (_source->eos())
-					break;
+					return destinationCursor;
 
 				byte high = _source->readByte();
-				bytesRead++;
 				if (_source->eos())
-					break;
+					return destinationCursor;
 
 				uint16 length = (high & 0xF) + 2;
 				uint16 offset = low | ((high & 0xF0)<<4);
@@ -90,7 +75,7 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
 				{
 					byte temp = _window[(offset + j) & 0xFFF];
 					_window[_windowCursor] = temp;
-					_destination.push_back(temp);
+					destination[destinationCursor++] = temp;
 					_windowCursor = (_windowCursor + 1) & 0xFFF;
 				}
 			};
@@ -98,10 +83,8 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {
 			mask = mask << 1;
 		}
 	}
-}
 
-void LzssReadStream::decompressAll() {
-	decompressBytes(_source->size());
+	return destinationCursor;
 }
 
 bool LzssReadStream::eos() const {
@@ -109,30 +92,13 @@ bool LzssReadStream::eos() const {
 }
 
 uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) {
-	// Check if there are enough bytes available
-	// If not, keep decompressing until we have enough bytes or until we reach EOS
-	while (dataSize > _destination.size() - _readCursor) {
-		// Check if we can read any more data from source
-		if (_source->eos()) {
-			// Shorten the dataSize to what we have left and flag that we're at EOS
-			dataSize = _destination.size() - _readCursor;
-			_eosFlag = true;
-			break;
-		}
-
-		decompressBytes(_blockSize);
-	}
-
-	if (dataSize > 0) {
-		memcpy(dataPtr, _destination.begin() + _readCursor, dataSize);
-		_readCursor += dataSize;
+	uint32 bytesRead = decompressBytes(static_cast<byte *>(dataPtr), dataSize);
+	if (bytesRead < dataSize) {
+		// Flag that we're at EOS
+		_eosFlag = true;
 	}
 
 	return dataSize;
 }
 
-uint32 LzssReadStream::currentSize() const {
-	return _destination.size();
-}
-
 } // End of namespace ZVision
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 142bf9e..0dea25b 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -34,14 +34,11 @@ class LzssReadStream : public Common::ReadStream {
 public:
 	/**
 	 * A class that decompresses LZSS data and implements ReadStream for easy access 
-	 * to the decompiled data. It can either decompress all the data in the beginning 
-	 * or decompress as needed by read().
+	 * to the decompiled data.
 	 *
 	 * @param source              The source data
-	 * @param stream			  Decompress the data as needed (true) or all at once (false)
-	 * @param decompressedSize    The size of the decompressed data. If npos, the class will choose a size and grow as needed
 	 */
-	LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = _npos);
+	LzssReadStream(Common::SeekableReadStream *source);
 
 public:
 	static const uint32 _npos = 0xFFFFFFFFu;
@@ -49,7 +46,6 @@ public:
 
 private:
 	Common::SeekableReadStream *_source;
-	Common::Array<char> _destination;
 	char _window[_blockSize];
 	uint16 _windowCursor;
 	uint32 _readCursor;
@@ -58,7 +54,6 @@ private:
 public:
 	bool eos() const;
 	uint32 read(void *dataPtr, uint32 dataSize);
-	uint32 currentSize() const;
 
 private:
 	/**
@@ -66,9 +61,7 @@ private:
 	 *
 	 * @param numberOfBytes    How many bytes to decompress. This is a count of source bytes, not destination bytes
 	 */
-	void decompressBytes(uint32 numberOfBytes);
-	/** Decompress all of the source stream. */
-	void decompressAll();
+	uint32 decompressBytes(byte* destination, uint32 numberOfBytes);
 };
 
 }


Commit: b316df9e821a7cb27290e8ebed49eb78c2ee5884
    https://github.com/scummvm/scummvm/commit/b316df9e821a7cb27290e8ebed49eb78c2ee5884
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:27-07:00

Commit Message:
ZVISION: Add a return statement for when image load fails

Changed paths:
    engines/zvision/image.cpp



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
index cacfec3..c482381 100644
--- a/engines/zvision/image.cpp
+++ b/engines/zvision/image.cpp
@@ -63,9 +63,10 @@ void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint
 
 		// Decode
 		Graphics::TGADecoder tga;
-		if (!tga.loadStream(file))
+		if (!tga.loadStream(file)) {
 			error("Error while reading TGA image");
-		file.close();
+			return;
+		}
 
 		const Graphics::Surface *tgaSurface = tga.getSurface();
 		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);


Commit: d546e11cf12d90eb246513ccc0be867172f0af96
    https://github.com/scummvm/scummvm/commit/d546e11cf12d90eb246513ccc0be867172f0af96
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:28-07:00

Commit Message:
ZVISION: Fix namespace indentation

Changed paths:
    engines/zvision/console.h



diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index cf22c42..3110d8a 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -27,21 +27,20 @@
 
 namespace ZVision {
 
-	class ZVision;
+class ZVision;
 
-	class Console : public GUI::Debugger {
-	public:
-		Console(ZVision *engine);
-		virtual ~Console() {}
+class Console : public GUI::Debugger {
+public:
+	Console(ZVision *engine);
+	virtual ~Console() {}
 
-	private:
-		ZVision *_engine;
+private:
+	ZVision *_engine;
 
-		bool cmdLoadImage(int argc, const char **argv);
-		bool cmdLoadVideo(int argc, const char **argv);
-		bool cmdLoadSound(int argc, const char **argv);
-		bool cmdRawToWav(int argc, const char **argv);
-	};
+	bool cmdLoadImage(int argc, const char **argv);
+	bool cmdLoadVideo(int argc, const char **argv);
+	bool cmdLoadSound(int argc, const char **argv);
+};
 
 } // End of namespace ZVision
 #endif


Commit: 471364077953509ae7528d3097ca746fe5588f7c
    https://github.com/scummvm/scummvm/commit/471364077953509ae7528d3097ca746fe5588f7c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:29-07:00

Commit Message:
ZVISION: Remove extraneous member variable

Changed paths:
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 35c708a..d169620 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -30,7 +30,6 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
 		: _source(source),
 		  // It's convention to set the starting cursor position to blockSize - 16
 		  _windowCursor(0x0FEE),
-		  _readCursor(0),
 		  _eosFlag(false) {
 	// Clear the window to null
 	memset(_window, 0, _blockSize);
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 0dea25b..b2d6085 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -48,7 +48,6 @@ private:
 	Common::SeekableReadStream *_source;
 	char _window[_blockSize];
 	uint16 _windowCursor;
-	uint32 _readCursor;
 	bool _eosFlag;
 
 public:


Commit: 94000e07811831f1ffdb2575b0cc3513c34a1d36
    https://github.com/scummvm/scummvm/commit/94000e07811831f1ffdb2575b0cc3513c34a1d36
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:29-07:00

Commit Message:
ZVISION: Replace includes with forward declarations

Changed paths:
    engines/zvision/lzss_read_stream.h
    engines/zvision/script_manager.h
    engines/zvision/single_value_container.cpp
    engines/zvision/single_value_container.h
    engines/zvision/utility.cpp
    engines/zvision/utility.h
    engines/zvision/zfs_archive.cpp
    engines/zvision/zfs_archive.h



diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index b2d6085..0814220 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -25,9 +25,12 @@
 
 #include "common/types.h"
 #include "common/stream.h"
-#include "common/memstream.h"
 #include "common/array.h"
 
+namespace Common {
+class SeekableReadStream;
+}
+
 namespace ZVision {
 
 class LzssReadStream : public Common::ReadStream {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 7924eee..2d9bcc3 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -23,14 +23,17 @@
 #ifndef ZVISION_SCRIPT_MANAGER_H
 #define ZVISION_SCRIPT_MANAGER_H
 
-#include "common/str.h"
-#include "common/stream.h"
 #include "common/hashmap.h"
 #include "common/stack.h"
 
 #include "zvision/puzzle.h"
 #include "zvision/control.h"
 
+namespace Common {
+class String;
+class SeekableReadStream;
+}
+
 namespace ZVision {
 
 class ZVision;
diff --git a/engines/zvision/single_value_container.cpp b/engines/zvision/single_value_container.cpp
index 7e27098..0fd758a 100644
--- a/engines/zvision/single_value_container.cpp
+++ b/engines/zvision/single_value_container.cpp
@@ -21,7 +21,9 @@
  */
 
 #include "common/scummsys.h"
+
 #include "common/textconsole.h"
+#include "common/str.h"
 
 #include "zvision/single_value_container.h"
 
diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
index 49c7267..593f11c 100644
--- a/engines/zvision/single_value_container.h
+++ b/engines/zvision/single_value_container.h
@@ -23,7 +23,9 @@
 #ifndef ZVISION_OBJECT_H
 #define ZVISION_OBJECT_H
 
-#include "common/str.h"
+namespace Common {
+class String;
+}
 
 namespace ZVision {
 
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 42fadc7..bf8e5c9 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 
 #include "common/tokenizer.h"
+#include "common/file.h"
 
 #include "zvision/utility.h"
 #include "zvision/zvision.h"
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 46f81ef..e68d0de 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -24,10 +24,12 @@
 #ifndef ZVISION_UTILITY_H
 #define ZVISION_UTILITY_H
 
-#include "common/str.h"
-#include "common/file.h"
 #include "common/array.h"
 
+namespace Common {
+class String;
+}
+
 namespace ZVision {
 
 class ZVision;
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index fbfe3d3..f815d9c 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -22,10 +22,12 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/zfs_archive.h"
 #include "common/hashmap.h"
 #include "common/memstream.h"
 #include "common/debug.h"
+#include "common/file.h"
+
+#include "zvision/zfs_archive.h"
 
 namespace ZVision {
 
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
index cb371f2..e683ac1 100644
--- a/engines/zvision/zfs_archive.h
+++ b/engines/zvision/zfs_archive.h
@@ -24,8 +24,12 @@
 #define ZVISION_ZFS_ARCHIVE_H
 
 #include "common/archive.h"
-#include "common/file.h"
-#include "common/fs.h"
+#include "common/hashmap.h"
+
+
+namespace Common {
+class String;
+}
 
 namespace ZVision {
 
@@ -48,7 +52,7 @@ struct ZfsEntryHeader {
 	uint32 unknown;
 };
 
-typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
+typedef Common::HashMap<Common::String, ZfsEntryHeader*> ZfsEntryHeaderMap;
 
 class ZfsArchive : public Common::Archive {
 public:


Commit: 6d7541a43040ee6791bf0099ddff9645753ac24b
    https://github.com/scummvm/scummvm/commit/6d7541a43040ee6791bf0099ddff9645753ac24b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:30-07:00

Commit Message:
ZVISION: Create RenderManager class and move code from image.cpp

Changed paths:
  A engines/zvision/render_manager.cpp
  A engines/zvision/render_manager.h
  R engines/zvision/image.cpp



diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp
deleted file mode 100644
index c482381..0000000
--- a/engines/zvision/image.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
-
-#include "common/scummsys.h"
-
-#include "common/file.h"
-#include "common/system.h"
-
-#include "graphics/decoders/tga.h"
-
-#include "zvision/zvision.h"
-#include "zvision/lzss_read_stream.h"
-
-namespace ZVision {
-
-void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
-	Common::File file;
-
-	if (!file.open(fileName)) {
-		error("Could not open file %s", fileName.c_str());
-		return;
-	}
-
-	// Read the magic number
-	// Some files are true TGA, while others are TGZ
-	uint32 fileType;
-	fileType = file.readUint32BE();
-
-	// Check for TGZ files
-	if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
-		// TGZ files have a header and then Bitmap data that is compressed with LZSS
-		uint32 decompressedSize = file.readSint32LE();
-		uint32 width = file.readSint32LE();
-		uint32 height = file.readSint32LE();
-
-		LzssReadStream stream(&file);
-		byte *buffer = new byte[decompressedSize];
-		stream.read(buffer, decompressedSize);
-
-		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
-	} else {
-		// Reset the cursor
-		file.seek(0);
-
-		// Decode
-		Graphics::TGADecoder tga;
-		if (!tga.loadStream(file)) {
-			error("Error while reading TGA image");
-			return;
-		}
-
-		const Graphics::Surface *tgaSurface = tga.getSurface();
-		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
-
-		tga.destroy();
-	}
-
-	_needsScreenUpdate = true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
new file mode 100644
index 0000000..671e7c0
--- /dev/null
+++ b/engines/zvision/render_manager.cpp
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/decoders/tga.h"
+
+#include "zvision/render_manager.h"
+#include "zvision/lzss_read_stream.h"
+
+namespace ZVision {
+
+RenderManager::RenderManager(OSystem *system) : _system(system) {}
+
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
+	Common::File file;
+
+	if (!file.open(fileName)) {
+		error("Could not open file %s", fileName.c_str());
+		return;
+	}
+
+	// Read the magic number
+	// Some files are true TGA, while others are TGZ
+	uint32 fileType;
+	fileType = file.readUint32BE();
+
+	// Check for TGZ files
+	if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
+		// TGZ files have a header and then Bitmap data that is compressed with LZSS
+		uint32 decompressedSize = file.readSint32LE();
+		uint32 width = file.readSint32LE();
+		uint32 height = file.readSint32LE();
+
+		LzssReadStream stream(&file);
+		byte *buffer = new byte[decompressedSize];
+		stream.read(buffer, decompressedSize);
+
+		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
+	} else {
+		// Reset the cursor
+		file.seek(0);
+
+		// Decode
+		Graphics::TGADecoder tga;
+		if (!tga.loadStream(file))
+			error("Error while reading TGA image");
+		file.close();
+
+		const Graphics::Surface *tgaSurface = tga.getSurface();
+		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
+
+		tga.destroy();
+	}
+
+	_needsScreenUpdate = true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
new file mode 100644
index 0000000..137ec51
--- /dev/null
+++ b/engines/zvision/render_manager.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.
+ *
+ */
+
+#ifndef ZVISION_RENDER_MANAGER_H
+#define ZVISION_RENDER_MANAGER_H
+
+#include "common/types.h"
+
+class OSystem;
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class RenderManager {
+public:
+	RenderManager(OSystem *system);
+
+public:
+	enum RenderState {
+		PANORAMA,
+		TILT,
+		FLAT
+	};
+
+private:
+	OSystem *_system;
+	RenderState _renderState;
+
+	struct {
+		uint16 fieldOfView;
+		uint16 linearScale;
+	} _panoramaOptions;
+
+	// TODO: See if tilt and panorama need to have separate options
+	struct {
+		uint16 fieldOfView;
+		uint16 linearScale;
+	} _tiltOptions;
+
+	bool _needsScreenUpdate;
+
+public:
+	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: 4bd95987d2119027fa175e08f22d0171f53358c0
    https://github.com/scummvm/scummvm/commit/4bd95987d2119027fa175e08f22d0171f53358c0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:31-07:00

Commit Message:
ZVISION: Convert old code to use RenderManager

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index ed244c1..2b45ed2 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -29,6 +29,7 @@
 
 #include "zvision/console.h"
 #include "zvision/zvision.h"
+#include "zvision/render_manager.h"
 #include "zvision/zork_avi_decoder.h"
 #include "zvision/zork_raw.h"
 #include "zvision/utility.h"
@@ -47,7 +48,7 @@ bool Console::cmdLoadImage(int argc, const char **argv) {
 		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen\n");
 		return true;
 	}
-	_engine->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+	_engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
 
 	return true;
 }
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 3110d8a..05b8f12 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -40,6 +40,7 @@ private:
 	bool cmdLoadImage(int argc, const char **argv);
 	bool cmdLoadVideo(int argc, const char **argv);
 	bool cmdLoadSound(int argc, const char **argv);
+	bool cmdRawToWav(int argc, const char **argv);
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 4ce775d..0e2e027 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -35,6 +35,7 @@
 #include "zvision/zvision.h"
 #include "zvision/console.h"
 #include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
 #include "zvision/zfs_archive.h"
 #include "zvision/detection.h"
 
@@ -73,6 +74,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 
 	// Create managers
 	_scriptManager = new ScriptManager(this);
+	_renderManager = new RenderManager(_system);
 
 	debug("ZVision::ZVision");
 }
@@ -151,6 +153,10 @@ ScriptManager *ZVision::getScriptManager() const {
 	return _scriptManager;
 }
 
+RenderManager *ZVision::getRenderManager() const {
+	return _renderManager;
+}
+
 Common::RandomSource *ZVision::getRandomSource() const {
 	return _rnd;
 }
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 17a7c02..7740dba 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -40,6 +40,7 @@ namespace ZVision {
 struct ZVisionGameDescription;
 class Console;
 class ScriptManager;
+class RenderManager;
  
 // our engine debug channels
 enum {
@@ -65,6 +66,8 @@ private:
 	Common::RandomSource *_rnd;
 	// Managers
 	ScriptManager *_scriptManager;
+	RenderManager *_renderManager;
+
 	// To prevent allocation every time we process events
 	Common::Event _event;
 
@@ -77,10 +80,10 @@ public:
 	Common::Language getLanguage() const;
 	virtual Common::Error run();
 	ScriptManager *getScriptManager() const;
+	RenderManager *getRenderManager() const;
 	Common::RandomSource *getRandomSource() const;
 	ZVisionGameId getGameId() const;
 
-	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
 	void startVideo(Video::VideoDecoder *videoDecoder);
 	void continueVideo();
 


Commit: 2bfefd969128b0a33afc8beccf52a4e9f6e4840f
    https://github.com/scummvm/scummvm/commit/2bfefd969128b0a33afc8beccf52a4e9f6e4840f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:32-07:00

Commit Message:
ZVISION: Remove extraneous file

Changed paths:
  R engines/zvision/graphics.cpp



diff --git a/engines/zvision/graphics.cpp b/engines/zvision/graphics.cpp
deleted file mode 100644
index 610960d..0000000
--- a/engines/zvision/graphics.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/zvision.h"
-
-namespace ZVision {
-
-} // End of namespace ZVision


Commit: b3eb48996af2236baf89dd5afd6cfeef1b5e86bd
    https://github.com/scummvm/scummvm/commit/b3eb48996af2236baf89dd5afd6cfeef1b5e86bd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:32-07:00

Commit Message:
ZVISION: Fix memory leaks

Changed paths:
    engines/zvision/events.cpp
    engines/zvision/render_manager.cpp
    engines/zvision/utility.cpp
    engines/zvision/video.cpp



diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index a3d6b6b..afa2d95 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -65,7 +65,7 @@ void ZVision::processEvents() {
 					initGraphics(_width, _height, true, &_pixelFormat);
 					delete _currentVideo;
 					_currentVideo = 0;
-					delete _scaledVideoFrameBuffer;
+					delete[] _scaledVideoFrameBuffer;
 					_scaledVideoFrameBuffer = 0;
 				}
 				break;
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 671e7c0..6d3f7c6 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -59,6 +59,8 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 		stream.read(buffer, decompressedSize);
 
 		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
+
+		delete[] buffer;
 	} else {
 		// Reset the cursor
 		file.seek(0);
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index bf8e5c9..fa29fe6 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -225,6 +225,8 @@ void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Com
 	int16 *buffer = new int16[file.size()];
 	int readBytes = audioStream->readBuffer(buffer, file.size());
 	output.write(buffer, file.size() * 2);
+
+	delete[] buffer;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 0cca486..0428090 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -118,7 +118,7 @@ void ZVision::continueVideo() {
 		initGraphics(_width, _height, true, &_pixelFormat);
 		delete _currentVideo;
 		_currentVideo = 0;
-		delete _scaledVideoFrameBuffer;
+		delete[] _scaledVideoFrameBuffer;
 		_scaledVideoFrameBuffer = 0;
 	}
 


Commit: 9e6b2dfc12706f4b367fedf951759c8be0ab5e90
    https://github.com/scummvm/scummvm/commit/9e6b2dfc12706f4b367fedf951759c8be0ab5e90
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:33-07:00

Commit Message:
ZVISION: Create member function for creating a panorama look up table

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 6d3f7c6..2a8ed12 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -24,6 +24,7 @@
 
 #include "common/file.h"
 #include "common/system.h"
+#include "common/rect.h"
 
 #include "graphics/decoders/tga.h"
 
@@ -32,7 +33,12 @@
 
 namespace ZVision {
 
-RenderManager::RenderManager(OSystem *system) : _system(system) {}
+RenderManager::RenderManager(OSystem *system, const int width, const int height)
+	: _system(system),
+	  _width(width),
+	  _height(height),
+	  _renderTable(width, height) {
+}
 
 void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
 	Common::File file;
@@ -80,4 +86,40 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 	_needsScreenUpdate = true;
 }
 
+void RenderManager::generatePanoramaLookupTable() {
+	float fieldOfView = _panoramaOptions.fieldOfView;
+	float scale = _panoramaOptions.linearScale;
+	_renderTable.clear();
+
+	double halfWidth = (double)_width / 2.0;
+	double halfHeight = (double)_height / 2.0;
+
+	double fovRadians = (fieldOfView * 3.14159265 / 180.0);
+	double halfHeightOverTan = halfHeight / tan(fovRadians);
+	double tanOverHalfHeight = tan(fovRadians) / halfHeight;
+
+	for (int32 x = 0; x < _width; x++) {
+		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
+		double xPos = (double)x - halfWidth + 0.01;
+
+		double tempX = atan(xPos*tanOverHalfHeight);
+		double scaledX = scale * halfHeightOverTan * tempX;
+		double nn = cos(tempX);
+		double newHalfWidth = halfHeight * nn * halfHeightOverTan * tanOverHalfHeight*2.0;
+
+		int32 newX = floor(scaledX);// + half_w);
+
+		double yScale = newHalfWidth / (double)_height;
+		double et2 = ((double)_height - newHalfWidth) / 2.0;
+
+		for (int32 y = 0; y < _height; y++) {
+			double et1 = (double)y*yScale;
+
+			_renderTable(x, y).x = newX; //pixel index
+
+			int32 newY = floor(et2 + et1);
+			_renderTable(x, y).y = newY; //pixel index
+		}
+	}
+}
 } // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 137ec51..e481c26 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -25,17 +25,20 @@
 
 #include "common/types.h"
 
+#include "zvision/dense_2d_array.h"
+
 class OSystem;
 
 namespace Common {
 class String;
+class Point;
 }
 
 namespace ZVision {
 
 class RenderManager {
 public:
-	RenderManager(OSystem *system);
+	RenderManager(OSystem *system, const int width, const int height);
 
 public:
 	enum RenderState {
@@ -46,6 +49,8 @@ public:
 
 private:
 	OSystem *_system;
+	const int _width;
+	const int _height;
 	RenderState _renderState;
 
 	struct {
@@ -59,10 +64,13 @@ private:
 		uint16 linearScale;
 	} _tiltOptions;
 
+	Dense2DArray<Common::Point> _renderTable;
+
 	bool _needsScreenUpdate;
 
 public:
 	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
+	void generatePanoramaLookupTable();
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0e2e027..57c9dea 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -74,7 +74,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 
 	// Create managers
 	_scriptManager = new ScriptManager(this);
-	_renderManager = new RenderManager(_system);
+	_renderManager = new RenderManager(_system, _width, _height);
 
 	debug("ZVision::ZVision");
 }


Commit: cd51b646f39fb826f5d618c6d61c996844f628dd
    https://github.com/scummvm/scummvm/commit/cd51b646f39fb826f5d618c6d61c996844f628dd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:33-07:00

Commit Message:
ZVISION: Create a class for handling all render table logic

Aka, creating the lookup tables, storing the current render state, and eventually doing
the image mutations.

Changed paths:
  A engines/zvision/render_table.cpp
  A engines/zvision/render_table.h



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
new file mode 100644
index 0000000..1baf951
--- /dev/null
+++ b/engines/zvision/render_table.cpp
@@ -0,0 +1,95 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/render_table.h"
+
+
+namespace ZVision {
+
+RenderTable::RenderTable(uint32 numRows, uint32 numColumns)
+		: _numRows(numRows),
+		  _numColumns(numColumns) {
+	assert(numRows != 0 && numColumns != 0);
+
+	_internalBuffer = new Common::Point[numRows * numColumns];
+}
+
+RenderTable::~RenderTable() {
+	delete[] _internalBuffer;
+}
+
+void RenderTable::setRenderState(RenderState newState) {
+	_renderState = newState;
+
+	switch (newState) {
+	case PANORAMA:
+		_panoramaOptions.fieldOfView = 60;
+		_panoramaOptions.linearScale = 1;
+		generatePanoramaLookupTable();
+		break;
+	case TILT:
+		generateTiltLookupTable();
+		break;
+	case FLAT:
+		// Intentionally left empty
+		break;
+	}
+}
+
+void RenderTable::generatePanoramaLookupTable() {
+	float fieldOfView = _panoramaOptions.fieldOfView;
+	float scale = _panoramaOptions.linearScale;
+
+	memset(_internalBuffer, 0, _numRows * _numColumns * sizeof(uint16));
+
+	float halfWidth = (float)_numColumns / 2.0f;
+	float halfHeight = (float)_numRows / 2.0f;
+
+	float fovRadians = (fieldOfView * M_PI / 180.0f);
+	float halfHeightOverTan = halfHeight / tan(fovRadians);
+	float tanOverHalfHeight = tan(fovRadians) / halfHeight;
+
+	for (uint32 x = 0; x < _numRows; x++) {
+		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
+		float xPos = (float)x - halfWidth + 0.01;
+		float tempX = atan(xPos*tanOverHalfHeight);
+
+		int32 newX = floor(scale * halfHeightOverTan * tempX);// + half_w);
+		float cosX = cos(tempX);
+
+		for (uint32 y = 0; y < _numColumns; y++) {
+			int32 newY = floor(halfHeight + (y - halfHeight) * cosX);
+
+			uint32 index = x * _numColumns + y;
+			_internalBuffer[index].x = newX; //pixel index
+			_internalBuffer[index].y = newY; //pixel index
+		}
+	}
+}
+
+void RenderTable::generateTiltLookupTable() {
+
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
new file mode 100644
index 0000000..9d54551
--- /dev/null
+++ b/engines/zvision/render_table.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_RENDER_TABLE_H
+#define ZVISION_RENDER_TABLE_H
+
+#include "common/types.h"
+#include "common/rect.h"
+
+namespace ZVision {
+
+class RenderTable {
+public:
+	RenderTable(uint32 numRows, uint32 numColumns);
+	~RenderTable();
+
+public:
+	enum RenderState {
+		PANORAMA,
+		TILT,
+		FLAT
+	};
+
+private:
+	uint32 _numColumns, _numRows;
+	Common::Point *_internalBuffer;
+	RenderState _renderState;
+
+	struct {
+		uint16 fieldOfView;
+		uint16 linearScale;
+	} _panoramaOptions;
+
+	// TODO: See if tilt and panorama need to have separate options
+	struct {
+		uint16 fieldOfView;
+		uint16 linearScale;
+	} _tiltOptions;
+
+public:
+	void setRenderState(RenderState newState);
+
+private:
+	void generatePanoramaLookupTable();
+	void generateTiltLookupTable();
+};
+
+} // End of namesapce ZVision
+
+#endif


Commit: ed4490730902780923bf1e91ed3617d56efb7c24
    https://github.com/scummvm/scummvm/commit/ed4490730902780923bf1e91ed3617d56efb7c24
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:34-07:00

Commit Message:
ZVISION: Move rendering logic from ZVision class to RenderManager class

Changed paths:
    engines/zvision/events.cpp
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h
    engines/zvision/video.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index afa2d95..a01ea74 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -27,6 +27,7 @@
 #include "common/events.h"
 #include "engines/util.h"
 
+#include "zvision/render_manager.h"
 
 namespace ZVision {
 
@@ -61,13 +62,9 @@ void ZVision::processEvents() {
 					quitGame();
 				break;
 			case Common::KEYCODE_ESCAPE:
-				if (_currentVideo != 0) {
-					initGraphics(_width, _height, true, &_pixelFormat);
-					delete _currentVideo;
-					_currentVideo = 0;
-					delete[] _scaledVideoFrameBuffer;
-					_scaledVideoFrameBuffer = 0;
-				}
+				if (_renderManager->isVideoPlaying())
+					_renderManager->cancelVideo();
+
 				break;
 			default:
 				break;
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 2a8ed12..8c3d37a 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -24,8 +24,8 @@
 
 #include "common/file.h"
 #include "common/system.h"
-#include "common/rect.h"
 
+#include "engines/util.h"
 #include "graphics/decoders/tga.h"
 
 #include "zvision/render_manager.h"
@@ -37,9 +37,29 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
 	: _system(system),
 	  _width(width),
 	  _height(height),
+	  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
+	  _currentVideo(0),
+	  _scaledVideoFrameBuffer(0),
 	  _renderTable(width, height) {
 }
 
+/**
+ * Initialize graphics
+ */
+void RenderManager::initialize() {
+	initGraphics(_width, _height, true, &_pixelFormat);
+}
+
+void RenderManager::updateScreen(bool isConsoleActive) {
+	if (_currentVideo != 0)
+		continueVideo();
+
+	if (_needsScreenUpdate || isConsoleActive) {
+		_system->updateScreen();
+		_needsScreenUpdate = false;
+	}
+}
+
 void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
 	Common::File file;
 
@@ -86,40 +106,8 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 	_needsScreenUpdate = true;
 }
 
-void RenderManager::generatePanoramaLookupTable() {
-	float fieldOfView = _panoramaOptions.fieldOfView;
-	float scale = _panoramaOptions.linearScale;
-	_renderTable.clear();
-
-	double halfWidth = (double)_width / 2.0;
-	double halfHeight = (double)_height / 2.0;
-
-	double fovRadians = (fieldOfView * 3.14159265 / 180.0);
-	double halfHeightOverTan = halfHeight / tan(fovRadians);
-	double tanOverHalfHeight = tan(fovRadians) / halfHeight;
-
-	for (int32 x = 0; x < _width; x++) {
-		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
-		double xPos = (double)x - halfWidth + 0.01;
-
-		double tempX = atan(xPos*tanOverHalfHeight);
-		double scaledX = scale * halfHeightOverTan * tempX;
-		double nn = cos(tempX);
-		double newHalfWidth = halfHeight * nn * halfHeightOverTan * tanOverHalfHeight*2.0;
-
-		int32 newX = floor(scaledX);// + half_w);
-
-		double yScale = newHalfWidth / (double)_height;
-		double et2 = ((double)_height - newHalfWidth) / 2.0;
-
-		for (int32 y = 0; y < _height; y++) {
-			double et1 = (double)y*yScale;
-
-			_renderTable(x, y).x = newX; //pixel index
-
-			int32 newY = floor(et2 + et1);
-			_renderTable(x, y).y = newY; //pixel index
-		}
-	}
+void RenderManager::setRenderState(RenderTable::RenderState state) {
+	_renderTable.setRenderState(state);
 }
+
 } // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index e481c26..f2f1dd7 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -24,14 +24,20 @@
 #define ZVISION_RENDER_MANAGER_H
 
 #include "common/types.h"
+#include "common/rect.h"
 
-#include "zvision/dense_2d_array.h"
+#include "graphics/pixelformat.h"
+
+#include "zvision/render_table.h"
 
 class OSystem;
 
 namespace Common {
 class String;
-class Point;
+}
+
+namespace Video {
+class VideoDecoder;
 }
 
 namespace ZVision {
@@ -40,37 +46,62 @@ class RenderManager {
 public:
 	RenderManager(OSystem *system, const int width, const int height);
 
-public:
-	enum RenderState {
-		PANORAMA,
-		TILT,
-		FLAT
-	};
-
 private:
 	OSystem *_system;
 	const int _width;
 	const int _height;
-	RenderState _renderState;
-
-	struct {
-		uint16 fieldOfView;
-		uint16 linearScale;
-	} _panoramaOptions;
+	const Graphics::PixelFormat _pixelFormat;
+	RenderTable _renderTable;
 
-	// TODO: See if tilt and panorama need to have separate options
-	struct {
-		uint16 fieldOfView;
-		uint16 linearScale;
-	} _tiltOptions;
-
-	Dense2DArray<Common::Point> _renderTable;
+	Video::VideoDecoder *_currentVideo;
+	byte *_scaledVideoFrameBuffer;
 
 	bool _needsScreenUpdate;
 
 public:
+	void initialize();
+	void updateScreen(bool isConsoleActive);
+
+	/**
+	 * Start a video playing. It will also load the first frame of the video.
+	 *
+	 * @param videoDecoder    The video to play
+	 */
+	void startVideo(Video::VideoDecoder *videoDecoder);
+	/**
+	 * @return    Is a video currently being played
+	 */
+	bool isVideoPlaying() { return _currentVideo == 0; }
+	/**
+	 * Cancels a video prematurely. Any sound remaining in the queue will continue to play.
+	 * The last frame of the video will remain on the screen until something else overwrites it
+	 */
+	void cancelVideo();
+
+	/**
+	 * Blits the image to the screen. Actual screen updates won't happen until the end of the frame.
+	 * The image will be clipped to fit inside the window.
+	 *
+	 * @param fileName                   Name of the image file
+	 * @param x                          X position where the image should be put
+	 * @param y                          Y position where the image should be put
+	 */
 	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
-	void generatePanoramaLookupTable();
+
+	/**
+	 * Set how the frame should be rendered
+	 *
+	 * @param state    One of the RenderStates
+	 */
+	void setRenderState(RenderTable::RenderState state);
+
+	bool needsScreenUpdate() { return _needsScreenUpdate; };
+
+private:
+	/**
+	 * Checks the time since the last video frame, and blits the next frame to the screen
+	 */
+	void continueVideo();
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 0428090..c0b575b 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -23,11 +23,11 @@
 #include "common/scummsys.h"
 
 #include "common/system.h"
+#include "video/video_decoder.h"
 #include "engines/util.h"
-
 #include "graphics/surface.h"
 
-#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
 
 
 namespace ZVision {
@@ -71,7 +71,7 @@ void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte b
 	}
 }
 
-void ZVision::startVideo(Video::VideoDecoder *videoDecoder) {
+void RenderManager::startVideo(Video::VideoDecoder *videoDecoder) {
 	if (!videoDecoder)
 		return;
 
@@ -89,12 +89,7 @@ void ZVision::startVideo(Video::VideoDecoder *videoDecoder) {
 	continueVideo();
 }
 
-void ZVision::continueVideo() {
-	if (_currentVideo == 0) {
-		warning("No video loaded. Nothing to continue");
-		return;
-	}
-
+void RenderManager::continueVideo() {
 	byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel;
 	uint16 width = _currentVideo->getWidth();
 	uint16 height = _currentVideo->getHeight();
@@ -115,13 +110,16 @@ void ZVision::continueVideo() {
 			}
 		}
 	} else {
-		initGraphics(_width, _height, true, &_pixelFormat);
-		delete _currentVideo;
-		_currentVideo = 0;
-		delete[] _scaledVideoFrameBuffer;
-		_scaledVideoFrameBuffer = 0;
+		cancelVideo();
 	}
+}
 
+void RenderManager::cancelVideo() {
+	initGraphics(_width, _height, true, &_pixelFormat);
+	delete _currentVideo;
+	_currentVideo = 0;
+	delete[] _scaledVideoFrameBuffer;
+	_scaledVideoFrameBuffer = 0;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 57c9dea..8cd7343 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -46,9 +46,6 @@ namespace ZVision {
 ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 		: Engine(syst),
 		  _gameDescription(gameDesc),
-		  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
-		  _currentVideo(0),
-		  _scaledVideoFrameBuffer(0),
 		  _width(640),
 		  _height(480) {
 	// Put your engine in a sane state, but do nothing big yet;
@@ -104,7 +101,7 @@ void ZVision::initialize() {
 		SearchMan.add(name, archive);
 	}
 
-	initGraphics(_width, _height, true, &_pixelFormat);
+	_renderManager->initialize();
 
 	_scriptManager->initialize();
 
@@ -127,19 +124,13 @@ Common::Error ZVision::run() {
 		uint32 deltaTime = currentTime - lastTime;
 		lastTime = currentTime;
 
-		if (_currentVideo != 0)
-			continueVideo();
-		else {
-			_scriptManager->updateNodes(deltaTime);
-			_scriptManager->checkPuzzleCriteria();
-		}
-
-		if (_needsScreenUpdate || _console->isActive()) {
-			_system->updateScreen();
-			_needsScreenUpdate = false;
-		}
+		_scriptManager->updateNodes(deltaTime);
+		_scriptManager->checkPuzzleCriteria();
+
+		// Render a frame
+		_renderManager->updateScreen(_console->isActive());
 		
-		// Calculate the frame delay based off a desired frame rate
+		// Calculate the frame delay based off a desired frame time
 		int delay = desiredFrameTime - (currentTime - _system->getMillis());
 		// Ensure non-negative
 		delay = delay < 0 ? 0 : delay;
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 7740dba..2e6ec11 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -27,8 +27,6 @@
 #include "common/random.h"
 #include "common/events.h"
 
-#include "video/video_decoder.h"
-
 #include "engines/engine.h"
 
 #include "zvision/detection.h"
@@ -58,7 +56,6 @@ public:
 private:
 	Console *_console;
 	const ZVisionGameDescription *_gameDescription;
-	const Graphics::PixelFormat _pixelFormat;
 	const int _width;
 	const int _height;
 
@@ -71,10 +68,6 @@ private:
 	// To prevent allocation every time we process events
 	Common::Event _event;
 
-	bool _needsScreenUpdate;
-
-	Video::VideoDecoder *_currentVideo;
-	byte *_scaledVideoFrameBuffer;
 public:
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;
@@ -84,9 +77,6 @@ public:
 	Common::RandomSource *getRandomSource() const;
 	ZVisionGameId getGameId() const;
 
-	void startVideo(Video::VideoDecoder *videoDecoder);
-	void continueVideo();
-
 private:
 	void initialize();
 


Commit: de2e7fd144622436429da2af79e155724af49d46
    https://github.com/scummvm/scummvm/commit/de2e7fd144622436429da2af79e155724af49d46
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:35-07:00

Commit Message:
ZVISION: Convert error() to warning()

I did not realize the intended behavior of error() is to close the application

Changed paths:
    engines/zvision/render_manager.cpp



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 8c3d37a..b2c9e29 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -64,7 +64,7 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 	Common::File file;
 
 	if (!file.open(fileName)) {
-		error("Could not open file %s", fileName.c_str());
+		warning("Could not open file %s", fileName.c_str());
 		return;
 	}
 
@@ -94,7 +94,7 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 		// Decode
 		Graphics::TGADecoder tga;
 		if (!tga.loadStream(file))
-			error("Error while reading TGA image");
+			warning("Error while reading TGA image");
 		file.close();
 
 		const Graphics::Surface *tgaSurface = tga.getSurface();


Commit: 88934cd5d01c20c4add55c81277923f481674176
    https://github.com/scummvm/scummvm/commit/88934cd5d01c20c4add55c81277923f481674176
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:35-07:00

Commit Message:
ZVISION: Convert console code to use RenderManager and add method for setRenderState

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 2b45ed2..687be8f 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -41,6 +41,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
 	DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound));
 	DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
+	DCmd_Register("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -61,7 +62,7 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
 
 	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
 	if (videoDecoder && videoDecoder->loadFile(argv[1])) {
-		_engine->startVideo(videoDecoder);
+		_engine->getRenderManager()->startVideo(videoDecoder);
 	}
 
 	return true;
@@ -92,6 +93,27 @@ bool Console::cmdRawToWav(int argc, const char **argv) {
 	}
 
 	convertRawToWav(argv[1], _engine, argv[2]);
+	return true;
+}
+
+bool Console::cmdSetRenderState(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+		return true;
+	}
+
+	Common::String renderState(argv[1]);
+
+	if (renderState.matchString("panorama", true))
+		_engine->getRenderManager()->setRenderState(RenderTable::PANORAMA);
+	else if (renderState.matchString("tilt", true))
+		_engine->getRenderManager()->setRenderState(RenderTable::TILT);
+	else if (renderState.matchString("flat", true))
+		_engine->getRenderManager()->setRenderState(RenderTable::FLAT);
+	else
+		DebugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+
+	return true;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 05b8f12..e293703 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -41,6 +41,7 @@ private:
 	bool cmdLoadVideo(int argc, const char **argv);
 	bool cmdLoadSound(int argc, const char **argv);
 	bool cmdRawToWav(int argc, const char **argv);
+	bool cmdSetRenderState(int argc, const char **argv);
 };
 
 } // End of namespace ZVision


Commit: 73f02759f914327732bac2f1a750f3a95efe17ce
    https://github.com/scummvm/scummvm/commit/73f02759f914327732bac2f1a750f3a95efe17ce
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:36-07:00

Commit Message:
ZVISION: Remove supurflouous 'const' and add 'inline'

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index b3831d4..06c228d 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -68,7 +68,7 @@ struct Puzzle {
 	// Used by the ScriptManager to allow unique-ification of _referenceTable
 	// The unique-ification is done by sorting, then iterating and removing duplicates
 	// The sort uses operator<
-	const bool operator<(const Puzzle &other) const {
+	inline bool operator<(const Puzzle &other) const {
 		return key < other.key;
 	}
 };


Commit: df2e78e6f85c4c519e61985febcc3d70085202f0
    https://github.com/scummvm/scummvm/commit/df2e78e6f85c4c519e61985febcc3d70085202f0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:37-07:00

Commit Message:
ZVISION: Remove variable used for debugging purposes

Changed paths:
    engines/zvision/utility.cpp



diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index fa29fe6..2942a35 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -223,7 +223,7 @@ void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Com
 	output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
 	output.writeUint32LE(file.size() * 2);
 	int16 *buffer = new int16[file.size()];
-	int readBytes = audioStream->readBuffer(buffer, file.size());
+	audioStream->readBuffer(buffer, file.size());
 	output.write(buffer, file.size() * 2);
 
 	delete[] buffer;


Commit: 65a08c71c6912ec0bcf20987652f7bd5d50a7791
    https://github.com/scummvm/scummvm/commit/65a08c71c6912ec0bcf20987652f7bd5d50a7791
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:37-07:00

Commit Message:
ZVISION: Fix unsigned/signed compiler warning

Changed paths:
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index e68d0de..58a7ec3 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -70,7 +70,7 @@ template<class T>
 void removeDuplicateEntries(Common::Array<T> *container) {
 	Common::sort(container->front(), container->back());
 
-	for (int i = 0; i < container->size(); i++) {
+	for (uint32 i = 0; i < container->size(); i++) {
 		while (container[i] == container[i +1]) {
 			container->remove_at(i + 1);
 		}


Commit: 364e9d659cf62566611921c3b2abceb2d97e2632
    https://github.com/scummvm/scummvm/commit/364e9d659cf62566611921c3b2abceb2d97e2632
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:38-07:00

Commit Message:
ZVISION: Force all files to be registered with SearchMan as 'flat'

There are 10 file name conflicts as a result, but the conflicts are byte identical.

Changed paths:
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 8cd7343..b79ecb4 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -56,11 +56,11 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
  
 	// However this is the place to specify all default directories
 	const Common::FSNode gameDataDir(ConfMan.get("path"));
-	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4);
-	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4);
-	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4);
-	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");
-	SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");
+	// TODO: There are 10 file clashes when we flatten the directories. From a quick look, the files are exactly the same, so it shouldn't matter. But I'm noting it here just in-case it does become a problem.
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4, true);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4, true);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4, true);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
  
 	// Here is the right place to set up the engine specific debug channels
 	//DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");


Commit: 2349fcfd3170e84d9ec2dd95bd7180fcaa0752e7
    https://github.com/scummvm/scummvm/commit/2349fcfd3170e84d9ec2dd95bd7180fcaa0752e7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:39-07:00

Commit Message:
ZVISION: Modify renderImageToScreen to take into account the current RenderState

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b2c9e29..183f823 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -60,7 +60,45 @@ void RenderManager::updateScreen(bool isConsoleActive) {
 	}
 }
 
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
+void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+	// Panoramas are transposed
+	// The actual data is transposed in the RenderTable lookup
+	if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+		uint32 temp = imageHeight;
+		imageHeight = imageWidth;
+		imageWidth = temp;
+	}
+	
+	// Check if we truly want a subRect of the image
+	if (subRectangle.isEmpty())
+		subRectangle = Common::Rect(imageWidth, imageHeight);
+
+	// Clip to image bounds
+	subRectangle.clip(imageWidth, imageHeight);
+	// Clip destRect to screen bounds
+	Common::Rect destRect(destinationX, destinationY, destinationX + subRectangle.width(), destinationY + subRectangle.height());
+	destRect.clip(_width, _height);
+	// Clip subRect to screen bounds
+	subRectangle.translate(destRect.left - destinationX, destRect.top - destinationY);
+	subRectangle.setWidth(destRect.width());
+	subRectangle.setHeight(destRect.height());
+
+	// Check for validity
+	if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
+		return;
+
+	if (_renderTable.getRenderState() == RenderTable::FLAT) {
+		_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
+	} else {
+		uint16 *destBuffer = new uint16[destRect.width() * destRect.height()];
+		_renderTable.mutateImage((uint16 *)buffer, destBuffer, horizontalPitch, subRectangle);
+
+		_system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left, destRect.top, destRect.width(), destRect.height());
+		delete[] destBuffer;
+	}
+}
+
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
 	Common::File file;
 
 	if (!file.open(fileName)) {
@@ -77,15 +115,16 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 	if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
 		// TGZ files have a header and then Bitmap data that is compressed with LZSS
 		uint32 decompressedSize = file.readSint32LE();
-		uint32 width = file.readSint32LE();
-		uint32 height = file.readSint32LE();
+		uint32 imageWidth = file.readSint32LE();
+		uint32 imageHeight = file.readSint32LE();
 
 		LzssReadStream stream(&file);
 		byte *buffer = new byte[decompressedSize];
 		stream.read(buffer, decompressedSize);
 
-		_system->copyRectToScreen(buffer, width * 2, x, y, width, height);
+		uint32 horizontalPitch = imageWidth * sizeof(uint16);
 
+		renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle);
 		delete[] buffer;
 	} else {
 		// Reset the cursor
@@ -93,12 +132,13 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
 
 		// Decode
 		Graphics::TGADecoder tga;
-		if (!tga.loadStream(file))
+		if (!tga.loadStream(file)) {
 			warning("Error while reading TGA image");
-		file.close();
+			return;
+		}
 
 		const Graphics::Surface *tgaSurface = tga.getSurface();
-		_system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h);
+		renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle);		
 
 		tga.destroy();
 	}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index f2f1dd7..db00888 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -79,14 +79,15 @@ public:
 	void cancelVideo();
 
 	/**
-	 * Blits the image to the screen. Actual screen updates won't happen until the end of the frame.
+	 * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
 	 * The image will be clipped to fit inside the window.
 	 *
-	 * @param fileName                   Name of the image file
-	 * @param x                          X position where the image should be put
-	 * @param y                          Y position where the image should be put
+	 * @param fileName        Name of the image file
+	 * @param destinationX    X position where the image should be put
+	 * @param destinationY    Y position where the image should be put
+	 * @param subRectangle    The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
 	 */
-	void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
+	void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
 
 	/**
 	 * Set how the frame should be rendered
@@ -102,6 +103,8 @@ private:
 	 * Checks the time since the last video frame, and blits the next frame to the screen
 	 */
 	void continueVideo();
+
+	void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle);
 };
 
 } // End of namespace ZVision


Commit: 3d223e2123672e00ccc38c2fd3d33dbe814d7156
    https://github.com/scummvm/scummvm/commit/3d223e2123672e00ccc38c2fd3d33dbe814d7156
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:39-07:00

Commit Message:
ZVISION: Modify the RenderTable panorama math to account for panoramas being transposed

Changed paths:
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 1baf951..3743c42 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -29,7 +29,8 @@ namespace ZVision {
 
 RenderTable::RenderTable(uint32 numRows, uint32 numColumns)
 		: _numRows(numRows),
-		  _numColumns(numColumns) {
+		  _numColumns(numColumns),
+		  _renderState(RenderState::FLAT) {
 	assert(numRows != 0 && numColumns != 0);
 
 	_internalBuffer = new Common::Point[numRows * numColumns];
@@ -57,6 +58,21 @@ void RenderTable::setRenderState(RenderState newState) {
 	}
 }
 
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 horizontalPitch, Common::Rect subRectangle) {
+	uint32 imageWidth = horizontalPitch / 2;
+
+	for (int y = subRectangle.top; y < subRectangle.bottom; y++) {
+		uint32 normalizedY = y - subRectangle.top;
+		for (int x = subRectangle.left; x < subRectangle.right; x++) {
+			uint32 normalizedX = x - subRectangle.left;
+
+			uint32 index = y * _numColumns + x;
+			uint32 sourceIndex = _internalBuffer[index].y * imageWidth + _internalBuffer[index].x;
+			destBuffer[normalizedY * subRectangle.width() + normalizedX] = sourceBuffer[sourceIndex];
+		}
+	}
+}
+
 void RenderTable::generatePanoramaLookupTable() {
 	float fieldOfView = _panoramaOptions.fieldOfView;
 	float scale = _panoramaOptions.linearScale;
@@ -70,20 +86,23 @@ void RenderTable::generatePanoramaLookupTable() {
 	float halfHeightOverTan = halfHeight / tan(fovRadians);
 	float tanOverHalfHeight = tan(fovRadians) / halfHeight;
 
-	for (uint32 x = 0; x < _numRows; x++) {
+	// TODO: Change the algorithm to write a whole row at a time instead of a whole column at a time. AKA: for(y) { for(x) {}} instead of for(x) { for(y) {}}
+	for (uint32 x = 0; x < _numColumns; x++) {
 		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
-		float xPos = (float)x - halfWidth + 0.01;
-		float tempX = atan(xPos*tanOverHalfHeight);
+		float temp = atan(tanOverHalfHeight * ((float)x - halfWidth + 0.01f));
 
-		int32 newX = floor(scale * halfHeightOverTan * tempX);// + half_w);
-		float cosX = cos(tempX);
+		int32 newX = floor((halfHeightOverTan * scale * temp) + halfWidth);
+		float cosX = cos(temp);
 
-		for (uint32 y = 0; y < _numColumns; y++) {
+		for (uint32 y = 0; y < _numRows; y++) {
 			int32 newY = floor(halfHeight + (y - halfHeight) * cosX);
 
-			uint32 index = x * _numColumns + y;
-			_internalBuffer[index].x = newX; //pixel index
-			_internalBuffer[index].y = newY; //pixel index
+			// Panorama images are transposed. Rather than trying to transpose the source, we know 
+			// they will be mutated by this table. Therefore we can swap the axes here
+			uint32 index = y * _numColumns + x;
+
+			_internalBuffer[index].x = newY; //pixel index
+			_internalBuffer[index].y = newX; //pixel index
 		}
 	}
 }
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 9d54551..fca7681 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -57,13 +57,15 @@ private:
 	} _tiltOptions;
 
 public:
+	RenderState getRenderState() { return _renderState; }
 	void setRenderState(RenderState newState);
+	void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 horizontalPitch, Common::Rect subRectangle);
 
 private:
 	void generatePanoramaLookupTable();
 	void generateTiltLookupTable();
 };
 
-} // End of namesapce ZVision
+} // End of namespace ZVision
 
 #endif


Commit: c8359ad56ca4bf84ac1110ef1ceccbc9d4dc97dd
    https://github.com/scummvm/scummvm/commit/c8359ad56ca4bf84ac1110ef1ceccbc9d4dc97dd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:40-07:00

Commit Message:
ZVISION: Modify loadImage console command to account for new render options

Changed paths:
    engines/zvision/console.cpp



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 687be8f..bfe2609 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -45,11 +45,14 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
-	if (argc != 4) {
-		DebugPrintf("Use loadimage <fileName> <x> <y> to load an image to the screen\n");
+	if (argc == 4)
+		_engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+	else if (argc == 8)
+		_engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]), Common::Rect(atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), atoi(argv[7])));
+	else {
+		DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> [ <subRectX1> <subRectY2> <subRectX2> <subRectY2> ] to load an image to the screen\n");
 		return true;
 	}
-	_engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
 
 	return true;
 }


Commit: 34b3a788981a94830023946dcc45bc6a1e028805
    https://github.com/scummvm/scummvm/commit/34b3a788981a94830023946dcc45bc6a1e028805
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:41-07:00

Commit Message:
ZVISION: Fix error causing image discontinutities

The width and height were swapped when passed to the class constructor.

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 3743c42..388dc85 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -27,7 +27,7 @@
 
 namespace ZVision {
 
-RenderTable::RenderTable(uint32 numRows, uint32 numColumns)
+RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
 		: _numRows(numRows),
 		  _numColumns(numColumns),
 		  _renderState(RenderState::FLAT) {
@@ -97,10 +97,10 @@ void RenderTable::generatePanoramaLookupTable() {
 		for (uint32 y = 0; y < _numRows; y++) {
 			int32 newY = floor(halfHeight + (y - halfHeight) * cosX);
 
-			// Panorama images are transposed. Rather than trying to transpose the source, we know 
-			// they will be mutated by this table. Therefore we can swap the axes here
 			uint32 index = y * _numColumns + x;
 
+			// Panorama images are transposed. Rather than trying to transpose the source, we know
+			// they will be mutated by this table. Therefore we can swap the axes here
 			_internalBuffer[index].x = newY; //pixel index
 			_internalBuffer[index].y = newX; //pixel index
 		}


Commit: 611ff31a56055b1ec05445597087cb042de2c648
    https://github.com/scummvm/scummvm/commit/611ff31a56055b1ec05445597087cb042de2c648
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:41-07:00

Commit Message:
ZVISION: Copy Point struct from rect.h and turn it into a templated class

Changed paths:
  A engines/zvision/point.h



diff --git a/engines/zvision/point.h b/engines/zvision/point.h
new file mode 100644
index 0000000..da244e9
--- /dev/null
+++ b/engines/zvision/point.h
@@ -0,0 +1,80 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef COMMON_ZVISION_POINT_H
+#define COMMON_ZVISION_POINT_H
+
+#include "common/types.h"
+
+namespace ZVision {
+
+/**
+ * Simple class for handling both 2D position and size.
+ */
+template<class T>
+class Point {
+public:
+	T x;	///< The horizontal part of the point
+	T y;	///< The vertical part of the point
+
+public:
+	Point() : x(0), y(0) {}
+	Point(T x1, T y1) : x(x1), y(y1) {}
+
+public:
+	bool operator==(const Point &p) const { return x == p.x && y == p.y; }
+	bool operator!=(const Point &p) const { return x != p.x || y != p.y; }
+	Point operator+(const Point &delta) const {	return Point(x + delta.x, y + delta.y);	}
+	Point operator-(const Point &delta) const {	return Point(x - delta.x, y - delta.y);	}
+
+	void operator+=(const Point &delta) {
+		x += delta.x;
+		y += delta.y;
+	}
+
+	void operator-=(const Point &delta) {
+		x -= delta.x;
+		y -= delta.y;
+	}
+
+	/**
+	 * Return the square of the distance between this point and the point p.
+	 *
+	 * @param p		the other point
+	 * @return the distance between this and p
+	 */
+	uint sqrDist(const Point &p) const {
+		int diffx = ABS(p.x - x);
+		if (diffx >= 0x1000)
+			return 0xFFFFFF;
+
+		int diffy = ABS(p.y - y);
+		if (diffy >= 0x1000)
+			return 0xFFFFFF;
+
+		return uint(diffx * diffx + diffy * diffy);
+	}
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: a23970bbc68865ccffa4c2e0849ffe244d48d5f1
    https://github.com/scummvm/scummvm/commit/a23970bbc68865ccffa4c2e0849ffe244d48d5f1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:42-07:00

Commit Message:
ZVISION: Convert RenderTable to only storing (x,y) offsets instead of absolute postions.

This allows the destRectangle to be offset within the RenderTable

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 183f823..cfd53fd 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -91,7 +91,7 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
 		_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
 	} else {
 		uint16 *destBuffer = new uint16[destRect.width() * destRect.height()];
-		_renderTable.mutateImage((uint16 *)buffer, destBuffer, horizontalPitch, subRectangle);
+		_renderTable.mutateImage((uint16 *)buffer, destBuffer, imageWidth, imageHeight, subRectangle, destRect);
 
 		_system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left, destRect.top, destRect.width(), destRect.height());
 		delete[] destBuffer;
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 388dc85..085908f 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -22,8 +22,9 @@
 
 #include "common/scummsys.h"
 
-#include "zvision/render_table.h"
 
+#include "zvision/render_table.h"
+#include "zvision/point.h"
 
 namespace ZVision {
 
@@ -33,7 +34,7 @@ RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
 		  _renderState(RenderState::FLAT) {
 	assert(numRows != 0 && numColumns != 0);
 
-	_internalBuffer = new Common::Point[numRows * numColumns];
+	_internalBuffer = new Point<int16>[numRows * numColumns];
 }
 
 RenderTable::~RenderTable() {
@@ -58,17 +59,33 @@ void RenderTable::setRenderState(RenderState newState) {
 	}
 }
 
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 horizontalPitch, Common::Rect subRectangle) {
-	uint32 imageWidth = horizontalPitch / 2;
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle) {
+	bool isTransposed = _renderState == RenderTable::PANORAMA || _renderState == RenderTable::TILT;
 
 	for (int y = subRectangle.top; y < subRectangle.bottom; y++) {
 		uint32 normalizedY = y - subRectangle.top;
+
 		for (int x = subRectangle.left; x < subRectangle.right; x++) {
 			uint32 normalizedX = x - subRectangle.left;
 
-			uint32 index = y * _numColumns + x;
-			uint32 sourceIndex = _internalBuffer[index].y * imageWidth + _internalBuffer[index].x;
-			destBuffer[normalizedY * subRectangle.width() + normalizedX] = sourceBuffer[sourceIndex];
+			uint32 index = (y + destRectangle.top) * _numColumns + (x + destRectangle.left);
+
+			// RenderTable only stores offsets from the original coordinates
+			uint32 sourceYIndex = y + _internalBuffer[index].y;
+			uint32 sourceXIndex = x + _internalBuffer[index].x;
+
+			// Clamp the yIndex to the size of the image
+			sourceYIndex = CLIP<uint32>(sourceYIndex, 0, imageHeight - 1);
+
+			// Clamp the xIndex to the size of the image
+			sourceXIndex = CLIP<uint32>(sourceXIndex, 0, imageWidth - 1);
+
+			// TODO: Figure out a way to not have branching every loop. The only way that comes to mind is to have a whole separate set of for loops for isTransposed, but that's ugly. The compiler might do this anyway in the end
+			if (isTransposed) {
+				destBuffer[normalizedY * subRectangle.width() + normalizedX] = sourceBuffer[sourceXIndex * imageHeight + sourceYIndex];
+			} else {
+				destBuffer[normalizedY * subRectangle.width() + normalizedX] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
+			}
 		}
 	}
 }
@@ -91,7 +108,7 @@ void RenderTable::generatePanoramaLookupTable() {
 		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
 		float temp = atan(tanOverHalfHeight * ((float)x - halfWidth + 0.01f));
 
-		int32 newX = floor((halfHeightOverTan * scale * temp) + halfWidth);
+		int32 newX = floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth);
 		float cosX = cos(temp);
 
 		for (uint32 y = 0; y < _numRows; y++) {
@@ -99,10 +116,9 @@ void RenderTable::generatePanoramaLookupTable() {
 
 			uint32 index = y * _numColumns + x;
 
-			// Panorama images are transposed. Rather than trying to transpose the source, we know
-			// they will be mutated by this table. Therefore we can swap the axes here
-			_internalBuffer[index].x = newY; //pixel index
-			_internalBuffer[index].y = newX; //pixel index
+			// Only store the x,y offsets instead of the absolute positions
+			_internalBuffer[index].x = newX - x; //pixel index
+			_internalBuffer[index].y = newY - y; //pixel index
 		}
 	}
 }
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index fca7681..cb91f88 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -26,6 +26,8 @@
 #include "common/types.h"
 #include "common/rect.h"
 
+#include "zvision/point.h"
+
 namespace ZVision {
 
 class RenderTable {
@@ -42,7 +44,7 @@ public:
 
 private:
 	uint32 _numColumns, _numRows;
-	Common::Point *_internalBuffer;
+	Point<int16> *_internalBuffer;
 	RenderState _renderState;
 
 	struct {
@@ -59,7 +61,7 @@ private:
 public:
 	RenderState getRenderState() { return _renderState; }
 	void setRenderState(RenderState newState);
-	void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 horizontalPitch, Common::Rect subRectangle);
+	void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
 
 private:
 	void generatePanoramaLookupTable();


Commit: 4acdf5b7d51869bfb697e345a9a90f487d8fafc0
    https://github.com/scummvm/scummvm/commit/4acdf5b7d51869bfb697e345a9a90f487d8fafc0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:43-07:00

Commit Message:
ZVISION: Convert panoramaOptions and tiltOptions to floats

Changed paths:
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 085908f..d1f8258 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -47,7 +47,7 @@ void RenderTable::setRenderState(RenderState newState) {
 	switch (newState) {
 	case PANORAMA:
 		_panoramaOptions.fieldOfView = 60;
-		_panoramaOptions.linearScale = 1;
+		_panoramaOptions.linearScale = 0.55f;
 		generatePanoramaLookupTable();
 		break;
 	case TILT:
@@ -91,15 +91,12 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
 }
 
 void RenderTable::generatePanoramaLookupTable() {
-	float fieldOfView = _panoramaOptions.fieldOfView;
-	float scale = _panoramaOptions.linearScale;
-
 	memset(_internalBuffer, 0, _numRows * _numColumns * sizeof(uint16));
 
 	float halfWidth = (float)_numColumns / 2.0f;
 	float halfHeight = (float)_numRows / 2.0f;
 
-	float fovRadians = (fieldOfView * M_PI / 180.0f);
+	float fovRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
 	float halfHeightOverTan = halfHeight / tan(fovRadians);
 	float tanOverHalfHeight = tan(fovRadians) / halfHeight;
 
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index cb91f88..ec405e5 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -48,14 +48,14 @@ private:
 	RenderState _renderState;
 
 	struct {
-		uint16 fieldOfView;
-		uint16 linearScale;
+		float fieldOfView;
+		float linearScale;
 	} _panoramaOptions;
 
 	// TODO: See if tilt and panorama need to have separate options
 	struct {
-		uint16 fieldOfView;
-		uint16 linearScale;
+		float fieldOfView;
+		float linearScale;
 	} _tiltOptions;
 
 public:


Commit: f8bc82080a82d7ed198c88d7a839c32e092ede52
    https://github.com/scummvm/scummvm/commit/f8bc82080a82d7ed198c88d7a839c32e092ede52
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:43-07:00

Commit Message:
ZVISION: Create function for mixing two RGB<555> colors

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index d1f8258..ca7f9a8 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 
+#include "graphics/colormasks.h"
 
 #include "zvision/render_table.h"
 #include "zvision/point.h"
@@ -59,6 +60,27 @@ void RenderTable::setRenderState(RenderState newState) {
 	}
 }
 
+uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
+	assert(percentColorOne < 1.0f);
+
+	float rOne = float((colorOne & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift);
+	float rTwo = float((colorTwo & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift);
+	float gOne = float((colorOne & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift);
+	float gTwo = float((colorTwo & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift);
+	float bOne = float((colorOne & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift);
+	float bTwo = float((colorTwo & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift);
+
+	float rFinal = rOne * percentColorOne + rTwo * (1.0f - percentColorOne);
+	float gFinal = gOne * percentColorOne + gTwo * (1.0f - percentColorOne);
+	float bFinal = bOne * percentColorOne + bTwo * (1.0f - percentColorOne);
+
+	uint16 returnColor = (byte(rFinal + 0.5f) << Graphics::ColorMasks<555>::kRedShift) |
+	                     (byte(gFinal + 0.5f) << Graphics::ColorMasks<555>::kGreenShift) |
+						 (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift);
+
+	return returnColor;
+}
+
 void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle) {
 	bool isTransposed = _renderState == RenderTable::PANORAMA || _renderState == RenderTable::TILT;
 


Commit: 48b9741f413fb32ed5efedfe248093be811678c6
    https://github.com/scummvm/scummvm/commit/48b9741f413fb32ed5efedfe248093be811678c6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:44-07:00

Commit Message:
ZVISION: Rename Point template class to Vector2

Also remove templating

Changed paths:
  A engines/zvision/vector2.h
  R engines/zvision/point.h
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/point.h b/engines/zvision/point.h
deleted file mode 100644
index da244e9..0000000
--- a/engines/zvision/point.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public 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 COMMON_ZVISION_POINT_H
-#define COMMON_ZVISION_POINT_H
-
-#include "common/types.h"
-
-namespace ZVision {
-
-/**
- * Simple class for handling both 2D position and size.
- */
-template<class T>
-class Point {
-public:
-	T x;	///< The horizontal part of the point
-	T y;	///< The vertical part of the point
-
-public:
-	Point() : x(0), y(0) {}
-	Point(T x1, T y1) : x(x1), y(y1) {}
-
-public:
-	bool operator==(const Point &p) const { return x == p.x && y == p.y; }
-	bool operator!=(const Point &p) const { return x != p.x || y != p.y; }
-	Point operator+(const Point &delta) const {	return Point(x + delta.x, y + delta.y);	}
-	Point operator-(const Point &delta) const {	return Point(x - delta.x, y - delta.y);	}
-
-	void operator+=(const Point &delta) {
-		x += delta.x;
-		y += delta.y;
-	}
-
-	void operator-=(const Point &delta) {
-		x -= delta.x;
-		y -= delta.y;
-	}
-
-	/**
-	 * Return the square of the distance between this point and the point p.
-	 *
-	 * @param p		the other point
-	 * @return the distance between this and p
-	 */
-	uint sqrDist(const Point &p) const {
-		int diffx = ABS(p.x - x);
-		if (diffx >= 0x1000)
-			return 0xFFFFFF;
-
-		int diffy = ABS(p.y - y);
-		if (diffy >= 0x1000)
-			return 0xFFFFFF;
-
-		return uint(diffx * diffx + diffy * diffy);
-	}
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index ca7f9a8..5754c91 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -25,7 +25,7 @@
 #include "graphics/colormasks.h"
 
 #include "zvision/render_table.h"
-#include "zvision/point.h"
+#include "zvision/vector2.h"
 
 namespace ZVision {
 
@@ -35,7 +35,7 @@ RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
 		  _renderState(RenderState::FLAT) {
 	assert(numRows != 0 && numColumns != 0);
 
-	_internalBuffer = new Point<int16>[numRows * numColumns];
+	_internalBuffer = new Vector2[numRows * numColumns];
 }
 
 RenderTable::~RenderTable() {
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index ec405e5..3f87c2e 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -26,7 +26,7 @@
 #include "common/types.h"
 #include "common/rect.h"
 
-#include "zvision/point.h"
+#include "zvision/vector2.h"
 
 namespace ZVision {
 
@@ -44,7 +44,7 @@ public:
 
 private:
 	uint32 _numColumns, _numRows;
-	Point<int16> *_internalBuffer;
+	Vector2 *_internalBuffer;
 	RenderState _renderState;
 
 	struct {
diff --git a/engines/zvision/vector2.h b/engines/zvision/vector2.h
new file mode 100644
index 0000000..d301aef
--- /dev/null
+++ b/engines/zvision/vector2.h
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 COMMON_ZVISION_POINT_H
+#define COMMON_ZVISION_POINT_H
+
+#include "common/scummsys.h"
+
+namespace ZVision {
+
+/**
+ * Simple class for handling both 2D position and size.
+ */
+class Vector2 {
+public:
+	int16 x;	///< The horizontal part of the point
+	int16 y;	///< The vertical part of the point
+
+public:
+	Vector2() : x(0), y(0) {}
+	Vector2(int16 x1, int16 y1) : x(x1), y(y1) {}
+
+public:
+	bool operator==(const Vector2 &p) const { return x == p.x && y == p.y; }
+	bool operator!=(const Vector2 &p) const { return x != p.x || y != p.y; }
+	Vector2 operator+(const Vector2 &delta) const {	return Vector2(x + delta.x, y + delta.y);	}
+	Vector2 operator-(const Vector2 &delta) const {	return Vector2(x - delta.x, y - delta.y);	}
+
+	void operator+=(const Vector2 &delta) {
+		x += delta.x;
+		y += delta.y;
+	}
+
+	void operator-=(const Vector2 &delta) {
+		x -= delta.x;
+		y -= delta.y;
+	}
+
+	/**
+	 * Return the square of the distance between this point and the point p.
+	 *
+	 * @param p		the other point
+	 * @return the distance between this and p
+	 */
+	uint sqrDist(const Vector2 &p) const {
+		int diffx = ABS(p.x - x);
+		if (diffx >= 0x1000)
+			return 0xFFFFFF;
+
+		int diffy = ABS(p.y - y);
+		if (diffy >= 0x1000)
+			return 0xFFFFFF;
+
+		return uint(diffx * diffx + diffy * diffy);
+	}
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: 564379d3eed127fd6c41a9a42bb149afbc7fb75e
    https://github.com/scummvm/scummvm/commit/564379d3eed127fd6c41a9a42bb149afbc7fb75e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:44-07:00

Commit Message:
ZVISION: Create method to get RenderTable object pointer from RenderManager

Remove passthrough methods

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index bfe2609..12555fe 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -108,11 +108,11 @@ bool Console::cmdSetRenderState(int argc, const char **argv) {
 	Common::String renderState(argv[1]);
 
 	if (renderState.matchString("panorama", true))
-		_engine->getRenderManager()->setRenderState(RenderTable::PANORAMA);
+		_engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::PANORAMA);
 	else if (renderState.matchString("tilt", true))
-		_engine->getRenderManager()->setRenderState(RenderTable::TILT);
+		_engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::TILT);
 	else if (renderState.matchString("flat", true))
-		_engine->getRenderManager()->setRenderState(RenderTable::FLAT);
+		_engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
 	else
 		DebugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
 
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index cfd53fd..10afe1f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -146,8 +146,8 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
 	_needsScreenUpdate = true;
 }
 
-void RenderManager::setRenderState(RenderTable::RenderState state) {
-	_renderTable.setRenderState(state);
+RenderTable *RenderManager::getRenderTable() {
+	return &_renderTable;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index db00888..8b4d7e8 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -89,12 +89,7 @@ public:
 	 */
 	void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
 
-	/**
-	 * Set how the frame should be rendered
-	 *
-	 * @param state    One of the RenderStates
-	 */
-	void setRenderState(RenderTable::RenderState state);
+	RenderTable *getRenderTable();
 
 	bool needsScreenUpdate() { return _needsScreenUpdate; };
 


Commit: 5376aa7b3cb234134cec5923f65ab7c9273a9528
    https://github.com/scummvm/scummvm/commit/5376aa7b3cb234134cec5923f65ab7c9273a9528
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:45-07:00

Commit Message:
ZVISION: Move generating the RenderTable to outside setRenderState

This allows the panorama/tilt options to mutated without having to generate the table multiple times.

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/console.h
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 12555fe..e9bbdd7 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -42,6 +42,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound));
 	DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
 	DCmd_Register("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState));
+	DCmd_Register("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -119,4 +120,20 @@ bool Console::cmdSetRenderState(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdGenerateRenderTable(int argc, const char **argv) {
+	_engine->getRenderManager()->getRenderTable()->generateRenderTable();
+
+	return true;
+}
+
+bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
+
+	return true;
+}
+
+bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
+
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index e293703..7fa4acc 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -42,6 +42,7 @@ private:
 	bool cmdLoadSound(int argc, const char **argv);
 	bool cmdRawToWav(int argc, const char **argv);
 	bool cmdSetRenderState(int argc, const char **argv);
+	bool cmdGenerateRenderTable(int argc, const char **argv);
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 5754c91..1ba1648 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -49,10 +49,9 @@ void RenderTable::setRenderState(RenderState newState) {
 	case PANORAMA:
 		_panoramaOptions.fieldOfView = 60;
 		_panoramaOptions.linearScale = 0.55f;
-		generatePanoramaLookupTable();
 		break;
 	case TILT:
-		generateTiltLookupTable();
+
 		break;
 	case FLAT:
 		// Intentionally left empty
@@ -112,6 +111,20 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
 	}
 }
 
+void RenderTable::generateRenderTable() {
+	switch (_renderState) {
+	case ZVision::RenderTable::PANORAMA:
+		generatePanoramaLookupTable();
+		break;
+	case ZVision::RenderTable::TILT:
+		generateTiltLookupTable();
+		break;
+	case ZVision::RenderTable::FLAT:
+		// Intentionally left empty
+		break;
+	}
+}
+
 void RenderTable::generatePanoramaLookupTable() {
 	memset(_internalBuffer, 0, _numRows * _numColumns * sizeof(uint16));
 
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 3f87c2e..a48e608 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -62,6 +62,7 @@ public:
 	RenderState getRenderState() { return _renderState; }
 	void setRenderState(RenderState newState);
 	void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
+	void generateRenderTable();
 
 private:
 	void generatePanoramaLookupTable();


Commit: b9dd61437c88fae024fd2d344b1f75020a5f7eb5
    https://github.com/scummvm/scummvm/commit/b9dd61437c88fae024fd2d344b1f75020a5f7eb5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:45-07:00

Commit Message:
ZVISION: Create class for ActionDelayRender

Changed paths:
    engines/zvision/actions.h



diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 9b2267d..224f901 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -40,9 +40,7 @@ public:
 
 
 // The different types of actions
-// CROSSFADE,
 // DEBUG,
-// DELAY_RENDER,
 // DISABLE_CONTROL,
 // DISABLE_VENUS,
 // DISPLAY_MESSAGE,
@@ -129,6 +127,16 @@ private:
 	uint16 _timeInMillis;
 };
 
+class ActionDelayRender : public ResultAction {
+public:
+	ActionDelayRender(Common::String *line);
+	bool execute(ZVision *engine);
+
+private:
+	// TODO: Check if this should actually be frames or if it should be milliseconds/seconds
+	byte framesToDelay;
+};
+
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(Common::String *line);


Commit: 0e4e6ee9bf1f3a640191df6b22e6965a7199d171
    https://github.com/scummvm/scummvm/commit/0e4e6ee9bf1f3a640191df6b22e6965a7199d171
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:46-07:00

Commit Message:
ZVISION: Create methods for altering panoramaOptions and create console commands for them

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/console.h
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index e9bbdd7..3dad7af 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -43,6 +43,8 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
 	DCmd_Register("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState));
 	DCmd_Register("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
+	DCmd_Register("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
+	DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -127,11 +129,23 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) {
 }
 
 bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Use setpanoramafov <fieldOfView> to change the current panorama field of view\n");
+		return true;
+	}
+
+	_engine->getRenderManager()->getRenderTable()->setPanoramaFoV(atof(argv[1]));
 
 	return true;
 }
 
 bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Use setpanoramascale <scale> to change the current panorama scale\n");
+		return true;
+	}
+
+	_engine->getRenderManager()->getRenderTable()->setPanoramaScale(atof(argv[1]));
 
 	return true;
 }
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 7fa4acc..7b1beeb 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -43,6 +43,8 @@ private:
 	bool cmdRawToWav(int argc, const char **argv);
 	bool cmdSetRenderState(int argc, const char **argv);
 	bool cmdGenerateRenderTable(int argc, const char **argv);
+	bool cmdSetPanoramaFoV(int argc, const char **argv);
+	bool cmdSetPanoramaScale(int argc, const char **argv);
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 1ba1648..b5a2809 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -156,7 +156,16 @@ void RenderTable::generatePanoramaLookupTable() {
 }
 
 void RenderTable::generateTiltLookupTable() {
+void RenderTable::setPanoramaFoV(float fov) {
+	assert(fov > 0.0f);
 
+	_panoramaOptions.fieldOfView = fov;
+}
+
+void RenderTable::setPanoramaScale(float scale) {
+	assert(scale > 0.0f);
+
+	_panoramaOptions.linearScale = scale;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index a48e608..5698fea 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -64,6 +64,9 @@ public:
 	void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
 	void generateRenderTable();
 
+	void setPanoramaFoV(float fov);
+	void setPanoramaScale(float scale);
+
 private:
 	void generatePanoramaLookupTable();
 	void generateTiltLookupTable();


Commit: 8f3e27cbd03831569f37e2edc5beebe9fd93de12
    https://github.com/scummvm/scummvm/commit/8f3e27cbd03831569f37e2edc5beebe9fd93de12
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:46-07:00

Commit Message:
ZVISION: Fix closing braces on generateTiltLookupTable

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index b5a2809..90a5aaf 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -156,6 +156,9 @@ void RenderTable::generatePanoramaLookupTable() {
 }
 
 void RenderTable::generateTiltLookupTable() {
+
+}
+
 void RenderTable::setPanoramaFoV(float fov) {
 	assert(fov > 0.0f);
 


Commit: e076d8e52ff2917fb68eb7ea302f96fcbe76f84d
    https://github.com/scummvm/scummvm/commit/e076d8e52ff2917fb68eb7ea302f96fcbe76f84d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:47-07:00

Commit Message:
ZVISION: Change default panorama FoV to 27 degrees

This is to match Marisa Chan's implementation. Images at this FoV also look better.

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 90a5aaf..0bd8f23 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -47,7 +47,7 @@ void RenderTable::setRenderState(RenderState newState) {
 
 	switch (newState) {
 	case PANORAMA:
-		_panoramaOptions.fieldOfView = 60;
+		_panoramaOptions.fieldOfView = 27.0f;
 		_panoramaOptions.linearScale = 0.55f;
 		break;
 	case TILT:


Commit: 1c551d43595a6acfb7f00bb3f0713435576e0f0e
    https://github.com/scummvm/scummvm/commit/1c551d43595a6acfb7f00bb3f0713435576e0f0e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-04T11:32:47-07:00

Commit Message:
ZVISION: Only scale videos when needed

This avoids crashes for videos that exceed the screen size when scaled

Changed paths:
    engines/zvision/video.cpp



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index c0b575b..caf43ae 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -91,20 +91,27 @@ void RenderManager::startVideo(Video::VideoDecoder *videoDecoder) {
 
 void RenderManager::continueVideo() {
 	byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel;
-	uint16 width = _currentVideo->getWidth();
-	uint16 height = _currentVideo->getHeight();
-	uint16 pitch = width * bytesPerPixel;
+	uint16 origWidth = _currentVideo->getWidth();
+	uint16 origHeight = _currentVideo->getHeight();
+	uint16 pitch = origWidth * bytesPerPixel;
+	bool shouldBeScaled = (origWidth * 2 <= 640 && origHeight * 2 <= 480);
+	uint16 finalWidth = shouldBeScaled ? origWidth * 2 : origWidth;
+	uint16 finalHeight = shouldBeScaled ? origHeight * 2 : origHeight;
 
-	uint16 x = (_system->getWidth() - (width * 2)) / 2;
-	uint16 y = (_system->getHeight() - (height * 2)) / 2;
+	uint16 x = (_system->getWidth() - finalWidth) / 2;
+	uint16 y = (_system->getHeight() - finalHeight) / 2;
 
 	if (!_currentVideo->endOfVideo()) {
 		if (_currentVideo->needsUpdate()) {
 			const Graphics::Surface *frame = _currentVideo->decodeNextFrame();
 
-			if (frame) {		
-				scale2x(static_cast<byte *>(frame->pixels), _scaledVideoFrameBuffer, width, height, bytesPerPixel);
-				_system->copyRectToScreen(_scaledVideoFrameBuffer, pitch * 2, x, y, width * 2, height * 2);
+			if (frame) {
+				if (shouldBeScaled) {
+					scale2x((byte *)frame->pixels, _scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel);
+					_system->copyRectToScreen(_scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
+				} else {
+					_system->copyRectToScreen((byte *)frame->pixels, pitch, x, y, finalWidth, finalHeight);
+				}
 
 				_needsScreenUpdate = true;
 			}


Commit: 032afd3c1a6fe929cafde4f30f4c1e59b7ac6a89
    https://github.com/scummvm/scummvm/commit/032afd3c1a6fe929cafde4f30f4c1e59b7ac6a89
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-04T11:32:48-07:00

Commit Message:
ZVISION: Fix compilation

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 0bd8f23..e3ce779 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -32,7 +32,7 @@ namespace ZVision {
 RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
 		: _numRows(numRows),
 		  _numColumns(numColumns),
-		  _renderState(RenderState::FLAT) {
+		  _renderState(FLAT) {
 	assert(numRows != 0 && numColumns != 0);
 
 	_internalBuffer = new Vector2[numRows * numColumns];


Commit: 93c6670f6f80b98dd05df09d710b3c683cfd1173
    https://github.com/scummvm/scummvm/commit/93c6670f6f80b98dd05df09d710b3c683cfd1173
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:48-07:00

Commit Message:
ZVISION: Create clone member function for ResultAction class

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 791eda1..35e5d48 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -37,6 +37,10 @@ ActionAdd::ActionAdd(Common::String *line) {
 	sscanf(line->c_str(), ":add(%u,%hhu)", &_key, &_value);
 }
 
+ResultAction *ActionAdd::clone() const {
+	return new ActionAdd(*this);
+}
+
 bool ActionAdd::execute(ZVision *engine) {
 	engine->getScriptManager()->addToStateValue(_key, _value);
 	return true;
@@ -51,6 +55,10 @@ ActionAssign::ActionAssign(Common::String *line) {
 	sscanf(line->c_str(), ":assign(%u, %hhu)", &_key, &_value);
 }
 
+ResultAction *ActionAssign::clone() const {
+	return new ActionAssign(*this);
+}
+
 bool ActionAssign::execute(ZVision *engine) {
 	engine->getScriptManager()->setStateValue(_key, _value);
 	return true;
@@ -65,6 +73,10 @@ ActionAttenuate::ActionAttenuate(Common::String *line) {
 	sscanf(line->c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
 }
 
+ResultAction *ActionAttenuate::clone() const {
+	return new ActionAttenuate(*this);
+}
+
 bool ActionAttenuate::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -79,6 +91,10 @@ ActionChangeLocation::ActionChangeLocation(Common::String *line) {
 	sscanf(line->c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
 }
 
+ResultAction *ActionChangeLocation::clone() const {
+	return new ActionChangeLocation(*this);
+}
+
 bool ActionChangeLocation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -95,6 +111,10 @@ ActionCrossfade::ActionCrossfade(Common::String *line) {
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
+ResultAction *ActionCrossfade::clone() const {
+	return new ActionCrossfade(*this);
+}
+
 bool ActionCrossfade::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -110,6 +130,10 @@ ActionPreloadAnimation::ActionPreloadAnimation(Common::String *line) {
 	sscanf(line->c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
 }
 
+ResultAction *ActionPreloadAnimation::clone() const {
+	return new ActionPreloadAnimation(*this);
+}
+
 bool ActionPreloadAnimation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -127,6 +151,10 @@ ActionPlayAnimation::ActionPlayAnimation(Common::String *line) {
            &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 }
 
+ResultAction *ActionPlayAnimation::clone() const {
+	return new ActionPlayAnimation(*this);
+}
+
 bool ActionPlayAnimation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -141,6 +169,10 @@ ActionRandom::ActionRandom(Common::String *line) {
 	sscanf(line->c_str(), ":random:%u, %u)", &_key, &_max);
 }
 
+ResultAction *ActionRandom::clone() const {
+	return new ActionRandom(*this);
+}
+
 bool ActionRandom::execute(ZVision *engine) {
 	uint32 randNumber = engine->getRandomSource()->getRandomNumber(_max);
 	engine->getScriptManager()->setStateValue(_key, randNumber);
@@ -156,6 +188,10 @@ ActionTimer::ActionTimer(Common::String *line) {
 	sscanf(line->c_str(), ":timer:%u(%hu)", &_key, &_time);
 }
 
+ResultAction *ActionTimer::clone() const {
+	return new ActionTimer(*this);
+}
+
 bool ActionTimer::execute(ZVision *engine) {
 	engine->getScriptManager()->addActionNode(new NodeTimer(_key, _time));
 	return true;
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 224f901..75cffab 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -35,6 +35,7 @@ class ZVision;
 class ResultAction {
 public:
 	virtual ~ResultAction() {}
+	virtual ResultAction *clone() const = 0;
 	virtual bool execute(ZVision *engine) = 0;
 };
 
@@ -73,6 +74,7 @@ public:
 class ActionAdd : public ResultAction {
 public:
 	ActionAdd(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -83,6 +85,7 @@ private:
 class ActionAssign : public ResultAction {
 public:
 	ActionAssign(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -93,6 +96,7 @@ private:
 class ActionAttenuate : public ResultAction {
 public:
 	ActionAttenuate(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -103,6 +107,7 @@ private:
 class ActionChangeLocation : public ResultAction {
 public:
 	ActionChangeLocation(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -115,6 +120,7 @@ private:
 class ActionCrossfade : public ResultAction {
 public:
 	ActionCrossfade(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -130,6 +136,7 @@ private:
 class ActionDelayRender : public ResultAction {
 public:
 	ActionDelayRender(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -140,6 +147,7 @@ private:
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -159,6 +167,7 @@ private:
 class ActionPreloadAnimation : public ResultAction {
 public:
 	ActionPreloadAnimation(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -178,6 +187,7 @@ private:
 class ActionRandom : public ResultAction {
 public:
 	ActionRandom(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -188,6 +198,7 @@ private:
 class ActionTimer : public ResultAction {
 public:
 	ActionTimer(Common::String *line);
+	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:


Commit: 7d58ebf2819562893df2f07b916c9712d5b7413f
    https://github.com/scummvm/scummvm/commit/7d58ebf2819562893df2f07b916c9712d5b7413f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:49-07:00

Commit Message:
ZVISION: Convert Puzzle to a class

It needed a copy constructor and destructor to handle the heap memory ResultActions

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 06c228d..08d8a5c 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -58,7 +58,27 @@ enum StateFlags {
 	DISABLED = 0x04
 };
 
-struct Puzzle {
+class Puzzle {
+public:
+	~Puzzle() {
+		for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+			delete (*iter);
+		}
+	}
+
+	Puzzle() {}
+
+	// Copy constructor
+	Puzzle(const Puzzle &other) 
+			: key(other.key),
+			  criteriaList(other.criteriaList),
+			  flags(flags) {
+		// We have to clone the ResultActions since they are on the heap
+		for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+			resultActions.push_back((*iter)->clone());
+		}
+	}
+
 	uint32 key;
 	Common::List<Criteria> criteriaList;
 	// This has to be list of pointers because ResultAction is abstract


Commit: cf9790a9d6407e3bfea46cea1c59abe9ab5de31c
    https://github.com/scummvm/scummvm/commit/cf9790a9d6407e3bfea46cea1c59abe9ab5de31c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:49-07:00

Commit Message:
ZVISION: Create mutators for _tiltOptions

Changed paths:
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index e3ce779..49203df 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -171,4 +171,16 @@ void RenderTable::setPanoramaScale(float scale) {
 	_panoramaOptions.linearScale = scale;
 }
 
+void RenderTable::setTiltFoV(float fov) {
+	assert(fov > 0.0f);
+
+	_tiltOptions.fieldOfView = fov;
+}
+
+void RenderTable::setTiltScale(float scale) {
+	assert(scale > 0.0f);
+
+	_tiltOptions.linearScale = scale;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 5698fea..ccb5926 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -67,6 +67,9 @@ public:
 	void setPanoramaFoV(float fov);
 	void setPanoramaScale(float scale);
 
+	void setTiltFoV(float fov);
+	void setTiltScale(float scale);
+
 private:
 	void generatePanoramaLookupTable();
 	void generateTiltLookupTable();


Commit: b20437a17d1a740e70dd1fa0bbf3bc6cfeb6c494
    https://github.com/scummvm/scummvm/commit/b20437a17d1a740e70dd1fa0bbf3bc6cfeb6c494
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:50-07:00

Commit Message:
ZVISION: Modify Criteria parsing to handle empty Criteria

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 168a6d8..cebb57a 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -72,22 +72,32 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
 	trimCommentsAndWhiteSpace(&line);
 
 	while (!line.contains('}')) {
-		if (line.matchString("criteria {", true))
-			puzzle.criteriaList.push_back(parseCriteria(stream));
-		else if (line.matchString("results {", true))
-			parseResult(stream, puzzle.resultActions);
-		else if (line.matchString("flags {", true))
+		if (line.matchString("criteria {", true)) {
+			Criteria criteria;
+			if (parseCriteria(&criteria, stream)) {
+				puzzle.criteriaList.push_back(criteria);
+			}
+		} else if (line.matchString("results {", true)) {
+			parseResults(stream, puzzle.resultActions);
+		} else if (line.matchString("flags {", true)) {
 			puzzle.flags = parseFlags(stream);
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(&line);
 	}
 }
 
-Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const {
-	Criteria criteria;
-
+bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(&line);
 
+	// Criteria can be empty
+	if (line.contains('}')) {
+		return false;
+	}
+
 	while (!line.contains('}')) {
 		// Split the string into tokens using ' ' as a delimiter
 		Common::StringTokenizer tokenizer(line);
@@ -95,35 +105,35 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
 
 		// Parse the id out of the first token
 		token = tokenizer.nextToken();
-		sscanf(token.c_str(), "[%u]", &(criteria.key));
+		sscanf(token.c_str(), "[%u]", &(criteria->key));
 
 		// Parse the operator out of the second token
 		token = tokenizer.nextToken();
 		if (token.c_str()[0] == '=')
-			criteria.criteriaOperator = EQUAL_TO;
+			criteria->criteriaOperator = EQUAL_TO;
 		else if (token.c_str()[0] == '!')
-			criteria.criteriaOperator = NOT_EQUAL_TO;
+			criteria->criteriaOperator = NOT_EQUAL_TO;
 		else if (token.c_str()[0] == '>')
-			criteria.criteriaOperator = GREATER_THAN;
+			criteria->criteriaOperator = GREATER_THAN;
 		else if (token.c_str()[0] == '<')
-			criteria.criteriaOperator = LESS_THAN;
+			criteria->criteriaOperator = LESS_THAN;
 
 		// First determine if the last token is an id or a value
 		// Then parse it into 'argument'
 		token = tokenizer.nextToken();
 		if (token.contains('[')) {
-			sscanf(token.c_str(), "[%u]", &(criteria.argument));
-			criteria.argumentIsAKey = true;
+			sscanf(token.c_str(), "[%u]", &(criteria->argument));
+			criteria->argumentIsAKey = true;
 		} else {
-			sscanf(token.c_str(), "%u", &(criteria.argument));
-			criteria.argumentIsAKey = false;
+			sscanf(token.c_str(), "%u", &(criteria->argument));
+			criteria->argumentIsAKey = false;
 		}
 
 		line = stream.readLine();
 		trimCommentsAndWhiteSpace(&line);
 	}
 
-	return criteria;
+	return true;
 }
 
 void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 2d9bcc3..ec16477 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -97,10 +97,11 @@ private:
 	 * Parses the stream into a Criteria object
 	 * Helper method for parsePuzzle. 
 	 *
-	 * @param stream    Scr file stream
-	 * @return          Created Criteria object
+	 * @param criteria    Pointer to the Criteria object to fill
+	 * @param stream      Scr file stream
+	 * @return            Whether any criteria were read
 	 */
-	Criteria parseCriteria(Common::SeekableReadStream &stream) const;
+	bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const;
 
 	/**
 	 * Parses the stream into a Results object


Commit: c22c91b7d3056fdbb100b3b0fd6bda1aa8626b79
    https://github.com/scummvm/scummvm/commit/c22c91b7d3056fdbb100b3b0fd6bda1aa8626b79
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:50-07:00

Commit Message:
ZVISION: Create Control class

Changed paths:
  A engines/zvision/control.cpp
    engines/zvision/control.h



diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
new file mode 100644
index 0000000..59ef14e
--- /dev/null
+++ b/engines/zvision/control.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/stream.h"
+
+#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
+#include "zvision/render_table.h"
+#include "zvision/control.h"
+#include "zvision/utility.h"
+
+namespace ZVision {
+
+void Control::parseFlatControl(ZVision *engine) {
+	engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
+}
+
+void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream) {
+	RenderTable *renderTable = engine->getRenderManager()->getRenderTable();
+	renderTable->setRenderState(RenderTable::PANORAMA);
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(&line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("angle*", true)) {
+			float fov;
+			sscanf(line.c_str(), "angle(%f)", &fov);
+			renderTable->setPanoramaFoV(fov);
+		} else if (line.matchString("linscale*", true)) {
+			float scale;
+			sscanf(line.c_str(), "angle(%f)", &scale);
+			renderTable->setPanoramaScale(scale);
+		} else if (line.matchString("reversepana*", true)) {
+			byte reverse;
+			sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+			if (reverse == 1) {
+				renderTable->setPanoramaReverse(true);
+			}
+		} else if (line.matchString("zeropoint*", true)) {
+			// TODO: Implement
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(&line);
+	}
+}
+
+void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream) {
+	RenderTable *renderTable = engine->getRenderManager()->getRenderTable();
+	renderTable->setRenderState(RenderTable::TILT);
+
+	// Loop until we find the closing brace
+	Common::String line = stream.readLine();
+	trimCommentsAndWhiteSpace(&line);
+
+	while (!line.contains('}')) {
+		if (line.matchString("angle*", true)) {
+			float fov;
+			sscanf(line.c_str(), "angle(%f)", &fov);
+			renderTable->setTiltFoV(fov);
+		} else if (line.matchString("linscale*", true)) {
+			float scale;
+			sscanf(line.c_str(), "angle(%f)", &scale);
+			renderTable->setTiltScale(scale);
+		} else if (line.matchString("reversepana*", true)) {
+			byte reverse;
+			sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+			if (reverse == 1) {
+				renderTable->setTiltReverse(true);
+			}
+		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(&line);
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 1f59478..edc0fc2 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,11 +25,27 @@
 
 #include "common/types.h"
 
+namespace Common {
+class SeekableReadStream;
+}
+
 namespace ZVision {
 
-struct Control {
-	uint16 id;
+class ZVision;
+
+class Control {
+public:
+	virtual ~Control() {}
+	virtual bool execute(ZVision *engine) = 0;
+
+protected:
+	uint32 key;
 
+// Static member functions
+public:
+	static void parseFlatControl(ZVision *engine);
+	static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
+	static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
 };
 
 } // End of namespace ZVision


Commit: 48a3a1530db615baf2388eb16118facb79f0a28a
    https://github.com/scummvm/scummvm/commit/48a3a1530db615baf2388eb16118facb79f0a28a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:51-07:00

Commit Message:
ZVISION: Move the criteriaMet bool outside of the loop

Only fire off the Results of ALL of the criteria are met

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 7fcf2f6..85c900b 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -77,10 +77,10 @@ void ScriptManager::updateNodes(uint32 deltaTimeMillis) {
 void ScriptManager::checkPuzzleCriteria() {
 	while (!_puzzlesToCheck.empty()) {
 		Puzzle *puzzle = _puzzlesToCheck.pop();
+
 		// Check each Criteria
+		bool criteriaMet = false;
 		for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
-			bool criteriaMet = false;
-
 			// Get the value to compare against
 			byte argumentValue;
 			if ((*iter).argument)
@@ -104,11 +104,16 @@ void ScriptManager::checkPuzzleCriteria() {
 				break;
 			}
 
-			// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
-			if (criteriaMet) {
-				for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
-					(*resultIter)->execute(_engine);
-				}
+			if (!criteriaMet) {
+				break;
+			}
+		}
+
+		// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
+		// criteriaList can be empty. Aka, the puzzle should be executed immediately
+		if (puzzle->criteriaList.empty() || criteriaMet) {
+			for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+				(*resultIter)->execute(_engine);
 			}
 		}
 	}


Commit: 2063cb711dce1894125d1cc6bab5a2d27a163be3
    https://github.com/scummvm/scummvm/commit/2063cb711dce1894125d1cc6bab5a2d27a163be3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:51-07:00

Commit Message:
ZVISION: Add 'reverse' to _tiltOptions and _panoramaOptions to handle Control options

Changed paths:
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 49203df..adf1d64 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -49,6 +49,7 @@ void RenderTable::setRenderState(RenderState newState) {
 	case PANORAMA:
 		_panoramaOptions.fieldOfView = 27.0f;
 		_panoramaOptions.linearScale = 0.55f;
+		_panoramaOptions.reverse = false;
 		break;
 	case TILT:
 
@@ -171,6 +172,10 @@ void RenderTable::setPanoramaScale(float scale) {
 	_panoramaOptions.linearScale = scale;
 }
 
+void RenderTable::setPanoramaReverse(bool reverse) {
+	_panoramaOptions.reverse = reverse;
+}
+
 void RenderTable::setTiltFoV(float fov) {
 	assert(fov > 0.0f);
 
@@ -183,4 +188,8 @@ void RenderTable::setTiltScale(float scale) {
 	_tiltOptions.linearScale = scale;
 }
 
+void RenderTable::setTiltReverse(bool reverse) {
+	_tiltOptions.reverse = reverse;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index ccb5926..e5535a0 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -50,12 +50,14 @@ private:
 	struct {
 		float fieldOfView;
 		float linearScale;
+		bool reverse;
 	} _panoramaOptions;
 
 	// TODO: See if tilt and panorama need to have separate options
 	struct {
 		float fieldOfView;
 		float linearScale;
+		bool reverse;
 	} _tiltOptions;
 
 public:
@@ -66,9 +68,11 @@ public:
 
 	void setPanoramaFoV(float fov);
 	void setPanoramaScale(float scale);
+	void setPanoramaReverse(bool reverse);
 
 	void setTiltFoV(float fov);
 	void setTiltScale(float scale);
+	void setTiltReverse(bool reverse);
 
 private:
 	void generatePanoramaLookupTable();


Commit: d4ae293f881ae07afd243173ddd11d5b0cfa12b3
    https://github.com/scummvm/scummvm/commit/d4ae293f881ae07afd243173ddd11d5b0cfa12b3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:52-07:00

Commit Message:
ZVISION: Rename parseResult() to parseResults()

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index cebb57a..ca66e3b 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -136,7 +136,7 @@ bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream
 	return true;
 }
 
-void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
+void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(&line);
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index ec16477..1b12a06 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -110,7 +110,7 @@ private:
 	 * @param stream    Scr file stream
 	 * @return          Created Results object
 	 */
-	void parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const;
+	void parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const;
 
 	/**
 	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum


Commit: 070042fcb4ea473cd2bfbebf9838957cdb9150b8
    https://github.com/scummvm/scummvm/commit/070042fcb4ea473cd2bfbebf9838957cdb9150b8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:52-07:00

Commit Message:
ZVISION: Modify Control parsing to use new Control class structure

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index ca66e3b..ec73fa1 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -56,13 +56,11 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 			parsePuzzle(puzzle, file);
 			_activePuzzles.push_back(puzzle);
 		} else if (line.matchString("control:*", true)) {
-			Control control;
-			char controlType[20];
-			sscanf(line.c_str(),"control:%u %s",&(control.id), controlType);
-
-			parseControl(control, file);
-			/** Holds the currently active puzzles */
-			_activeControls.push_back(control);
+			Control *control = parseControl(line, file);
+			// Some controls don't require nodes. They just initialize the scene
+			if (control != 0) {
+				_activeControls.push_back(control);
+			}
 		}
 	}
 }
@@ -284,13 +282,38 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
 		} else if (line.matchString("DISABLED", true)) {
 			flags |= DISABLED;
 		}
+
+		line = stream.readLine();
+		trimCommentsAndWhiteSpace(&line);
 	}
 
 	return flags;
 }
 
-void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) {
+Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
+	Control *control = 0;
+	uint32 key;
+	char controlTypeBuffer[20];
+
+	sscanf(line.c_str(), "control:%u %s {", &key, controlTypeBuffer);
+
+	Common::String controlType(controlTypeBuffer);
+
+	if (controlType.equalsIgnoreCase("push_toggle")) {
+
+	} else if (controlType.equalsIgnoreCase("flat")) {
+		Control::parseFlatControl(_engine);
+		return 0;
+	} else if (controlType.equalsIgnoreCase("pana")) {
+		Control::parsePanoramaControl(_engine, stream);
+		return 0;
+	}
+	else if (controlType.equalsIgnoreCase("tilt")) {
+		Control::parseTiltControl(_engine, stream);
+		return 0;
+	}
 
+	return control;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 1b12a06..8ffd3a0 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -60,7 +60,7 @@ private:
 	/** Holds the currently active puzzles */
 	Common::List<Puzzle> _activePuzzles;
 	/** Holds the currently active controls */
-	Common::List<Control> _activeControls;
+	Common::List<Control *> _activeControls;
 
 public:
 	
@@ -123,10 +123,10 @@ private:
 	/**
 	 * Helper method for parseScrFile. Parses the stream into a Control object
 	 *
-	 * @param control    The object to store what is parsed
-	 * @param stream     Scr file stream
+	 * @param line      The line initially read
+	 * @param stream    Scr file stream
 	 */
-	void parseControl(Control &control, Common::SeekableReadStream &stream);
+	Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
 };
 
 


Commit: 00eb2792438f118775546011d2f1abdc9b0bc0cd
    https://github.com/scummvm/scummvm/commit/00eb2792438f118775546011d2f1abdc9b0bc0cd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:53-07:00

Commit Message:
ZVISION: Create ScriptManager member function to change location

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 35e5d48..0cec6af 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -88,7 +88,7 @@ bool ActionAttenuate::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionChangeLocation::ActionChangeLocation(Common::String *line) {
-	sscanf(line->c_str(), ":change_location(%c,%c,%2c,%hu)", &_world, &_room, &_nodeview, &_x);
+	sscanf(line->c_str(), ":change_location(%c,%c,%c%c,%hu)", &_world, &_room, &_node, &_view, &_x);
 }
 
 ResultAction *ActionChangeLocation::clone() const {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 75cffab..83f871d 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -113,7 +113,8 @@ public:
 private:
 	char _world;
 	char _room;
-	char _nodeview[2];
+	char _node;
+	char _view;
 	int16 _x;
 };
 
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 85c900b..97f2cad 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -136,4 +136,28 @@ void ScriptManager::addActionNode(ActionNode *node) {
 	_activeNodes.push_back(node);
 }
 
+void ScriptManager::changeLocation(char world, char room, char node, char view, uint16 x) {
+	// Clear all the containers
+	_referenceTable.clear();
+	_puzzlesToCheck.clear();
+	_activePuzzles.clear();
+	// _activeControls is a list of pointers to the heap, so we have to delete the Controls before we call clear()
+	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+		delete (*iter);
+	}
+	_activeControls.clear();
+
+	// Parse into puzzles and controls
+	Common::String fileName = Common::String::format("%c%c%c&c.scr", world, room, node, view);
+	parseScrFile(fileName);
+
+	// Create the puzzle reference table
+	createReferenceTable();
+
+	// Add all the puzzles to the stack to be checked
+	for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+		_puzzlesToCheck.push(&(*iter));
+	}
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 8ffd3a0..caec0dd 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -74,6 +74,8 @@ public:
 
 	void addActionNode(ActionNode *node);
 
+	void changeLocation(char world, char room, char node, char view, uint16 x);
+
 private:
 	void createReferenceTable();
 


Commit: ea47c28ddf20e366d43317ca273e84db0acd32db
    https://github.com/scummvm/scummvm/commit/ea47c28ddf20e366d43317ca273e84db0acd32db
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:53-07:00

Commit Message:
ZVISION: Make ActionNode::process() pure virtual

Changed paths:
    engines/zvision/action_node.h



diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index cd5c9f3..324dba2 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -32,7 +32,7 @@ class ZVision;
 class ActionNode {
 public:
 	virtual ~ActionNode() {}
-	virtual bool process(ZVision *engine, uint32 deltaTimeInMillis);
+	virtual bool process(ZVision *engine, uint32 deltaTimeInMillis) = 0;
 };
 
 class NodeTimer : public ActionNode {


Commit: f975fbe52190ccc0ca1264d6aa63a897ad784f31
    https://github.com/scummvm/scummvm/commit/f975fbe52190ccc0ca1264d6aa63a897ad784f31
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:54-07:00

Commit Message:
ZVISION: Move Puzzle logic into a .cpp file

Changed paths:
  A engines/zvision/puzzle.cpp
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.cpp b/engines/zvision/puzzle.cpp
new file mode 100644
index 0000000..8399919
--- /dev/null
+++ b/engines/zvision/puzzle.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/actions.h"
+#include "zvision/puzzle.h"
+
+namespace ZVision {
+
+Puzzle::~Puzzle() {
+	for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+		delete (*iter);
+	}
+}
+
+Puzzle::Puzzle(const Puzzle &other)
+		: key(other.key),
+		  criteriaList(other.criteriaList),
+		  flags(flags) {
+	// We have to clone the ResultActions since they are on the heap
+	for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+		resultActions.push_back((*iter)->clone());
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 08d8a5c..a0c4e9d 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -60,24 +60,9 @@ enum StateFlags {
 
 class Puzzle {
 public:
-	~Puzzle() {
-		for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
-			delete (*iter);
-		}
-	}
-
 	Puzzle() {}
-
-	// Copy constructor
-	Puzzle(const Puzzle &other) 
-			: key(other.key),
-			  criteriaList(other.criteriaList),
-			  flags(flags) {
-		// We have to clone the ResultActions since they are on the heap
-		for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
-			resultActions.push_back((*iter)->clone());
-		}
-	}
+	~Puzzle();
+	Puzzle(const Puzzle &other);
 
 	uint32 key;
 	Common::List<Criteria> criteriaList;


Commit: f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7
    https://github.com/scummvm/scummvm/commit/f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:54-07:00

Commit Message:
ZVISION: Move CriteriaOperator, Criteria, and StateFlag inside the Puzzle class

Changed paths:
    engines/zvision/puzzle.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index a0c4e9d..fba139c 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -29,41 +29,43 @@ namespace ZVision {
 
 class ResultAction;
 
-/** How criteria should be decided */
-enum CriteriaOperator {
-	EQUAL_TO,
-	NOT_EQUAL_TO,
-	GREATER_THAN,
-	LESS_THAN
-};
-
-/** Criteria for a Puzzle result to be fired */
-struct Criteria {
-	/** The key of a global state */
-	uint32 key;
-	/**  
-	 * What we're comparing the value of the global state against
-	 * This can either be a pure value or it can be the key of another global state
-	 */
-	uint32 argument;
-	/** How to do the comparison */
-	CriteriaOperator criteriaOperator;
-	/** Whether 'argument' is the key of a global state (true) or a pure value (false) */
-	bool argumentIsAKey;
-};
-
-enum StateFlags {
-	ONCE_PER_INST = 0x01,
-	DO_ME_NOW = 0x02,
-	DISABLED = 0x04
-};
-
 class Puzzle {
 public:
 	Puzzle() {}
 	~Puzzle();
 	Puzzle(const Puzzle &other);
+	
+public:
+	/** How criteria should be decided */
+	enum CriteriaOperator {
+		EQUAL_TO,
+		NOT_EQUAL_TO,
+		GREATER_THAN,
+		LESS_THAN
+	};
+
+	/** Criteria for a Puzzle result to be fired */
+	struct Criteria {
+		/** The key of a global state */
+		uint32 key;
+		/**  
+		 * What we're comparing the value of the global state against
+		 * This can either be a pure value or it can be the key of another global state
+		 */
+		uint32 argument;
+		/** How to do the comparison */
+		CriteriaOperator criteriaOperator;
+		/** Whether 'argument' is the key of a global state (true) or a pure value (false) */
+		bool argumentIsAKey;
+	};
 
+	enum StateFlags {
+		ONCE_PER_INST = 0x01,
+		DO_ME_NOW = 0x02,
+		DISABLED = 0x04
+	};
+
+public:
 	uint32 key;
 	Common::List<Criteria> criteriaList;
 	// This has to be list of pointers because ResultAction is abstract
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index ec73fa1..5f2140d 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -71,7 +71,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
 
 	while (!line.contains('}')) {
 		if (line.matchString("criteria {", true)) {
-			Criteria criteria;
+			Puzzle::Criteria criteria;
 			if (parseCriteria(&criteria, stream)) {
 				puzzle.criteriaList.push_back(criteria);
 			}
@@ -86,7 +86,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
 	}
 }
 
-bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const {
+bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(&line);
@@ -108,13 +108,13 @@ bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream
 		// Parse the operator out of the second token
 		token = tokenizer.nextToken();
 		if (token.c_str()[0] == '=')
-			criteria->criteriaOperator = EQUAL_TO;
+			criteria->criteriaOperator = Puzzle::EQUAL_TO;
 		else if (token.c_str()[0] == '!')
-			criteria->criteriaOperator = NOT_EQUAL_TO;
+			criteria->criteriaOperator = Puzzle::NOT_EQUAL_TO;
 		else if (token.c_str()[0] == '>')
-			criteria->criteriaOperator = GREATER_THAN;
+			criteria->criteriaOperator = Puzzle::GREATER_THAN;
 		else if (token.c_str()[0] == '<')
-			criteria->criteriaOperator = LESS_THAN;
+			criteria->criteriaOperator = Puzzle::LESS_THAN;
 
 		// First determine if the last token is an id or a value
 		// Then parse it into 'argument'
@@ -276,11 +276,11 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
 
 	while (!line.contains('}')) {
 		if (line.matchString("ONCE_PER_INST", true)) {
-			flags |= ONCE_PER_INST;
+			flags |= Puzzle::ONCE_PER_INST;
 		} else if (line.matchString("DO_ME_NOW", true)) {
-			flags |= DO_ME_NOW;
+			flags |= Puzzle::DO_ME_NOW;
 		} else if (line.matchString("DISABLED", true)) {
-			flags |= DISABLED;
+			flags |= Puzzle::DISABLED;
 		}
 
 		line = stream.readLine();
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 97f2cad..0ff0509 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -45,7 +45,7 @@ void ScriptManager::createReferenceTable() {
 		Puzzle *puzzlePtr = &(*activePuzzleIter);
 
 		// Iterate through each Criteria and add a reference from the criteria key to the Puzzle
-		for (Common::List<Criteria>::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
+		for (Common::List<Puzzle::Criteria>::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
 			_referenceTable[criteriaIter->key].push_back(puzzlePtr);
 
 			// If the argument is a key, add a reference to it as well
@@ -80,7 +80,7 @@ void ScriptManager::checkPuzzleCriteria() {
 
 		// Check each Criteria
 		bool criteriaMet = false;
-		for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
+		for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
 			// Get the value to compare against
 			byte argumentValue;
 			if ((*iter).argument)
@@ -90,16 +90,16 @@ void ScriptManager::checkPuzzleCriteria() {
 
 			// Do the comparison
 			switch ((*iter).criteriaOperator) {
-			case EQUAL_TO:
+			case Puzzle::EQUAL_TO:
 				criteriaMet = getStateValue(iter->key) == argumentValue;
 				break;
-			case NOT_EQUAL_TO:
+			case Puzzle::NOT_EQUAL_TO:
 				criteriaMet = getStateValue(iter->key) != argumentValue;
 				break;
-			case GREATER_THAN:
+			case Puzzle::GREATER_THAN:
 				criteriaMet = getStateValue(iter->key) > argumentValue;
 				break;
-			case LESS_THAN:
+			case Puzzle::LESS_THAN:
 				criteriaMet = getStateValue(iter->key) < argumentValue;
 				break;
 			}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index caec0dd..3e054ff 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -103,7 +103,7 @@ private:
 	 * @param stream      Scr file stream
 	 * @return            Whether any criteria were read
 	 */
-	bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const;
+	bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
 
 	/**
 	 * Parses the stream into a Results object


Commit: 89d8496dbac2fb1fc5fc77d5b26fa2a9405f9d77
    https://github.com/scummvm/scummvm/commit/89d8496dbac2fb1fc5fc77d5b26fa2a9405f9d77
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-04T11:32:55-07:00

Commit Message:
ZVISION: Add detection entry and directories for ZGI

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



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 8c87c90..a799cc2 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -71,6 +71,20 @@ static const ZVisionGameDescription gameDescriptions[] = {
 		ZorkNemesis
 	},
 
+	{
+		// Zork Grand Inquisitor English version
+		{
+			"zgi",
+			0,
+			AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944),
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		ZorkGrandInquisitor
+	},
+
 	{ AD_TABLE_END_MARKER }
 };
 
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b79ecb4..fa91f8c 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -60,6 +60,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 	SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4, true);
 	SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4, true);
 	SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4, true);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets1", 0, 2, true);
+	SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
 	SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
  
 	// Here is the right place to set up the engine specific debug channels


Commit: f1135292d0d714187b719988dba8d5a7d487fe94
    https://github.com/scummvm/scummvm/commit/f1135292d0d714187b719988dba8d5a7d487fe94
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:55-07:00

Commit Message:
ZVISION: Optimize integer type usages

The general thought is int is faster than int16 or byte. So if you can afford the
space, use it over int16 or byte. Also, only use int32 when you specifically need
the 32 bits.

Changed paths:
    engines/zvision/action_node.cpp
    engines/zvision/action_node.h
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/control.cpp
    engines/zvision/events.cpp
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h
    engines/zvision/puzzle.h
    engines/zvision/render_table.cpp
    engines/zvision/render_table.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h
    engines/zvision/utility.h
    engines/zvision/video.cpp
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
index dec52d9..1a51690 100644
--- a/engines/zvision/action_node.cpp
+++ b/engines/zvision/action_node.cpp
@@ -28,7 +28,7 @@
 
 namespace ZVision {
 
-NodeTimer::NodeTimer(uint32 key, uint32 timeInSeconds) 
+NodeTimer::NodeTimer(uint32 key, uint timeInSeconds) 
 	: _key(key), _timeLeft(timeInSeconds * 1000) {}
 
 bool NodeTimer::process(ZVision *engine, uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index 324dba2..5b4430c 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -37,7 +37,7 @@ public:
 
 class NodeTimer : public ActionNode {
 public:
-	NodeTimer(uint32 key, uint32 timeInSeconds);
+	NodeTimer(uint32 key, uint timeInSeconds);
 	/**
 	 * Decrement the timer by the delta time. If the timer is finished, set the status
 	 * in _globalState and let this node be deleted
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 0cec6af..2e1334c 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -174,7 +174,7 @@ ResultAction *ActionRandom::clone() const {
 }
 
 bool ActionRandom::execute(ZVision *engine) {
-	uint32 randNumber = engine->getRandomSource()->getRandomNumber(_max);
+	uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
 	engine->getScriptManager()->setStateValue(_key, randNumber);
 	return true;
 }
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 83f871d..8380f15 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -79,7 +79,7 @@ public:
 
 private:
 	uint32 _key;
-	byte _value;
+	uint _value;
 };
 
 class ActionAssign : public ResultAction {
@@ -90,7 +90,7 @@ public:
 
 private:
 	uint32 _key;
-	byte _value;
+	uint _value;
 };
 
 class ActionAttenuate : public ResultAction {
@@ -101,7 +101,7 @@ public:
 
 private:
 	uint32 _key;
-	int16 _attenuation;
+	int _attenuation;
 };
 
 class ActionChangeLocation : public ResultAction {
@@ -115,7 +115,7 @@ private:
 	char _room;
 	char _node;
 	char _view;
-	int16 _x;
+	uint32 _x;
 };
 
 class ActionCrossfade : public ResultAction {
@@ -127,11 +127,11 @@ public:
 private:
 	uint32 _keyOne;
 	uint32 _keyTwo;
-	byte _oneStartVolume;
-	byte _twoStartVolume;
-	byte _oneEndVolume;
-	byte _twoEndVolume;
-	uint16 _timeInMillis;
+	uint _oneStartVolume;
+	uint _twoStartVolume;
+	uint _oneEndVolume;
+	uint _twoEndVolume;
+	uint _timeInMillis;
 };
 
 class ActionDelayRender : public ResultAction {
@@ -142,7 +142,7 @@ public:
 
 private:
 	// TODO: Check if this should actually be frames or if it should be milliseconds/seconds
-	byte framesToDelay;
+	uint32 framesToDelay;
 };
 
 class ActionPlayAnimation : public ResultAction {
@@ -160,8 +160,8 @@ private:
 	uint32 _height;
 	uint32 _start;
 	uint32 _end;
-	uint32 _mask;
-	byte _framerate;
+	uint _mask;
+	uint _framerate;
 	bool _loop;
 };
 
@@ -174,8 +174,8 @@ public:
 private:
 	uint32 _key;
 	Common::String _fileName;
-	uint32 _mask;
-	byte _framerate;
+	uint _mask;
+	uint _framerate;
 };
 
 // TODO: See if this exists in ZGI. It doesn't in ZNem
@@ -193,7 +193,7 @@ public:
 
 private:
 	uint32 _key;
-	uint32 _max;
+	uint _max;
 };
 
 class ActionTimer : public ResultAction {
@@ -204,7 +204,7 @@ public:
 
 private:
 	uint32 _key;
-	uint32 _time;
+	uint _time;
 };
 
 } // End of namespace ZVision
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 59ef14e..af384cb 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -54,8 +54,8 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
 			sscanf(line.c_str(), "angle(%f)", &scale);
 			renderTable->setPanoramaScale(scale);
 		} else if (line.matchString("reversepana*", true)) {
-			byte reverse;
-			sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+			uint reverse;
+			sscanf(line.c_str(), "reversepana(%u)", &reverse);
 			if (reverse == 1) {
 				renderTable->setPanoramaReverse(true);
 			}
@@ -86,8 +86,8 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
 			sscanf(line.c_str(), "angle(%f)", &scale);
 			renderTable->setTiltScale(scale);
 		} else if (line.matchString("reversepana*", true)) {
-			byte reverse;
-			sscanf(line.c_str(), "reversepana(%hhu)", &reverse);
+			uint reverse;
+			sscanf(line.c_str(), "reversepana(%u)", &reverse);
 			if (reverse == 1) {
 				renderTable->setTiltReverse(true);
 			}
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index a01ea74..e392d3c 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -87,7 +87,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
 
 }
 
-void ZVision::onKeyDown(uint16 keyCode) {
+void ZVision::onKeyDown(uint keyCode) {
 
 }
 
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index d169620..8518c8f 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -42,9 +42,9 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
 		byte flagbyte = _source->readByte();
 		if (_source->eos())
 			break;
-		byte mask = 1;
+		uint mask = 1;
 
-		for (uint32 i = 0; i < 8; i++) {
+		for (int i = 0; i < 8; i++) {
 			if ((flagbyte & mask) == mask)
 			{
 				byte data = _source->readByte();
@@ -70,7 +70,7 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
 				uint16 length = (high & 0xF) + 2;
 				uint16 offset = low | ((high & 0xF0)<<4);
 
-				for(byte j = 0; j <= length; j++)
+				for(int j = 0; j <= length; j++)
 				{
 					byte temp = _window[(offset + j) & 0xFFF];
 					_window[_windowCursor] = temp;
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 0814220..25bb663 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -49,8 +49,8 @@ public:
 
 private:
 	Common::SeekableReadStream *_source;
-	char _window[_blockSize];
-	uint16 _windowCursor;
+	byte _window[BLOCK_SIZE];
+	uint _windowCursor;
 	bool _eosFlag;
 
 public:
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index fba139c..c73a345 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -70,7 +70,7 @@ public:
 	Common::List<Criteria> criteriaList;
 	// This has to be list of pointers because ResultAction is abstract
 	Common::List<ResultAction *> resultActions;
-	byte flags;
+	uint flags;
 
 	// Used by the ScriptManager to allow unique-ification of _referenceTable
 	// The unique-ification is done by sorting, then iterating and removing duplicates
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index adf1d64..531114c 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -29,7 +29,7 @@
 
 namespace ZVision {
 
-RenderTable::RenderTable(uint32 numColumns, uint32 numRows)
+RenderTable::RenderTable(uint numColumns, uint numRows)
 		: _numRows(numRows),
 		  _numColumns(numColumns),
 		  _renderState(FLAT) {
@@ -85,10 +85,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
 	bool isTransposed = _renderState == RenderTable::PANORAMA || _renderState == RenderTable::TILT;
 
 	for (int y = subRectangle.top; y < subRectangle.bottom; y++) {
-		uint32 normalizedY = y - subRectangle.top;
+		uint normalizedY = y - subRectangle.top;
 
 		for (int x = subRectangle.left; x < subRectangle.right; x++) {
-			uint32 normalizedX = x - subRectangle.left;
+			uint normalizedX = x - subRectangle.left;
 
 			uint32 index = (y + destRectangle.top) * _numColumns + (x + destRectangle.left);
 
@@ -137,15 +137,15 @@ void RenderTable::generatePanoramaLookupTable() {
 	float tanOverHalfHeight = tan(fovRadians) / halfHeight;
 
 	// TODO: Change the algorithm to write a whole row at a time instead of a whole column at a time. AKA: for(y) { for(x) {}} instead of for(x) { for(y) {}}
-	for (uint32 x = 0; x < _numColumns; x++) {
+	for (uint x = 0; x < _numColumns; x++) {
 		// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
 		float temp = atan(tanOverHalfHeight * ((float)x - halfWidth + 0.01f));
 
-		int32 newX = floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth);
+		int32 newX = int32(floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth));
 		float cosX = cos(temp);
 
-		for (uint32 y = 0; y < _numRows; y++) {
-			int32 newY = floor(halfHeight + (y - halfHeight) * cosX);
+		for (uint y = 0; y < _numRows; y++) {
+			int32 newY = int32(floor(halfHeight + ((float)y - halfHeight) * cosX));
 
 			uint32 index = y * _numColumns + x;
 
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index e5535a0..82bea62 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -32,7 +32,7 @@ namespace ZVision {
 
 class RenderTable {
 public:
-	RenderTable(uint32 numRows, uint32 numColumns);
+	RenderTable(uint numRows, uint numColumns);
 	~RenderTable();
 
 public:
@@ -43,7 +43,7 @@ public:
 	};
 
 private:
-	uint32 _numColumns, _numRows;
+	uint _numColumns, _numRows;
 	Vector2 *_internalBuffer;
 	RenderState _renderState;
 
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 5f2140d..fe78a82 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -267,8 +267,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 	return;
 }
 
-byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
-	byte flags;
+uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
+	uint flags = 0;
 
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 0ff0509..90bc202 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -60,7 +60,7 @@ void ScriptManager::createReferenceTable() {
 	}
 }
 
-void ScriptManager::updateNodes(uint32 deltaTimeMillis) {
+void ScriptManager::updateNodes(uint deltaTimeMillis) {
 	// If process() returns true, it means the node can be deleted
 	for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
 		if ((*iter)->process(_engine, deltaTimeMillis)) {
@@ -82,7 +82,7 @@ void ScriptManager::checkPuzzleCriteria() {
 		bool criteriaMet = false;
 		for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
 			// Get the value to compare against
-			byte argumentValue;
+			uint argumentValue;
 			if ((*iter).argument)
 				argumentValue = getStateValue(iter->argument);
 			else
@@ -119,16 +119,16 @@ void ScriptManager::checkPuzzleCriteria() {
 	}
 }
 
-byte ScriptManager::getStateValue(uint32 key) {
+uint ScriptManager::getStateValue(uint32 key) {
 	return _globalState[key];
 }
 
 // TODO: Add logic to check _referenceTable and add to _puzzlesToCheck if necessary
-void ScriptManager::setStateValue(uint32 key, byte value) {
+void ScriptManager::setStateValue(uint32 key, uint value) {
 	_globalState[key] = value;
 }
 
-void ScriptManager::addToStateValue(uint32 key, byte valueToAdd) {
+void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
 	_globalState[key] += valueToAdd;
 }
 
@@ -136,7 +136,7 @@ void ScriptManager::addActionNode(ActionNode *node) {
 	_activeNodes.push_back(node);
 }
 
-void ScriptManager::changeLocation(char world, char room, char node, char view, uint16 x) {
+void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 x) {
 	// Clear all the containers
 	_referenceTable.clear();
 	_puzzlesToCheck.clear();
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 3e054ff..e8a8324 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -50,7 +50,7 @@ private:
 	 * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a 
 	 * particular state key are checked after the key is modified.
 	 */
-	Common::HashMap<uint32, byte> _globalState;
+	Common::HashMap<uint32, uint> _globalState;
 	/** Holds the currently active ActionNodes */
 	Common::List<ActionNode *> _activeNodes;
 	/** References _globalState keys to Puzzles */
@@ -65,16 +65,16 @@ private:
 public:
 	
 	void initialize();
-	void updateNodes(uint32 deltaTimeMillis);
+	void updateNodes(uint deltaTimeMillis);
 	void checkPuzzleCriteria();
 
-	byte getStateValue(uint32 key);
-	void setStateValue(uint32 key, byte value);
-	void addToStateValue(uint32 key, byte valueToAdd);
+	uint getStateValue(uint32 key);
+	void setStateValue(uint32 key, uint value);
+	void addToStateValue(uint32 key, uint valueToAdd);
 
 	void addActionNode(ActionNode *node);
 
-	void changeLocation(char world, char room, char node, char view, uint16 x);
+	void changeLocation(char world, char room, char node, char view, uint32 x);
 
 private:
 	void createReferenceTable();
@@ -118,9 +118,9 @@ private:
 	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum
 	 *
 	 * @param stream    Scr file stream
-	 * @return          Bitwise or of all the flags set within the puzzle
+	 * @return          Bitwise OR of all the flags set within the puzzle
 	 */
-	byte parseFlags(Common::SeekableReadStream &stream) const;
+	uint parseFlags(Common::SeekableReadStream &stream) const;
 
 	/**
 	 * Helper method for parseScrFile. Parses the stream into a Control object
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 58a7ec3..e68d0de 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -70,7 +70,7 @@ template<class T>
 void removeDuplicateEntries(Common::Array<T> *container) {
 	Common::sort(container->front(), container->back());
 
-	for (uint32 i = 0; i < container->size(); i++) {
+	for (int i = 0; i < container->size(); i++) {
 		while (container[i] == container[i +1]) {
 			container->remove_at(i + 1);
 		}
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index caf43ae..1ccf736 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -33,15 +33,15 @@
 namespace ZVision {
 
 // Taken from SCI
-void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+void scale2x(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel) {
 	assert(bytesPerPixel == 1 || bytesPerPixel == 2);
-	const int newWidth = srcWidth * 2;
-	const int pitch = newWidth * bytesPerPixel;
+	const uint32 newWidth = srcWidth * 2;
+	const uint32 pitch = newWidth * bytesPerPixel;
 	const byte *srcPtr = src;
 
 	if (bytesPerPixel == 1) {
-		for (int y = 0; y < srcHeight; y++) {
-			for (int x = 0; x < srcWidth; x++) {
+		for (uint32 y = 0; y < srcHeight; y++) {
+			for (uint32 x = 0; x < srcWidth; x++) {
 				const byte color = *srcPtr++;
 				dst[0] = color;
 				dst[1] = color;
@@ -52,8 +52,8 @@ void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte b
 			dst += newWidth;
 		}
 	} else if (bytesPerPixel == 2) {
-		for (int y = 0; y < srcHeight; y++) {
-			for (int x = 0; x < srcWidth; x++) {
+		for (uint32 y = 0; y < srcHeight; y++) {
+			for (uint32 x = 0; x < srcWidth; x++) {
 				const byte color = *srcPtr++;
 				const byte color2 = *srcPtr++;
 				dst[0] = color;
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 03a35e0..742ba18 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -73,10 +73,10 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
 }
 
 int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
-	uint32 bytesRead = 0;
+	int bytesRead = 0;
 
 	// 0: Left, 1: Right
-	byte channel = 0;
+	uint channel = 0;
 
 	while (bytesRead < numSamples) {
 		byte encodedSample = _stream->readByte();
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 6d25d19..4e40a57 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -36,7 +36,7 @@ class ZVision;
 
 struct SoundParams {
 	char identifier;
-	uint16 rate;
+	uint32 rate;
 	bool stereo;
 	bool packed;
 };
@@ -73,7 +73,7 @@ private:
 	Audio::Timestamp _playtime;                                // Calculated total play time
 	Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
 	bool _endOfData;                                           // Whether the stream end has been reached
-	byte _stereo;
+	uint _stereo;
 
 	/** 
 	 * Holds the frequency and index from the last sample
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index fa91f8c..ca43549 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -117,7 +117,7 @@ Common::Error ZVision::run() {
 	// Main loop
 	uint32 currentTime = _system->getMillis();
 	uint32 lastTime = currentTime;
-	const uint32 desiredFrameTime = 33; // ~30 fps
+	const uint desiredFrameTime = 33; // ~30 fps
 
 	while (!shouldQuit()) {
 		processEvents();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 2e6ec11..9588623 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -83,7 +83,7 @@ private:
 	void processEvents();
 	void onMouseDown(const Common::Point &pos);
 	void onMouseMove(const Common::Point &pos);
-	void onKeyDown(uint16 keyCode);
+	void onKeyDown(uint keyCode);
 };
 
 } // End of namespace ZVision


Commit: 5e442c363ee870b63b13c6325c07be04bfb28fab
    https://github.com/scummvm/scummvm/commit/5e442c363ee870b63b13c6325c07be04bfb28fab
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:56-07:00

Commit Message:
ZVISION: Convert String pointers to const references

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 2e1334c..fda6e1b 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,8 +33,8 @@ namespace ZVision {
 // ActionAdd
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAdd::ActionAdd(Common::String *line) {
 	sscanf(line->c_str(), ":add(%u,%hhu)", &_key, &_value);
+ActionAdd::ActionAdd(const Common::String &line) {
 }
 
 ResultAction *ActionAdd::clone() const {
@@ -51,8 +51,8 @@ bool ActionAdd::execute(ZVision *engine) {
 // ActionAssign
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAssign::ActionAssign(Common::String *line) {
 	sscanf(line->c_str(), ":assign(%u, %hhu)", &_key, &_value);
+ActionAssign::ActionAssign(const Common::String &line) {
 }
 
 ResultAction *ActionAssign::clone() const {
@@ -69,8 +69,8 @@ bool ActionAssign::execute(ZVision *engine) {
 // ActionAttenuate
 //////////////////////////////////////////////////////////////////////////////
 
-ActionAttenuate::ActionAttenuate(Common::String *line) {
 	sscanf(line->c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
+ActionAttenuate::ActionAttenuate(const Common::String &line) {
 }
 
 ResultAction *ActionAttenuate::clone() const {
@@ -87,8 +87,8 @@ bool ActionAttenuate::execute(ZVision *engine) {
 // ActionChangeLocation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionChangeLocation::ActionChangeLocation(Common::String *line) {
 	sscanf(line->c_str(), ":change_location(%c,%c,%c%c,%hu)", &_world, &_room, &_node, &_view, &_x);
+ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
 }
 
 ResultAction *ActionChangeLocation::clone() const {
@@ -105,9 +105,9 @@ bool ActionChangeLocation::execute(ZVision *engine) {
 // ActionCrossfade
 //////////////////////////////////////////////////////////////////////////////
 
-ActionCrossfade::ActionCrossfade(Common::String *line) {
 	sscanf(line->c_str(), 
            ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
+ActionCrossfade::ActionCrossfade(const Common::String &line) {
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
@@ -125,9 +125,9 @@ bool ActionCrossfade::execute(ZVision *engine) {
 // ActionPreloadAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionPreloadAnimation::ActionPreloadAnimation(Common::String *line) {
 	// The two %*hhu are always 0 and dont seem to have a use
 	sscanf(line->c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
+ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
 }
 
 ResultAction *ActionPreloadAnimation::clone() const {
@@ -144,10 +144,10 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
 // ActionPlayAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-ActionPlayAnimation::ActionPlayAnimation(Common::String *line) {
 	// The two %*hhu are always 0 and dont seem to have a use
 	sscanf(line->c_str(), 
            ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
+ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
            &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 }
 
@@ -165,8 +165,8 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
 // ActionRandom
 //////////////////////////////////////////////////////////////////////////////
 
-ActionRandom::ActionRandom(Common::String *line) {
 	sscanf(line->c_str(), ":random:%u, %u)", &_key, &_max);
+ActionRandom::ActionRandom(const Common::String &line) {
 }
 
 ResultAction *ActionRandom::clone() const {
@@ -184,8 +184,8 @@ bool ActionRandom::execute(ZVision *engine) {
 // ActionTimer
 //////////////////////////////////////////////////////////////////////////////
 
-ActionTimer::ActionTimer(Common::String *line) {
 	sscanf(line->c_str(), ":timer:%u(%hu)", &_key, &_time);
+ActionTimer::ActionTimer(const Common::String &line) {
 }
 
 ResultAction *ActionTimer::clone() const {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 8380f15..e10a688 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -73,7 +73,7 @@ public:
 
 class ActionAdd : public ResultAction {
 public:
-	ActionAdd(Common::String *line);
+	ActionAdd(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -84,7 +84,7 @@ private:
 
 class ActionAssign : public ResultAction {
 public:
-	ActionAssign(Common::String *line);
+	ActionAssign(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -95,7 +95,7 @@ private:
 
 class ActionAttenuate : public ResultAction {
 public:
-	ActionAttenuate(Common::String *line);
+	ActionAttenuate(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -106,7 +106,7 @@ private:
 
 class ActionChangeLocation : public ResultAction {
 public:
-	ActionChangeLocation(Common::String *line);
+	ActionChangeLocation(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -120,7 +120,7 @@ private:
 
 class ActionCrossfade : public ResultAction {
 public:
-	ActionCrossfade(Common::String *line);
+	ActionCrossfade(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -136,7 +136,7 @@ private:
 
 class ActionDelayRender : public ResultAction {
 public:
-	ActionDelayRender(Common::String *line);
+	ActionDelayRender(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -147,7 +147,7 @@ private:
 
 class ActionPlayAnimation : public ResultAction {
 public:
-	ActionPlayAnimation(Common::String *line);
+	ActionPlayAnimation(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -167,7 +167,7 @@ private:
 
 class ActionPreloadAnimation : public ResultAction {
 public:
-	ActionPreloadAnimation(Common::String *line);
+	ActionPreloadAnimation(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -181,13 +181,13 @@ private:
 // TODO: See if this exists in ZGI. It doesn't in ZNem
 //class ActionUnloadAnimation : public ResultAction {
 //public:
-//	ActionUnloadAnimation(Common::String *line);
+//	ActionUnloadAnimation(const Common::String &line);
 //	bool execute(ZVision *engine);
 //};
 
 class ActionRandom : public ResultAction {
 public:
-	ActionRandom(Common::String *line);
+	ActionRandom(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
@@ -198,7 +198,7 @@ private:
 
 class ActionTimer : public ResultAction {
 public:
-	ActionTimer(Common::String *line);
+	ActionTimer(const Common::String &line);
 	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index fe78a82..0bd28ec 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -143,11 +143,11 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 	while (!line.contains('}')) {
 		// Parse for the action type
 		if (line.matchString("*:add*", true)) {
-			actionList.push_back(new ActionAdd(&line));
+			actionList.push_back(new ActionAdd(line));
 		} else if (line.matchString("*:animplay*", true)) {
-			actionList.push_back(new ActionPlayAnimation(&line));
+			actionList.push_back(new ActionPlayAnimation(line));
 		} else if (line.matchString("*:animpreload*", true)) {
-			actionList.push_back(new ActionPreloadAnimation(&line));
+			actionList.push_back(new ActionPreloadAnimation(line));
 		} else if (line.matchString("*:animunload*", true)) {
 			
 


Commit: d06083aa9625c285454da562bb7397b7cbae8987
    https://github.com/scummvm/scummvm/commit/d06083aa9625c285454da562bb7397b7cbae8987
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:57-07:00

Commit Message:
ZVISION: Convert sscanf formats to follow new int lengths

Changed paths:
    engines/zvision/actions.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index fda6e1b..689d540 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,8 +33,8 @@ namespace ZVision {
 // ActionAdd
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":add(%u,%hhu)", &_key, &_value);
 ActionAdd::ActionAdd(const Common::String &line) {
+	sscanf(line.c_str(), ":add(%u,%u)", &_key, &_value);
 }
 
 ResultAction *ActionAdd::clone() const {
@@ -51,8 +51,8 @@ bool ActionAdd::execute(ZVision *engine) {
 // ActionAssign
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":assign(%u, %hhu)", &_key, &_value);
 ActionAssign::ActionAssign(const Common::String &line) {
+	sscanf(line.c_str(), ":assign(%u, %u)", &_key, &_value);
 }
 
 ResultAction *ActionAssign::clone() const {
@@ -69,8 +69,8 @@ bool ActionAssign::execute(ZVision *engine) {
 // ActionAttenuate
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":assign(%u, %hd)", &_key, &_attenuation);
 ActionAttenuate::ActionAttenuate(const Common::String &line) {
+	sscanf(line.c_str(), ":assign(%u, %d)", &_key, &_attenuation);
 }
 
 ResultAction *ActionAttenuate::clone() const {
@@ -87,8 +87,8 @@ bool ActionAttenuate::execute(ZVision *engine) {
 // ActionChangeLocation
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":change_location(%c,%c,%c%c,%hu)", &_world, &_room, &_node, &_view, &_x);
 ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
+	sscanf(line.c_str(), ":change_location(%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
 }
 
 ResultAction *ActionChangeLocation::clone() const {
@@ -105,9 +105,9 @@ bool ActionChangeLocation::execute(ZVision *engine) {
 // ActionCrossfade
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), 
-           ":crossfade(%u %u %hhu %hhu %hhu %hhu %hu)",
 ActionCrossfade::ActionCrossfade(const Common::String &line) {
+	sscanf(line.c_str(),
+           ":crossfade(%u %u %u %u %u %u %u)",
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
@@ -125,9 +125,9 @@ bool ActionCrossfade::execute(ZVision *engine) {
 // ActionPreloadAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line->c_str(), ":animpreload:%u(%s %*hhu %*hhu %u %hhu)", &_key, &_fileName, &_mask, &_framerate);
 ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
+	// The two %*u are always 0 and dont seem to have a use
+	sscanf(line.c_str(), ":animpreload:%u(%s %*u %*u %u %u)", &_key, &_fileName, &_mask, &_framerate);
 }
 
 ResultAction *ActionPreloadAnimation::clone() const {
@@ -144,10 +144,10 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
 // ActionPlayAnimation
 //////////////////////////////////////////////////////////////////////////////
 
-	// The two %*hhu are always 0 and dont seem to have a use
-	sscanf(line->c_str(), 
-           ":animplay:%u(%s %u %u %u %u %u %u %hhu %*hhu %*hhu %u %hhu)",
 ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
+	// The two %*u are always 0 and dont seem to have a use
+	sscanf(line.c_str(),
+           ":animplay:%u(%s %u %u %u %u %u %u %u %*u %*u %u %u)",
            &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 }
 
@@ -165,8 +165,8 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
 // ActionRandom
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":random:%u, %u)", &_key, &_max);
 ActionRandom::ActionRandom(const Common::String &line) {
+	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
 }
 
 ResultAction *ActionRandom::clone() const {
@@ -184,8 +184,8 @@ bool ActionRandom::execute(ZVision *engine) {
 // ActionTimer
 //////////////////////////////////////////////////////////////////////////////
 
-	sscanf(line->c_str(), ":timer:%u(%hu)", &_key, &_time);
 ActionTimer::ActionTimer(const Common::String &line) {
+	sscanf(line.c_str(), ":timer:%u(%u)", &_key, &_time);
 }
 
 ResultAction *ActionTimer::clone() const {


Commit: 903e21b8aff563d50f591289eb454cd65bf09d5d
    https://github.com/scummvm/scummvm/commit/903e21b8aff563d50f591289eb454cd65bf09d5d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:57-07:00

Commit Message:
ZVISION: Initialize the iterator

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 90bc202..2f486c4 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -55,7 +55,7 @@ void ScriptManager::createReferenceTable() {
 	}
 
 	// Remove duplicate entries
-	for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter; referenceTableIter != _referenceTable.end(); referenceTableIter++) {
+	for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); referenceTableIter++) {
 		removeDuplicateEntries(&(referenceTableIter->_value));
 	}
 }


Commit: 8ec0a90611560dcb29d0ceb8fc476408c0de4103
    https://github.com/scummvm/scummvm/commit/8ec0a90611560dcb29d0ceb8fc476408c0de4103
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:58-07:00

Commit Message:
ZVISION: Convert _blockSize to an anonymous enum

Changed paths:
    engines/zvision/lzss_read_stream.cpp
    engines/zvision/lzss_read_stream.h



diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 8518c8f..03ab12d 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -32,7 +32,7 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
 		  _windowCursor(0x0FEE),
 		  _eosFlag(false) {
 	// Clear the window to null
-	memset(_window, 0, _blockSize);
+	memset(_window, 0, BLOCK_SIZE);
 }
 
 uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) {
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 25bb663..25a8b67 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -43,9 +43,10 @@ public:
 	 */
 	LzssReadStream(Common::SeekableReadStream *source);
 
-public:
-	static const uint32 _npos = 0xFFFFFFFFu;
-	static const uint16 _blockSize = 0x1000u;
+private:
+	enum {
+		BLOCK_SIZE = 0x1000
+	};
 
 private:
 	Common::SeekableReadStream *_source;


Commit: e170be4ea595459065b55c3e218418150c8a53e5
    https://github.com/scummvm/scummvm/commit/e170be4ea595459065b55c3e218418150c8a53e5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:59-07:00

Commit Message:
ZVISION: Remove redundant class qualifier

Changed paths:
    engines/zvision/script_manager.h



diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index e8a8324..07dd3d8 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -103,7 +103,7 @@ private:
 	 * @param stream      Scr file stream
 	 * @return            Whether any criteria were read
 	 */
-	bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
+	bool parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
 
 	/**
 	 * Parses the stream into a Results object


Commit: 87f2e9a894442bcd2e2e52aa775154045a9304dd
    https://github.com/scummvm/scummvm/commit/87f2e9a894442bcd2e2e52aa775154045a9304dd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:32:59-07:00

Commit Message:
ZVISION: Update module.mk with current obj

Changed paths:
    engines/zvision/module.mk



diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 3d672d9..f90bb15 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,17 +1,21 @@
 MODULE := engines/zvision
  
 MODULE_OBJS := \
+	action_node.o \
 	actions.o \
 	console.o \
+	control.o \
 	detection.o \
 	events.o \
-	graphics.o \
-	image.o \
 	lzss_read_stream.o \
+	puzzle.o \
+	render_manager.o \
+	render_table.o \
 	scr_file_handling.o \
 	script_manager.o \
 	scripts.o \
 	single_value_container.o \
+	utility.o \
 	video.o \
 	zvision.o \
 	zfs_archive.o \


Commit: d43e1e97419fea23ec2952fd05052e09d71b8037
    https://github.com/scummvm/scummvm/commit/d43e1e97419fea23ec2952fd05052e09d71b8037
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:00-07:00

Commit Message:
ZVISION: Add filename parsing for ActionPlayAnimation

Changed paths:
    engines/zvision/actions.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 689d540..d1f5b93 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -145,10 +145,14 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
+	char fileName[25];
+
 	// The two %*u are always 0 and dont seem to have a use
 	sscanf(line.c_str(),
            ":animplay:%u(%s %u %u %u %u %u %u %u %*u %*u %u %u)",
-           &_key, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
+           &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
+
+	_fileName = Common::String(fileName);
 }
 
 ResultAction *ActionPlayAnimation::clone() const {


Commit: 8e3ffdece89d608620adfc182b487f683270cbbd
    https://github.com/scummvm/scummvm/commit/8e3ffdece89d608620adfc182b487f683270cbbd
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:00-07:00

Commit Message:
ZVISION: Initialize _needsScreenUpdate in RenderManager

Changed paths:
    engines/zvision/render_manager.cpp



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 10afe1f..7edbf52 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -40,6 +40,7 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
 	  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
 	  _currentVideo(0),
 	  _scaledVideoFrameBuffer(0),
+	  _needsScreenUpdate(false),
 	  _renderTable(width, height) {
 }
 


Commit: 4729641cf91eb1ac7528446fb922f5b18e2d46b3
    https://github.com/scummvm/scummvm/commit/4729641cf91eb1ac7528446fb922f5b18e2d46b3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:01-07:00

Commit Message:
ZVISION: Fix typo in format string

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 2f486c4..ad986d6 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -148,7 +148,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
 	_activeControls.clear();
 
 	// Parse into puzzles and controls
-	Common::String fileName = Common::String::format("%c%c%c&c.scr", world, room, node, view);
+	Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
 	parseScrFile(fileName);
 
 	// Create the puzzle reference table


Commit: 3df425004dda026f6989a0020f24bd380cfd34f2
    https://github.com/scummvm/scummvm/commit/3df425004dda026f6989a0020f24bd380cfd34f2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:01-07:00

Commit Message:
ZVISION: Remove superfluous comma

Changed paths:
    engines/zvision/single_value_container.h



diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
index 593f11c..54677ff 100644
--- a/engines/zvision/single_value_container.h
+++ b/engines/zvision/single_value_container.h
@@ -44,7 +44,7 @@ public:
 		UINT32,
 		FLOAT,
 		DOUBLE,
-		STRING,
+		STRING
 	};
 
 	// Constructors


Commit: 99ecc80e861c17ecb6f3bcc5e9e6c7b5dcb860a7
    https://github.com/scummvm/scummvm/commit/99ecc80e861c17ecb6f3bcc5e9e6c7b5dcb860a7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:02-07:00

Commit Message:
ZVISION: Initialize iterator

Changed paths:
    engines/zvision/utility.cpp



diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 2942a35..2e1ade6 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -174,8 +174,8 @@ void dumpEveryResultAction(const Common::String &destFile) {
 			trimCommentsAndWhiteSpace(&line);
 		}
 
-		for (Common::HashMap<Common::String, bool>::iterator iter = fileAlreadyUsed.begin(); iter != fileAlreadyUsed.end(); ++iter) {
-			iter->_value = false;
+		for (Common::HashMap<Common::String, bool>::iterator fileUsedIter = fileAlreadyUsed.begin(); fileUsedIter != fileAlreadyUsed.end(); ++fileUsedIter) {
+			fileUsedIter->_value = false;
 		}
 	}
 


Commit: cf453120168ebadacc49d29c8683658fe457963d
    https://github.com/scummvm/scummvm/commit/cf453120168ebadacc49d29c8683658fe457963d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:03-07:00

Commit Message:
ZVISION: Fix unsigned/signed mismatch warning

Changed paths:
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index e68d0de..9cc0d1e 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -70,7 +70,7 @@ template<class T>
 void removeDuplicateEntries(Common::Array<T> *container) {
 	Common::sort(container->front(), container->back());
 
-	for (int i = 0; i < container->size(); i++) {
+	for (uint i = 0; i < container->size(); i++) {
 		while (container[i] == container[i +1]) {
 			container->remove_at(i + 1);
 		}


Commit: 2faaf8488bb5bdace2c017b37f825bc38f41ef84
    https://github.com/scummvm/scummvm/commit/2faaf8488bb5bdace2c017b37f825bc38f41ef84
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:04-07:00

Commit Message:
ZVISION: Convert ResultAction pointers to SharePtr

This gets rid of the need for specific destruction as well as making the copy swap
operations in the ScriptManger _referenceTable more efficient

Changed paths:
  R engines/zvision/puzzle.cpp
    engines/zvision/module.mk
    engines/zvision/puzzle.h
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index f90bb15..26cf4ee 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -8,7 +8,6 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	lzss_read_stream.o \
-	puzzle.o \
 	render_manager.o \
 	render_table.o \
 	scr_file_handling.o \
diff --git a/engines/zvision/puzzle.cpp b/engines/zvision/puzzle.cpp
deleted file mode 100644
index 8399919..0000000
--- a/engines/zvision/puzzle.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
-
-#include "common/scummsys.h"
-
-#include "zvision/actions.h"
-#include "zvision/puzzle.h"
-
-namespace ZVision {
-
-Puzzle::~Puzzle() {
-	for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
-		delete (*iter);
-	}
-}
-
-Puzzle::Puzzle(const Puzzle &other)
-		: key(other.key),
-		  criteriaList(other.criteriaList),
-		  flags(flags) {
-	// We have to clone the ResultActions since they are on the heap
-	for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
-		resultActions.push_back((*iter)->clone());
-	}
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index c73a345..5e060c0 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -23,19 +23,15 @@
 #ifndef ZVISION_PUZZLE_H
 #define ZVISION_PUZZLE_H
 
+
 #include "common/list.h"
+#include "common/ptr.h"
 
 namespace ZVision {
 
 class ResultAction;
 
-class Puzzle {
-public:
-	Puzzle() {}
-	~Puzzle();
-	Puzzle(const Puzzle &other);
-	
-public:
+struct Puzzle {
 	/** How criteria should be decided */
 	enum CriteriaOperator {
 		EQUAL_TO,
@@ -65,11 +61,10 @@ public:
 		DISABLED = 0x04
 	};
 
-public:
 	uint32 key;
 	Common::List<Criteria> criteriaList;
 	// This has to be list of pointers because ResultAction is abstract
-	Common::List<ResultAction *> resultActions;
+	Common::List<Common::SharedPtr<ResultAction>> resultActions;
 	uint flags;
 
 	// Used by the ScriptManager to allow unique-ification of _referenceTable
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 0bd28ec..860e771 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -134,7 +134,7 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe
 	return true;
 }
 
-void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
+void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<ResultAction> > &actionList) const {
 	// Loop until we find the closing brace
 	Common::String line = stream.readLine();
 	trimCommentsAndWhiteSpace(&line);
@@ -143,14 +143,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 	while (!line.contains('}')) {
 		// Parse for the action type
 		if (line.matchString("*:add*", true)) {
-			actionList.push_back(new ActionAdd(line));
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionAdd(line)));
 		} else if (line.matchString("*:animplay*", true)) {
-			actionList.push_back(new ActionPlayAnimation(line));
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPlayAnimation(line)));
 		} else if (line.matchString("*:animpreload*", true)) {
-			actionList.push_back(new ActionPreloadAnimation(line));
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPreloadAnimation(line)));
 		} else if (line.matchString("*:animunload*", true)) {
-			
-
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionUnloadAnimation(line)));
 		} else if (line.matchString("*:attenuate*", true)) {
 			
 
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index ad986d6..540971a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -112,7 +112,7 @@ void ScriptManager::checkPuzzleCriteria() {
 		// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
 		// criteriaList can be empty. Aka, the puzzle should be executed immediately
 		if (puzzle->criteriaList.empty() || criteriaMet) {
-			for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+			for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
 				(*resultIter)->execute(_engine);
 			}
 		}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 07dd3d8..c43030d 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -106,13 +106,14 @@ private:
 	bool parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
 
 	/**
-	 * Parses the stream into a Results object
+	 * Parses the stream into a ResultAction objects
 	 * Helper method for parsePuzzle. 
 	 *
-	 * @param stream    Scr file stream
-	 * @return          Created Results object
+	 * @param stream        Scr file stream
+	 * @param actionList    The list where the results will be added
+	 * @return              Created Results object
 	 */
-	void parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const;
+	void parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<ResultAction> > &actionList) const;
 
 	/**
 	 * Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum


Commit: 93e4f4dbf7cb6868e790d877ba01678ba19a8fbb
    https://github.com/scummvm/scummvm/commit/93e4f4dbf7cb6868e790d877ba01678ba19a8fbb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:04-07:00

Commit Message:
ZVISION: Sort using iterators instead of the actual elements

Also convert the argument to a reference instead of a pointer

Changed paths:
    engines/zvision/script_manager.cpp
    engines/zvision/utility.h



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 540971a..cd4e174 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -56,7 +56,7 @@ void ScriptManager::createReferenceTable() {
 
 	// Remove duplicate entries
 	for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); referenceTableIter++) {
-		removeDuplicateEntries(&(referenceTableIter->_value));
+		removeDuplicateEntries(referenceTableIter->_value);
 	}
 }
 
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 9cc0d1e..8974809 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -67,12 +67,12 @@ void dumpEveryResultAction(const Common::String &destFile);
  * @return                
  */
 template<class T>
-void removeDuplicateEntries(Common::Array<T> *container) {
-	Common::sort(container->front(), container->back());
+void removeDuplicateEntries(Common::Array<T> &container) {
+	Common::sort(container.begin(), container.end());
 
-	for (uint i = 0; i < container->size(); i++) {
-		while (container[i] == container[i +1]) {
-			container->remove_at(i + 1);
+	for (uint i = 0; i + 1 < container.size(); i++) {
+		while (container[i] == container[i + 1]) {
+			container.remove_at(i + 1);
 		}
 	}
 }


Commit: 44ee28c13f39328a4e5e0eca27ac0b5349fe1253
    https://github.com/scummvm/scummvm/commit/44ee28c13f39328a4e5e0eca27ac0b5349fe1253
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:05-07:00

Commit Message:
ZVISION: Remove ResultAction clone member function

Puzzle now uses smart pointers so clone is no longer necessary

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index d1f5b93..438cec7 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -37,10 +37,6 @@ ActionAdd::ActionAdd(const Common::String &line) {
 	sscanf(line.c_str(), ":add(%u,%u)", &_key, &_value);
 }
 
-ResultAction *ActionAdd::clone() const {
-	return new ActionAdd(*this);
-}
-
 bool ActionAdd::execute(ZVision *engine) {
 	engine->getScriptManager()->addToStateValue(_key, _value);
 	return true;
@@ -55,10 +51,6 @@ ActionAssign::ActionAssign(const Common::String &line) {
 	sscanf(line.c_str(), ":assign(%u, %u)", &_key, &_value);
 }
 
-ResultAction *ActionAssign::clone() const {
-	return new ActionAssign(*this);
-}
-
 bool ActionAssign::execute(ZVision *engine) {
 	engine->getScriptManager()->setStateValue(_key, _value);
 	return true;
@@ -73,10 +65,6 @@ ActionAttenuate::ActionAttenuate(const Common::String &line) {
 	sscanf(line.c_str(), ":assign(%u, %d)", &_key, &_attenuation);
 }
 
-ResultAction *ActionAttenuate::clone() const {
-	return new ActionAttenuate(*this);
-}
-
 bool ActionAttenuate::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -91,10 +79,6 @@ ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
 	sscanf(line.c_str(), ":change_location(%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
 }
 
-ResultAction *ActionChangeLocation::clone() const {
-	return new ActionChangeLocation(*this);
-}
-
 bool ActionChangeLocation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -111,10 +95,6 @@ ActionCrossfade::ActionCrossfade(const Common::String &line) {
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
-ResultAction *ActionCrossfade::clone() const {
-	return new ActionCrossfade(*this);
-}
-
 bool ActionCrossfade::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -128,10 +108,7 @@ bool ActionCrossfade::execute(ZVision *engine) {
 ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
 	// The two %*u are always 0 and dont seem to have a use
 	sscanf(line.c_str(), ":animpreload:%u(%s %*u %*u %u %u)", &_key, &_fileName, &_mask, &_framerate);
-}
 
-ResultAction *ActionPreloadAnimation::clone() const {
-	return new ActionPreloadAnimation(*this);
 }
 
 bool ActionPreloadAnimation::execute(ZVision *engine) {
@@ -155,10 +132,6 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
 	_fileName = Common::String(fileName);
 }
 
-ResultAction *ActionPlayAnimation::clone() const {
-	return new ActionPlayAnimation(*this);
-}
-
 bool ActionPlayAnimation::execute(ZVision *engine) {
 	// TODO: Implement
 	return true;
@@ -173,10 +146,6 @@ ActionRandom::ActionRandom(const Common::String &line) {
 	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
 }
 
-ResultAction *ActionRandom::clone() const {
-	return new ActionRandom(*this);
-}
-
 bool ActionRandom::execute(ZVision *engine) {
 	uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
 	engine->getScriptManager()->setStateValue(_key, randNumber);
@@ -192,8 +161,6 @@ ActionTimer::ActionTimer(const Common::String &line) {
 	sscanf(line.c_str(), ":timer:%u(%u)", &_key, &_time);
 }
 
-ResultAction *ActionTimer::clone() const {
-	return new ActionTimer(*this);
 }
 
 bool ActionTimer::execute(ZVision *engine) {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index e10a688..7ee51ad 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -35,7 +35,6 @@ class ZVision;
 class ResultAction {
 public:
 	virtual ~ResultAction() {}
-	virtual ResultAction *clone() const = 0;
 	virtual bool execute(ZVision *engine) = 0;
 };
 
@@ -74,7 +73,6 @@ public:
 class ActionAdd : public ResultAction {
 public:
 	ActionAdd(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -85,7 +83,6 @@ private:
 class ActionAssign : public ResultAction {
 public:
 	ActionAssign(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -96,7 +93,6 @@ private:
 class ActionAttenuate : public ResultAction {
 public:
 	ActionAttenuate(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -107,7 +103,6 @@ private:
 class ActionChangeLocation : public ResultAction {
 public:
 	ActionChangeLocation(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -121,7 +116,6 @@ private:
 class ActionCrossfade : public ResultAction {
 public:
 	ActionCrossfade(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -137,7 +131,6 @@ private:
 class ActionDelayRender : public ResultAction {
 public:
 	ActionDelayRender(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -148,7 +141,6 @@ private:
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -168,7 +160,6 @@ private:
 class ActionPreloadAnimation : public ResultAction {
 public:
 	ActionPreloadAnimation(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -188,7 +179,6 @@ private:
 class ActionRandom : public ResultAction {
 public:
 	ActionRandom(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:
@@ -199,7 +189,6 @@ private:
 class ActionTimer : public ResultAction {
 public:
 	ActionTimer(const Common::String &line);
-	ResultAction *clone() const;
 	bool execute(ZVision *engine);
 
 private:


Commit: 87be3180c73c16af0609f9e734d499233d69784f
    https://github.com/scummvm/scummvm/commit/87be3180c73c16af0609f9e734d499233d69784f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:05-07:00

Commit Message:
ZVISION: Fix sscanf formatting errors

Changed paths:
    engines/zvision/actions.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 438cec7..a1ea967 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -34,7 +34,7 @@ namespace ZVision {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionAdd::ActionAdd(const Common::String &line) {
-	sscanf(line.c_str(), ":add(%u,%u)", &_key, &_value);
+	sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
 }
 
 bool ActionAdd::execute(ZVision *engine) {
@@ -48,7 +48,7 @@ bool ActionAdd::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionAssign::ActionAssign(const Common::String &line) {
-	sscanf(line.c_str(), ":assign(%u, %u)", &_key, &_value);
+	sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
 }
 
 bool ActionAssign::execute(ZVision *engine) {
@@ -62,7 +62,7 @@ bool ActionAssign::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionAttenuate::ActionAttenuate(const Common::String &line) {
-	sscanf(line.c_str(), ":assign(%u, %d)", &_key, &_attenuation);
+	sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
 }
 
 bool ActionAttenuate::execute(ZVision *engine) {
@@ -76,7 +76,7 @@ bool ActionAttenuate::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
-	sscanf(line.c_str(), ":change_location(%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
+	sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
 }
 
 bool ActionChangeLocation::execute(ZVision *engine) {
@@ -91,7 +91,7 @@ bool ActionChangeLocation::execute(ZVision *engine) {
 
 ActionCrossfade::ActionCrossfade(const Common::String &line) {
 	sscanf(line.c_str(),
-           ":crossfade(%u %u %u %u %u %u %u)",
+           "%*[^(](%u %u %u %u %u %u %u)",
            &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
 }
 
@@ -106,9 +106,12 @@ bool ActionCrossfade::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
+	char fileName[25];
+
 	// The two %*u are always 0 and dont seem to have a use
-	sscanf(line.c_str(), ":animpreload:%u(%s %*u %*u %u %u)", &_key, &_fileName, &_mask, &_framerate);
+	sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
 
+	_fileName = Common::String(fileName);
 }
 
 bool ActionPreloadAnimation::execute(ZVision *engine) {
@@ -126,7 +129,7 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
 
 	// The two %*u are always 0 and dont seem to have a use
 	sscanf(line.c_str(),
-           ":animplay:%u(%s %u %u %u %u %u %u %u %*u %*u %u %u)",
+           "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
            &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
 
 	_fileName = Common::String(fileName);
@@ -143,7 +146,7 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionRandom::ActionRandom(const Common::String &line) {
-	sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max);
+	sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
 }
 
 bool ActionRandom::execute(ZVision *engine) {
@@ -158,9 +161,9 @@ bool ActionRandom::execute(ZVision *engine) {
 //////////////////////////////////////////////////////////////////////////////
 
 ActionTimer::ActionTimer(const Common::String &line) {
-	sscanf(line.c_str(), ":timer:%u(%u)", &_key, &_time);
 }
 
+	sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
 }
 
 bool ActionTimer::execute(ZVision *engine) {


Commit: 8d5e92b935966fdae84182dd7e7845280fb38ad4
    https://github.com/scummvm/scummvm/commit/8d5e92b935966fdae84182dd7e7845280fb38ad4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:06-07:00

Commit Message:
ZVISION: Add console cmd for changing location

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 3dad7af..aaf43c5 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -29,6 +29,7 @@
 
 #include "zvision/console.h"
 #include "zvision/zvision.h"
+#include "zvision/script_manager.h"
 #include "zvision/render_manager.h"
 #include "zvision/zork_avi_decoder.h"
 #include "zvision/zork_raw.h"
@@ -45,6 +46,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
 	DCmd_Register("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
 	DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
+	DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -150,4 +152,15 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdChangeLocation(int argc, const char **argv) {
+	if (argc != 6) {
+		DebugPrintf("Use changelocation <char: world> <char: room> <char:node> <char:view> <int: x position> to change your location");
+		return true;
+	}
+
+	_engine->getScriptManager()->changeLocation(*(argv[1]), *(argv[2]), *(argv[3]), *(argv[4]), atoi(argv[5]));
+
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 7b1beeb..d7d2ce9 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -45,6 +45,7 @@ private:
 	bool cmdGenerateRenderTable(int argc, const char **argv);
 	bool cmdSetPanoramaFoV(int argc, const char **argv);
 	bool cmdSetPanoramaScale(int argc, const char **argv);
+	bool cmdChangeLocation(int argc, const char **argv);
 };
 
 } // End of namespace ZVision


Commit: 5ef19407b4b16943c33265df4dc388738e710522
    https://github.com/scummvm/scummvm/commit/5ef19407b4b16943c33265df4dc388738e710522
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:07-07:00

Commit Message:
ZVISION: Fix typo in panarama and tilt control parsing

Changed paths:
    engines/zvision/control.cpp



diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index af384cb..986a7ae 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -51,7 +51,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
 			renderTable->setPanoramaFoV(fov);
 		} else if (line.matchString("linscale*", true)) {
 			float scale;
-			sscanf(line.c_str(), "angle(%f)", &scale);
+			sscanf(line.c_str(), "linscale(%f)", &scale);
 			renderTable->setPanoramaScale(scale);
 		} else if (line.matchString("reversepana*", true)) {
 			uint reverse;
@@ -83,7 +83,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
 			renderTable->setTiltFoV(fov);
 		} else if (line.matchString("linscale*", true)) {
 			float scale;
-			sscanf(line.c_str(), "angle(%f)", &scale);
+			sscanf(line.c_str(), "linscale(%f)", &scale);
 			renderTable->setTiltScale(scale);
 		} else if (line.matchString("reversepana*", true)) {
 			uint reverse;


Commit: ebe83ed3909de75f401278afbf85a02c9a9ccf1a
    https://github.com/scummvm/scummvm/commit/ebe83ed3909de75f401278afbf85a02c9a9ccf1a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:07-07:00

Commit Message:
ZVISION: Make panorama and tilt control generate the RenderTable after setting all the settings

Changed paths:
    engines/zvision/control.cpp



diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 986a7ae..fdb88c6 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -66,6 +66,8 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
 		line = stream.readLine();
 		trimCommentsAndWhiteSpace(&line);
 	}
+
+	renderTable->generateRenderTable();
 }
 
 void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream) {
@@ -96,6 +98,8 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
 		line = stream.readLine();
 		trimCommentsAndWhiteSpace(&line);
 	}
+
+	renderTable->generateRenderTable();
 }
 
 } // End of namespace ZVision


Commit: 47f10fe78426159f76abd585f4b40f3025e7473f
    https://github.com/scummvm/scummvm/commit/47f10fe78426159f76abd585f4b40f3025e7473f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:08-07:00

Commit Message:
ZVISION: Overload renderImageToScreen to handle fileNames and ReadStreams

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 7edbf52..4fd1a83 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -63,14 +63,14 @@ void RenderManager::updateScreen(bool isConsoleActive) {
 
 void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
 	// Panoramas are transposed
-	// The actual data is transposed in the RenderTable lookup
+	// The actual data is transposed in mutateImage
 	if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
 		uint32 temp = imageHeight;
 		imageHeight = imageWidth;
 		imageWidth = temp;
 	}
 	
-	// Check if we truly want a subRect of the image
+	// If subRect is empty, use the entire image
 	if (subRectangle.isEmpty())
 		subRectangle = Common::Rect(imageWidth, imageHeight);
 
@@ -107,19 +107,23 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
 		return;
 	}
 
+	renderImageToScreen(file, destinationX, destinationY, subRectangle);
+}
+
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
 	// Read the magic number
 	// Some files are true TGA, while others are TGZ
 	uint32 fileType;
-	fileType = file.readUint32BE();
+	fileType = stream.readUint32BE();
 
 	// Check for TGZ files
 	if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
 		// TGZ files have a header and then Bitmap data that is compressed with LZSS
-		uint32 decompressedSize = file.readSint32LE();
-		uint32 imageWidth = file.readSint32LE();
-		uint32 imageHeight = file.readSint32LE();
+		uint32 decompressedSize = stream.readSint32LE();
+		uint32 imageWidth = stream.readSint32LE();
+		uint32 imageHeight = stream.readSint32LE();
 
-		LzssReadStream stream(&file);
+		LzssReadStream stream(&stream);
 		byte *buffer = new byte[decompressedSize];
 		stream.read(buffer, decompressedSize);
 
@@ -129,11 +133,11 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
 		delete[] buffer;
 	} else {
 		// Reset the cursor
-		file.seek(0);
+		stream.seek(0);
 
 		// Decode
 		Graphics::TGADecoder tga;
-		if (!tga.loadStream(file)) {
+		if (!tga.loadStream(stream)) {
 			warning("Error while reading TGA image");
 			return;
 		}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 8b4d7e8..f9d1375 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -34,6 +34,7 @@ class OSystem;
 
 namespace Common {
 class String;
+class SeekableReadStream;
 }
 
 namespace Video {
@@ -89,6 +90,17 @@ public:
 	 */
 	void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
 
+	/**
+	 * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
+	 * The image will be clipped to fit inside the window.
+	 *
+	 * @param stream          Stream to read the image data from
+	 * @param destinationX    X position where the image should be put
+	 * @param destinationY    Y position where the image should be put
+	 * @param subRectangle    The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
+	 */
+	void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
+
 	RenderTable *getRenderTable();
 
 	bool needsScreenUpdate() { return _needsScreenUpdate; };


Commit: 9e996c4fec6477395d98ddc670df8732db3d7f28
    https://github.com/scummvm/scummvm/commit/9e996c4fec6477395d98ddc670df8732db3d7f28
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:08-07:00

Commit Message:
ZVISION: Convert _activeNodes and _activeControls to Lists of SharedPtr

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 860e771..8c8c6c4 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -56,9 +56,10 @@ void ScriptManager::parseScrFile(Common::String fileName) {
 			parsePuzzle(puzzle, file);
 			_activePuzzles.push_back(puzzle);
 		} else if (line.matchString("control:*", true)) {
-			Control *control = parseControl(line, file);
+			Common::SharedPtr<Control> control;
+
 			// Some controls don't require nodes. They just initialize the scene
-			if (control != 0) {
+			if (parseControl(line, file, control)) {
 				_activeControls.push_back(control);
 			}
 		}
@@ -289,8 +290,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
 	return flags;
 }
 
-Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
-	Control *control = 0;
+bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr<Control> &control) {
 	uint32 key;
 	char controlTypeBuffer[20];
 
@@ -302,17 +302,17 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
 
 	} else if (controlType.equalsIgnoreCase("flat")) {
 		Control::parseFlatControl(_engine);
-		return 0;
+		return false;
 	} else if (controlType.equalsIgnoreCase("pana")) {
 		Control::parsePanoramaControl(_engine, stream);
-		return 0;
+		return false;
 	}
 	else if (controlType.equalsIgnoreCase("tilt")) {
 		Control::parseTiltControl(_engine, stream);
-		return 0;
+		return false;
 	}
 
-	return control;
+	return true;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index cd4e174..55cd570 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -62,12 +62,10 @@ void ScriptManager::createReferenceTable() {
 
 void ScriptManager::updateNodes(uint deltaTimeMillis) {
 	// If process() returns true, it means the node can be deleted
-	for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
+	for (Common::List<Common::SharedPtr<ActionNode> >::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
 		if ((*iter)->process(_engine, deltaTimeMillis)) {
-			// Remove the node from _activeNodes, then delete it
-			ActionNode *node = *iter;
+			// Remove the node from _activeNodes, the SharedPtr destructor will delete the actual ActionNode
 			iter = _activeNodes.erase(iter);
-			delete node;
 		} else {
 			iter++;
 		}
@@ -132,7 +130,7 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
 	_globalState[key] += valueToAdd;
 }
 
-void ScriptManager::addActionNode(ActionNode *node) {
+void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
 	_activeNodes.push_back(node);
 }
 
@@ -141,10 +139,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
 	_referenceTable.clear();
 	_puzzlesToCheck.clear();
 	_activePuzzles.clear();
-	// _activeControls is a list of pointers to the heap, so we have to delete the Controls before we call clear()
-	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
-		delete (*iter);
-	}
+	// We can clear without deleting from the heap because we use SharedPtr
 	_activeControls.clear();
 
 	// Parse into puzzles and controls
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index c43030d..8834031 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -52,7 +52,7 @@ private:
 	 */
 	Common::HashMap<uint32, uint> _globalState;
 	/** Holds the currently active ActionNodes */
-	Common::List<ActionNode *> _activeNodes;
+	Common::List<Common::SharedPtr<ActionNode> > _activeNodes;
 	/** References _globalState keys to Puzzles */
 	Common::HashMap<uint32, Common::Array<Puzzle *> > _referenceTable;
 	/** Holds the Puzzles that should be checked this frame */
@@ -60,7 +60,7 @@ private:
 	/** Holds the currently active puzzles */
 	Common::List<Puzzle> _activePuzzles;
 	/** Holds the currently active controls */
-	Common::List<Control *> _activeControls;
+	Common::List<Common::SharedPtr<Control> > _activeControls;
 
 public:
 	
@@ -72,7 +72,7 @@ public:
 	void setStateValue(uint32 key, uint value);
 	void addToStateValue(uint32 key, uint valueToAdd);
 
-	void addActionNode(ActionNode *node);
+	void addActionNode(const Common::SharedPtr<ActionNode> &node);
 
 	void changeLocation(char world, char room, char node, char view, uint32 x);
 
@@ -129,7 +129,7 @@ private:
 	 * @param line      The line initially read
 	 * @param stream    Scr file stream
 	 */
-	Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
+	bool parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr<Control> &control);
 };
 
 


Commit: 11118262e4d884a838ac8ce0f8d674948aac1d33
    https://github.com/scummvm/scummvm/commit/11118262e4d884a838ac8ce0f8d674948aac1d33
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:09-07:00

Commit Message:
ZVISION: Add logic to check _referenceTable Puzzles every time a globalState is changed

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 55cd570..2e57c18 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -121,9 +121,14 @@ uint ScriptManager::getStateValue(uint32 key) {
 	return _globalState[key];
 }
 
-// TODO: Add logic to check _referenceTable and add to _puzzlesToCheck if necessary
 void ScriptManager::setStateValue(uint32 key, uint value) {
 	_globalState[key] = value;
+
+	if (_referenceTable.contains(key)) {
+		for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); iter++) {
+			_puzzlesToCheck.push((*iter));
+		}
+	}
 }
 
 void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {


Commit: 8bbc260b8642d08c049acb81546e82bc88100ee2
    https://github.com/scummvm/scummvm/commit/8bbc260b8642d08c049acb81546e82bc88100ee2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:10-07:00

Commit Message:
ZVISION: Create RenderManager method to set the current background image

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 4fd1a83..b6163c8 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -24,6 +24,7 @@
 
 #include "common/file.h"
 #include "common/system.h"
+#include "common/stream.h"
 
 #include "engines/util.h"
 #include "graphics/decoders/tga.h"
@@ -39,6 +40,7 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
 	  _height(height),
 	  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
 	  _currentVideo(0),
+	  _currentBackground(0),
 	  _scaledVideoFrameBuffer(0),
 	  _needsScreenUpdate(false),
 	  _renderTable(width, height) {
@@ -155,4 +157,18 @@ RenderTable *RenderManager::getRenderTable() {
 	return &_renderTable;
 }
 
+void RenderManager::setBackgroundImage(const Common::String &fileName) {
+	Common::File *file = new Common::File;
+
+	if (!file->open(fileName)) {
+		warning("Could not open file %s", fileName.c_str());
+		return;
+	}
+
+	_currentBackground = file;
+
+	// TODO: Check if all the panoramas are the same height. AKA: can we hardcode the vertical centering to 80px?
+	renderImageToScreen(*_currentBackground, 0, 80);
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index f9d1375..fc2598e 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -54,6 +54,8 @@ private:
 	const Graphics::PixelFormat _pixelFormat;
 	RenderTable _renderTable;
 
+	Common::SeekableReadStream *_currentBackground;
+
 	Video::VideoDecoder *_currentVideo;
 	byte *_scaledVideoFrameBuffer;
 
@@ -101,6 +103,14 @@ public:
 	 */
 	void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
 
+	/**
+	 * Sets the current background image to be used by the RenderManager and immediately
+	 * blits it to the screen. (It won't show up until the end of the frame)
+	 *
+	 * @param fileName    The name of the image file
+	 */
+	void setBackgroundImage(const Common::String &fileName);
+
 	RenderTable *getRenderTable();
 
 	bool needsScreenUpdate() { return _needsScreenUpdate; };


Commit: 32b3363acddcc25fb2380fbb66df829832d5200d
    https://github.com/scummvm/scummvm/commit/32b3363acddcc25fb2380fbb66df829832d5200d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:10-07:00

Commit Message:
ZVISION: Add ActionSetScreen

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index a1ea967..9a8dee0 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -25,6 +25,7 @@
 #include "zvision/actions.h"
 #include "zvision/zvision.h"
 #include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
 #include "zvision/action_node.h"
 
 namespace ZVision {
@@ -157,17 +158,34 @@ bool ActionRandom::execute(ZVision *engine) {
 
 
 //////////////////////////////////////////////////////////////////////////////
-// ActionTimer
+// ActionSetScreen
 //////////////////////////////////////////////////////////////////////////////
 
-ActionTimer::ActionTimer(const Common::String &line) {
+ActionSetScreen::ActionSetScreen(const Common::String &line) {
+	char fileName[25];
+	sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
+
+	_fileName = Common::String(fileName);
 }
 
+bool ActionSetScreen::execute(ZVision *engine) {
+	RenderManager *renderManager = engine->getRenderManager();
+	renderManager->setBackgroundImage(_fileName);
+
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionTimer
+//////////////////////////////////////////////////////////////////////////////
+
+ActionTimer::ActionTimer(const Common::String &line) {
 	sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
 }
 
 bool ActionTimer::execute(ZVision *engine) {
-	engine->getScriptManager()->addActionNode(new NodeTimer(_key, _time));
+	engine->getScriptManager()->addActionNode(Common::SharedPtr<ActionNode>(new NodeTimer(_key, _time)));
 	return true;
 }
 
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 7ee51ad..3922f92 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -186,6 +186,15 @@ private:
 	uint _max;
 };
 
+class ActionSetScreen : public ResultAction {
+public:
+	ActionSetScreen(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+	Common::String _fileName;
+};
+
 class ActionTimer : public ResultAction {
 public:
 	ActionTimer(const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 8c8c6c4..1dc8ee5 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -233,8 +233,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 			
 
 		} else if (line.matchString("*:set_screen*", true)) {
-			
-
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionSetScreen(line)));
 		} else if (line.matchString("*:set_venus*", true)) {
 			
 


Commit: d89a55d3deb703c23c6bb111c256a11ba17c5faf
    https://github.com/scummvm/scummvm/commit/d89a55d3deb703c23c6bb111c256a11ba17c5faf
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:11-07:00

Commit Message:
ZVISION: Create class definitions for mutliple ResultAction children

Changed paths:
    engines/zvision/actions.h



diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 3922f92..46b31e9 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -128,6 +128,14 @@ private:
 	uint _timeInMillis;
 };
 
+class ActionDebug : public ResultAction {
+public:
+	ActionDebug(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
 class ActionDelayRender : public ResultAction {
 public:
 	ActionDelayRender(const Common::String &line);
@@ -138,6 +146,54 @@ private:
 	uint32 framesToDelay;
 };
 
+class ActionDisableControl : public ResultAction {
+public:
+	ActionDisableControl(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
+class ActionDisableVenus : public ResultAction {
+public:
+	ActionDisableVenus(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
+class ActionDisplayMessage : public ResultAction {
+public:
+	ActionDisplayMessage(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
+class ActionDissolve : public ResultAction {
+public:
+	ActionDissolve(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
+class ActionDistort : public ResultAction {
+public:
+	ActionDistort(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
+class ActionEnableControl : public ResultAction {
+public:
+	ActionEnableControl(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+};
+
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(const Common::String &line);
@@ -170,11 +226,11 @@ private:
 };
 
 // TODO: See if this exists in ZGI. It doesn't in ZNem
-//class ActionUnloadAnimation : public ResultAction {
-//public:
-//	ActionUnloadAnimation(const Common::String &line);
-//	bool execute(ZVision *engine);
-//};
+class ActionUnloadAnimation : public ResultAction {
+public:
+	ActionUnloadAnimation(const Common::String &line);
+	bool execute(ZVision *engine);
+};
 
 class ActionRandom : public ResultAction {
 public:


Commit: 3fd5a8ab5a626998a358282e3af7668f3bdd9403
    https://github.com/scummvm/scummvm/commit/3fd5a8ab5a626998a358282e3af7668f3bdd9403
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:11-07:00

Commit Message:
ZVISION: Offset the RenderTable index by the normalized coords, not the subRect coords

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 531114c..55c11ec 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -90,7 +90,7 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
 		for (int x = subRectangle.left; x < subRectangle.right; x++) {
 			uint normalizedX = x - subRectangle.left;
 
-			uint32 index = (y + destRectangle.top) * _numColumns + (x + destRectangle.left);
+			uint32 index = (normalizedY + destRectangle.top) * _numColumns + (normalizedX + destRectangle.left);
 
 			// RenderTable only stores offsets from the original coordinates
 			uint32 sourceYIndex = y + _internalBuffer[index].y;


Commit: c828074df9384b1e6eb3176d346ffc1b18dd2b11
    https://github.com/scummvm/scummvm/commit/c828074df9384b1e6eb3176d346ffc1b18dd2b11
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T11:33:12-07:00

Commit Message:
ZVISION: Remove extraneous comments

Changed paths:
    engines/zvision/render_table.cpp



diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 55c11ec..b6598c1 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -150,8 +150,8 @@ void RenderTable::generatePanoramaLookupTable() {
 			uint32 index = y * _numColumns + x;
 
 			// Only store the x,y offsets instead of the absolute positions
-			_internalBuffer[index].x = newX - x; //pixel index
-			_internalBuffer[index].y = newY - y; //pixel index
+			_internalBuffer[index].x = newX - x;
+			_internalBuffer[index].y = newY - y;
 		}
 	}
 }


Commit: 0a8f57721bdc2f907e2fb42083341f81fabd9dce
    https://github.com/scummvm/scummvm/commit/0a8f57721bdc2f907e2fb42083341f81fabd9dce
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T21:01:42-07:00

Commit Message:
ZVISION: Create Clock class to handle deltaTime while pausing and unpausing the game

Changed paths:
  A engines/zvision/clock.cpp
  A engines/zvision/clock.h



diff --git a/engines/zvision/clock.cpp b/engines/zvision/clock.cpp
new file mode 100644
index 0000000..2324d39
--- /dev/null
+++ b/engines/zvision/clock.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.
+ *
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/system.h"
+
+#include "zvision/clock.h"
+
+namespace ZVision {
+
+Clock::Clock(OSystem *system) 
+	: _system(system),
+	  _lastTime(0),
+	  _deltaTime(0),
+	  _pausedTime(0),
+	  _paused(false) {
+}
+
+void Clock::update() {
+	uint32 currentTime = _system->getMillis();
+	_deltaTime = currentTime - _lastTime - _pausedTime;
+	if (_deltaTime < 0) {
+		_deltaTime = 0;
+	}
+
+	if (_paused) {
+		_pausedTime += _deltaTime;
+	} else if (_pausedTime > 0) {
+		_pausedTime = 0;
+	}
+
+	_lastTime = currentTime;
+}
+
+void Clock::start() {
+	if (_paused) {
+		_paused = false;
+	}
+}
+
+void Clock::stop() {
+	if (!_paused) {
+		_paused = true;
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/clock.h b/engines/zvision/clock.h
new file mode 100644
index 0000000..d17db6c
--- /dev/null
+++ b/engines/zvision/clock.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_CLOCK_H
+#define ZVISION_CLOCK_H
+
+#include "common/types.h"
+
+class OSystem;
+
+namespace ZVision {
+
+/* Class for handling frame to frame deltaTime while keeping track of time pauses/un-pauses */
+class Clock {
+public:
+	Clock(OSystem *system);
+
+private:
+	OSystem *_system;
+	uint32 _lastTime;
+	uint32 _deltaTime;
+	uint32 _pausedTime;
+	bool _paused;
+
+public:
+	/**
+	 * Updates _deltaTime with the difference between the current time and
+	 * when the last update() was called.
+	 */
+	void update();
+	/**
+	 * Get the delta time since the last frame. (The time between update() calls)
+	 *
+	 * @return    Delta time since the last frame (in milliseconds)
+	 */
+	uint32 getDeltaTime() const { return _deltaTime; }
+	/**
+	 * Get the time from the program starting to the last update() call
+	 *
+	 * @return Time from program start to last update() call (in milliseconds)
+	 */
+	uint32 getLastMeasuredTime() { return _lastTime; }
+
+	/**
+	 * Pause the clock. Any future delta times will take this pause into account.
+	 * Has no effect if the clock is already paused.    
+	 */
+	void start();
+	/**
+	 * Un-pause the clock.
+	 * Has no effect if the clock is already un-paused.    
+	 */
+	void stop();
+};
+
+} // End of namespace ZVision
+
+#endif


Commit: a86a0832e08c777ef23f2ce97004963b301dd598
    https://github.com/scummvm/scummvm/commit/a86a0832e08c777ef23f2ce97004963b301dd598
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T21:52:21-07:00

Commit Message:
ZVISION: Create console method for dumping a file by name

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



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index aaf43c5..9c7d79a 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -47,6 +47,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	DCmd_Register("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
 	DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
 	DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
+	DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
 }
 
 bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -163,4 +164,15 @@ bool Console::cmdChangeLocation(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdDumpFile(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Use dumpfile <fileName> to dump a file");
+		return true;
+	}
+
+	writeFileContentsToFile(argv[1], argv[1]);
+
+	return true;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index d7d2ce9..be3ebf1 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -46,6 +46,7 @@ private:
 	bool cmdSetPanoramaFoV(int argc, const char **argv);
 	bool cmdSetPanoramaScale(int argc, const char **argv);
 	bool cmdChangeLocation(int argc, const char **argv);
+	bool cmdDumpFile(int argc, const char **argv);
 };
 
 } // End of namespace ZVision


Commit: 7b9858d6b45ad4c02729445975518a48292c3658
    https://github.com/scummvm/scummvm/commit/7b9858d6b45ad4c02729445975518a48292c3658
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T21:52:31-07:00

Commit Message:
ZVISION: Make video code blocking.

The script system requires that all ResultAction::execute() block until they finish. The video system *was* 'asyncronous'
in that you would just start a video and then run() would finish processing it. This code forces the video to complely finish
before playVideo returns. The Clock object is used to keep track of deltaTime while the video is playing.

Changed paths:
    engines/zvision/console.cpp
    engines/zvision/events.cpp
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h
    engines/zvision/video.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 9c7d79a..6634e0b 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -69,9 +69,9 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
 		return true;
 	}
 
-	Video::VideoDecoder *videoDecoder = new ZorkAVIDecoder();
-	if (videoDecoder && videoDecoder->loadFile(argv[1])) {
-		_engine->getRenderManager()->startVideo(videoDecoder);
+	ZorkAVIDecoder videoDecoder;
+	if (videoDecoder.loadFile(argv[1])) {
+		_engine->playVideo(videoDecoder);
 	}
 
 	return true;
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index e392d3c..508d261 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -61,11 +61,6 @@ void ZVision::processEvents() {
 				if (_event.kbd.hasFlags(Common::KBD_CTRL))
 					quitGame();
 				break;
-			case Common::KEYCODE_ESCAPE:
-				if (_renderManager->isVideoPlaying())
-					_renderManager->cancelVideo();
-
-				break;
 			default:
 				break;
 			}
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b6163c8..604c310 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -38,25 +38,12 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
 	: _system(system),
 	  _width(width),
 	  _height(height),
-	  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),	// RGB555
-	  _currentVideo(0),
 	  _currentBackground(0),
-	  _scaledVideoFrameBuffer(0),
 	  _needsScreenUpdate(false),
 	  _renderTable(width, height) {
 }
 
-/**
- * Initialize graphics
- */
-void RenderManager::initialize() {
-	initGraphics(_width, _height, true, &_pixelFormat);
-}
-
 void RenderManager::updateScreen(bool isConsoleActive) {
-	if (_currentVideo != 0)
-		continueVideo();
-
 	if (_needsScreenUpdate || isConsoleActive) {
 		_system->updateScreen();
 		_needsScreenUpdate = false;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index fc2598e..9554e88 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -26,8 +26,6 @@
 #include "common/types.h"
 #include "common/rect.h"
 
-#include "graphics/pixelformat.h"
-
 #include "zvision/render_table.h"
 
 class OSystem;
@@ -51,7 +49,6 @@ private:
 	OSystem *_system;
 	const int _width;
 	const int _height;
-	const Graphics::PixelFormat _pixelFormat;
 	RenderTable _renderTable;
 
 	Common::SeekableReadStream *_currentBackground;
@@ -66,22 +63,6 @@ public:
 	void updateScreen(bool isConsoleActive);
 
 	/**
-	 * Start a video playing. It will also load the first frame of the video.
-	 *
-	 * @param videoDecoder    The video to play
-	 */
-	void startVideo(Video::VideoDecoder *videoDecoder);
-	/**
-	 * @return    Is a video currently being played
-	 */
-	bool isVideoPlaying() { return _currentVideo == 0; }
-	/**
-	 * Cancels a video prematurely. Any sound remaining in the queue will continue to play.
-	 * The last frame of the video will remain on the screen until something else overwrites it
-	 */
-	void cancelVideo();
-
-	/**
 	 * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
 	 * The image will be clipped to fit inside the window.
 	 *
@@ -116,11 +97,6 @@ public:
 	bool needsScreenUpdate() { return _needsScreenUpdate; };
 
 private:
-	/**
-	 * Checks the time since the last video frame, and blits the next frame to the screen
-	 */
-	void continueVideo();
-
 	void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle);
 };
 
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 1ccf736..8550a6c 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -27,7 +27,9 @@
 #include "engines/util.h"
 #include "graphics/surface.h"
 
+#include "zvision/clock.h"
 #include "zvision/render_manager.h"
+#include "zvision/zvision.h"
 
 
 namespace ZVision {
@@ -71,62 +73,77 @@ void scale2x(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte
 	}
 }
 
-void RenderManager::startVideo(Video::VideoDecoder *videoDecoder) {
-	if (!videoDecoder)
-		return;
-
-	_currentVideo = videoDecoder;
-
+void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
+	// Videos use a different pixel format
 	Common::List<Graphics::PixelFormat> formats;
-	formats.push_back(videoDecoder->getPixelFormat());
+	formats.push_back(videoDecoder.getPixelFormat());
 	initGraphics(_width, _height, true, formats);
-	
-	_scaledVideoFrameBuffer = new byte[_currentVideo->getWidth() * _currentVideo->getHeight() * _currentVideo->getPixelFormat().bytesPerPixel * 4];
-
-	_currentVideo->start();
 
-	// Load the first frame
-	continueVideo();
-}
-
-void RenderManager::continueVideo() {
-	byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel;
-	uint16 origWidth = _currentVideo->getWidth();
-	uint16 origHeight = _currentVideo->getHeight();
+	byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
+	uint16 origWidth = videoDecoder.getWidth();
+	uint16 origHeight = videoDecoder.getHeight();
 	uint16 pitch = origWidth * bytesPerPixel;
+
+	// Most videos are very small. Therefore we do a simple 2x scale
 	bool shouldBeScaled = (origWidth * 2 <= 640 && origHeight * 2 <= 480);
 	uint16 finalWidth = shouldBeScaled ? origWidth * 2 : origWidth;
 	uint16 finalHeight = shouldBeScaled ? origHeight * 2 : origHeight;
 
-	uint16 x = (_system->getWidth() - finalWidth) / 2;
-	uint16 y = (_system->getHeight() - finalHeight) / 2;
+	byte *scaledVideoFrameBuffer = new byte[origHeight * pitch * 4];
+
+	uint16 x = (_width - finalWidth) / 2;
+	uint16 y = (_height - finalHeight) / 2;
+
+	_clock->stop();
+	videoDecoder.start();
+
+	// Only continue while the video is still playing
+	while (videoDecoder.isPlaying()) {
+		_clock->update();
+		uint32 currentTime = _clock->getLastMeasuredTime();
+
+		// Check for engine quit and video stop key presses
+		while (_eventMan->pollEvent(_event)) {
+			switch (_event.type) {
+			case Common::EVENT_KEYDOWN:
+				switch (_event.kbd.keycode) {
+				case Common::KEYCODE_q:
+					if (_event.kbd.hasFlags(Common::KBD_CTRL))
+						quitGame();
+					break;
+				case Common::KEYCODE_SPACE:
+					videoDecoder.stop();
+					break;
+				}
+			}
+		}
 
-	if (!_currentVideo->endOfVideo()) {
-		if (_currentVideo->needsUpdate()) {
-			const Graphics::Surface *frame = _currentVideo->decodeNextFrame();
+		if (videoDecoder.needsUpdate()) {
+			const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
 
 			if (frame) {
 				if (shouldBeScaled) {
-					scale2x((byte *)frame->pixels, _scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel);
-					_system->copyRectToScreen(_scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
+					scale2x((byte *)frame->pixels, scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel);
+					_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
 				} else {
 					_system->copyRectToScreen((byte *)frame->pixels, pitch, x, y, finalWidth, finalHeight);
 				}
 
-				_needsScreenUpdate = true;
+				_system->updateScreen();
 			}
 		}
-	} else {
-		cancelVideo();
+
+		// Calculate the frame delay based off a desired frame time
+		int delay = _desiredFrameTime - (currentTime - _system->getMillis());
+		// Ensure non-negative
+		delay = delay < 0 ? 0 : delay;
+		_system->delayMillis(delay);
 	}
-}
 
-void RenderManager::cancelVideo() {
+	_clock->stop();
+
+	// Reset the pixel format to the original state
 	initGraphics(_width, _height, true, &_pixelFormat);
-	delete _currentVideo;
-	_currentVideo = 0;
-	delete[] _scaledVideoFrameBuffer;
-	_scaledVideoFrameBuffer = 0;
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index ca43549..0015c41 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -31,11 +31,14 @@
 #include "common/file.h"
 
 #include "engines/util.h"
+
+#include "audio/mixer.h"
  
 #include "zvision/zvision.h"
 #include "zvision/console.h"
 #include "zvision/script_manager.h"
 #include "zvision/render_manager.h"
+#include "zvision/clock.h"
 #include "zvision/zfs_archive.h"
 #include "zvision/detection.h"
 
@@ -47,7 +50,9 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 		: Engine(syst),
 		  _gameDescription(gameDesc),
 		  _width(640),
-		  _height(480) {
+		  _height(480),
+		  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /*RGB 555*/
+		  _desiredFrameTime(33) /* ~30 fps */ {
 	// Put your engine in a sane state, but do nothing big yet;
 	// in particular, do not load data from files; rather, if you
 	// need to do such things, do them from run().
@@ -75,14 +80,19 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 	_scriptManager = new ScriptManager(this);
 	_renderManager = new RenderManager(_system, _width, _height);
 
+	// Create clock
+	_clock = new Clock(_system);
+
 	debug("ZVision::ZVision");
 }
- 
+
 ZVision::~ZVision() {
 	debug("ZVision::~ZVision");
  
 	// Dispose of resources
 	delete _console;
+	delete _clock;
+	delete _renderManager;
 	delete _scriptManager;
 	delete _rnd;
  
@@ -103,7 +113,7 @@ void ZVision::initialize() {
 		SearchMan.add(name, archive);
 	}
 
-	_renderManager->initialize();
+	initGraphics(_width, _height, true, &_pixelFormat);
 
 	_scriptManager->initialize();
 
@@ -115,25 +125,20 @@ Common::Error ZVision::run() {
 	initialize();
 
 	// Main loop
-	uint32 currentTime = _system->getMillis();
-	uint32 lastTime = currentTime;
-	const uint desiredFrameTime = 33; // ~30 fps
-
 	while (!shouldQuit()) {
-		processEvents();
+		_clock->update();
+		uint32 currentTime = _clock->getLastMeasuredTime();
 		
-		currentTime = _system->getMillis();
-		uint32 deltaTime = currentTime - lastTime;
-		lastTime = currentTime;
+		processEvents();
 
-		_scriptManager->updateNodes(deltaTime);
+		_scriptManager->updateNodes(_clock->getDeltaTime());
 		_scriptManager->checkPuzzleCriteria();
 
 		// Render a frame
 		_renderManager->updateScreen(_console->isActive());
 		
 		// Calculate the frame delay based off a desired frame time
-		int delay = desiredFrameTime - (currentTime - _system->getMillis());
+		int delay = _desiredFrameTime - (currentTime - _system->getMillis());
 		// Ensure non-negative
 		delay = delay < 0 ? 0 : delay;
 		_system->delayMillis(delay);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 9588623..459096a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -29,16 +29,24 @@
 
 #include "engines/engine.h"
 
+#include "graphics/pixelformat.h"
+
 #include "zvision/detection.h"
 
 #include "gui/debugger.h"
- 
+
+
+namespace Video {
+class VideoDecoder;
+}
+
 namespace ZVision {
 
 struct ZVisionGameDescription;
 class Console;
 class ScriptManager;
 class RenderManager;
+class Clock;
  
 // our engine debug channels
 enum {
@@ -58,25 +66,35 @@ private:
 	const ZVisionGameDescription *_gameDescription;
 	const int _width;
 	const int _height;
+	const Graphics::PixelFormat _pixelFormat;
+
+	const uint _desiredFrameTime;
 
 	// We need random numbers
 	Common::RandomSource *_rnd;
+
 	// Managers
 	ScriptManager *_scriptManager;
 	RenderManager *_renderManager;
 
+	// Clock
+	Clock *_clock;
+
 	// To prevent allocation every time we process events
 	Common::Event _event;
 
 public:
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;
-	virtual Common::Error run();
+	Common::Error run();
+
 	ScriptManager *getScriptManager() const;
 	RenderManager *getRenderManager() const;
 	Common::RandomSource *getRandomSource() const;
 	ZVisionGameId getGameId() const;
 
+	void playVideo(Video::VideoDecoder &videoDecoder);
+
 private:
 	void initialize();
 


Commit: c4dc3989a70939fd98f1d55dffb548e68f80adfb
    https://github.com/scummvm/scummvm/commit/c4dc3989a70939fd98f1d55dffb548e68f80adfb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T21:53:40-07:00

Commit Message:
ZVISION: Make the return from makeRawZorkStream more specific

Changed paths:
    engines/zvision/zork_raw.cpp
    engines/zvision/zork_raw.h



diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 742ba18..92f6592 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -155,7 +155,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
 	return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
 }
 
-Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
+Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
 	Common::File *file = new Common::File();
 	assert(file->open(filePath));
 
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 4e40a57..f19ffc1 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -126,7 +126,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
 								                bool stereo,
                                                 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
 
-Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
+Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
 
 } // End of namespace ZVision
 


Commit: ec7036469c57eecb7afb226cc3dd176fcc74c0cb
    https://github.com/scummvm/scummvm/commit/ec7036469c57eecb7afb226cc3dd176fcc74c0cb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:05:14-07:00

Commit Message:
ZVISION: Make _clock a member variable instead of a pointer to the heap

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



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 8550a6c..51cccee 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -94,13 +94,13 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
 	uint16 x = (_width - finalWidth) / 2;
 	uint16 y = (_height - finalHeight) / 2;
 
-	_clock->stop();
+	_clock.stop();
 	videoDecoder.start();
 
 	// Only continue while the video is still playing
 	while (videoDecoder.isPlaying()) {
-		_clock->update();
-		uint32 currentTime = _clock->getLastMeasuredTime();
+		_clock.update();
+		uint32 currentTime = _clock.getLastMeasuredTime();
 
 		// Check for engine quit and video stop key presses
 		while (_eventMan->pollEvent(_event)) {
@@ -140,7 +140,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
 		_system->delayMillis(delay);
 	}
 
-	_clock->stop();
+	_clock.stop();
 
 	// Reset the pixel format to the original state
 	initGraphics(_width, _height, true, &_pixelFormat);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0015c41..f406b5e 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -52,7 +52,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 		  _width(640),
 		  _height(480),
 		  _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /*RGB 555*/
-		  _desiredFrameTime(33) /* ~30 fps */ {
+		  _desiredFrameTime(33), /* ~30 fps */
+		  _clock(_system) {
 	// Put your engine in a sane state, but do nothing big yet;
 	// in particular, do not load data from files; rather, if you
 	// need to do such things, do them from run().
@@ -80,9 +81,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 	_scriptManager = new ScriptManager(this);
 	_renderManager = new RenderManager(_system, _width, _height);
 
-	// Create clock
-	_clock = new Clock(_system);
-
 	debug("ZVision::ZVision");
 }
 
@@ -91,7 +89,6 @@ ZVision::~ZVision() {
  
 	// Dispose of resources
 	delete _console;
-	delete _clock;
 	delete _renderManager;
 	delete _scriptManager;
 	delete _rnd;
@@ -126,12 +123,12 @@ Common::Error ZVision::run() {
 
 	// Main loop
 	while (!shouldQuit()) {
-		_clock->update();
-		uint32 currentTime = _clock->getLastMeasuredTime();
+		_clock.update();
+		uint32 currentTime = _clock.getLastMeasuredTime();
 		
 		processEvents();
 
-		_scriptManager->updateNodes(_clock->getDeltaTime());
+		_scriptManager->updateNodes(_clock.getDeltaTime());
 		_scriptManager->checkPuzzleCriteria();
 
 		// Render a frame
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 459096a..3eff16e 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -32,6 +32,7 @@
 #include "graphics/pixelformat.h"
 
 #include "zvision/detection.h"
+#include "zvision/clock.h"
 
 #include "gui/debugger.h"
 
@@ -46,7 +47,6 @@ struct ZVisionGameDescription;
 class Console;
 class ScriptManager;
 class RenderManager;
-class Clock;
  
 // our engine debug channels
 enum {
@@ -78,7 +78,7 @@ private:
 	RenderManager *_renderManager;
 
 	// Clock
-	Clock *_clock;
+	Clock _clock;
 
 	// To prevent allocation every time we process events
 	Common::Event _event;


Commit: 1d694dcb81604c20a8755f80d509eccb8904017e
    https://github.com/scummvm/scummvm/commit/1d694dcb81604c20a8755f80d509eccb8904017e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:05:25-07:00

Commit Message:
ZVISION: Add support for engine pausing from higher up (GMM, phone call, etc.)

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



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f406b5e..aaf843f 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -144,6 +144,16 @@ Common::Error ZVision::run() {
 	return Common::kNoError;
 }
 
+void ZVision::pauseEngineIntern(bool pause) {
+	_mixer->pauseAll(pause);
+
+	if (pause) {
+		_clock.stop();
+	} else {
+		_clock.start();
+	}
+}
+
 ScriptManager *ZVision::getScriptManager() const {
 	return _scriptManager;
 }
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 3eff16e..990b6e8 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -87,6 +87,7 @@ public:
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;
 	Common::Error run();
+	void pauseEngineIntern(bool pause);
 
 	ScriptManager *getScriptManager() const;
 	RenderManager *getRenderManager() const;


Commit: 4b0015b8e997e9ca95141216f2b24ee33df01055
    https://github.com/scummvm/scummvm/commit/4b0015b8e997e9ca95141216f2b24ee33df01055
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:05:25-07:00

Commit Message:
ZVISION: Check if a key exists before returning _globalState value.

operator[] creates a key value pair if it doesn't exist. So blindly returning a value without checking if the
key exists could result in undefined behavior, depening on what the value is initialized to in its constructor

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 2e57c18..7fcade2 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -118,7 +118,10 @@ void ScriptManager::checkPuzzleCriteria() {
 }
 
 uint ScriptManager::getStateValue(uint32 key) {
-	return _globalState[key];
+	if (_globalState.contains(key))
+		return _globalState[key];
+	else
+		return 0;
 }
 
 void ScriptManager::setStateValue(uint32 key, uint value) {


Commit: 20c892092907e66c6c13d1598b973486ba2fc95c
    https://github.com/scummvm/scummvm/commit/20c892092907e66c6c13d1598b973486ba2fc95c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:05:26-07:00

Commit Message:
ZVISION: Pass the scr fileName as a const reference

Changed paths:
    engines/zvision/scr_file_handling.cpp
    engines/zvision/script_manager.h



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 1dc8ee5..cd3cfe4 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -33,7 +33,7 @@
 
 namespace ZVision {
 
-void ScriptManager::parseScrFile(Common::String fileName) {
+void ScriptManager::parseScrFile(const Common::String &fileName) {
 	Common::File file;
 	if (!file.open(fileName))
 		return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 8834031..484069b 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -84,7 +84,7 @@ private:
 	 *
 	 * @param fileName		Name of the .scr file
 	 */
-	void parseScrFile(Common::String fileName);
+	void parseScrFile(const Common::String &fileName);
 
 	/**
 	 * Parses the stream into a Puzzle object


Commit: 6515e2d31bbbad55168b8b27142cdc50f366795d
    https://github.com/scummvm/scummvm/commit/6515e2d31bbbad55168b8b27142cdc50f366795d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:14:20-07:00

Commit Message:
ZVISION: Add ActionMusic

Changed paths:
    engines/zvision/actions.cpp
    engines/zvision/actions.h
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 9a8dee0..cd84a6b 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -22,11 +22,16 @@
 
 #include "common/scummsys.h"
 
+#include "common/file.h"
+
+#include "audio/decoders/wave.h"
+
 #include "zvision/actions.h"
 #include "zvision/zvision.h"
 #include "zvision/script_manager.h"
 #include "zvision/render_manager.h"
 #include "zvision/action_node.h"
+#include "zvision/zork_raw.h"
 
 namespace ZVision {
 
@@ -103,6 +108,60 @@ bool ActionCrossfade::execute(ZVision *engine) {
 
 
 //////////////////////////////////////////////////////////////////////////////
+// ActionMusic
+//////////////////////////////////////////////////////////////////////////////
+
+ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
+	uint type;
+	char fileNameBuffer[25];
+	uint loop;
+	uint volume = 255;
+
+	sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
+
+	// type 4 are midi sound effect files
+	if (type == 4) {
+		_soundType = Audio::Mixer::kSFXSoundType;
+		_fileName = Common::String::format("midi/%s/%u.wav", fileNameBuffer, loop);
+		_loop = false;
+	} else {
+		// TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType
+		_soundType = Audio::Mixer::kPlainSoundType;
+		_fileName = Common::String(fileNameBuffer);
+		_loop = loop == 1 ? true : false;
+	}
+
+	// Volume is optional. If it doesn't appear, assume full volume
+	if (volume != 255) {
+		// Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
+		_volume = volume * 255 / 100;
+	}
+}
+
+bool ActionMusic::execute(ZVision *engine) {
+	Audio::RewindableAudioStream *audioStream;
+
+	if (_fileName.contains(".wav")) {
+		Common::File file;
+		if (file.open(_fileName)) {
+			audioStream = Audio::makeWAVStream(&file, DisposeAfterUse::NO);
+		}
+	} else {
+		audioStream = makeRawZorkStream(_fileName, engine);
+	}
+	
+	if (_loop) {
+		Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+		engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
+	} else {
+		engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
+	}
+
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
 // ActionPreloadAnimation
 //////////////////////////////////////////////////////////////////////////////
 
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 46b31e9..76db25a 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -25,7 +25,11 @@
 
 #include "common/scummsys.h"
 
-#include "common/str.h"
+#include "audio/mixer.h"
+
+namespace Common {
+class String;
+}
 
 namespace ZVision {
 
@@ -194,6 +198,19 @@ public:
 private:
 };
 
+class ActionMusic : public ResultAction {
+public:
+	ActionMusic(const Common::String &line);
+	bool execute(ZVision *engine);
+
+private:
+	uint32 _key;
+	Audio::Mixer::SoundType _soundType;
+	Common::String _fileName;
+	bool _loop;
+	byte _volume;
+};
+
 class ActionPlayAnimation : public ResultAction {
 public:
 	ActionPlayAnimation(const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index cd3cfe4..9759fd8 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -200,8 +200,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 			
 
 		} else if (line.matchString("*:music*", true)) {
-			
-
+			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionMusic(line)));
 		} else if (line.matchString("*:pan_track*", true)) {
 			
 


Commit: 65b5a2797b29dc4c0ca9a1bd2bd2e92083deb081
    https://github.com/scummvm/scummvm/commit/65b5a2797b29dc4c0ca9a1bd2bd2e92083deb081
Author: richiesams (adastley at gmail.com)
Date: 2013-08-04T22:18:01-07:00

Commit Message:
ZVISION: Fix index out of range error

Changed paths:
    engines/zvision/utility.h



diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 8974809..3348a43 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -71,7 +71,7 @@ void removeDuplicateEntries(Common::Array<T> &container) {
 	Common::sort(container.begin(), container.end());
 
 	for (uint i = 0; i + 1 < container.size(); i++) {
-		while (container[i] == container[i + 1]) {
+		while (i + 1 < container.size() && container[i] == container[i + 1]) {
 			container.remove_at(i + 1);
 		}
 	}


Commit: cefb0253ae93dc97e73a83145e314caf7e5f2885
    https://github.com/scummvm/scummvm/commit/cefb0253ae93dc97e73a83145e314caf7e5f2885
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T08:26:23-07:00

Commit Message:
ZVISION: Change _pausedTime to be a reference to when time was paused, instead of accumulation of time

Changed paths:
    engines/zvision/clock.cpp



diff --git a/engines/zvision/clock.cpp b/engines/zvision/clock.cpp
index 2324d39..fe32252 100644
--- a/engines/zvision/clock.cpp
+++ b/engines/zvision/clock.cpp
@@ -39,15 +39,14 @@ Clock::Clock(OSystem *system)
 
 void Clock::update() {
 	uint32 currentTime = _system->getMillis();
-	_deltaTime = currentTime - _lastTime - _pausedTime;
-	if (_deltaTime < 0) {
-		_deltaTime = 0;
-	}
 
+	_deltaTime = (currentTime - _lastTime);
 	if (_paused) {
-		_pausedTime += _deltaTime;
-	} else if (_pausedTime > 0) {
-		_pausedTime = 0;
+		_deltaTime -= (currentTime - _pausedTime);
+	}
+
+	if (_deltaTime < 0) {
+		_deltaTime = 0;
 	}
 
 	_lastTime = currentTime;
@@ -55,12 +54,14 @@ void Clock::update() {
 
 void Clock::start() {
 	if (_paused) {
+		_lastTime = _system->getMillis();
 		_paused = false;
 	}
 }
 
 void Clock::stop() {
 	if (!_paused) {
+		_pausedTime = _system->getMillis();
 		_paused = true;
 	}
 }


Commit: 3f5cf500498970d2a8f71a9604db31ba00bb262e
    https://github.com/scummvm/scummvm/commit/3f5cf500498970d2a8f71a9604db31ba00bb262e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T08:27:00-07:00

Commit Message:
ZVISION: Use videoDecoder.getTimeToNextFrame() to calculate the frame delay

Changed paths:
    engines/zvision/video.cpp



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 51cccee..c476cf2 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -99,9 +99,6 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
 
 	// Only continue while the video is still playing
 	while (videoDecoder.isPlaying()) {
-		_clock.update();
-		uint32 currentTime = _clock.getLastMeasuredTime();
-
 		// Check for engine quit and video stop key presses
 		while (_eventMan->pollEvent(_event)) {
 			switch (_event.type) {
@@ -133,11 +130,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
 			}
 		}
 
-		// Calculate the frame delay based off a desired frame time
-		int delay = _desiredFrameTime - (currentTime - _system->getMillis());
-		// Ensure non-negative
-		delay = delay < 0 ? 0 : delay;
-		_system->delayMillis(delay);
+		_system->delayMillis(videoDecoder.getTimeToNextFrame());
 	}
 
 	_clock.stop();


Commit: 9dec0adcdc20e0a31594f9971a0c828255a36874
    https://github.com/scummvm/scummvm/commit/9dec0adcdc20e0a31594f9971a0c828255a36874
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:49:47-07:00

Commit Message:
ZVISION: Conform to gcc template spacing requirements

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 5e060c0..18dfcb8 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -64,7 +64,7 @@ struct Puzzle {
 	uint32 key;
 	Common::List<Criteria> criteriaList;
 	// This has to be list of pointers because ResultAction is abstract
-	Common::List<Common::SharedPtr<ResultAction>> resultActions;
+	Common::List<Common::SharedPtr<ResultAction> > resultActions;
 	uint flags;
 
 	// Used by the ScriptManager to allow unique-ification of _referenceTable


Commit: 3723a0bad3a968e7df30ccb7a4df0fe1e4662e33
    https://github.com/scummvm/scummvm/commit/3723a0bad3a968e7df30ccb7a4df0fe1e4662e33
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:50:39-07:00

Commit Message:
ZVISION: sscanf to a uint first instead of directly to a bool

Changed paths:
    engines/zvision/actions.cpp



diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index cd84a6b..bddec38 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -186,13 +186,15 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
 
 ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
 	char fileName[25];
+	uint loop;
 
 	// The two %*u are always 0 and dont seem to have a use
 	sscanf(line.c_str(),
            "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
-           &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loop, &_mask, &_framerate);
+           &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &loop, &_mask, &_framerate);
 
 	_fileName = Common::String(fileName);
+	_loop = loop == 1 ? true : false;
 }
 
 bool ActionPlayAnimation::execute(ZVision *engine) {


Commit: 914763600352385fdda127aa456419d5e4a9cd7e
    https://github.com/scummvm/scummvm/commit/914763600352385fdda127aa456419d5e4a9cd7e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:51:16-07:00

Commit Message:
ZVISION: Allow _deltaTime to go negative so it can be clamped to zero properly

Changed paths:
    engines/zvision/clock.h



diff --git a/engines/zvision/clock.h b/engines/zvision/clock.h
index d17db6c..3939ba1 100644
--- a/engines/zvision/clock.h
+++ b/engines/zvision/clock.h
@@ -38,7 +38,7 @@ public:
 private:
 	OSystem *_system;
 	uint32 _lastTime;
-	uint32 _deltaTime;
+	int32 _deltaTime;
 	uint32 _pausedTime;
 	bool _paused;
 


Commit: 9036b8d3d2c42b5b082986ce8c5fffc74c07f6db
    https://github.com/scummvm/scummvm/commit/9036b8d3d2c42b5b082986ce8c5fffc74c07f6db
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:53:57-07:00

Commit Message:
ZVISION: Create ZVisionGameId entry None

This is used to end the AD table

Changed paths:
    engines/zvision/detection.h



diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index b1e5dcb..f08cfd2 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -28,8 +28,9 @@
 namespace ZVision {
 
 enum ZVisionGameId {
-	ZorkNemesis,
-	ZorkGrandInquisitor
+	None = 0,
+	ZorkNemesis = 1,
+	ZorkGrandInquisitor = 2
 };
 
 struct ZVisionGameDescription {


Commit: 623b2625ffb4ea77be826d645488d05ecf554538
    https://github.com/scummvm/scummvm/commit/623b2625ffb4ea77be826d645488d05ecf554538
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:53:58-07:00

Commit Message:
ZVISION: Properly end the AD table

Changed paths:
    engines/zvision/detection.cpp



diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index a799cc2..d9bb692 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -85,7 +85,10 @@ static const ZVisionGameDescription gameDescriptions[] = {
 		ZorkGrandInquisitor
 	},
 
-	{ AD_TABLE_END_MARKER }
+	{
+		AD_TABLE_END_MARKER,
+		None
+	}
 };
 
 } // End of namespace ZVision


Commit: 1b05d2fd7d662e692fa22ef7b1ecb59a63a3765a
    https://github.com/scummvm/scummvm/commit/1b05d2fd7d662e692fa22ef7b1ecb59a63a3765a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:54:43-07:00

Commit Message:
ZVISION: Add linking for clock.o

Changed paths:
    engines/zvision/module.mk



diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 26cf4ee..14fc035 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/zvision
 MODULE_OBJS := \
 	action_node.o \
 	actions.o \
+	clock.o \
 	console.o \
 	control.o \
 	detection.o \


Commit: 6564dc044407d1df9adee74de3376b75114844e1
    https://github.com/scummvm/scummvm/commit/6564dc044407d1df9adee74de3376b75114844e1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:55:20-07:00

Commit Message:
ZVISION: Rename inner variable to prevent variable shadowing

Changed paths:
    engines/zvision/render_manager.cpp



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 604c310..b38db00 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -112,9 +112,9 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
 		uint32 imageWidth = stream.readSint32LE();
 		uint32 imageHeight = stream.readSint32LE();
 
-		LzssReadStream stream(&stream);
+		LzssReadStream lzssStream(&stream);
 		byte *buffer = new byte[decompressedSize];
-		stream.read(buffer, decompressedSize);
+		lzssStream.read(buffer, decompressedSize);
 
 		uint32 horizontalPitch = imageWidth * sizeof(uint16);
 


Commit: 76d4fb569d2d158ca05b3fb09095efc35ed27a12
    https://github.com/scummvm/scummvm/commit/76d4fb569d2d158ca05b3fb09095efc35ed27a12
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:55:52-07:00

Commit Message:
ZVISION: Comment out usage of ActionUnloadAnimation until it is implemented

Changed paths:
    engines/zvision/scr_file_handling.cpp



diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 9759fd8..06fb0fa 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -150,7 +150,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 		} else if (line.matchString("*:animpreload*", true)) {
 			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPreloadAnimation(line)));
 		} else if (line.matchString("*:animunload*", true)) {
-			actionList.push_back(Common::SharedPtr<ResultAction>(new ActionUnloadAnimation(line)));
+			//actionList.push_back(Common::SharedPtr<ResultAction>(new ActionUnloadAnimation(line)));
 		} else if (line.matchString("*:attenuate*", true)) {
 			
 


Commit: 4806a3726b02d2e8d00db00f752d3b8818c49206
    https://github.com/scummvm/scummvm/commit/4806a3726b02d2e8d00db00f752d3b8818c49206
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:56:32-07:00

Commit Message:
ZVISION: Add default case statements for event handling in videos

Changed paths:
    engines/zvision/video.cpp



diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index c476cf2..f27c3fa 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -111,7 +111,11 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
 				case Common::KEYCODE_SPACE:
 					videoDecoder.stop();
 					break;
+				default:
+					break;
 				}
+			default:
+				break;
 			}
 		}
 


Commit: f2823933b4017fcd51eaa96ffb5dd608fcaacf4f
    https://github.com/scummvm/scummvm/commit/f2823933b4017fcd51eaa96ffb5dd608fcaacf4f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T09:56:51-07:00

Commit Message:
ZVISION: Remove extraneous include

Changed paths:
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index aaf843f..a27f4cb 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -38,7 +38,6 @@
 #include "zvision/console.h"
 #include "zvision/script_manager.h"
 #include "zvision/render_manager.h"
-#include "zvision/clock.h"
 #include "zvision/zfs_archive.h"
 #include "zvision/detection.h"
 


Commit: 9bea3cb1c274d2a003ed4e80004fe2a8dc04373f
    https://github.com/scummvm/scummvm/commit/9bea3cb1c274d2a003ed4e80004fe2a8dc04373f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T10:51:07-07:00

Commit Message:
ZVISION: Add memory cleanup for _currentBackground

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b38db00..70f67de 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -43,6 +43,12 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
 	  _renderTable(width, height) {
 }
 
+RenderManager::~RenderManager() {
+	if (_currentBackground != 0) {
+		delete _currentBackground;
+	}
+}
+
 void RenderManager::updateScreen(bool isConsoleActive) {
 	if (_needsScreenUpdate || isConsoleActive) {
 		_system->updateScreen();
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 9554e88..c4318f7 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -44,6 +44,7 @@ namespace ZVision {
 class RenderManager {
 public:
 	RenderManager(OSystem *system, const int width, const int height);
+	~RenderManager();
 
 private:
 	OSystem *_system;


Commit: 1cff0fb0d6e33f436a998b07037b7a2428de34a8
    https://github.com/scummvm/scummvm/commit/1cff0fb0d6e33f436a998b07037b7a2428de34a8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T10:52:10-07:00

Commit Message:
ZVISION: Fix memory free mismatch caused by MemoryReadStream using free()

Changed paths:
    engines/zvision/zfs_archive.cpp



diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index f815d9c..3577ce3 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -138,7 +138,8 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
 	zfsArchive.open(_fileName);
 	zfsArchive.seek(entryHeader->offset);
 
-	byte* buffer = new byte[entryHeader->size];
+	// This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory
+	byte* buffer = (byte *)malloc(entryHeader->size);
 	zfsArchive.read(buffer, entryHeader->size);
 	// Decrypt the data in place
 	if (_header.xorKey != 0)


Commit: 6598bb20fda6aec37d5d7c96ceb6ecde47fda866
    https://github.com/scummvm/scummvm/commit/6598bb20fda6aec37d5d7c96ceb6ecde47fda866
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:06:23-07:00

Commit Message:
ZVISION: Create image auto screen centering during blitting

Changed paths:
    engines/zvision/render_manager.cpp
    engines/zvision/render_manager.h



diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 70f67de..1473dcc 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -56,7 +56,7 @@ void RenderManager::updateScreen(bool isConsoleActive) {
 	}
 }
 
-void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
 	// Panoramas are transposed
 	// The actual data is transposed in mutateImage
 	if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
@@ -83,6 +83,11 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
 	if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
 		return;
 
+	// Center the image on the screen if asked
+	if (autoCenter) {
+		destRect.moveTo((_width - subRectangle.width()) / 2, (_height - subRectangle.height()) / 2);
+	}
+
 	if (_renderTable.getRenderState() == RenderTable::FLAT) {
 		_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
 	} else {
@@ -94,7 +99,7 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
 	}
 }
 
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
 	Common::File file;
 
 	if (!file.open(fileName)) {
@@ -102,10 +107,10 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
 		return;
 	}
 
-	renderImageToScreen(file, destinationX, destinationY, subRectangle);
+	renderImageToScreen(file, destinationX, destinationY, subRectangle, autoCenter);
 }
 
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
 	// Read the magic number
 	// Some files are true TGA, while others are TGZ
 	uint32 fileType;
@@ -124,7 +129,7 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
 
 		uint32 horizontalPitch = imageWidth * sizeof(uint16);
 
-		renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle);
+		renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle, autoCenter);
 		delete[] buffer;
 	} else {
 		// Reset the cursor
@@ -138,7 +143,7 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
 		}
 
 		const Graphics::Surface *tgaSurface = tga.getSurface();
-		renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle);		
+		renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle, autoCenter);
 
 		tga.destroy();
 	}
@@ -160,8 +165,7 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
 
 	_currentBackground = file;
 
-	// TODO: Check if all the panoramas are the same height. AKA: can we hardcode the vertical centering to 80px?
-	renderImageToScreen(*_currentBackground, 0, 80);
+	renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(), true);
 }
 
 } // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index c4318f7..3352f41 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -72,7 +72,7 @@ public:
 	 * @param destinationY    Y position where the image should be put
 	 * @param subRectangle    The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
 	 */
-	void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
+	void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
 
 	/**
 	 * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
@@ -83,7 +83,7 @@ public:
 	 * @param destinationY    Y position where the image should be put
 	 * @param subRectangle    The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
 	 */
-	void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
+	void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
 
 	/**
 	 * Sets the current background image to be used by the RenderManager and immediately
@@ -98,7 +98,7 @@ public:
 	bool needsScreenUpdate() { return _needsScreenUpdate; };
 
 private:
-	void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle);
+	void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
 };
 
 } // End of namespace ZVision


Commit: 946f98b34d01c06fdea5416f0f0bbd6457bb1b86
    https://github.com/scummvm/scummvm/commit/946f98b34d01c06fdea5416f0f0bbd6457bb1b86
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:07:55-07:00

Commit Message:
ZVISION: Fix frame delay calculation being reversed. Also convert to int to ensure proper 0 clamping

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



diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index a27f4cb..7c9bdd8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -134,7 +134,7 @@ Common::Error ZVision::run() {
 		_renderManager->updateScreen(_console->isActive());
 		
 		// Calculate the frame delay based off a desired frame time
-		int delay = _desiredFrameTime - (currentTime - _system->getMillis());
+		int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
 		// Ensure non-negative
 		delay = delay < 0 ? 0 : delay;
 		_system->delayMillis(delay);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 990b6e8..5bb3d7c 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -68,7 +68,7 @@ private:
 	const int _height;
 	const Graphics::PixelFormat _pixelFormat;
 
-	const uint _desiredFrameTime;
+	const int _desiredFrameTime;
 
 	// We need random numbers
 	Common::RandomSource *_rnd;


Commit: 30afe1a81532f19c7ab872ff20e2b04c582ff221
    https://github.com/scummvm/scummvm/commit/30afe1a81532f19c7ab872ff20e2b04c582ff221
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:08:44-07:00

Commit Message:
ZVISION: Add some comments concerning StateFlag::DO_ME_NOW

Changed paths:
    engines/zvision/puzzle.h



diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 18dfcb8..e7846f5 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -57,7 +57,7 @@ struct Puzzle {
 
 	enum StateFlags {
 		ONCE_PER_INST = 0x01,
-		DO_ME_NOW = 0x02,
+		DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
 		DISABLED = 0x04
 	};
 


Commit: a31a97c520bbe49bf351b5178302a529f313a35e
    https://github.com/scummvm/scummvm/commit/a31a97c520bbe49bf351b5178302a529f313a35e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:19:24-07:00

Commit Message:
ZVISION: Add debug statements for Puzzle checking

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 7fcade2..395d45c 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -24,6 +24,7 @@
 
 #include "common/algorithm.h"
 #include "common/hashmap.h"
+#include "common/debug.h"
 
 #include "zvision/script_manager.h"
 #include "zvision/actions.h"
@@ -76,6 +77,8 @@ void ScriptManager::checkPuzzleCriteria() {
 	while (!_puzzlesToCheck.empty()) {
 		Puzzle *puzzle = _puzzlesToCheck.pop();
 
+		debug("Checking puzzle: %u", puzzle->key);
+
 		// Check each Criteria
 		bool criteriaMet = false;
 		for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
@@ -110,6 +113,8 @@ void ScriptManager::checkPuzzleCriteria() {
 		// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
 		// criteriaList can be empty. Aka, the puzzle should be executed immediately
 		if (puzzle->criteriaList.empty() || criteriaMet) {
+			debug("Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
+
 			for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
 				(*resultIter)->execute(_engine);
 			}


Commit: 435ed16e0360440367ceb36b09e2116b3325a01b
    https://github.com/scummvm/scummvm/commit/435ed16e0360440367ceb36b09e2116b3325a01b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:19:33-07:00

Commit Message:
ZVISION: Set the puzzle global variable after a Puzzle is completed

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 395d45c..5b42895 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -118,6 +118,9 @@ void ScriptManager::checkPuzzleCriteria() {
 			for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
 				(*resultIter)->execute(_engine);
 			}
+
+			// Set the puzzle as completed
+			setStateValue(puzzle->key, 1);
 		}
 	}
 }


Commit: 387bfb2806856dcf76cb12a7a3b571aa62a59298
    https://github.com/scummvm/scummvm/commit/387bfb2806856dcf76cb12a7a3b571aa62a59298
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:19:34-07:00

Commit Message:
ZVISION: Fix typo in Puzzle checking

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 5b42895..38ca107 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -84,7 +84,7 @@ void ScriptManager::checkPuzzleCriteria() {
 		for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
 			// Get the value to compare against
 			uint argumentValue;
-			if ((*iter).argument)
+			if ((*iter).argumentIsAKey)
 				argumentValue = getStateValue(iter->argument);
 			else
 				argumentValue = iter->argument;


Commit: 931ad00a2d208335fc45885bfc7f53a53e6d9dce
    https://github.com/scummvm/scummvm/commit/931ad00a2d208335fc45885bfc7f53a53e6d9dce
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:19:34-07:00

Commit Message:
ZVISION: Add StateFlag handling to Puzzle checking

Changed paths:
    engines/zvision/script_manager.cpp



diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 38ca107..fe6548c 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -77,6 +77,15 @@ void ScriptManager::checkPuzzleCriteria() {
 	while (!_puzzlesToCheck.empty()) {
 		Puzzle *puzzle = _puzzlesToCheck.pop();
 
+		// Check if the puzzle is already finished
+		// If it doesn't have the flag ONCE_PER_INST it can be done more than once
+		// Also check that the puzzle isn't disabled
+		if (getStateValue(puzzle->key) == 1 &&
+		    (puzzle->flags & Puzzle::StateFlags::ONCE_PER_INST) == Puzzle::StateFlags::ONCE_PER_INST &&
+		    (puzzle->flags & Puzzle::StateFlags::DISABLED) == 0) {
+			continue;
+		}
+
 		debug("Checking puzzle: %u", puzzle->key);
 
 		// Check each Criteria


Commit: b98a8fbf12717457c087b4e169d72f461310c667