[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
https://github.com/scummvm/scummvm/commit/b98a8fbf12717457c087b4e169d72f461310c667
Author: richiesams (adastley at gmail.com)
Date: 2013-08-05T17:20:36-07:00
Commit Message:
ZVISION: Fix loop logic so videos can end
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index f27c3fa..32f7b1f 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -98,9 +98,9 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
videoDecoder.start();
// Only continue while the video is still playing
- while (videoDecoder.isPlaying()) {
+ while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
// Check for engine quit and video stop key presses
- while (_eventMan->pollEvent(_event)) {
+ while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
Commit: f67e0042b046c57526f72d8f33b7c36b5508a66a
https://github.com/scummvm/scummvm/commit/f67e0042b046c57526f72d8f33b7c36b5508a66a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-07T13:26:59-07:00
Commit Message:
ZVISION: Create console method to dump all cursor file names
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 6634e0b..f9b4e70 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -48,6 +48,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
+ DCmd_Register("dumpcursorfilenames", WRAP_METHOD(Console, cmdDumpAllCursorFileNames));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -175,4 +176,20 @@ bool Console::cmdDumpFile(int argc, const char **argv) {
return true;
}
+bool Console::cmdDumpAllCursorFileNames(int argc, const char **argv) {
+ Common::DumpFile outputFile;
+ outputFile.open("cursorFileNames.txt");
+
+ Common::ArchiveMemberList list;
+ SearchMan.listMatchingMembers(list, "*.zcr");
+
+ // Register the file entries within the zfs archives with the SearchMan
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ outputFile.writeString((*iter)->getName());
+ outputFile.writeByte('\n');
+ }
+
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index be3ebf1..3c08f20 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -47,6 +47,7 @@ private:
bool cmdSetPanoramaScale(int argc, const char **argv);
bool cmdChangeLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
+ bool cmdDumpAllCursorFileNames(int argc, const char **argv);
};
} // End of namespace ZVision
Commit: b4b60e1f632f928bb3f28b99ff4689a9cd24c680
https://github.com/scummvm/scummvm/commit/b4b60e1f632f928bb3f28b99ff4689a9cd24c680
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T10:16:43-07:00
Commit Message:
ZVISION: Call _system->updateScreen() every frame
Otherwise the cursor will not be updated
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 1473dcc..f759c1f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -49,13 +49,6 @@ RenderManager::~RenderManager() {
}
}
-void RenderManager::updateScreen(bool isConsoleActive) {
- if (_needsScreenUpdate || isConsoleActive) {
- _system->updateScreen();
- _needsScreenUpdate = false;
- }
-}
-
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
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 3352f41..4b4e178 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -61,7 +61,6 @@ private:
public:
void initialize();
- void updateScreen(bool isConsoleActive);
/**
* Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 7c9bdd8..338bbc5 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -130,9 +130,9 @@ Common::Error ZVision::run() {
_scriptManager->updateNodes(_clock.getDeltaTime());
_scriptManager->checkPuzzleCriteria();
- // Render a frame
- _renderManager->updateScreen(_console->isActive());
-
+ // Update the screen
+ _system->updateScreen();
+
// Calculate the frame delay based off a desired frame time
int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
// Ensure non-negative
Commit: 268282ab22d18e92180aa7653ef52b47a6ed1b51
https://github.com/scummvm/scummvm/commit/268282ab22d18e92180aa7653ef52b47a6ed1b51
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T12:05:31-07:00
Commit Message:
ZVISION: Create class for decoding .zcr cursor files
Changed paths:
A engines/zvision/cursor.cpp
A engines/zvision/cursor.h
engines/zvision/module.mk
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
new file mode 100644
index 0000000..601c58f
--- /dev/null
+++ b/engines/zvision/cursor.cpp
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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/str.h"
+#include "common/file.h"
+
+#include "zvision/cursor.h"
+
+
+namespace ZVision {
+
+ZorkCursor::ZorkCursor()
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0),
+ _surface(0) {
+}
+
+ZorkCursor::ZorkCursor(const Common::String &fileName)
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0),
+ _surface(0) {
+ Common::File file;
+ if (!file.open(fileName))
+ return;
+
+ uint32 magic = file.readUint32BE();
+ if (magic != MKTAG('Z', 'C', 'R', '1')) {
+ warning("%s is not a Zork Cursor file", fileName.c_str());
+ return;
+ }
+
+ _hotspotX = file.readUint16LE();
+ _hotspotY = file.readUint16LE();
+ _width = file.readUint16LE();
+ _height = file.readUint16LE();
+
+ uint dataSize = _width * _height * 2;
+ _surface = new byte[dataSize];
+ uint32 bytesRead = file.read(_surface, dataSize);
+ assert(bytesRead == dataSize);
+}
+
+ZorkCursor::ZorkCursor(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ uint dataSize = _width * _height * 2;
+ _surface = new byte[dataSize];
+
+ memcpy(_surface, other._surface, dataSize);
+}
+
+ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ uint dataSize = _width * _height * 2;
+ _surface = new byte[dataSize];
+
+ memcpy(_surface, other._surface, dataSize);
+
+ return *this;
+}
+
+ZorkCursor::~ZorkCursor() {
+ if (_surface != 0) {
+ delete[] _surface;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
new file mode 100644
index 0000000..0d91a48
--- /dev/null
+++ b/engines/zvision/cursor.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_CURSOR_H
+#define ZVISION_CURSOR_H
+
+#include "common/types.h"
+
+#include "graphics/cursor.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class ZorkCursor : public Graphics::Cursor {
+public:
+ ZorkCursor();
+ ZorkCursor(const Common::String &fileName);
+ ZorkCursor(const ZorkCursor &other);
+ ~ZorkCursor();
+
+private:
+ uint16 _width;
+ uint16 _height;
+ uint16 _hotspotX;
+ uint16 _hotspotY;
+ byte *_surface;
+
+public:
+ ZorkCursor &operator=(const ZorkCursor &other);
+
+ uint16 getWidth() const { return _width; }
+ uint16 getHeight() const { return _height; }
+ uint16 getHotspotX() const { return _hotspotX; }
+ uint16 getHotspotY() const { return _hotspotY; }
+ byte getKeyColor() const { return 0; }
+ const byte *getSurface() const { return _surface; }
+ const byte *getPalette() const { return 0; }
+ byte getPaletteStartIndex() const { return 0; }
+ uint16 getPaletteCount() const { return 0; }
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 14fc035..feafad5 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
clock.o \
console.o \
control.o \
+ cursor.o \
detection.o \
events.o \
lzss_read_stream.o \
Commit: f31f35bf7bcd964b970eb4817135c966c9bad823
https://github.com/scummvm/scummvm/commit/f31f35bf7bcd964b970eb4817135c966c9bad823
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T12:06:23-07:00
Commit Message:
ZVISION: Create console command to render a cursor image to the screen
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index f9b4e70..f1b192f 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
+#include "common/system.h"
#include "gui/debugger.h"
#include "common/file.h"
#include "common/bufferedstream.h"
@@ -34,6 +35,8 @@
#include "zvision/zork_avi_decoder.h"
#include "zvision/zork_raw.h"
#include "zvision/utility.h"
+#include "zvision/cursor.h"
+
namespace ZVision {
@@ -49,6 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
DCmd_Register("dumpcursorfilenames", WRAP_METHOD(Console, cmdDumpAllCursorFileNames));
+ DCmd_Register("showcursor", WRAP_METHOD(Console, cmdShowCursor));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -192,4 +196,12 @@ bool Console::cmdDumpAllCursorFileNames(int argc, const char **argv) {
return true;
}
+bool Console::cmdShowCursor(int argc, const char **argv) {
+ ZorkCursor cursor(argv[1]);
+
+ _engine->_system->copyRectToScreen(cursor.getSurface(), cursor.getWidth() * 2, 0, 0, cursor.getWidth(), cursor.getHeight());
+
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 3c08f20..995c418 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -48,6 +48,7 @@ private:
bool cmdChangeLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
bool cmdDumpAllCursorFileNames(int argc, const char **argv);
+ bool cmdShowCursor(int argc, const char **argv);
};
} // End of namespace ZVision
Commit: 06e6cb5d1f9b6cc7d632e3a7e31267363dad3503
https://github.com/scummvm/scummvm/commit/06e6cb5d1f9b6cc7d632e3a7e31267363dad3503
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T12:51:18-07:00
Commit Message:
ZVISION: Create method for cycling through all the cursors so as to identify them more easily
Changed paths:
engines/zvision/events.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 508d261..3163563 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -61,6 +61,9 @@ void ZVision::processEvents() {
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
+ case Common::KEYCODE_F1:
+ cycleThroughCursors();
+ break;
default:
break;
}
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 338bbc5..46b6c01 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -40,6 +40,7 @@
#include "zvision/render_manager.h"
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
+#include "zvision/cursor.h"
#include "zvision/utility.h"
@@ -169,4 +170,59 @@ ZVisionGameId ZVision::getGameId() const {
return _gameDescription->gameId;
}
+void ZVision::cycleThroughCursors() {
+ Common::ArchiveMemberList list;
+ SearchMan.listMatchingMembers(list, "*.zcr");
+
+ Common::ArchiveMemberList::iterator iter = list.begin();
+ ZorkCursor cursor;
+ bool cursorChanged = false;
+
+ _system->showMouse(true);
+
+ bool done = false;
+ while (!done && !shouldQuit()) {
+ _clock.update();
+ uint32 currentTime = _clock.getLastMeasuredTime();
+
+ while (_eventMan->pollEvent(_event)) {
+ if (_event.type == Common::EVENT_KEYDOWN) {
+ switch (_event.kbd.keycode) {
+ case Common::KEYCODE_LEFT:
+ --iter;
+ cursorChanged = true;
+ break;
+ case Common::KEYCODE_RIGHT:
+ ++iter;
+ cursorChanged = true;
+ break;
+ case Common::KEYCODE_RETURN:
+ debug("%s", (*iter)->getName().c_str());
+ break;
+ case Common::KEYCODE_ESCAPE:
+ done = true;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (cursorChanged) {
+ cursor = ZorkCursor((*iter)->getName());
+
+ _system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getHeight(), true, &_pixelFormat);
+ cursorChanged = false;
+ }
+
+ _system->updateScreen();
+
+ // Calculate the frame delay based off a desired frame time
+ int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
+ // Ensure non-negative
+ delay = delay < 0 ? 0 : delay;
+ _system->delayMillis(delay);
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 5bb3d7c..29c1ddd 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -96,6 +96,8 @@ public:
void playVideo(Video::VideoDecoder &videoDecoder);
+ void cycleThroughCursors();
+
private:
void initialize();
Commit: 0feac806b235867aae4078d2b5c58c38b3b23e21
https://github.com/scummvm/scummvm/commit/0feac806b235867aae4078d2b5c58c38b3b23e21
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T12:51:45-07:00
Commit Message:
ZVISION: Add a ZGI folder directory to the SearchMan
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 46b6c01..7cfa42e 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -69,6 +69,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
SearchMan.addSubDirectoryMatching(gameDataDir, "zassets1", 0, 2, true);
SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, 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: f89120310cd08dc0640b51ed1e49dd02c3a028b9
https://github.com/scummvm/scummvm/commit/f89120310cd08dc0640b51ed1e49dd02c3a028b9
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T12:52:21-07:00
Commit Message:
ZVISION: Test for file.open before trying to read
Changed paths:
engines/zvision/utility.cpp
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 2e1ade6..fb4fe22 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -33,7 +33,10 @@ namespace ZVision {
void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
Common::File f;
- f.open(sourceFile);
+ if (!f.open(sourceFile)) {
+ return;
+ }
+
byte* buffer = new byte[f.size()];
f.read(buffer, f.size());
Commit: 1b277d34ac9d7b207e7e42964d00dd6f433daadc
https://github.com/scummvm/scummvm/commit/1b277d34ac9d7b207e7e42964d00dd6f433daadc
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T16:33:15-07:00
Commit Message:
ZVISION: Add class to manage cursors
Changed paths:
A engines/zvision/cursor_manager.cpp
A engines/zvision/cursor_manager.h
engines/zvision/events.cpp
engines/zvision/module.mk
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
new file mode 100644
index 0000000..43d288e
--- /dev/null
+++ b/engines/zvision/cursor_manager.cpp
@@ -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.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "common/system.h"
+#include "graphics/pixelformat.h"
+
+#include "zvision/zvision.h"
+#include "zvision/cursor_manager.h"
+
+
+namespace ZVision {
+
+const char *CursorManager::_cursorNames[] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" };
+
+const char *CursorManager::_zgiCursorFileNames[] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr",
+ "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" };
+
+const char *CursorManager::_zNemCursorFileNames[] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
+
+
+CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
+ : _engine(engine),
+ _pixelFormat(pixelFormat),
+ _cursorIsPushed(false),
+ _currentCursor("idle") {
+ // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
+ if (_engine->getGameId() == ZorkNemesis) {
+ Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[11]));
+ _idleCursor = ZorkCursor(name);
+ } else if (_engine->getGameId() == ZorkGrandInquisitor) {
+ _idleCursor = ZorkCursor(_zgiCursorFileNames[11]);
+ }
+}
+
+void CursorManager::initialize() {
+ _engine->_system->setMouseCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
+ _engine->_system->showMouse(true);
+}
+
+void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
+ _cursorIsPushed = pushed;
+
+ if (cursorName == "idle" && !pushed) {
+ revertToIdle();
+ return;
+ }
+
+ // WARNING: The range of this loop is hardcoded to the length of _cursorNames
+ for (int i = 0; i < 18; i++) {
+ if (_engine->getGameId() == ZorkNemesis) {
+ if (_cursorNames[i] == cursorName) {
+ // ZNem uses a/b at the end of the file to signify not pushed/pushed respectively
+ Common::String pushedFlag = pushed ? "b" : "a";
+ Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag);
+
+ changeCursor(ZorkCursor(name));
+ return;
+ }
+ } else if (_engine->getGameId() == ZorkGrandInquisitor) {
+ if (_cursorNames[i] == cursorName) {
+ if (!pushed) {
+ changeCursor(ZorkCursor(_zgiCursorFileNames[i]));
+ } else {
+ // ZGI flips not pushed/pushed between a/c and b/d
+ // It flips the 4th character of the name
+ char buffer[25];
+ strcpy(buffer, _zgiCursorFileNames[i]);
+ buffer[3] += 2;
+ }
+ return;
+ }
+ }
+ }
+
+ // If we get here, something went wrong
+ warning("No cursor found for identifier %s", cursorName.c_str());
+}
+
+void CursorManager::changeCursor(const ZorkCursor &cursor) {
+ _engine->_system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat);
+}
+
+void CursorManager::cursorDown(bool pushed) {
+ if (_cursorIsPushed == pushed)
+ return;
+
+ _cursorIsPushed = pushed;
+ changeCursor(_currentCursor, pushed);
+}
+
+void CursorManager::revertToIdle() {
+ _currentCursor = "idle";
+ _engine->_system->setMouseCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
new file mode 100644
index 0000000..9145385
--- /dev/null
+++ b/engines/zvision/cursor_manager.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_CURSOR_MANAGER_H
+#define ZVISION_CURSOR_MANAGER_H
+
+#include "common/types.h"
+
+#include "zvision/cursor.h"
+
+
+namespace Graphics {
+struct PixelFormat;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class CursorManager {
+public:
+ CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat);
+
+private:
+ ZVision *_engine;
+ const Graphics::PixelFormat *_pixelFormat;
+ ZorkCursor _idleCursor;
+ Common::String _currentCursor;
+ bool _cursorIsPushed;
+
+ static const char *_cursorNames[];
+ static const char *_zgiCursorFileNames[];
+ static const char *_zNemCursorFileNames[];
+
+public:
+ void initialize();
+
+ void changeCursor(Common::String &cursorName, bool pushed);
+ void cursorDown(bool pushed);
+ void revertToIdle();
+
+private:
+ void changeCursor(const ZorkCursor &cursor);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 3163563..17f48db 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -27,7 +27,7 @@
#include "common/events.h"
#include "engines/util.h"
-#include "zvision/render_manager.h"
+#include "zvision/cursor_manager.h"
namespace ZVision {
@@ -39,6 +39,7 @@ void ZVision::processEvents() {
break;
case Common::EVENT_LBUTTONUP:
+ onMouseUp(_event.mouse);
break;
case Common::EVENT_RBUTTONDOWN:
@@ -78,7 +79,11 @@ void ZVision::processEvents() {
}
void ZVision::onMouseDown(const Common::Point &pos) {
+ _cursorManager->cursorDown(true);
+}
+void ZVision::onMouseUp(const Common::Point &pos) {
+ _cursorManager->cursorDown(false);
}
void ZVision::onMouseMove(const Common::Point &pos) {
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index feafad5..7e74b0b 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
console.o \
control.o \
cursor.o \
+ cursor_manager.o \
detection.o \
events.o \
lzss_read_stream.o \
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 7cfa42e..e1f719d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -38,9 +38,9 @@
#include "zvision/console.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
+#include "zvision/cursor_manager.h"
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
-#include "zvision/cursor.h"
#include "zvision/utility.h"
@@ -81,6 +81,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
_renderManager = new RenderManager(_system, _width, _height);
+ _cursorManager = new CursorManager(this, &_pixelFormat);
debug("ZVision::ZVision");
}
@@ -90,6 +91,7 @@ ZVision::~ZVision() {
// Dispose of resources
delete _console;
+ delete _cursorManager;
delete _renderManager;
delete _scriptManager;
delete _rnd;
@@ -114,6 +116,8 @@ void ZVision::initialize() {
initGraphics(_width, _height, true, &_pixelFormat);
_scriptManager->initialize();
+ // Has to be done after graphics has been initialized
+ _cursorManager->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 29c1ddd..0a4ed08 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -47,6 +47,7 @@ struct ZVisionGameDescription;
class Console;
class ScriptManager;
class RenderManager;
+class CursorManager;
// our engine debug channels
enum {
@@ -76,6 +77,7 @@ private:
// Managers
ScriptManager *_scriptManager;
RenderManager *_renderManager;
+ CursorManager *_cursorManager;
// Clock
Clock _clock;
@@ -91,6 +93,7 @@ public:
ScriptManager *getScriptManager() const;
RenderManager *getRenderManager() const;
+ CursorManager *getCursorManager() const;
Common::RandomSource *getRandomSource() const;
ZVisionGameId getGameId() const;
@@ -103,6 +106,7 @@ private:
void processEvents();
void onMouseDown(const Common::Point &pos);
+ void onMouseUp(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
void onKeyDown(uint keyCode);
};
Commit: ed4977848b1761ebfd09db9ea21d744236b813c6
https://github.com/scummvm/scummvm/commit/ed4977848b1761ebfd09db9ea21d744236b813c6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-09T16:42:27-07:00
Commit Message:
ZVISION: Fix invalid argument for String::format()
Changed paths:
engines/zvision/cursor_manager.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 43d288e..0115ec9 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -74,7 +74,7 @@ void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
if (_cursorNames[i] == cursorName) {
// ZNem uses a/b at the end of the file to signify not pushed/pushed respectively
Common::String pushedFlag = pushed ? "b" : "a";
- Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag);
+ Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag.c_str());
changeCursor(ZorkCursor(name));
return;
Commit: 9740087441fa2f5b0655c7065f891686c8579cb0
https://github.com/scummvm/scummvm/commit/9740087441fa2f5b0655c7065f891686c8579cb0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:07:27-07:00
Commit Message:
ZVISION: Add documentation for the ResultAction base class
Changed paths:
engines/zvision/actions.h
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 76db25a..b75ca8b 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -36,9 +36,21 @@ namespace ZVision {
// Forward declaration of ZVision. This file is included before ZVision is declared
class ZVision;
+/**
+ * The base class that represents any action that a Puzzle can take.
+ * This class is purely virtual.
+ */
class ResultAction {
public:
virtual ~ResultAction() {}
+ /**
+ * This is called by the script system whenever a Puzzle's criteria are found to be true.
+ * It should execute any necessary actions and return a value indicating whether the script
+ * system should continue to test puzzles. In 99% of cases this will be 'true'.
+ *
+ * @param engine A pointer to the base engine so the ResultAction can access all the necessary methods
+ * @return Should the script system continue to test any remaining puzzles (true) or immediately break and go on to the next frame (false)
+ */
virtual bool execute(ZVision *engine) = 0;
};
Commit: 86b3dfa22105a3edf8e99263637f60bc65f97739
https://github.com/scummvm/scummvm/commit/86b3dfa22105a3edf8e99263637f60bc65f97739
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:07:56-07:00
Commit Message:
ZVISION: Make ZFS Archive member name indexing case-insensitive
Changed paths:
engines/zvision/zfs_archive.h
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
index e683ac1..3bf4925 100644
--- a/engines/zvision/zfs_archive.h
+++ b/engines/zvision/zfs_archive.h
@@ -52,7 +52,7 @@ struct ZfsEntryHeader {
uint32 unknown;
};
-typedef Common::HashMap<Common::String, ZfsEntryHeader*> ZfsEntryHeaderMap;
+typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
class ZfsArchive : public Common::Archive {
public:
Commit: 416cde1358ecdb18ae3f6c8bc2f794e9ac13755b
https://github.com/scummvm/scummvm/commit/416cde1358ecdb18ae3f6c8bc2f794e9ac13755b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:14:00-07:00
Commit Message:
ZVISION: Change video code to support arbitrary scaling and whether the video can be skipped
Changed paths:
engines/zvision/video.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 32f7b1f..9f98b14 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -34,10 +34,11 @@
namespace ZVision {
-// Taken from SCI
-void scale2x(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel) {
+// Taken/modified from SCI
+void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint scaleAmount) {
assert(bytesPerPixel == 1 || bytesPerPixel == 2);
- const uint32 newWidth = srcWidth * 2;
+
+ const uint32 newWidth = srcWidth * scaleAmount;
const uint32 pitch = newWidth * bytesPerPixel;
const byte *srcPtr = src;
@@ -45,54 +46,70 @@ void scale2x(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte
for (uint32 y = 0; y < srcHeight; y++) {
for (uint32 x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
- dst[0] = color;
- dst[1] = color;
- dst[newWidth] = color;
- dst[newWidth + 1] = color;
- dst += 2;
+
+ for (int i = 0; i < scaleAmount; i++) {
+ dst[i] = color;
+ dst[pitch + i] = color;
+ }
+ dst += scaleAmount;
}
- dst += newWidth;
+ dst += pitch;
}
} else if (bytesPerPixel == 2) {
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;
- 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;
+
+ for (int i = 0; i < scaleAmount; i++) {
+ dst[i] = color;
+ dst[i + 1] = color2;
+ dst[pitch + i] = color;
+ dst[pitch + i + 1] = color2;
+ }
+ dst += 2 * scaleAmount;
}
dst += pitch;
}
}
}
-void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
+void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
// Videos use a different pixel format
Common::List<Graphics::PixelFormat> formats;
formats.push_back(videoDecoder.getPixelFormat());
initGraphics(_width, _height, true, formats);
byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
+
uint16 origWidth = videoDecoder.getWidth();
uint16 origHeight = videoDecoder.getHeight();
+
+ uint scale = 1;
+ // If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
+ if (destRect.isEmpty()) {
+ // Most videos are very small. Therefore we do a simple 2x scale
+ if (origWidth * 2 <= 640 && origHeight * 2 <= 480) {
+ scale = 2;
+ }
+ } else {
+ // Assume bilinear scaling. AKA calculate the scale from just the width.
+ // Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
+ // TODO: Test ^these^ assumptions
+ uint scale = destRect.width() / origWidth;
+
+ // TODO: Test if we need to support downscale.
+ }
+
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 finalWidth = origWidth * scale;
+ uint16 finalHeight = origHeight * scale;
- byte *scaledVideoFrameBuffer = new byte[origHeight * pitch * 4];
+ byte *scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
- uint16 x = (_width - finalWidth) / 2;
- uint16 y = (_height - finalHeight) / 2;
+ uint16 x = ((_width - finalWidth) / 2) + destRect.left;
+ uint16 y = ((_height - finalHeight) / 2) + destRect.top;
_clock.stop();
videoDecoder.start();
@@ -109,7 +126,9 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
quitGame();
break;
case Common::KEYCODE_SPACE:
- videoDecoder.stop();
+ if (skippable) {
+ videoDecoder.stop();
+ }
break;
default:
break;
@@ -123,8 +142,8 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder) {
const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
if (frame) {
- if (shouldBeScaled) {
- scale2x((byte *)frame->pixels, scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel);
+ if (scale != 1) {
+ scaleBuffer((byte *)frame->pixels, scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
_system->copyRectToScreen((byte *)frame->pixels, pitch, x, y, finalWidth, finalHeight);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 0a4ed08..8363fb1 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -97,7 +97,7 @@ public:
Common::RandomSource *getRandomSource() const;
ZVisionGameId getGameId() const;
- void playVideo(Video::VideoDecoder &videoDecoder);
+ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
void cycleThroughCursors();
Commit: 694a6099a6f4da7807b1ac1efba75953522da206
https://github.com/scummvm/scummvm/commit/694a6099a6f4da7807b1ac1efba75953522da206
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:14:15-07:00
Commit Message:
ZVISION: Implement ActionQuit
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 bddec38..81b6960 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -204,6 +204,17 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionQuit
+//////////////////////////////////////////////////////////////////////////////
+
+bool ActionQuit::execute(ZVision *engine) {
+ engine->quitGame();
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionRandom
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index b75ca8b..48703b9 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -254,6 +254,12 @@ private:
uint _framerate;
};
+class ActionQuit : public ResultAction {
+public:
+ ActionQuit() {}
+ bool execute(ZVision *engine);
+};
+
// TODO: See if this exists in ZGI. It doesn't in ZNem
class ActionUnloadAnimation : public ResultAction {
public:
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 06fb0fa..0bb8d26 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -211,8 +211,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:quit*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionQuit()));
} else if (line.matchString("*:random*", true)) {
Commit: 2176aa55fc71fb7ac8b44f81fcc070c927e3d505
https://github.com/scummvm/scummvm/commit/2176aa55fc71fb7ac8b44f81fcc070c927e3d505
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:18:29-07:00
Commit Message:
ZVISION: Implement ActionStreamVideo
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 81b6960..8c10837 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -32,6 +32,7 @@
#include "zvision/render_manager.h"
#include "zvision/action_node.h"
#include "zvision/zork_raw.h"
+#include "zvision/zork_avi_decoder.h"
namespace ZVision {
@@ -249,6 +250,36 @@ bool ActionSetScreen::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionStreamVideo
+//////////////////////////////////////////////////////////////////////////////
+
+ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
+ char fileName[25];
+ uint skippable;
+
+ sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x, &_y, &_width, &_height, &_flags, &skippable);
+
+ _fileName = Common::String(fileName);
+ _skippable = (skippable == 0) ? false : true;
+}
+
+bool ActionStreamVideo::execute(ZVision *engine) {
+ ZorkAVIDecoder decoder;
+ if (!decoder.loadFile(_fileName)) {
+ return true;
+ }
+
+ Common::Rect destRect;
+ if ((_flags & 0x1) == 0x1) {
+ destRect = Common::Rect(_x, _y, _x + _width, _y + _height);
+ }
+
+ engine->playVideo(decoder, destRect, _skippable);
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionTimer
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 48703b9..bb44617 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -286,6 +286,21 @@ private:
Common::String _fileName;
};
+class ActionStreamVideo : public ResultAction {
+public:
+ ActionStreamVideo(const Common::String &line);
+ bool execute(ZVision *engine);
+
+private:
+ Common::String _fileName;
+ uint _x;
+ uint _y;
+ uint _width;
+ uint _height;
+ uint _flags;
+ bool _skippable;
+};
+
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 0bb8d26..061079c 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -239,8 +239,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:streamvideo*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
} else if (line.matchString("*:syncsound*", true)) {
Commit: 5bba509db8a84a5d6c2ab4863990683977203e60
https://github.com/scummvm/scummvm/commit/5bba509db8a84a5d6c2ab4863990683977203e60
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:25:38-07:00
Commit Message:
ZVISION: Create a global puzzle list and parse universe.scr into it during ScriptManager::initialize()
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 061079c..efd1229 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -33,7 +33,7 @@
namespace ZVision {
-void ScriptManager::parseScrFile(const Common::String &fileName) {
+void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
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
@@ -54,7 +54,11 @@ void ScriptManager::parseScrFile(const Common::String &fileName) {
sscanf(line.c_str(),"puzzle:%u",&(puzzle.key));
parsePuzzle(puzzle, file);
- _activePuzzles.push_back(puzzle);
+ if (isGlobal) {
+ _globalPuzzles.push_back(puzzle);
+ } else {
+ _activePuzzles.push_back(puzzle);
+ }
} else if (line.matchString("control:*", true)) {
Common::SharedPtr<Control> control;
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index fe6548c..027fec4 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -35,13 +35,12 @@ namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine) : _engine(engine) {}
-// TODO: Actually do something in the initialize or remove it
void ScriptManager::initialize() {
-
+ parseScrFile("universe.scr", true);
}
void ScriptManager::createReferenceTable() {
- // Iterate through each Puzzle
+ // Iterate through each local Puzzle
for (Common::List<Puzzle>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
Puzzle *puzzlePtr = &(*activePuzzleIter);
@@ -50,7 +49,21 @@ void ScriptManager::createReferenceTable() {
_referenceTable[criteriaIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
- if (criteriaIter->argument)
+ if (criteriaIter->argumentIsAKey)
+ _referenceTable[criteriaIter->argument].push_back(puzzlePtr);
+ }
+ }
+
+ // Iterate through each global Puzzle
+ for (Common::List<Puzzle>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
+ Puzzle *puzzlePtr = &(*globalPuzzleIter);
+
+ // Iterate through each Criteria and add a reference from the criteria key to the Puzzle
+ for (Common::List<Puzzle::Criteria>::iterator criteriaIter = globalPuzzleIter->criteriaList.begin(); criteriaIter != (*globalPuzzleIter).criteriaList.end(); criteriaIter++) {
+ _referenceTable[criteriaIter->key].push_back(puzzlePtr);
+
+ // If the argument is a key, add a reference to it as well
+ if (criteriaIter->argumentIsAKey)
_referenceTable[criteriaIter->argument].push_back(puzzlePtr);
}
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 484069b..63dc4f8 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -59,6 +59,8 @@ private:
Common::Stack<Puzzle *> _puzzlesToCheck;
/** Holds the currently active puzzles */
Common::List<Puzzle> _activePuzzles;
+ /** Holds the global puzzles */
+ Common::List<Puzzle>_globalPuzzles;
/** Holds the currently active controls */
Common::List<Common::SharedPtr<Control> > _activeControls;
@@ -82,9 +84,10 @@ private:
/**
* Parses a script file into triggers and events
*
- * @param fileName Name of the .scr file
+ * @param fileName Name of the .scr file
+ * @param isGlobal Are the puzzles included in the file global (true). AKA, the won't be purged during location changes
*/
- void parseScrFile(const Common::String &fileName);
+ void parseScrFile(const Common::String &fileName, bool isGlobal = false);
/**
* Parses the stream into a Puzzle object
Commit: dd11566ffdb46a867550e82b3605e3c76cf194a3
https://github.com/scummvm/scummvm/commit/dd11566ffdb46a867550e82b3605e3c76cf194a3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:28:41-07:00
Commit Message:
ZVISION: Move the ScriptManager update functions to a single update() function.
Then make the individual update functions private
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 027fec4..4ccbbef 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -39,6 +39,11 @@ void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
}
+void ScriptManager::update(uint deltaTimeMillis) {
+ updateNodes(deltaTimeMillis);
+ checkPuzzleCriteria();
+}
+
void ScriptManager::createReferenceTable() {
// Iterate through each local Puzzle
for (Common::List<Puzzle>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 63dc4f8..2999425 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -67,8 +67,7 @@ private:
public:
void initialize();
- void updateNodes(uint deltaTimeMillis);
- void checkPuzzleCriteria();
+ void update(uint deltaTimeMillis);
uint getStateValue(uint32 key);
void setStateValue(uint32 key, uint value);
@@ -80,6 +79,8 @@ public:
private:
void createReferenceTable();
+ void updateNodes(uint deltaTimeMillis);
+ void checkPuzzleCriteria();
/**
* Parses a script file into triggers and events
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index e1f719d..0dd62d7 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -133,8 +133,7 @@ Common::Error ZVision::run() {
processEvents();
- _scriptManager->updateNodes(_clock.getDeltaTime());
- _scriptManager->checkPuzzleCriteria();
+ _scriptManager->update(_clock.getDeltaTime());
// Update the screen
_system->updateScreen();
Commit: 2565f96c55b39f5155d10625def873f2c07207e8
https://github.com/scummvm/scummvm/commit/2565f96c55b39f5155d10625def873f2c07207e8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:31:57-07:00
Commit Message:
ZVISION: Make ScriptManager::changeLocation delay the actual change until the end of the frame
This prevents memory corruption since changeLocation could be called in the middle of
a Puzzle list iteration and changeLocation clears all the Puzzle lists.
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 4ccbbef..586cc2a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -33,7 +33,7 @@
namespace ZVision {
-ScriptManager::ScriptManager(ZVision *engine) : _engine(engine) {}
+ScriptManager::ScriptManager(ZVision *engine) : _engine(engine), _changeLocation(false) {}
void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
@@ -42,6 +42,11 @@ void ScriptManager::initialize() {
void ScriptManager::update(uint deltaTimeMillis) {
updateNodes(deltaTimeMillis);
checkPuzzleCriteria();
+
+ if (_changeLocation) {
+ changeLocationIntern();
+ _changeLocation = false;
+ }
}
void ScriptManager::createReferenceTable() {
@@ -178,6 +183,19 @@ void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
}
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 x) {
+ _nextLocation.world = world;
+ _nextLocation.room = room;
+ _nextLocation.node = node;
+ _nextLocation.view = view;
+ _nextLocation.x = x;
+
+ _changeLocation = true;
+}
+
+void ScriptManager::changeLocationIntern() {
+ assert(_nextLocation.world != 0);
+ debug("Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.x);
+
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
@@ -186,16 +204,21 @@ 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", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
parseScrFile(fileName);
// Create the puzzle reference table
createReferenceTable();
- // Add all the puzzles to the stack to be checked
+ // Add all the local puzzles to the stack to be checked
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
_puzzlesToCheck.push(&(*iter));
}
+
+ // Add all the global puzzles to the stack to be checked
+ for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ _puzzlesToCheck.push(&(*iter));
+ }
}
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 2999425..8e79548 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -39,6 +39,14 @@ namespace ZVision {
class ZVision;
class ActionNode;
+struct Location {
+ char world;
+ char room;
+ char node;
+ char view;
+ uint32 x;
+};
+
class ScriptManager {
public:
ScriptManager(ZVision *engine);
@@ -64,6 +72,9 @@ private:
/** Holds the currently active controls */
Common::List<Common::SharedPtr<Control> > _activeControls;
+ Location _nextLocation;
+ bool _changeLocation;
+
public:
void initialize();
@@ -79,6 +90,7 @@ public:
private:
void createReferenceTable();
+ void changeLocationIntern();
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
Commit: 327d4a1ccff41af28b010679a29168b7e839de29
https://github.com/scummvm/scummvm/commit/327d4a1ccff41af28b010679a29168b7e839de29
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:32:57-07:00
Commit Message:
ZVISION: Implement ActionChangeLocation::execute()
Changed paths:
engines/zvision/actions.cpp
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 8c10837..4fe77c1 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -87,8 +87,10 @@ ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
}
bool ActionChangeLocation::execute(ZVision *engine) {
- // TODO: Implement
- return true;
+ // We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking
+ engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _x);
+ // Tell the puzzle system to stop checking any more puzzles
+ return false;
}
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index efd1229..a47bf0f 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -162,8 +162,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:change_location*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionChangeLocation(line)));
} else if (line.matchString("*:crossfade*", true)) {
Commit: 309034c153568372f49d3b5c5c13537e53e2cdeb
https://github.com/scummvm/scummvm/commit/309034c153568372f49d3b5c5c13537e53e2cdeb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:36:57-07:00
Commit Message:
ZVISION: Stop checking puzzles if ResultAction::execute() returns false
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 586cc2a..3a574a3 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -142,17 +142,21 @@ 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);
+ bool shouldContinue = true;
for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
- (*resultIter)->execute(_engine);
+ shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
}
// Set the puzzle as completed
setStateValue(puzzle->key, 1);
+
+ if (!shouldContinue) {
+ break;
+ }
}
}
}
Commit: 17a806a01b6def7ef59cc2501cf53dacc902b4e2
https://github.com/scummvm/scummvm/commit/17a806a01b6def7ef59cc2501cf53dacc902b4e2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-10T15:38:33-07:00
Commit Message:
ZVISION: Add parsing skip for action::copy_file. It is not used.
I don't really know what it is used for, but Marisa Chan completely ignores it.
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 a47bf0f..f116774 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -255,6 +255,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:universe_music*", true)) {
+ } else if (line.matchString("*:copy_file*", true)) {
+ // Not used. Purposely left empty
} else {
warning("Unhandled result action type: %s", line.c_str());
}
Commit: c6b82e7753f24a3ea03596204f62975666aa2239
https://github.com/scummvm/scummvm/commit/c6b82e7753f24a3ea03596204f62975666aa2239
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T11:39:52-07:00
Commit Message:
ZVISION: Fix parsed arguments in ActionStreamVideo
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 4fe77c1..2316530 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -259,7 +259,7 @@ ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
char fileName[25];
uint skippable;
- sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x, &_y, &_width, &_height, &_flags, &skippable);
+ sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable);
_fileName = Common::String(fileName);
_skippable = (skippable == 0) ? false : true;
@@ -272,8 +272,9 @@ bool ActionStreamVideo::execute(ZVision *engine) {
}
Common::Rect destRect;
+ // 0x1 flags that the destRect dimensions are different from the original video dimensions
if ((_flags & 0x1) == 0x1) {
- destRect = Common::Rect(_x, _y, _x + _width, _y + _height);
+ destRect = Common::Rect(_x1, _y1, _x2, _y2);
}
engine->playVideo(decoder, destRect, _skippable);
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index bb44617..8e00cb5 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -293,10 +293,10 @@ public:
private:
Common::String _fileName;
- uint _x;
- uint _y;
- uint _width;
- uint _height;
+ uint _x1;
+ uint _y1;
+ uint _x2;
+ uint _y2;
uint _flags;
bool _skippable;
};
Commit: bd4e6e0c1873d6a1fe387114d06ec95a0756a2db
https://github.com/scummvm/scummvm/commit/bd4e6e0c1873d6a1fe387114d06ec95a0756a2db
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T11:40:23-07:00
Commit Message:
ZVISION: Remove Graphics::Cursor inheritance and remove extraneous methods
Changed paths:
engines/zvision/cursor.h
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 0d91a48..77093c4 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -33,7 +33,7 @@ class String;
namespace ZVision {
-class ZorkCursor : public Graphics::Cursor {
+class ZorkCursor {
public:
ZorkCursor();
ZorkCursor(const Common::String &fileName);
@@ -56,9 +56,6 @@ public:
uint16 getHotspotY() const { return _hotspotY; }
byte getKeyColor() const { return 0; }
const byte *getSurface() const { return _surface; }
- const byte *getPalette() const { return 0; }
- byte getPaletteStartIndex() const { return 0; }
- uint16 getPaletteCount() const { return 0; }
};
} // End of namespace ZVision
Commit: f6033afa0252384e618adebd0f1aef5867a312f8
https://github.com/scummvm/scummvm/commit/f6033afa0252384e618adebd0f1aef5867a312f8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T11:42:00-07:00
Commit Message:
ZVISION: Change CursorManager to go through CursorMan instead going directly to OSystem
This had to be done so the cursor didn't disappear after the user went to GMM or debug console
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/cursor_manager.h
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 0115ec9..6f60ddf 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -24,6 +24,7 @@
#include "common/system.h"
#include "graphics/pixelformat.h"
+#include "graphics/cursorman.h"
#include "zvision/zvision.h"
#include "zvision/cursor_manager.h"
@@ -44,8 +45,7 @@ const char *CursorManager::_zNemCursorFileNames[] = { "00act", "arrow", "back",
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
: _engine(engine),
_pixelFormat(pixelFormat),
- _cursorIsPushed(false),
- _currentCursor("idle") {
+ _cursorIsPushed(false) {
// WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
if (_engine->getGameId() == ZorkNemesis) {
Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[11]));
@@ -53,15 +53,20 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel
} else if (_engine->getGameId() == ZorkGrandInquisitor) {
_idleCursor = ZorkCursor(_zgiCursorFileNames[11]);
}
+ revertToIdle();
}
void CursorManager::initialize() {
- _engine->_system->setMouseCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- _engine->_system->showMouse(true);
+ CursorMan.showMouse(true);
}
-void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
- _cursorIsPushed = pushed;
+void CursorManager::changeCursor(const Common::String &cursorName) {
+ changeCursor(cursorName, _cursorIsPushed);
+}
+
+void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) {
+ if (_cursorIsPushed != pushed)
+ _cursorIsPushed = pushed;
if (cursorName == "idle" && !pushed) {
revertToIdle();
@@ -71,7 +76,9 @@ void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
// WARNING: The range of this loop is hardcoded to the length of _cursorNames
for (int i = 0; i < 18; i++) {
if (_engine->getGameId() == ZorkNemesis) {
- if (_cursorNames[i] == cursorName) {
+ if (cursorName.equals(_cursorNames[i])) {
+ _currentCursor = cursorName;
+
// ZNem uses a/b at the end of the file to signify not pushed/pushed respectively
Common::String pushedFlag = pushed ? "b" : "a";
Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag.c_str());
@@ -80,7 +87,9 @@ void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
return;
}
} else if (_engine->getGameId() == ZorkGrandInquisitor) {
- if (_cursorNames[i] == cursorName) {
+ if (cursorName.equals(_cursorNames[i])) {
+ _currentCursor = cursorName;
+
if (!pushed) {
changeCursor(ZorkCursor(_zgiCursorFileNames[i]));
} else {
@@ -100,7 +109,7 @@ void CursorManager::changeCursor(Common::String &cursorName, bool pushed) {
}
void CursorManager::changeCursor(const ZorkCursor &cursor) {
- _engine->_system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat);
+ CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat);
}
void CursorManager::cursorDown(bool pushed) {
@@ -113,7 +122,7 @@ void CursorManager::cursorDown(bool pushed) {
void CursorManager::revertToIdle() {
_currentCursor = "idle";
- _engine->_system->setMouseCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
+ CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
}
} // End of namespace ZVision
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 9145385..9f624c8 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -36,6 +36,12 @@ namespace ZVision {
class ZVision;
+/**
+ * Class to manage cursor changes. The actual changes have to be done
+ * through CursorMan. Otherwise the cursor will disappear after GMM
+ * or debug console.
+ * TODO: Figure out a way to get rid of the extraneous data copying due to having to use CursorMan
+ */
class CursorManager {
public:
CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat);
@@ -54,7 +60,8 @@ private:
public:
void initialize();
- void changeCursor(Common::String &cursorName, bool pushed);
+ void changeCursor(const Common::String &cursorName);
+ void changeCursor(const Common::String &cursorName, bool pushed);
void cursorDown(bool pushed);
void revertToIdle();
Commit: b76927ab4eb5e199f7be6d068a94dc3c531122b1
https://github.com/scummvm/scummvm/commit/b76927ab4eb5e199f7be6d068a94dc3c531122b1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T11:43:29-07:00
Commit Message:
ZVISION: Remove extraneous _needsScreenUpdate bool
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 f759c1f..132c597 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -39,7 +39,6 @@ RenderManager::RenderManager(OSystem *system, const int width, const int height)
_width(width),
_height(height),
_currentBackground(0),
- _needsScreenUpdate(false),
_renderTable(width, height) {
}
@@ -141,7 +140,6 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
tga.destroy();
}
- _needsScreenUpdate = true;
}
RenderTable *RenderManager::getRenderTable() {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 4b4e178..6e267eb 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -57,8 +57,6 @@ private:
Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
- bool _needsScreenUpdate;
-
public:
void initialize();
@@ -94,7 +92,6 @@ public:
RenderTable *getRenderTable();
- bool needsScreenUpdate() { return _needsScreenUpdate; };
private:
void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
Commit: a3315037ffde458ff8356c5e7ef9913c4f7b245c
https://github.com/scummvm/scummvm/commit/a3315037ffde458ff8356c5e7ef9913c4f7b245c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T11:44:23-07:00
Commit Message:
ZVISION: Create methods for converting screen coords to image coords
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
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 132c597..2d45ad8 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -80,6 +80,8 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
destRect.moveTo((_width - subRectangle.width()) / 2, (_height - subRectangle.height()) / 2);
}
+ _backgroundOffset = Common::Point(destRect.left, destRect.top);
+
if (_renderTable.getRenderState() == RenderTable::FLAT) {
_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
@@ -139,7 +141,17 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
tga.destroy();
}
+}
+
+const Common::Point RenderManager::convertToImageCoords(const Common::Point &point) {
+ Common::Point newPoint(point);
+
+ if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+ newPoint = _renderTable.convertWarpedPointToFlatCoords(newPoint);
+ }
+ newPoint -= _backgroundOffset;
+ return newPoint;
}
RenderTable *RenderManager::getRenderTable() {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 6e267eb..aea2450 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -53,6 +53,7 @@ private:
RenderTable _renderTable;
Common::SeekableReadStream *_currentBackground;
+ Common::Point _backgroundOffset;
Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
@@ -90,8 +91,9 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
- RenderTable *getRenderTable();
+ const Common::Point convertToImageCoords(const Common::Point &point);
+ RenderTable *getRenderTable();
private:
void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index b6598c1..2a111ce 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -60,6 +60,16 @@ void RenderTable::setRenderState(RenderState newState) {
}
}
+const Common::Point RenderTable::convertWarpedPointToFlatCoords(const Common::Point &point) {
+ uint32 index = point.y * _numColumns + point.x;
+
+ Common::Point newPoint(point);
+ newPoint.x += _internalBuffer[index].x;
+ newPoint.y += _internalBuffer[index].y;
+
+ return newPoint;
+}
+
uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
assert(percentColorOne < 1.0f);
@@ -157,7 +167,14 @@ void RenderTable::generatePanoramaLookupTable() {
}
void RenderTable::generateTiltLookupTable() {
+ for (uint x = 0; x < _numColumns; x++) {
+ for (uint y = 0; y < _numRows; y++) {
+ uint32 index = y * _numColumns + x;
+ _internalBuffer[index].x = 0;
+ _internalBuffer[index].y = 0;
+ }
+ }
}
void RenderTable::setPanoramaFoV(float fov) {
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 82bea62..5cef062 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -63,6 +63,9 @@ private:
public:
RenderState getRenderState() { return _renderState; }
void setRenderState(RenderState newState);
+
+ const Common::Point convertWarpedPointToFlatCoords(const Common::Point &point);
+
void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
void generateRenderTable();
Commit: 3eb6c0ebd8c523c0c66e639fc1ea1f02b8575231
https://github.com/scummvm/scummvm/commit/3eb6c0ebd8c523c0c66e639fc1ea1f02b8575231
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:02:38-07:00
Commit Message:
ZVISION: Convert hardcoded constants to anonymous enum variables
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/cursor_manager.h
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 6f60ddf..698168b 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -32,31 +32,31 @@
namespace ZVision {
-const char *CursorManager::_cursorNames[] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" };
+const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" };
-const char *CursorManager::_zgiCursorFileNames[] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr",
- "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" };
+const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr",
+ "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" };
-const char *CursorManager::_zNemCursorFileNames[] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
+const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
: _engine(engine),
_pixelFormat(pixelFormat),
_cursorIsPushed(false) {
- // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
+ // WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
if (_engine->getGameId() == ZorkNemesis) {
- Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[11]));
+ Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
_idleCursor = ZorkCursor(name);
} else if (_engine->getGameId() == ZorkGrandInquisitor) {
- _idleCursor = ZorkCursor(_zgiCursorFileNames[11]);
+ _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]);
}
- revertToIdle();
}
void CursorManager::initialize() {
+ revertToIdle();
CursorMan.showMouse(true);
}
@@ -73,8 +73,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
return;
}
- // WARNING: The range of this loop is hardcoded to the length of _cursorNames
- for (int i = 0; i < 18; i++) {
+ for (int i = 0; i < NUM_CURSORS; i++) {
if (_engine->getGameId() == ZorkNemesis) {
if (cursorName.equals(_cursorNames[i])) {
_currentCursor = cursorName;
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 9f624c8..496c652 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -47,6 +47,12 @@ public:
CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat);
private:
+ enum {
+ NUM_CURSORS = 18,
+ // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
+ IDLE_CURSOR_INDEX = 11
+ };
+
ZVision *_engine;
const Graphics::PixelFormat *_pixelFormat;
ZorkCursor _idleCursor;
Commit: 668b0e6c892c67253fe5d763ab752bf7dfbd1c3f
https://github.com/scummvm/scummvm/commit/668b0e6c892c67253fe5d763ab752bf7dfbd1c3f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:03:30-07:00
Commit Message:
ZVISION: Throw a warning when a .scr file isn't opened
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 f116774..6a71fe4 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -35,8 +35,10 @@ namespace ZVision {
void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
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
+ if (!file.open(fileName)) {
+ warning("Script file not found: %s", fileName.c_str());
+ return;
+ }
while(!file.eos()) {
Common::String line = file.readLine();
Commit: 19e829ae95bc69f470d285bdf90d4b45b42248a4
https://github.com/scummvm/scummvm/commit/19e829ae95bc69f470d285bdf90d4b45b42248a4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:04:03-07:00
Commit Message:
ZVISION: Ignore .scr file lines that are empty
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 6a71fe4..cd4baa3 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -148,6 +148,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
// TODO: Re-order the if-then statements in order of highest occurrence
while (!line.contains('}')) {
+ if (line.empty()) {
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ continue;
+ }
+
// Parse for the action type
if (line.matchString("*:add*", true)) {
actionList.push_back(Common::SharedPtr<ResultAction>(new ActionAdd(line)));
Commit: 9f0420e1cef30eaebdf28c32f70fe6467bb9a227
https://github.com/scummvm/scummvm/commit/9f0420e1cef30eaebdf28c32f70fe6467bb9a227
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:04:46-07:00
Commit Message:
ZVISION: Change the initializer list formatting to conform to how everything else is formatted
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 3a574a3..9faff18 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -33,7 +33,10 @@
namespace ZVision {
-ScriptManager::ScriptManager(ZVision *engine) : _engine(engine), _changeLocation(false) {}
+ScriptManager::ScriptManager(ZVision *engine)
+ : _engine(engine),
+ _changeLocation(false) {
+}
void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
Commit: 9681d7515e769b4db2566b4c17328bb836fe9d41
https://github.com/scummvm/scummvm/commit/9681d7515e769b4db2566b4c17328bb836fe9d41
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:05:38-07:00
Commit Message:
ZVISION: Fix enum qualifiers
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 9faff18..c8c6f6c 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -107,8 +107,8 @@ void ScriptManager::checkPuzzleCriteria() {
// 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) {
+ (puzzle->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST &&
+ (puzzle->flags & Puzzle::DISABLED) == 0) {
continue;
}
Commit: 553a3ced68914f965a5d86c262d338d2bcfc8095
https://github.com/scummvm/scummvm/commit/553a3ced68914f965a5d86c262d338d2bcfc8095
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:06:11-07:00
Commit Message:
ZVISION: Remove a verbose debug message
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index c8c6f6c..da2a381 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -112,8 +112,6 @@ void ScriptManager::checkPuzzleCriteria() {
continue;
}
- 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++) {
Commit: ca7680599534aec4f89a65bb5a087e3372488896
https://github.com/scummvm/scummvm/commit/ca7680599534aec4f89a65bb5a087e3372488896
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:06:45-07:00
Commit Message:
ZVISION: Fix accidental redeclaration of the scale variable
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 9f98b14..b3e32b7 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -96,7 +96,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
// Assume bilinear scaling. AKA calculate the scale from just the width.
// Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
// TODO: Test ^these^ assumptions
- uint scale = destRect.width() / origWidth;
+ scale = destRect.width() / origWidth;
// TODO: Test if we need to support downscale.
}
Commit: dd77956819091d4a8d3578375fc66a02f4e8283b
https://github.com/scummvm/scummvm/commit/dd77956819091d4a8d3578375fc66a02f4e8283b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:08:22-07:00
Commit Message:
ZVISION: Move SearchMan directory registration outside ZVision constructor
The launcher can do some extra changes within SearchMan after engine constructor.
This makes sure everything is set before registering more directories
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0dd62d7..72441eb 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -60,17 +60,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Do not initialize graphics here
- // However this is the place to specify all default directories
- const Common::FSNode gameDataDir(ConfMan.get("path"));
- // 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, "zassets1", 0, 2, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, 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");
//DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");
@@ -101,6 +90,16 @@ ZVision::~ZVision() {
}
void ZVision::initialize() {
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ // 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, "zassets1", 0, 2, true);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, true);
+
// Find zfs archive files
Common::ArchiveMemberList list;
SearchMan.listMatchingMembers(list, "*.zfs");
Commit: 3e8bc76127a66ad631095de94a57c31aabb7d6b4
https://github.com/scummvm/scummvm/commit/3e8bc76127a66ad631095de94a57c31aabb7d6b4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:09:19-07:00
Commit Message:
ZVISION: Create MousEvent class to handle mouse hovers/clicks
Changed paths:
A engines/zvision/mouse_event.cpp
A engines/zvision/mouse_event.h
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 7e74b0b..f072520 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS := \
detection.o \
events.o \
lzss_read_stream.o \
+ mouse_event.o \
render_manager.o \
render_table.o \
scr_file_handling.o \
diff --git a/engines/zvision/mouse_event.cpp b/engines/zvision/mouse_event.cpp
new file mode 100644
index 0000000..a7c9fe5
--- /dev/null
+++ b/engines/zvision/mouse_event.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/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/mouse_event.h"
+
+namespace ZVision {
+
+MouseEvent::MouseEvent(uint32 key, const Common::Rect &hotspot, const Common::String hoverCursor)
+ : _key(key),
+ _hotspot(hotspot),
+ _hoverCursor(hoverCursor) {
+}
+
+bool MouseEvent::withinHotspot(const Common::Point &point) {
+ return _hotspot.contains(point);
+}
+
+void MouseEvent::onClick(ZVision *engine) {
+ engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h
new file mode 100644
index 0000000..1fbd160
--- /dev/null
+++ b/engines/zvision/mouse_event.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_MOUSE_EVENT_H
+#define ZVISION_MOUSE_EVENT_H
+
+#include "common/types.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class MouseEvent {
+public:
+ MouseEvent(uint32 key, const Common::Rect &hotspot, const Common::String hoverCursor);
+
+private:
+ /** The Control key */
+ uint32 _key;
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _hotspot;
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+
+public:
+ bool withinHotspot(const Common::Point &point);
+ void onClick(ZVision *engine);
+ const Common::String getHoverCursor() { return _hoverCursor; }
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 269bed7c7d279e0785056a4e5ba1622317402449
https://github.com/scummvm/scummvm/commit/269bed7c7d279e0785056a4e5ba1622317402449
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:10:52-07:00
Commit Message:
ZVISION: Implement mouse event handling
Changed paths:
engines/zvision/events.cpp
engines/zvision/script_manager.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 17f48db..79ef0bd 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -28,9 +28,19 @@
#include "engines/util.h"
#include "zvision/cursor_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/mouse_event.h"
namespace ZVision {
+void ZVision::registerMouseEvent(const MouseEvent &event) {
+ _mouseEvents.push_back(event);
+}
+
+void ZVision::clearAllMouseEvents() {
+ _mouseEvents.clear();
+}
+
void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
@@ -84,10 +94,32 @@ void ZVision::onMouseDown(const Common::Point &pos) {
void ZVision::onMouseUp(const Common::Point &pos) {
_cursorManager->cursorDown(false);
+
+ Common::Point imageCoord(_renderManager->convertToImageCoords(pos));
+
+ for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ if (iter->withinHotspot(imageCoord)) {
+ iter->onClick(this);
+ }
+ }
}
void ZVision::onMouseMove(const Common::Point &pos) {
+ Common::Point imageCoord(_renderManager->convertToImageCoords(pos));
+
+ bool isWithinAHotspot = false;
+ for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ if (iter->withinHotspot(imageCoord)) {
+ _cursorManager->changeCursor(iter->getHoverCursor());
+ isWithinAHotspot = true;
+ }
+ }
+
+
+ if (!isWithinAHotspot) {
+ _cursorManager->revertToIdle();
+ }
}
void ZVision::onKeyDown(uint keyCode) {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index da2a381..03e7917 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -26,6 +26,7 @@
#include "common/hashmap.h"
#include "common/debug.h"
+#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/actions.h"
#include "zvision/action_node.h"
@@ -207,6 +208,7 @@ void ScriptManager::changeLocationIntern() {
_activePuzzles.clear();
// We can clear without deleting from the heap because we use SharedPtr
_activeControls.clear();
+ _engine->clearAllMouseEvents();
// Parse into puzzles and controls
Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 8363fb1..bf42bf2 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -33,6 +33,7 @@
#include "zvision/detection.h"
#include "zvision/clock.h"
+#include "zvision/mouse_event.h"
#include "gui/debugger.h"
@@ -82,6 +83,9 @@ private:
// Clock
Clock _clock;
+ // To store the current mouse events
+ Common::List<MouseEvent> _mouseEvents;
+
// To prevent allocation every time we process events
Common::Event _event;
@@ -99,6 +103,9 @@ public:
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
+ void registerMouseEvent(const MouseEvent &event);
+ void clearAllMouseEvents();
+
void cycleThroughCursors();
private:
Commit: 00a17a66d0e8317001829fe36639ef9201d15798
https://github.com/scummvm/scummvm/commit/00a17a66d0e8317001829fe36639ef9201d15798
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T13:12:01-07:00
Commit Message:
ZVISION: Implement push_toggle control handling
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index fdb88c6..02d15fe 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -102,4 +102,39 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
+void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
+ Common::Rect hotspot;
+ Common::String cursorName;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!line.contains('}')) {
+ if (line.matchString("*_hotspot*", true)) {
+ uint x;
+ uint y;
+ uint width;
+ uint height;
+
+ sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
+
+ hotspot = Common::Rect(x, y, x + width, y + height);
+ } else if (line.matchString("cursor*", true)) {
+ char nameBuffer[25];
+
+ sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
+
+ cursorName = Common::String(nameBuffer);
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ if (!hotspot.isEmpty() && !cursorName.empty()) {
+ engine->registerMouseEvent(MouseEvent(key, hotspot, cursorName));
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index edc0fc2..2d5426c 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -46,6 +46,7 @@ public:
static void parseFlatControl(ZVision *engine);
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
+ static void parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index cd4baa3..5b8af48 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -309,7 +309,8 @@ bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
-
+ Control::parsePushToggleControl(key, _engine, stream);
+ return false;
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
return false;
Commit: a49b77cd799a081d04a14f8eeaf8e61b678507bf
https://github.com/scummvm/scummvm/commit/a49b77cd799a081d04a14f8eeaf8e61b678507bf
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:38:10-07:00
Commit Message:
ZVISION: Fix memory leak
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 2d45ad8..e705a7f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -166,6 +166,9 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
return;
}
+ if (_currentBackground != 0) {
+ delete _currentBackground;
+ }
_currentBackground = file;
renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(), true);
Commit: 19a2a59c3cf9c9baf8d0366ab59d8a0ec2d0d7e4
https://github.com/scummvm/scummvm/commit/19a2a59c3cf9c9baf8d0366ab59d8a0ec2d0d7e4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:39:21-07:00
Commit Message:
ZVISION: Fix unsigned/signed mismatch
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index b3e32b7..ca95a7e 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -47,7 +47,7 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
for (uint32 x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
- for (int i = 0; i < scaleAmount; i++) {
+ for (uint i = 0; i < scaleAmount; i++) {
dst[i] = color;
dst[pitch + i] = color;
}
@@ -61,11 +61,11 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
const byte color = *srcPtr++;
const byte color2 = *srcPtr++;
- for (int i = 0; i < scaleAmount; i++) {
dst[i] = color;
dst[i + 1] = color2;
dst[pitch + i] = color;
dst[pitch + i + 1] = color2;
+ for (uint i = 0; i < scaleAmount; i++) {
}
dst += 2 * scaleAmount;
}
Commit: 5ef23e6f8daffd65dd605a28252398d1556760fe
https://github.com/scummvm/scummvm/commit/5ef23e6f8daffd65dd605a28252398d1556760fe
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:39:56-07:00
Commit Message:
ZVISION: Restart the Clock after the video finishes
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index ca95a7e..0d707e7 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -156,7 +156,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
_system->delayMillis(videoDecoder.getTimeToNextFrame());
}
- _clock.stop();
+ _clock.start();
// Reset the pixel format to the original state
initGraphics(_width, _height, true, &_pixelFormat);
Commit: e3f352cb0c3247f72dfc1f6fe65c57ada64f9755
https://github.com/scummvm/scummvm/commit/e3f352cb0c3247f72dfc1f6fe65c57ada64f9755
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:40:32-07:00
Commit Message:
ZVISION: Delete the scaledVideoFrameBuffer after we're done with it
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 0d707e7..2a320cb 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -158,6 +158,8 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
_clock.start();
+ delete[] scaledVideoFrameBuffer;
+
// Reset the pixel format to the original state
initGraphics(_width, _height, true, &_pixelFormat);
}
Commit: d8e45fc438a546bd7e1f8c66e345aafb33bb2a56
https://github.com/scummvm/scummvm/commit/d8e45fc438a546bd7e1f8c66e345aafb33bb2a56
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:42:40-07:00
Commit Message:
ZVISION: Only allocate memory for the scaled buffer if we're actually going to scale the video
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 2a320cb..0836eef 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -106,7 +106,10 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
uint16 finalWidth = origWidth * scale;
uint16 finalHeight = origHeight * scale;
- byte *scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
+ byte *scaledVideoFrameBuffer;
+ if (scale != 1) {
+ scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
+ }
uint16 x = ((_width - finalWidth) / 2) + destRect.left;
uint16 y = ((_height - finalHeight) / 2) + destRect.top;
@@ -158,7 +161,9 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
_clock.start();
- delete[] scaledVideoFrameBuffer;
+ if (scale != 1) {
+ delete[] scaledVideoFrameBuffer;
+ }
// Reset the pixel format to the original state
initGraphics(_width, _height, true, &_pixelFormat);
Commit: 372c55fd8be80182721566f09ab2d69c9f24abc5
https://github.com/scummvm/scummvm/commit/372c55fd8be80182721566f09ab2d69c9f24abc5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:43:39-07:00
Commit Message:
VIDEO: Disable SCI_32 plugin guard for DUCK Truemotion
ZVision AVI videos use DUCK Truemotion
Changed paths:
video/codecs/truemotion1.h
diff --git a/video/codecs/truemotion1.h b/video/codecs/truemotion1.h
index b2a35cf..39950b3 100644
--- a/video/codecs/truemotion1.h
+++ b/video/codecs/truemotion1.h
@@ -23,7 +23,7 @@
// Based on the TrueMotion 1 decoder by Alex Beregszaszi & Mike Melanson in FFmpeg
// Only compile if SCI32 is enabled or if we're building dynamic modules
-#if defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES)
+//#if defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES)
#ifndef VIDEO_CODECS_TRUEMOTION1_H
#define VIDEO_CODECS_TRUEMOTION1_H
@@ -106,4 +106,4 @@ private:
} // End of namespace Video
#endif // VIDEO_CODECS_TRUEMOTION1_H
-#endif // SCI32/Plugins guard
+//#endif // SCI32/Plugins guard
Commit: 7e93b6407a14c3c3fe75f03667362fcf8555e69d
https://github.com/scummvm/scummvm/commit/7e93b6407a14c3c3fe75f03667362fcf8555e69d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:44:13-07:00
Commit Message:
ZVISION: Fix frame scaling for 2bpp
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 0836eef..f9637d3 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -61,11 +61,13 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
const byte color = *srcPtr++;
const byte color2 = *srcPtr++;
- dst[i] = color;
- dst[i + 1] = color2;
- dst[pitch + i] = color;
- dst[pitch + i + 1] = color2;
for (uint i = 0; i < scaleAmount; i++) {
+ uint index = i *2;
+
+ dst[index] = color;
+ dst[index + 1] = color2;
+ dst[pitch + index] = color;
+ dst[pitch + index + 1] = color2;
}
dst += 2 * scaleAmount;
}
Commit: b9b8207a140531079f3e200e6858a8dc9cc7b5d2
https://github.com/scummvm/scummvm/commit/b9b8207a140531079f3e200e6858a8dc9cc7b5d2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-11T14:44:52-07:00
Commit Message:
ZVISION: Dispose of .zfs file streams after processing them
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 72441eb..7f925e9 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -107,7 +107,10 @@ void ZVision::initialize() {
// 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());
+ Common::SeekableReadStream *stream = (*iter)->createReadStream();
+ ZfsArchive *archive = new ZfsArchive(name, stream);
+
+ delete stream;
SearchMan.add(name, archive);
}
Commit: 878fde365ea74e52ec1539f87fee53ed6c8c4279
https://github.com/scummvm/scummvm/commit/878fde365ea74e52ec1539f87fee53ed6c8c4279
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T08:16:42-07:00
Commit Message:
ZVISION: Fix alignment formatting
Changed paths:
engines/zvision/zork_avi_decoder.h
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index 1dff304..1ce2508 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -47,11 +47,11 @@ private:
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)
- };
+private:
+ // Audio Codecs
+ enum {
+ kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
+ };
};
} // End of namespace ZVision
Commit: c020c6bf539d2a9fc4f91a422e1f63d9d9f374b3
https://github.com/scummvm/scummvm/commit/c020c6bf539d2a9fc4f91a422e1f63d9d9f374b3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T08:17:24-07:00
Commit Message:
ZVISION: Add check to CursorMan::changeCursor to prevent extraneous cursor changes
Changed paths:
engines/zvision/cursor_manager.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 698168b..361fe11 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -65,6 +65,9 @@ void CursorManager::changeCursor(const Common::String &cursorName) {
}
void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) {
+ if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed)
+ return;
+
if (_cursorIsPushed != pushed)
_cursorIsPushed = pushed;
Commit: 4c1e8b3f453fec9e18743a636bcf2d1c83135c2e
https://github.com/scummvm/scummvm/commit/4c1e8b3f453fec9e18743a636bcf2d1c83135c2e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T08:18:17-07:00
Commit Message:
ZVISION: Allow CursorManager::revertToIdle to take _cursorIsPushed into account
Changed paths:
engines/zvision/cursor_manager.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 361fe11..0e7c2bc 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -72,7 +72,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
_cursorIsPushed = pushed;
if (cursorName == "idle" && !pushed) {
- revertToIdle();
+ CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
return;
}
@@ -124,7 +124,10 @@ void CursorManager::cursorDown(bool pushed) {
void CursorManager::revertToIdle() {
_currentCursor = "idle";
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
+ if (!_cursorIsPushed)
+ CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
+ else
+ changeCursor(_currentCursor, _cursorIsPushed);
}
} // End of namespace ZVision
Commit: 003b30c77b34c9447bab3927d206101d5f341b4f
https://github.com/scummvm/scummvm/commit/003b30c77b34c9447bab3927d206101d5f341b4f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T08:18:41-07:00
Commit Message:
ZVISION: Create methods for setting left, right, up, down cursors
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/cursor_manager.h
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 0e7c2bc..50fa503 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -122,6 +122,22 @@ void CursorManager::cursorDown(bool pushed) {
changeCursor(_currentCursor, pushed);
}
+void CursorManager::setLeftCursor() {
+ changeCursor("leftarrow");
+}
+
+void CursorManager::setRightCursor() {
+ changeCursor("rightarrow");
+}
+
+void CursorManager::setUpCursor() {
+ changeCursor("zuparrow");
+}
+
+void CursorManager::setDownCursor() {
+ changeCursor("downarrow");
+}
+
void CursorManager::revertToIdle() {
_currentCursor = "idle";
if (!_cursorIsPushed)
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 496c652..fd61ac2 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -69,6 +69,12 @@ public:
void changeCursor(const Common::String &cursorName);
void changeCursor(const Common::String &cursorName, bool pushed);
void cursorDown(bool pushed);
+
+ void setLeftCursor();
+ void setRightCursor();
+ void setUpCursor();
+ void setDownCursor();
+
void revertToIdle();
private:
Commit: 54f16f2539d619b7cdb4e43d7de03e1f538a1c1f
https://github.com/scummvm/scummvm/commit/54f16f2539d619b7cdb4e43d7de03e1f538a1c1f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:04-07:00
Commit Message:
ZVISION: Create the concept of a working window
The working window is a Rect centered inside the actual window edges. All in-game
coordinates are in the working window coordinate system. Also, all images in-game
are clipped to the edges of the working window.
Changed paths:
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/render_manager.cpp b/engines/zvision/render_manager.cpp
index e705a7f..7855dc3 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -34,12 +34,13 @@
namespace ZVision {
-RenderManager::RenderManager(OSystem *system, const int width, const int height)
+RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow)
: _system(system),
- _width(width),
- _height(height),
+ _workingWidth(workingWindow.width()),
+ _workingHeight(workingWindow.height()),
+ _workingWindow(workingWindow),
_currentBackground(0),
- _renderTable(width, height) {
+ _renderTable(workingWindow.width(), workingWindow.height()) {
}
RenderManager::~RenderManager() {
@@ -75,20 +76,19 @@ 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);
}
_backgroundOffset = Common::Point(destRect.left, destRect.top);
if (_renderTable.getRenderState() == RenderTable::FLAT) {
- _system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
+ // Convert destRect to screen space by adding _workingWindowOffset
+ _system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height());
} else {
uint16 *destBuffer = new uint16[destRect.width() * destRect.height()];
_renderTable.mutateImage((uint16 *)buffer, destBuffer, imageWidth, imageHeight, subRectangle, destRect);
- _system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left, destRect.top, destRect.width(), destRect.height());
+ // Convert destRect to screen space by adding _workingWindow offest
+ _system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height());
delete[] destBuffer;
}
}
@@ -143,14 +143,20 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
}
}
-const Common::Point RenderManager::convertToImageCoords(const Common::Point &point) {
- Common::Point newPoint(point);
+const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
+ // Convert from screen space to working window space
+ Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
- newPoint = _renderTable.convertWarpedPointToFlatCoords(newPoint);
+ newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
}
newPoint -= _backgroundOffset;
+ if (newPoint.x < 0)
+ newPoint.x += _backgroundWidth;
+ if (newPoint.y < 0)
+ newPoint.y += _backgroundHeight;
+
return newPoint;
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index aea2450..8731675 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -43,13 +43,14 @@ namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system, const int width, const int height);
+ RenderManager(OSystem *system, const Common::Rect workingWindow);
~RenderManager();
private:
OSystem *_system;
- const int _width;
- const int _height;
+ const int _workingWidth;
+ const int _workingHeight;
+ const Common::Rect _workingWindow;
RenderTable _renderTable;
Common::SeekableReadStream *_currentBackground;
@@ -63,23 +64,23 @@ public:
/**
* 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.
+ * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
* @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.
+ * @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
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.
- * The image will be clipped to fit inside the window.
+ * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
* @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.
+ * @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
@@ -91,7 +92,7 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
- const Common::Point convertToImageCoords(const Common::Point &point);
+ const Common::Point screenSpaceToImageSpace(const Common::Point &point);
RenderTable *getRenderTable();
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index f9637d3..5497d0a 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -80,7 +80,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
// Videos use a different pixel format
Common::List<Graphics::PixelFormat> formats;
formats.push_back(videoDecoder.getPixelFormat());
- initGraphics(_width, _height, true, formats);
+ initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, formats);
byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
@@ -113,8 +113,8 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
}
- uint16 x = ((_width - finalWidth) / 2) + destRect.left;
- uint16 y = ((_height - finalHeight) / 2) + destRect.top;
+ uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
+ uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;
_clock.stop();
videoDecoder.start();
@@ -168,7 +168,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
}
// Reset the pixel format to the original state
- initGraphics(_width, _height, true, &_pixelFormat);
+ initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
}
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 7f925e9..0f6ec14 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -49,8 +49,7 @@ namespace ZVision {
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
: Engine(syst),
_gameDescription(gameDesc),
- _width(640),
- _height(480),
+ _workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT),
_pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /*RGB 555*/
_desiredFrameTime(33), /* ~30 fps */
_clock(_system) {
@@ -69,7 +68,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, _width, _height);
+ _renderManager = new RenderManager(_system, _workingWindow);
_cursorManager = new CursorManager(this, &_pixelFormat);
debug("ZVision::ZVision");
@@ -115,7 +114,7 @@ void ZVision::initialize() {
SearchMan.add(name, archive);
}
- initGraphics(_width, _height, true, &_pixelFormat);
+ initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
_scriptManager->initialize();
// Has to be done after graphics has been initialized
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index bf42bf2..ca71080 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -64,10 +64,19 @@ public:
~ZVision();
private:
+ enum {
+ WINDOW_WIDTH = 640,
+ WINDOW_HEIGHT = 480,
+ WORKING_WINDOW_WIDTH = 512,
+ WORKING_WINDOW_HEIGHT = 320,
+
+ ROTATION_SCREEN_EDGE_OFFSET = 60,
+ MAX_ROTATION_SPEED = 150 // Pixels per second
+ };
+
Console *_console;
const ZVisionGameDescription *_gameDescription;
- const int _width;
- const int _height;
+ const Common::Rect _workingWindow;
const Graphics::PixelFormat _pixelFormat;
const int _desiredFrameTime;
Commit: 85c67e5e2f87290bd6669e120c68a71b916c892d
https://github.com/scummvm/scummvm/commit/85c67e5e2f87290bd6669e120c68a71b916c892d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:19-07:00
Commit Message:
ZVISION: Implement ZVISION::getCursorManager()
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0f6ec14..f7e0ab8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -167,6 +167,10 @@ RenderManager *ZVision::getRenderManager() const {
return _renderManager;
}
+CursorManager *ZVision::getCursorManager() const {
+ return _cursorManager;
+}
+
Common::RandomSource *ZVision::getRandomSource() const {
return _rnd;
}
Commit: 65853bfe2ba4c7e526cce5d232efb6f645a9c96d
https://github.com/scummvm/scummvm/commit/65853bfe2ba4c7e526cce5d232efb6f645a9c96d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:19-07:00
Commit Message:
ZVISION: Fix header #defines to match their file names
Changed paths:
engines/zvision/actions.h
engines/zvision/single_value_container.h
engines/zvision/vector2.h
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 8e00cb5..511f3d9 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ZVISION_RESULT_ACTION_H
-#define ZVISION_RESULT_ACTION_H
+#ifndef ZVISION_ACTIONS_H
+#define ZVISION_ACTIONS_H
#include "common/scummsys.h"
diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
index 54677ff..45b5a89 100644
--- a/engines/zvision/single_value_container.h
+++ b/engines/zvision/single_value_container.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ZVISION_OBJECT_H
-#define ZVISION_OBJECT_H
+#ifndef ZVISION_SINGLE_VALUE_CONTAINER_H
+#define ZVISION_SINGLE_VALUE_CONTAINER_H
namespace Common {
class String;
diff --git a/engines/zvision/vector2.h b/engines/zvision/vector2.h
index d301aef..575915c 100644
--- a/engines/zvision/vector2.h
+++ b/engines/zvision/vector2.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef COMMON_ZVISION_POINT_H
-#define COMMON_ZVISION_POINT_H
+#ifndef ZVISION_VECTOR2_H
+#define ZVISION_VECTOR2_H
#include "common/scummsys.h"
Commit: 39934b1da7c6a7c0cf0a8d1e01af981ad83d09f0
https://github.com/scummvm/scummvm/commit/39934b1da7c6a7c0cf0a8d1e01af981ad83d09f0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:20-07:00
Commit Message:
ZVISION: Set the initial game location (The opening video and menu)
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 03e7917..93564ee 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -41,6 +41,7 @@ ScriptManager::ScriptManager(ZVision *engine)
void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
+ changeLocation('g', 'a', 'r', 'y', 0);
}
void ScriptManager::update(uint deltaTimeMillis) {
Commit: 1dcc56f7d27717f0ea0becd027639a41a37f6f2f
https://github.com/scummvm/scummvm/commit/1dcc56f7d27717f0ea0becd027639a41a37f6f2f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:20-07:00
Commit Message:
ZVISION: Slight function name change to increase clarity
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 2a111ce..ba506b1 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -60,7 +60,7 @@ void RenderTable::setRenderState(RenderState newState) {
}
}
-const Common::Point RenderTable::convertWarpedPointToFlatCoords(const Common::Point &point) {
+const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Point &point) {
uint32 index = point.y * _numColumns + point.x;
Common::Point newPoint(point);
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 5cef062..c38b5a6 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -64,7 +64,7 @@ public:
RenderState getRenderState() { return _renderState; }
void setRenderState(RenderState newState);
- const Common::Point convertWarpedPointToFlatCoords(const Common::Point &point);
+ const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
void generateRenderTable();
Commit: d8f9be74ff63d2ab21f23e6c1520a7bdebdf1286
https://github.com/scummvm/scummvm/commit/d8f9be74ff63d2ab21f23e6c1520a7bdebdf1286
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:21-07:00
Commit Message:
ZVISION: Add panning support
Changed paths:
engines/zvision/events.cpp
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 79ef0bd..68fa81e 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -26,6 +26,8 @@
#include "zvision/console.h"
#include "common/events.h"
#include "engines/util.h"
+#include "common/system.h"
+#include "common/rational.h"
#include "zvision/cursor_manager.h"
#include "zvision/render_manager.h"
@@ -95,7 +97,7 @@ void ZVision::onMouseDown(const Common::Point &pos) {
void ZVision::onMouseUp(const Common::Point &pos) {
_cursorManager->cursorDown(false);
- Common::Point imageCoord(_renderManager->convertToImageCoords(pos));
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
if (iter->withinHotspot(imageCoord)) {
@@ -105,17 +107,93 @@ void ZVision::onMouseUp(const Common::Point &pos) {
}
void ZVision::onMouseMove(const Common::Point &pos) {
- Common::Point imageCoord(_renderManager->convertToImageCoords(pos));
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
bool isWithinAHotspot = false;
- for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- if (iter->withinHotspot(imageCoord)) {
- _cursorManager->changeCursor(iter->getHoverCursor());
- isWithinAHotspot = true;
+ if (_workingWindow.contains(pos)) {
+ for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ if (iter->withinHotspot(imageCoord)) {
+ _cursorManager->changeCursor(iter->getHoverCursor());
+ isWithinAHotspot = true;
+ }
}
}
-
+ // Graph of the function governing rotation velocity:
+ //
+ // |--------------- working window -----------------|
+ // ^ |--------|
+ // | |
+ // +Max velocity | rotation screen edge offset _____________________
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // Zero velocity |______________________________ ______________________________/____________________________________>
+ // | Position -> /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // | /
+ // -Max velocity |_____________________/
+ // |
+ // |
+ // ^
+
+ // NOTE: RenderManger uses the inverse of velocity (ms/pixel instead of pixels/ms) because it allows you to accumulate whole
+ // pixels 'steps' instead of rounding pixels every frame
+
+ if (_workingWindow.contains(pos)) {
+ RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
+ if (renderState == RenderTable::PANORAMA) {
+ if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) {
+ // Linear function of distance to the left edge (y = -mx + b)
+ // We use fixed point math to get better accuracy
+ Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED;
+ _renderManager->setBackgroundVelocity(velocity.toInt());
+ _cursorManager->setLeftCursor();
+ isWithinAHotspot = true;
+ } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) {
+ // Linear function of distance to the right edge (y = mx)
+ // We use fixed point math to get better accuracy
+ Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET);
+ _renderManager->setBackgroundVelocity(velocity.toInt());
+ _cursorManager->setRightCursor();
+ isWithinAHotspot = true;
+ } else {
+ _renderManager->setBackgroundVelocity(0);
+ }
+ } else if (renderState == RenderTable::TILT) {
+ if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) {
+ // Linear function of distance to top edge
+ // We use fixed point math to get better accuracy
+ Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED;
+ _renderManager->setBackgroundVelocity(velocity.toInt());
+ _cursorManager->setUpCursor();
+ isWithinAHotspot = true;
+ } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) {
+ // Linear function of distance to the bottom edge (y = mx)
+ // We use fixed point math to get better accuracy
+ Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET);
+ _renderManager->setBackgroundVelocity(velocity.toInt());
+ _cursorManager->setDownCursor();
+ isWithinAHotspot = true;
+ } else {
+ _renderManager->setBackgroundVelocity(0);
+ }
+ }
+ } else {
+ _renderManager->setBackgroundVelocity(0);
+ }
if (!isWithinAHotspot) {
_cursorManager->revertToIdle();
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 7855dc3..b8dcd0d 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -40,6 +40,10 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow)
_workingHeight(workingWindow.height()),
_workingWindow(workingWindow),
_currentBackground(0),
+ _backgroundWidth(0),
+ _backgroundHeight(0),
+ _backgroundInverseVelocity(0),
+ _accumulatedVelocityMilliseconds(0),
_renderTable(workingWindow.width(), workingWindow.height()) {
}
@@ -56,6 +60,24 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
uint32 temp = imageHeight;
imageHeight = imageWidth;
imageWidth = temp;
+void RenderManager::update(uint deltaTimeInMillis) {
+ // An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
+ if (_backgroundInverseVelocity == 0)
+ return;
+
+ _accumulatedVelocityMilliseconds += deltaTimeInMillis;
+
+ int absVelocity = abs(_backgroundInverseVelocity);
+
+ uint numberOfSteps = 0;
+ while (_accumulatedVelocityMilliseconds >= absVelocity) {
+ _accumulatedVelocityMilliseconds -= absVelocity;
+ numberOfSteps++;
+ }
+
+ // Choose the direction of movement using the sign of the velocity
+ moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
+}
}
// If subRect is empty, use the entire image
@@ -178,6 +200,46 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
_currentBackground = file;
renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(), true);
+void RenderManager::setBackgroundPosition(int offset) {
+ if (_renderTable.getRenderState() == RenderTable::TILT) {
+ _backgroundOffset = Common::Point(0, offset);
+ } else {
+ _backgroundOffset = Common::Point(offset, 0);
+ }
+}
+
+void RenderManager::setBackgroundVelocity(int velocity) {
+ // setBackgroundVelocity(0) will be called quite often, so make sure
+ // _backgroundInverseVelocity isn't already 0 to prevent an extraneous assignment
+ if (velocity == 0) {
+ if (_backgroundInverseVelocity != 0) {
+ _backgroundInverseVelocity = 0;
+ }
+ } else {
+ _backgroundInverseVelocity = 1000 / velocity;
+ }
+}
+
+void RenderManager::moveBackground(int offset) {
+ if (_renderTable.getRenderState() == RenderTable::TILT) {
+ _backgroundOffset += Common::Point(0, offset);
+ } else {
+ _backgroundOffset += Common::Point(offset, 0);
+ }
+
+ // Make sure the offset is within image bounds
+ if (_backgroundOffset.x < 0)
+ _backgroundOffset.x += _backgroundWidth;
+ if (_backgroundOffset.x > _backgroundWidth)
+ _backgroundOffset.x -= _backgroundWidth;
+ if (_backgroundOffset.y < 0)
+ _backgroundOffset.y += _backgroundHeight;
+ if (_backgroundOffset.y > _backgroundHeight)
+ _backgroundOffset.y -= _backgroundHeight;
+
+ _currentBackground->seek(0);
+ // Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
+ renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 8731675..7d44a37 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -55,12 +55,18 @@ private:
Common::SeekableReadStream *_currentBackground;
Common::Point _backgroundOffset;
+ uint16 _backgroundWidth;
+ uint16 _backgroundHeight;
+
+ int _backgroundInverseVelocity;
+ uint _accumulatedVelocityMilliseconds;
Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
public:
void initialize();
+ void update(uint deltaTimeInMillis);
/**
* Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
@@ -92,6 +98,10 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
+ void setBackgroundPosition(int offset);
+
+ void setBackgroundVelocity(int velocity);
+
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
RenderTable *getRenderTable();
Commit: 8d57880c51f29374a745c2060260fd222a26afe4
https://github.com/scummvm/scummvm/commit/8d57880c51f29374a745c2060260fd222a26afe4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:21-07:00
Commit Message:
ZVISION: Clip coords outside the working window
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index ba506b1..aab4735 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -61,6 +61,13 @@ void RenderTable::setRenderState(RenderState newState) {
}
const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Point &point) {
+ // If we're outside the range of the RenderTable, no warping is happening. Return the maximum image coords
+ if (point.x >= _numColumns || point.y >= _numRows) {
+ int16 x = CLIP<int16>(point.x, 0, _numColumns);
+ int16 y = CLIP<int16>(point.y, 0, _numRows);
+ return Common::Point(x, y);
+ }
+
uint32 index = point.y * _numColumns + point.x;
Common::Point newPoint(point);
Commit: 6be19d850abd9123960c6f4bcf00ba73d5549953
https://github.com/scummvm/scummvm/commit/6be19d850abd9123960c6f4bcf00ba73d5549953
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:22-07:00
Commit Message:
ZVISION: Add background image wrapping
There is still a discontinuity when wrapping, but I am committing so that
others can look at the code
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 b8dcd0d..78fcf59 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -53,13 +53,6 @@ RenderManager::~RenderManager() {
}
}
-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) {
- uint32 temp = imageHeight;
- imageHeight = imageWidth;
- imageWidth = temp;
void RenderManager::update(uint deltaTimeInMillis) {
// An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
if (_backgroundInverseVelocity == 0)
@@ -78,29 +71,72 @@ void RenderManager::update(uint deltaTimeInMillis) {
// Choose the direction of movement using the sign of the velocity
moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
}
+
+void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+ if (wrap) {
+ _backgroundWidth = imageWidth;
+ _backgroundHeight = imageHeight;
}
// If subRect is empty, use the entire image
if (subRectangle.isEmpty())
- subRectangle = Common::Rect(imageWidth, imageHeight);
+ subRectangle = Common::Rect(subRectangle.left, subRectangle.top, subRectangle.left + imageWidth, subRectangle.top + imageHeight);
- // Clip to image bounds
- subRectangle.clip(imageWidth, imageHeight);
- // Clip destRect to screen bounds
+ // Clip destRect to working window bounds
Common::Rect destRect(destinationX, destinationY, destinationX + subRectangle.width(), destinationY + subRectangle.height());
- destRect.clip(_width, _height);
- // Clip subRect to screen bounds
+ destRect.clip(_workingWidth, _workingHeight);
+ // Clip subRect to working window bounds
subRectangle.translate(destRect.left - destinationX, destRect.top - destinationY);
subRectangle.setWidth(destRect.width());
subRectangle.setHeight(destRect.height());
+ // Clip to image bounds
+ Common::Point subRectOrigOrigin(subRectangle.left, subRectangle.top);
+ subRectangle.clip(imageWidth, imageHeight);
- // Check for validity
- if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
- return;
+ // If the image is to be wrapped, check if it's smaller than destRect
+ // If it is, then call renderSubRectToScreen with a subRect representing wrapping
+ if (wrap && subRectangle.width() < destRect.width()) {
+ uint32 wrapDestX;
+ uint32 wrapDestY;
+ Common::Rect wrapSubRect;
+
+ if (_backgroundWidth - subRectangle.left < destRect.width()) {
+ wrapDestX = destRect.left + subRectangle.width();
+ wrapDestY = destRect.top;
+ wrapSubRect = Common::Rect(0, 0, destRect.width() - subRectangle.width(), subRectangle.bottom);
+ } else {
+ wrapDestX = destRect.left;
+ wrapDestY = destRect.top;
+ wrapSubRect = Common::Rect(_backgroundWidth - subRectangle.width(), 0, _backgroundWidth - 1, subRectangle.bottom);
+ }
+ renderSubRectToScreen(buffer, imageWidth, imageHeight, horizontalPitch, wrapDestX, wrapDestY, wrapSubRect, false);
+ } else if (wrap && subRectangle.height() < destRect.height()) {
+ uint32 wrapDestX;
+ uint32 wrapDestY;
+ Common::Rect wrapSubRect;
+
+ if (_backgroundHeight - subRectangle.top < destRect.height()) {
+ wrapDestX = destRect.left;
+ wrapDestY = destRect.height() - subRectangle.height();
+ wrapSubRect = Common::Rect(0, 0, subRectangle.right, destRect.height() - subRectangle.height());
+ } else {
+ wrapDestX = destRect.left;
+ wrapDestY = destRect.top;
+ wrapSubRect = Common::Rect(0, _backgroundHeight - subRectangle.height(), subRectangle.right, _backgroundHeight - 1);
+ }
+
+ renderSubRectToScreen(buffer, imageWidth, imageHeight, horizontalPitch, wrapDestX, wrapDestY, wrapSubRect, false);
}
- _backgroundOffset = Common::Point(destRect.left, destRect.top);
+ // Clip destRect to image bounds
+ destRect.translate(subRectangle.left - subRectOrigOrigin.x, subRectangle.top - subRectOrigOrigin.y);
+ destRect.setWidth(subRectangle.width());
+ destRect.setHeight(subRectangle.height());
+
+ // Check all Rects for validity
+ if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
+ return;
if (_renderTable.getRenderState() == RenderTable::FLAT) {
// Convert destRect to screen space by adding _workingWindowOffset
@@ -109,13 +145,13 @@ void RenderManager::update(uint deltaTimeInMillis) {
uint16 *destBuffer = new uint16[destRect.width() * destRect.height()];
_renderTable.mutateImage((uint16 *)buffer, destBuffer, imageWidth, imageHeight, subRectangle, destRect);
- // Convert destRect to screen space by adding _workingWindow offest
+ // Convert destRect to screen space by adding _workingWindow offset
_system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height());
delete[] destBuffer;
}
}
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
Common::File file;
if (!file.open(fileName)) {
@@ -123,10 +159,10 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
return;
}
- renderImageToScreen(file, destinationX, destinationY, subRectangle, autoCenter);
+ renderImageToScreen(file, destinationX, destinationY, subRectangle);
}
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
uint32 fileType;
@@ -145,7 +181,15 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
uint32 horizontalPitch = imageWidth * sizeof(uint16);
- renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle, autoCenter);
+ // Panoramas are transposed
+ // The actual data is transposed in mutateImage
+ if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+ uint32 temp = imageHeight;
+ imageHeight = imageWidth;
+ imageWidth = temp;
+ }
+
+ renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle, wrap);
delete[] buffer;
} else {
// Reset the cursor
@@ -159,8 +203,19 @@ 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, autoCenter);
+ uint32 imageWidth = tgaSurface->w;
+ uint32 imageHeight = tgaSurface->h;
+
+ // Panoramas are transposed
+ // The actual data is transposed in mutateImage
+ if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+ uint32 temp = imageHeight;
+ imageHeight = imageWidth;
+ imageWidth = temp;
+ }
+
+ renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle, wrap);
tga.destroy();
}
}
@@ -199,7 +254,10 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
}
_currentBackground = file;
- renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(), true);
+ // Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
+ renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
+}
+
void RenderManager::setBackgroundPosition(int offset) {
if (_renderTable.getRenderState() == RenderTable::TILT) {
_backgroundOffset = Common::Point(0, offset);
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 7d44a37..a394586 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -61,7 +61,6 @@ private:
int _backgroundInverseVelocity;
uint _accumulatedVelocityMilliseconds;
- Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
public:
@@ -77,7 +76,7 @@ public:
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
+ void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = 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.
@@ -88,7 +87,7 @@ public:
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
+ void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -99,7 +98,7 @@ public:
void setBackgroundImage(const Common::String &fileName);
void setBackgroundPosition(int offset);
-
+
void setBackgroundVelocity(int velocity);
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
@@ -107,7 +106,9 @@ public:
RenderTable *getRenderTable();
private:
- void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
+ void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap);
+
+ void moveBackground(int offset);
};
} // End of namespace ZVision
Commit: 0fe3ae711a4a2fb20e6fb23664b18cdda8400c9b
https://github.com/scummvm/scummvm/commit/0fe3ae711a4a2fb20e6fb23664b18cdda8400c9b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:23-07:00
Commit Message:
ZVISION: Add cursor and background image resets during location change
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 93564ee..6aaf577 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -28,6 +28,8 @@
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/cursor_manager.h"
#include "zvision/actions.h"
#include "zvision/action_node.h"
#include "zvision/utility.h"
@@ -211,6 +213,15 @@ void ScriptManager::changeLocationIntern() {
_activeControls.clear();
_engine->clearAllMouseEvents();
+ // Revert to the idle cursor
+ _engine->getCursorManager()->revertToIdle();
+
+ // Change the background position
+ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.x);
+
+ // Reset the background velocity
+ _engine->getRenderManager()->setBackgroundVelocity(0);
+
// Parse into puzzles and controls
Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
parseScrFile(fileName);
Commit: 9b8bad3c834ebb4287305d86cdb991f565738814
https://github.com/scummvm/scummvm/commit/9b8bad3c834ebb4287305d86cdb991f565738814
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T09:20:23-07:00
Commit Message:
ZVISION: Add _renderManager::update() to ZEngene::run()
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f7e0ab8..2090d8a 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -116,9 +116,8 @@ void ZVision::initialize() {
initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
- _scriptManager->initialize();
- // Has to be done after graphics has been initialized
_cursorManager->initialize();
+ _scriptManager->initialize();
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
@@ -131,10 +130,12 @@ Common::Error ZVision::run() {
while (!shouldQuit()) {
_clock.update();
uint32 currentTime = _clock.getLastMeasuredTime();
-
+ uint32 deltaTime = _clock.getDeltaTime();
+
processEvents();
- _scriptManager->update(_clock.getDeltaTime());
+ _scriptManager->update(deltaTime);
+ _renderManager->update(deltaTime);
// Update the screen
_system->updateScreen();
Commit: 4e827b4dda458813dce650545b6f9fb923c514f4
https://github.com/scummvm/scummvm/commit/4e827b4dda458813dce650545b6f9fb923c514f4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T10:04:13-07:00
Commit Message:
ZVISION: Add documentation
Changed paths:
engines/zvision/cursor.h
engines/zvision/cursor_manager.h
engines/zvision/mouse_event.h
engines/zvision/render_manager.h
engines/zvision/zvision.h
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 77093c4..9a561fc 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -33,6 +33,10 @@ class String;
namespace ZVision {
+/**
+ * Utility class to parse and hold cursor data
+ * Modeled off Graphics::Cursor
+ */
class ZorkCursor {
public:
ZorkCursor();
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index fd61ac2..1c09620 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -64,20 +64,48 @@ private:
static const char *_zNemCursorFileNames[];
public:
+ /** Creates the idle cursor and shows it */
void initialize();
+ /**
+ * Parses a cursor name into a cursor file then creates and shows that cursor.
+ * It will use the current _isCursorPushed state to choose the correct cursor
+ *
+ * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
+ */
void changeCursor(const Common::String &cursorName);
+ /**
+ * Parses a cursor name into a cursor file then creates and shows that cursor.
+ *
+ * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
+ * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up)
+ */
void changeCursor(const Common::String &cursorName, bool pushed);
+ /**
+ * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen.
+ *
+ * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up)
+ */
void cursorDown(bool pushed);
+ /** Set the cursor to 'Left Arrow'. It will retain the current _isCursorPushed state */
void setLeftCursor();
+ /** Set the cursor to 'Right Arrow'. It will retain the current _isCursorPushed state */
void setRightCursor();
+ /** Set the cursor to 'Up Arrow'. It will retain the current _isCursorPushed state */
void setUpCursor();
+ /** Set the cursor to 'Down Arrow'. It will retain the current _isCursorPushed state */
void setDownCursor();
+ /** Set the cursor to 'Idle'. It will retain the current _isCursorPushed state */
void revertToIdle();
private:
+ /**
+ * Calls CursorMan.replaceCursor() using the data in cursor
+ *
+ * @param cursor The cursor to show
+ */
void changeCursor(const ZorkCursor &cursor);
};
diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h
index 1fbd160..5537bcc 100644
--- a/engines/zvision/mouse_event.h
+++ b/engines/zvision/mouse_event.h
@@ -48,8 +48,24 @@ private:
Common::String _hoverCursor;
public:
+ /**
+ * Does a simple Rect::contains() using _hotspot
+ *
+ * @param point The point to check against _hotspot
+ * @return The point is inside _hotspot (true) or not (false)
+ */
bool withinHotspot(const Common::Point &point);
+ /**
+ * Calls ScriptManager::setStateValue(_key, 1)
+ *
+ * @param engine The base engine
+ */
void onClick(ZVision *engine);
+ /**
+ * Gets the name of the cursor that should be displayed when withinHotspot returns true
+ *
+ * @return The name of the cursor. This should correspond to one of the names in CursorManager::_cursorNames[]
+ */
const Common::String getHoverCursor() { return _hoverCursor; }
};
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index a394586..073a2f6 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -48,23 +48,45 @@ public:
private:
OSystem *_system;
+
+ /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
+ /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
const int _workingHeight;
+ /**
+ * A Rectangle centered inside the actual window. All in-game coordinates
+ * are given in this coordinate space. Also, all images are clipped to the
+ * edges of this Rectangle
+ */
const Common::Rect _workingWindow;
+ /** Used to warp the background image */
RenderTable _renderTable;
Common::SeekableReadStream *_currentBackground;
+ /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
Common::Point _backgroundOffset;
+ /** The width of the current background image */
uint16 _backgroundWidth;
+ /** The height of the current background image */
uint16 _backgroundHeight;
+ /**
+ * The "velocity" at which the background image is panning. We actually store the inverse of velocity (ms/pixel instead of pixels/ms)
+ * because it allows you to accumulate whole pixels 'steps' instead of rounding pixels every frame
+ */
int _backgroundInverseVelocity;
+ /** Holds any 'leftover' milliseconds between frames */
uint _accumulatedVelocityMilliseconds;
byte *_scaledVideoFrameBuffer;
public:
void initialize();
+ /**
+ * Rotates the background image in accordance to the current _backgroundInverseVelocity
+ *
+ * @param deltaTimeInMillis The amount of time that has passed since the last frame
+ */
void update(uint deltaTimeInMillis);
/**
@@ -97,15 +119,50 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
+ /**
+ * Set the background position (_backgroundOffset). If the current RenderState is PANORAMA, the offset
+ * will be in the horizontal direction. If the current RenderState is TILT, the offset will be in the
+ * vertical direction.
+ *
+ * This method will not render anything on the screen. So if nothing else is called that renders the
+ * background, the change won't be seen until next frame.
+ *
+ * @param offset The amount to offset the background
+ */
void setBackgroundPosition(int offset);
+ /**
+ * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and
+ * positive velocities correspond to right / down scrolling
+ *
+ * @param velocity Velocity
+ */
void setBackgroundVelocity(int velocity);
+ /**
+ * Converts a point in screen coordinate space to image coordinate space
+ *
+ * @param point Point in screen coordinate space
+ * @return Point in image coordinate space
+ */
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
RenderTable *getRenderTable();
private:
+ /**
+ * Renders a subRectangle of an image to the screen. The destinationRect and SubRect
+ * will be clipped to image bound and to working window bounds
+ *
+ * @param buffer Pointer to (0, 0) of the image data
+ * @param imageWidth The width of the original image (not of the subRectangle)
+ * @param imageHeight The width of the original image (not of the subRectangle)
+ * @param horizontalPitch The horizontal pitch of the original image
+ * @param destinationX The x coordinate (in working window space) of where to put the final image
+ * @param destinationY The y coordinate (in working window space) of where to put the final image
+ * @param subRectangle A rectangle representing the part of the image that should be rendered
+ * @param wrap Should the image wrap (tile) if it doesn't completely fill the screen?
+ */
void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap);
void moveBackground(int offset);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index ca71080..58812d4 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -76,6 +76,11 @@ private:
Console *_console;
const ZVisionGameDescription *_gameDescription;
+ /**
+ * A Rectangle centered inside the actual window. All in-game coordinates
+ * are given in this coordinate space. Also, all images are clipped to the
+ * edges of this Rectangle
+ */
const Common::Rect _workingWindow;
const Graphics::PixelFormat _pixelFormat;
@@ -110,17 +115,40 @@ public:
Common::RandomSource *getRandomSource() const;
ZVisionGameId getGameId() const;
+ /**
+ * Play a video until it is finished. This is a blocking call. It will call
+ * _clock.stop() when the video starts and _clock.start() when the video finishes.
+ * It will also consume all events during video playback.
+ *
+ * @param videoDecoder The video to play
+ * @param destRect Where to put the video. (In working window coords)
+ * @param skippable If true, the video can be skipped at any time using [Spacebar]
+ */
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
+ /**
+ * Register a MouseEvent with the event system. These will be checked at every
+ * MOUSE_UP, MOUSE_DOWN, MOUSE_MOVE, etc.
+ *
+ * @param event The event to register
+ */
void registerMouseEvent(const MouseEvent &event);
+ /** Remove all MouseEvents from the event system */
void clearAllMouseEvents();
+ /**
+ * Utility method to cycle through all the cursors in the game. After
+ * calling, use Left and Right arrows to cycle. Esc to quit. This is a
+ * blocking function call.
+ */
void cycleThroughCursors();
private:
void initialize();
+ /** Called every frame from ZVision::run() to process any events from EventMan */
void processEvents();
+
void onMouseDown(const Common::Point &pos);
void onMouseUp(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
Commit: 435419cfe91eefa3a709af91f2ab172c3cbde022
https://github.com/scummvm/scummvm/commit/435419cfe91eefa3a709af91f2ab172c3cbde022
Author: richiesams (adastley at gmail.com)
Date: 2013-08-14T10:12:34-07:00
Commit Message:
ZVISION: Modify ASCII velocity drawing to represent the actual code
Velocity outside the working window is zero
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 68fa81e..ca96f52 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -121,37 +121,34 @@ void ZVision::onMouseMove(const Common::Point &pos) {
// Graph of the function governing rotation velocity:
//
- // |--------------- working window -----------------|
- // ^ |--------|
+ // |---------------- working window ------------------|
+ // ^ |---------|
// | |
- // +Max velocity | rotation screen edge offset _____________________
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // Zero velocity |______________________________ ______________________________/____________________________________>
- // | Position -> /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // | /
- // -Max velocity |_____________________/
+ // +Max velocity | rotation screen edge offset
+ // | /|
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // Zero velocity |______________________________ ______________________________/_________|__________________________>
+ // | Position -> | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // -Max velocity | |/
// |
// |
// ^
- // NOTE: RenderManger uses the inverse of velocity (ms/pixel instead of pixels/ms) because it allows you to accumulate whole
- // pixels 'steps' instead of rounding pixels every frame
-
if (_workingWindow.contains(pos)) {
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
Commit: 95d1ef68ab55920fb45923c974499529268fad67
https://github.com/scummvm/scummvm/commit/95d1ef68ab55920fb45923c974499529268fad67
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T12:14:02-07:00
Commit Message:
Merge branch 'master' into zvision
Changed paths:
A engines/zvision/action_node.cpp
A engines/zvision/action_node.h
A engines/zvision/actions.cpp
A engines/zvision/actions.h
A engines/zvision/clock.cpp
A engines/zvision/clock.h
A engines/zvision/console.cpp
A engines/zvision/console.h
A engines/zvision/control.cpp
A engines/zvision/control.h
A engines/zvision/cursor.cpp
A engines/zvision/cursor.h
A engines/zvision/cursor_manager.cpp
A engines/zvision/cursor_manager.h
A engines/zvision/detection.cpp
A engines/zvision/detection.h
A engines/zvision/events.cpp
A engines/zvision/lzss_read_stream.cpp
A engines/zvision/lzss_read_stream.h
A engines/zvision/module.mk
A engines/zvision/mouse_event.cpp
A engines/zvision/mouse_event.h
A engines/zvision/puzzle.h
A engines/zvision/render_manager.cpp
A engines/zvision/render_manager.h
A engines/zvision/render_table.cpp
A engines/zvision/render_table.h
A engines/zvision/scr_file_handling.cpp
A engines/zvision/script_manager.cpp
A engines/zvision/script_manager.h
A engines/zvision/scripts.cpp
A engines/zvision/single_value_container.cpp
A engines/zvision/single_value_container.h
A engines/zvision/tests.h
A engines/zvision/utility.cpp
A engines/zvision/utility.h
A engines/zvision/vector2.h
A engines/zvision/video.cpp
A engines/zvision/zfs_archive.cpp
A engines/zvision/zfs_archive.h
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
video/codecs/truemotion1.h
Commit: c0305d9534763d69223cb6a5ea20d20101236401
https://github.com/scummvm/scummvm/commit/c0305d9534763d69223cb6a5ea20d20101236401
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T12:15:30-07:00
Commit Message:
ZVISION: Rename variables and add comments to clarify the math behind panorama warping
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index aab4735..3bd0103 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -149,26 +149,32 @@ void RenderTable::generatePanoramaLookupTable() {
float halfWidth = (float)_numColumns / 2.0f;
float halfHeight = (float)_numRows / 2.0f;
- float fovRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
- float halfHeightOverTan = halfHeight / tan(fovRadians);
- float tanOverHalfHeight = tan(fovRadians) / halfHeight;
+ float fovInRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
+ float cylinderRadius = halfHeight / tan(fovInRadians);
// 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 (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));
+ // Alpha represents the horizontal angle between the viewer at the center of a cylinder and x
+ float alpha = atan(((float)x - halfWidth + 0.01f) / cylinderRadius);
- int32 newX = int32(floor((halfHeightOverTan * _panoramaOptions.linearScale * temp) + halfWidth));
- float cosX = cos(temp);
+ // To get x in cylinder coordinates, we just need to calculate the arc length
+ // We also scale it by _panoramaOptions.linearScale
+ int32 xInCylinderCoords = int32(floor((cylinderRadius * _panoramaOptions.linearScale * alpha) + halfWidth));
+
+
+ float cosAlpha = cos(alpha);
for (uint y = 0; y < _numRows; y++) {
- int32 newY = int32(floor(halfHeight + ((float)y - halfHeight) * cosX));
+ // To calculate y in cylinder coordinates, we can do similar triangles comparison,
+ // comparing the triangle from the center to the screen and from the center to the edge of the cylinder
+ int32 yInCylinderCoords = int32(floor(halfHeight + ((float)y - halfHeight) * cosAlpha));
uint32 index = y * _numColumns + x;
- // Only store the x,y offsets instead of the absolute positions
- _internalBuffer[index].x = newX - x;
- _internalBuffer[index].y = newY - y;
+ // Only store the (x,y) offsets instead of the absolute positions
+ _internalBuffer[index].x = xInCylinderCoords - x;
+ _internalBuffer[index].y = yInCylinderCoords - y;
}
}
}
Commit: 08a8ab885bf6a2eea1f0eb9d7526cdbe240561e6
https://github.com/scummvm/scummvm/commit/08a8ab885bf6a2eea1f0eb9d7526cdbe240561e6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T12:15:48-07:00
Commit Message:
ZVISION: Apply panorama/tilt warping after all images have been rendered to a backbuffer
This makes wrapped warping much easier as well as allowing changeLocation offsets to
work properly
Changed paths:
engines/zvision/console.cpp
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/render_table.cpp
engines/zvision/render_table.h
engines/zvision/zvision.cpp
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index f1b192f..6c7ac94 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -57,9 +57,9 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
bool Console::cmdLoadImage(int argc, const char **argv) {
if (argc == 4)
- _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+ _engine->getRenderManager()->renderImageToBackbuffer(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])));
+ _engine->getRenderManager()->renderImageToBackbuffer(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;
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 78fcf59..05536f3 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -34,23 +34,28 @@
namespace ZVision {
-RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow)
- : _system(system),
- _workingWidth(workingWindow.width()),
- _workingHeight(workingWindow.height()),
- _workingWindow(workingWindow),
- _currentBackground(0),
- _backgroundWidth(0),
- _backgroundHeight(0),
- _backgroundInverseVelocity(0),
- _accumulatedVelocityMilliseconds(0),
- _renderTable(workingWindow.width(), workingWindow.height()) {
+RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
+ : _system(system),
+ _workingWidth(workingWindow.width()),
+ _workingHeight(workingWindow.height()),
+ _workingWindow(workingWindow),
+ _pixelFormat(pixelFormat),
+ _currentBackground(0),
+ _backgroundWidth(0),
+ _backgroundHeight(0),
+ _backgroundInverseVelocity(0),
+ _accumulatedVelocityMilliseconds(0),
+ _renderTable(workingWindow.width(), workingWindow.height()) {
+ _backbuffer.create(_workingWidth, _workingHeight, pixelFormat);
+ _warpedBackbuffer = new uint16[_workingWidth *_workingHeight];
}
RenderManager::~RenderManager() {
if (_currentBackground != 0) {
delete _currentBackground;
}
+
+ _backbuffer.free();
}
void RenderManager::update(uint deltaTimeInMillis) {
@@ -62,7 +67,7 @@ void RenderManager::update(uint deltaTimeInMillis) {
int absVelocity = abs(_backgroundInverseVelocity);
- uint numberOfSteps = 0;
+ int numberOfSteps = 0;
while (_accumulatedVelocityMilliseconds >= absVelocity) {
_accumulatedVelocityMilliseconds -= absVelocity;
numberOfSteps++;
@@ -70,17 +75,23 @@ void RenderManager::update(uint deltaTimeInMillis) {
// Choose the direction of movement using the sign of the velocity
moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
+
+ // Warp the entire backbuffer
+ _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
+
+ // Blit the backbuffer to the screen
+ _system->copyRectToScreen(_backbuffer.getBasePtr(0, 0), _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
}
-void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed) {
if (wrap) {
- _backgroundWidth = imageWidth;
- _backgroundHeight = imageHeight;
+ _backgroundWidth = surface.w;
+ _backgroundHeight = surface.h;
}
// If subRect is empty, use the entire image
if (subRectangle.isEmpty())
- subRectangle = Common::Rect(subRectangle.left, subRectangle.top, subRectangle.left + imageWidth, subRectangle.top + imageHeight);
+ subRectangle = Common::Rect(subRectangle.left, subRectangle.top, subRectangle.left + surface.w, subRectangle.top + surface.h);
// Clip destRect to working window bounds
Common::Rect destRect(destinationX, destinationY, destinationX + subRectangle.width(), destinationY + subRectangle.height());
@@ -91,7 +102,7 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
subRectangle.setHeight(destRect.height());
// Clip to image bounds
Common::Point subRectOrigOrigin(subRectangle.left, subRectangle.top);
- subRectangle.clip(imageWidth, imageHeight);
+ subRectangle.clip(surface.w, surface.h);
// If the image is to be wrapped, check if it's smaller than destRect
// If it is, then call renderSubRectToScreen with a subRect representing wrapping
@@ -110,7 +121,7 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
wrapSubRect = Common::Rect(_backgroundWidth - subRectangle.width(), 0, _backgroundWidth - 1, subRectangle.bottom);
}
- renderSubRectToScreen(buffer, imageWidth, imageHeight, horizontalPitch, wrapDestX, wrapDestY, wrapSubRect, false);
+ renderSubRectToBackbuffer(surface, wrapDestX, wrapDestY, wrapSubRect, false, isTransposed);
} else if (wrap && subRectangle.height() < destRect.height()) {
uint32 wrapDestX;
uint32 wrapDestY;
@@ -126,32 +137,38 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
wrapSubRect = Common::Rect(0, _backgroundHeight - subRectangle.height(), subRectangle.right, _backgroundHeight - 1);
}
- renderSubRectToScreen(buffer, imageWidth, imageHeight, horizontalPitch, wrapDestX, wrapDestY, wrapSubRect, false);
+ renderSubRectToBackbuffer(surface, wrapDestX, wrapDestY, wrapSubRect, false, isTransposed);
+ } else {
+ // Clip destRect to image bounds
+ destRect.translate(subRectangle.left - subRectOrigOrigin.x, subRectangle.top - subRectOrigOrigin.y);
+ destRect.setWidth(subRectangle.width());
+ destRect.setHeight(subRectangle.height());
}
- // Clip destRect to image bounds
- destRect.translate(subRectangle.left - subRectOrigOrigin.x, subRectangle.top - subRectOrigOrigin.y);
- destRect.setWidth(subRectangle.width());
- destRect.setHeight(subRectangle.height());
-
// Check all Rects for validity
if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
return;
- if (_renderTable.getRenderState() == RenderTable::FLAT) {
- // Convert destRect to screen space by adding _workingWindowOffset
- _system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height());
+ if (isTransposed) {
+ copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(subRectangle.left, subRectangle.right), surface.w, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
- uint16 *destBuffer = new uint16[destRect.width() * destRect.height()];
- _renderTable.mutateImage((uint16 *)buffer, destBuffer, imageWidth, imageHeight, subRectangle, destRect);
+ _backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.right), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
+ }
+}
- // Convert destRect to screen space by adding _workingWindow offset
- _system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height());
- delete[] destBuffer;
+void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageHeight, int x, int y, int width, int height) {
+ uint16 *dest = (uint16 *)_backbuffer.getBasePtr(x, y);
+
+ for (int x = 0; x < width; x++) {
+ int columnOffset = x * imageHeight;
+ for (int y = 0; y < height; y++) {
+ *dest = buffer[columnOffset + y];
+ dest++;
+ }
}
}
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+void RenderManager::renderImageToBackbuffer(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
Common::File file;
if (!file.open(fileName)) {
@@ -159,10 +176,10 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
return;
}
- renderImageToScreen(file, destinationX, destinationY, subRectangle);
+ renderImageToBackbuffer(file, destinationX, destinationY, subRectangle);
}
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+void RenderManager::renderImageToBackbuffer(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
uint32 fileType;
@@ -179,17 +196,21 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
byte *buffer = new byte[decompressedSize];
lzssStream.read(buffer, decompressedSize);
- uint32 horizontalPitch = imageWidth * sizeof(uint16);
+ uint32 pitch = imageWidth * sizeof(uint16);
+ bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
- // Panoramas are transposed
- // The actual data is transposed in mutateImage
- if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
- uint32 temp = imageHeight;
+ if (isTransposed) {
+ uint16 temp = imageHeight;
imageHeight = imageWidth;
imageWidth = temp;
}
- renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle, wrap);
+ Graphics::Surface surface;
+ surface.init(imageWidth, imageHeight, pitch, buffer, _pixelFormat);
+
+ renderSubRectToBackbuffer(surface, destinationX, destinationY, subRectangle, wrap, isTransposed);
+
+ // We have to use delete[] instead of calling surface.free() because we created the memory with new[]
delete[] buffer;
} else {
// Reset the cursor
@@ -202,20 +223,16 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
return;
}
- const Graphics::Surface *tgaSurface = tga.getSurface();
+ Graphics::Surface tgaSurface = *(tga.getSurface());
+ bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
- uint32 imageWidth = tgaSurface->w;
- uint32 imageHeight = tgaSurface->h;
-
- // Panoramas are transposed
- // The actual data is transposed in mutateImage
- if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
- uint32 temp = imageHeight;
- imageHeight = imageWidth;
- imageWidth = temp;
+ if (isTransposed) {
+ uint16 temp = tgaSurface.h;
+ tgaSurface.h = tgaSurface.w;
+ tgaSurface.w = temp;
}
- renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle, wrap);
+ renderSubRectToBackbuffer(tgaSurface, destinationX, destinationY, subRectangle, wrap, isTransposed);
tga.destroy();
}
}
@@ -255,7 +272,7 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
_currentBackground = file;
// Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
- renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
+ renderImageToBackbuffer(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
}
void RenderManager::setBackgroundPosition(int offset) {
@@ -297,7 +314,7 @@ void RenderManager::moveBackground(int offset) {
_currentBackground->seek(0);
// Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
- renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
+ renderImageToBackbuffer(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 073a2f6..d5bf61f 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -26,6 +26,8 @@
#include "common/types.h"
#include "common/rect.h"
+#include "graphics/surface.h"
+
#include "zvision/render_table.h"
class OSystem;
@@ -43,11 +45,15 @@ namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system, const Common::Rect workingWindow);
+ RenderManager(OSystem *system, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
~RenderManager();
private:
OSystem *_system;
+ const Graphics::PixelFormat _pixelFormat;
+
+ Graphics::Surface _backbuffer;
+ uint16 *_warpedBackbuffer;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
@@ -90,7 +96,7 @@ public:
void update(uint deltaTimeInMillis);
/**
- * Blits the image or a portion of 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 backbuffer. Actual screen updates won't happen until the end of the frame.
* The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
* @param fileName Name of the image file
@@ -98,10 +104,10 @@ public:
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
+ void renderImageToBackbuffer(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = 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.
+ * Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
* The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
* @param stream Stream to read the image data from
@@ -109,7 +115,7 @@ public:
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
+ void renderImageToBackbuffer(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -151,7 +157,7 @@ public:
private:
/**
- * Renders a subRectangle of an image to the screen. The destinationRect and SubRect
+ * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect
* will be clipped to image bound and to working window bounds
*
* @param buffer Pointer to (0, 0) of the image data
@@ -163,7 +169,9 @@ private:
* @param subRectangle A rectangle representing the part of the image that should be rendered
* @param wrap Should the image wrap (tile) if it doesn't completely fill the screen?
*/
- void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap);
+ void renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed);
+
+ void copyTransposedRectToBackbuffer(const uint16 *buffer, int imageHeight, int x, int y, int width, int height);
void moveBackground(int offset);
};
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 3bd0103..a28f82b 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -98,16 +98,10 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
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;
-
- for (int y = subRectangle.top; y < subRectangle.bottom; y++) {
- uint normalizedY = y - subRectangle.top;
-
- for (int x = subRectangle.left; x < subRectangle.right; x++) {
- uint normalizedX = x - subRectangle.left;
-
- uint32 index = (normalizedY + destRectangle.top) * _numColumns + (normalizedX + destRectangle.left);
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight) {
+ for (uint32 y = 0; y < imageHeight; y++) {
+ for (uint32 x = 0; x < imageWidth; x++) {
+ uint32 index = y * _numColumns + x;
// RenderTable only stores offsets from the original coordinates
uint32 sourceYIndex = y + _internalBuffer[index].y;
@@ -119,12 +113,7 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 i
// 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];
- }
+ destBuffer[index] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
}
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index c38b5a6..7c04564 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight);
void generateRenderTable();
void setPanoramaFoV(float fov);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 2090d8a..ff234bf 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -68,7 +68,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, _workingWindow);
+ _renderManager = new RenderManager(_system, _workingWindow, _pixelFormat);
_cursorManager = new CursorManager(this, &_pixelFormat);
debug("ZVision::ZVision");
Commit: 999de6d400be8374a6834a81bb8b8f4da4a1756c
https://github.com/scummvm/scummvm/commit/999de6d400be8374a6834a81bb8b8f4da4a1756c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T12:15:58-07:00
Commit Message:
ZVISION: Convert Surface::pixels to Surface::getBasePtr(0, 0)
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 5497d0a..28c26f6 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -148,10 +148,10 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
if (frame) {
if (scale != 1) {
- scaleBuffer((byte *)frame->pixels, scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
+ scaleBuffer((byte *)frame->getBasePtr(0, 0), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
- _system->copyRectToScreen((byte *)frame->pixels, pitch, x, y, finalWidth, finalHeight);
+ _system->copyRectToScreen((byte *)frame->getBasePtr(0, 0), pitch, x, y, finalWidth, finalHeight);
}
_system->updateScreen();
Commit: 7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c
https://github.com/scummvm/scummvm/commit/7e8e9bf3d1e718758298b8fb5ccc6a0f296d5b9c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T12:31:21-07:00
Commit Message:
GRAPHICS: Create copyRectToSurface member function
Changed paths:
graphics/surface.cpp
graphics/surface.h
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 9291572..d808121 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -133,6 +133,24 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
+void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height) {
+ assert(buffer);
+
+ assert(x >= 0 && x < w);
+ assert(y >= 0 && y < h);
+ assert(height > 0 && y + height <= h);
+ assert(width > 0 && x + width <= w);
+
+ // Copy buffer data to internal buffer
+ const byte *src = (const byte *)buffer;
+ byte *dst = (byte *)getBasePtr(x, y);
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width * format.bytesPerPixel);
+ src += pitch;
+ dst += this->pitch;
+ }
+}
+
void Surface::hLine(int x, int y, int x2, uint32 color) {
// Clipping
if (y < 0 || y >= h)
diff --git a/graphics/surface.h b/graphics/surface.h
index b08d4a5..ad52ed8 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -209,6 +209,19 @@ public:
const Surface getSubArea(const Common::Rect &area) const;
/**
+ * Copies a bitmap to the Surface internal buffer. The pixel format
+ * of buffer must match the pixel format of the Surface.
+ *
+ * @param buffer The buffer containing the graphics data source
+ * @param pitch The pitch of the buffer (number of bytes in a scanline)
+ * @param x The x coordinate of the destination rectangle
+ * @param y The y coordinate of the destination rectangle
+ * @param width The width of the destination rectangle
+ * @param height The height of the destination rectangle
+ */
+ void copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height);
+
+ /**
* Convert the data to another pixel format.
*
* This works in-place. This means it will not create an additional buffer
Commit: 62043e949d396e0d86515d963fa32b792ab9ec01
https://github.com/scummvm/scummvm/commit/62043e949d396e0d86515d963fa32b792ab9ec01
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-08-15T13:09:30-07:00
Commit Message:
VIDEO: Add an over-ridable wrapper for the AVI audio track handler
Reimplementation of 7a49802c01b0c39be4e86335689db8f3359fde68
This is based on a suggestion made by clone2727, so the original
idea belongs to him.
Engines can now override the common AVI audio track handler with a
custom one. This is needed for the Z-Engine AVI videos, since they
use a custom audio decoder that is only used in the two Z-Engine
games, and has its own fake AVI audio format (17). This clashes with
the MS IMA ADPCM format, and therefore shouldn't pollute the common
AVI video decoder code. The addition of this over-ridable method
allows the Z-Engine to add its own custom AVI decoder while avoiding
code duplication.
Changed paths:
video/avi_decoder.cpp
video/avi_decoder.h
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 92a60fc..ff41099 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -93,6 +93,10 @@ AVIDecoder::~AVIDecoder() {
close();
}
+AVIDecoder::AVIAudioTrack *AVIDecoder::createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo) {
+ return new AVIAudioTrack(sHeader, wvInfo, _soundType);
+}
+
void AVIDecoder::initCommon() {
_decodedHeader = false;
_foundMovieList = false;
@@ -268,7 +272,7 @@ void AVIDecoder::handleStreamHeader(uint32 size) {
if (wvInfo.channels == 2)
sHeader.sampleSize /= 2;
- addTrack(new AVIAudioTrack(sHeader, wvInfo, _soundType));
+ addTrack(createAudioTrack(sHeader, wvInfo));
}
// Ensure that we're at the end of the chunk
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 5d52c7c..f7259bf 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -69,7 +69,6 @@ public:
protected:
void readNextPacket();
-private:
struct BitmapInfoHeader {
uint32 size;
uint32 width;
@@ -192,13 +191,12 @@ private:
AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType);
~AVIAudioTrack();
- void queueSound(Common::SeekableReadStream *stream);
+ virtual void queueSound(Common::SeekableReadStream *stream);
Audio::Mixer::SoundType getSoundType() const { return _soundType; }
protected:
Audio::AudioStream *getAudioStream() const;
- private:
// Audio Codecs
enum {
kWaveFormatNone = 0,
@@ -233,6 +231,9 @@ private:
void handleStreamHeader(uint32 size);
uint16 getStreamType(uint32 tag) const { return tag & 0xFFFF; }
byte getStreamIndex(uint32 tag) const;
+
+public:
+ virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo);
};
} // End of namespace Video
Commit: c2366dc99e7028fdf94ec7d020016e674bf33100
https://github.com/scummvm/scummvm/commit/c2366dc99e7028fdf94ec7d020016e674bf33100
Author: richiesams (adastley at gmail.com)
Date: 2013-08-15T13:11:24-07:00
Commit Message:
ZVISION: Fix error using subRectangle.right instead of .top
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 05536f3..a2ae7e8 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -152,7 +152,7 @@ void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32
if (isTransposed) {
copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(subRectangle.left, subRectangle.right), surface.w, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
- _backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.right), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
+ _backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.top), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
}
}
Commit: bdd9b18292105b2cd8d894d2e042accecd001913
https://github.com/scummvm/scummvm/commit/bdd9b18292105b2cd8d894d2e042accecd001913
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T08:43:12-07:00
Commit Message:
ZVISION: Disable videos until I can figure out how to fix the decoder
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 5b8af48..ff7df20 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -251,7 +251,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:streamvideo*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
+ //actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
} else if (line.matchString("*:syncsound*", true)) {
Commit: e6aa2d15ca75788065012ea64e881277ef4e5565
https://github.com/scummvm/scummvm/commit/e6aa2d15ca75788065012ea64e881277ef4e5565
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T08:44:35-07:00
Commit Message:
ZVISION: Only skip the background moving if velocity is 0 instead of returning and skipping everything
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index a2ae7e8..31b54b4 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -60,22 +60,21 @@ RenderManager::~RenderManager() {
void RenderManager::update(uint deltaTimeInMillis) {
// An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
- if (_backgroundInverseVelocity == 0)
- return;
+ if (_backgroundInverseVelocity != 0) {
+ _accumulatedVelocityMilliseconds += deltaTimeInMillis;
- _accumulatedVelocityMilliseconds += deltaTimeInMillis;
+ int absVelocity = abs(_backgroundInverseVelocity);
- int absVelocity = abs(_backgroundInverseVelocity);
+ int numberOfSteps = 0;
+ while (_accumulatedVelocityMilliseconds >= absVelocity) {
+ _accumulatedVelocityMilliseconds -= absVelocity;
+ numberOfSteps++;
+ }
- int numberOfSteps = 0;
- while (_accumulatedVelocityMilliseconds >= absVelocity) {
- _accumulatedVelocityMilliseconds -= absVelocity;
- numberOfSteps++;
+ // Choose the direction of movement using the sign of the velocity
+ moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
}
- // Choose the direction of movement using the sign of the velocity
- moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
-
// Warp the entire backbuffer
_renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
Commit: 26159e6ea52cab35eeba425c066e2faaa0540c2f
https://github.com/scummvm/scummvm/commit/26159e6ea52cab35eeba425c066e2faaa0540c2f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T08:44:56-07:00
Commit Message:
ZVISION: Only warp the backbuffer if we're in PANORAMA or TILT
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 31b54b4..5bc7095 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -76,7 +76,10 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
// Warp the entire backbuffer
- _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
+ //RenderTable::RenderState state = _renderTable.getRenderState();
+ //if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ // _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
+ //}
// Blit the backbuffer to the screen
_system->copyRectToScreen(_backbuffer.getBasePtr(0, 0), _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
Commit: af0a58ecda26f12c630db759667d7adc79e733d6
https://github.com/scummvm/scummvm/commit/af0a58ecda26f12c630db759667d7adc79e733d6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T08:45:31-07:00
Commit Message:
ZVISION: Fix copyTransposedRectToBackBuffer
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 5bc7095..bfafd7f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -152,21 +152,23 @@ void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32
return;
if (isTransposed) {
- copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(subRectangle.left, subRectangle.right), surface.w, destRect.left, destRect.top, destRect.width(), destRect.height());
+ copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(subRectangle.left, subRectangle.top), surface.h, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
_backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.top), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
}
}
-void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageHeight, int x, int y, int width, int height) {
+void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int x, int y, int width, int height) {
uint16 *dest = (uint16 *)_backbuffer.getBasePtr(x, y);
- for (int x = 0; x < width; x++) {
- int columnOffset = x * imageHeight;
- for (int y = 0; y < height; y++) {
- *dest = buffer[columnOffset + y];
+ for (int i = 0; i < width; i++) {
+ int columnOffset = i * imageWidth;
+ for (int j = 0; j < height; j++) {
+ *dest = buffer[columnOffset + j];
dest++;
}
+
+ dest += _backbuffer.w;
}
}
Commit: e0937a12cd47201a6dce6822e20657b2df5785af
https://github.com/scummvm/scummvm/commit/e0937a12cd47201a6dce6822e20657b2df5785af
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T10:17:29-07:00
Commit Message:
ZVISION: Move _cursorManager construction after the folder directories have been registered with SearchMan
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index ff234bf..080c763 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -69,7 +69,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
_renderManager = new RenderManager(_system, _workingWindow, _pixelFormat);
- _cursorManager = new CursorManager(this, &_pixelFormat);
debug("ZVision::ZVision");
}
@@ -116,6 +115,8 @@ void ZVision::initialize() {
initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
+ // CursorManager must be created after all the directories have been added
+ _cursorManager = new CursorManager(this, &_pixelFormat);
_cursorManager->initialize();
_scriptManager->initialize();
Commit: 1c6ffd133acdddb8d08249d3a49caf523fd1d01e
https://github.com/scummvm/scummvm/commit/1c6ffd133acdddb8d08249d3a49caf523fd1d01e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T10:18:19-07:00
Commit Message:
ZVISION: Clean up backbuffer memory after we're finished with it
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index bfafd7f..d8b8ce1 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -56,6 +56,7 @@ RenderManager::~RenderManager() {
}
_backbuffer.free();
+ delete[] _warpedBackbuffer;
}
void RenderManager::update(uint deltaTimeInMillis) {
Commit: a3c39f48767b06a8015269e48ca929fbc5bfa637
https://github.com/scummvm/scummvm/commit/a3c39f48767b06a8015269e48ca929fbc5bfa637
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T10:19:00-07:00
Commit Message:
ZVISION: Fix memory corruption in copyTransposedRectToBackBuffer
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 d8b8ce1..1f2c3a2 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -77,13 +77,16 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
// Warp the entire backbuffer
- //RenderTable::RenderState state = _renderTable.getRenderState();
- //if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- // _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
- //}
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
+ _system->copyRectToScreen(_warpedBackbuffer, _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
+ } else {
+ _system->copyRectToScreen(_backbuffer.getBasePtr(0, 0), _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
+ }
// Blit the backbuffer to the screen
- _system->copyRectToScreen(_backbuffer.getBasePtr(0, 0), _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
+
}
void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed) {
@@ -153,23 +156,24 @@ void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32
return;
if (isTransposed) {
- copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(subRectangle.left, subRectangle.top), surface.h, destRect.left, destRect.top, destRect.width(), destRect.height());
+ copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(0, 0), surface.h, destRect.left, destRect.top, destRect.width(), destRect.height(), subRectangle);
} else {
_backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.top), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
}
}
-void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int x, int y, int width, int height) {
- uint16 *dest = (uint16 *)_backbuffer.getBasePtr(x, y);
+void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int destinationX, int destinationY, int width, int height, const Common::Rect &subRect) {
+ uint16 *dest = (uint16 *)_backbuffer.getBasePtr(0, 0);
+
+ for (int16 x = subRect.left; x < subRect.right; x++) {
+ int16 normalizedX = x - subRect.left + destinationX;
+ int columnOffset = x * imageWidth;
- for (int i = 0; i < width; i++) {
- int columnOffset = i * imageWidth;
- for (int j = 0; j < height; j++) {
- *dest = buffer[columnOffset + j];
- dest++;
- }
+ for (int16 y = subRect.top; y < subRect.bottom; y++) {
+ int16 normalizeY = y - subRect.top + destinationY;
- dest += _backbuffer.w;
+ dest[normalizeY * _backbuffer.w + normalizedX] = buffer[columnOffset + y];
+ }
}
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index d5bf61f..f59f50d 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -171,7 +171,7 @@ private:
*/
void renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed);
- void copyTransposedRectToBackbuffer(const uint16 *buffer, int imageHeight, int x, int y, int width, int height);
+ void copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int destinationX, int destinationY, int width, int height, const Common::Rect &subRect);
void moveBackground(int offset);
};
Commit: 0a840fa664c210dfb85d6c62d4a80a08ca650843
https://github.com/scummvm/scummvm/commit/0a840fa664c210dfb85d6c62d4a80a08ca650843
Author: richiesams (adastley at gmail.com)
Date: 2013-08-16T15:27:51-07:00
Commit Message:
ZVISION: Rename 'x' variable in changeLocation to 'offset'
Since it can be in either the x or the y direction
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 2316530..504c250 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -83,12 +83,12 @@ bool ActionAttenuate::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
+ sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_offset);
}
bool ActionChangeLocation::execute(ZVision *engine) {
// We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking
- engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _x);
+ engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset);
// Tell the puzzle system to stop checking any more puzzles
return false;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 511f3d9..aa67be2 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -126,7 +126,7 @@ private:
char _room;
char _node;
char _view;
- uint32 _x;
+ uint32 _offset;
};
class ActionCrossfade : public ResultAction {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 6aaf577..5c0e336 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -191,19 +191,19 @@ void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
_activeNodes.push_back(node);
}
-void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 x) {
+void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
_nextLocation.world = world;
_nextLocation.room = room;
_nextLocation.node = node;
_nextLocation.view = view;
- _nextLocation.x = x;
+ _nextLocation.offset = offset;
_changeLocation = true;
}
void ScriptManager::changeLocationIntern() {
assert(_nextLocation.world != 0);
- debug("Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.x);
+ debug("Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
// Clear all the containers
_referenceTable.clear();
@@ -217,7 +217,7 @@ void ScriptManager::changeLocationIntern() {
_engine->getCursorManager()->revertToIdle();
// Change the background position
- _engine->getRenderManager()->setBackgroundPosition(_nextLocation.x);
+ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
// Reset the background velocity
_engine->getRenderManager()->setBackgroundVelocity(0);
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 8e79548..c0801ed 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -44,7 +44,7 @@ struct Location {
char room;
char node;
char view;
- uint32 x;
+ uint32 offset;
};
class ScriptManager {
@@ -86,7 +86,7 @@ public:
void addActionNode(const Common::SharedPtr<ActionNode> &node);
- void changeLocation(char world, char room, char node, char view, uint32 x);
+ void changeLocation(char world, char room, char node, char view, uint32 offset);
private:
void createReferenceTable();
Commit: 7d24f46e7e2c7d6322b2842d349986dc484eb063
https://github.com/scummvm/scummvm/commit/7d24f46e7e2c7d6322b2842d349986dc484eb063
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:42-07:00
Commit Message:
ZVISION: Modify cmdLoadSound to allow manual rate and isStereo
Usually those variables are parsed from the file name
Changed paths:
engines/zvision/console.cpp
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 6c7ac94..e7c46b9 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -83,19 +83,29 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
}
bool Console::cmdLoadSound(int argc, const char **argv) {
- if (argc != 2) {
- DebugPrintf("Use loadsound <fileName> to load a sound\n");
- return true;
- }
-
if (!Common::File::exists(argv[1])) {
DebugPrintf("File does not exist\n");
return true;
}
- Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine);
- Audio::SoundHandle handle;
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
+ if (argc == 2) {
+ Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine);
+ Audio::SoundHandle handle;
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
+
+ } else if (argc == 4) {
+ int isStereo = atoi(argv[3]);
+
+ Common::File *file = new Common::File();
+ file->open(argv[1]);
+
+ Audio::AudioStream *soundStream = makeRawZorkStream(file, atoi(argv[2]), isStereo == 0 ? false : true);
+ Audio::SoundHandle handle;
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
+ } else {
+ DebugPrintf("Use loadsound <fileName> [<rate> <isStereo: 1 or 0>] to load a sound\n");
+ return true;
+ }
return true;
}
Commit: e769164f791d19b69cbe7cb0be99fc474c562ed4
https://github.com/scummvm/scummvm/commit/e769164f791d19b69cbe7cb0be99fc474c562ed4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:53-07:00
Commit Message:
ZVISION: Render images by specifying a destination and then clipping
Instead of specifying a subRect. This also reverts the code that rendered to a
backbuffer and then did a full backbuffer warp. Wrapping is done in the RenderTable
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
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 1f2c3a2..e410610 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -38,16 +38,19 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
: _system(system),
_workingWidth(workingWindow.width()),
_workingHeight(workingWindow.height()),
+ _screenCenterX((workingWindow.left + workingWindow.right) /2),
+ _screenCenterY((workingWindow.top + workingWindow.bottom) /2),
_workingWindow(workingWindow),
_pixelFormat(pixelFormat),
_currentBackground(0),
_backgroundWidth(0),
_backgroundHeight(0),
_backgroundInverseVelocity(0),
+ _backgroundOffset(0, 0),
_accumulatedVelocityMilliseconds(0),
- _renderTable(workingWindow.width(), workingWindow.height()) {
- _backbuffer.create(_workingWidth, _workingHeight, pixelFormat);
- _warpedBackbuffer = new uint16[_workingWidth *_workingHeight];
+ _renderTable(_workingWidth, _workingHeight) {
+
+ _warpedBuffer = new uint16[_workingWidth *_workingHeight];
}
RenderManager::~RenderManager() {
@@ -55,8 +58,7 @@ RenderManager::~RenderManager() {
delete _currentBackground;
}
- _backbuffer.free();
- delete[] _warpedBackbuffer;
+ delete[] _warpedBuffer;
}
void RenderManager::update(uint deltaTimeInMillis) {
@@ -73,111 +75,83 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
// Choose the direction of movement using the sign of the velocity
- moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
+ moveBackground(_backgroundInverseVelocity < 0 ? numberOfSteps : -numberOfSteps);
}
+}
- // Warp the entire backbuffer
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- _renderTable.mutateImage((uint16 *)_backbuffer.getBasePtr(0, 0), _warpedBackbuffer, _workingWidth, _workingHeight);
- _system->copyRectToScreen(_warpedBackbuffer, _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
- } else {
- _system->copyRectToScreen(_backbuffer.getBasePtr(0, 0), _backbuffer.pitch, _workingWindow.left, _workingWindow.top, _backbuffer.w, _backbuffer.h);
+void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap, bool isTransposed) {
+ int16 subRectX = 0;
+ int16 subRectY = 0;
+
+ // Take care of negative destinations
+ if (destinationX < 0) {
+ subRectX = destinationX + surface.w;
+ destinationX = 0;
+ if (wrap) {
+ _backgroundOffset.x += surface.w;
+ }
+ } else if (destinationX >= surface.w) {
+ // Take care of extreme positive destinations
+ destinationX -= surface.w;
+ if (wrap) {
+ _backgroundOffset.x -= surface.w;
+ }
}
- // Blit the backbuffer to the screen
-
-}
+ // Take care of negative destinations
+ if (destinationY < 0) {
+ subRectY = destinationY + surface.h;
+ destinationY = 0;
+ if (wrap) {
+ _backgroundOffset.y += surface.h;
+ }
+ } else if (destinationY >= surface.h) {
+ // Take care of extreme positive destinations
+ destinationY -= surface.h;
+ if (wrap) {
+ _backgroundOffset.y -= surface.h;
+ }
+ }
-void RenderManager::renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed) {
if (wrap) {
_backgroundWidth = surface.w;
_backgroundHeight = surface.h;
- }
- // If subRect is empty, use the entire image
- if (subRectangle.isEmpty())
- subRectangle = Common::Rect(subRectangle.left, subRectangle.top, subRectangle.left + surface.w, subRectangle.top + surface.h);
-
- // Clip destRect to working window bounds
- Common::Rect destRect(destinationX, destinationY, destinationX + subRectangle.width(), destinationY + subRectangle.height());
- destRect.clip(_workingWidth, _workingHeight);
- // Clip subRect to working window bounds
- subRectangle.translate(destRect.left - destinationX, destRect.top - destinationY);
- subRectangle.setWidth(destRect.width());
- subRectangle.setHeight(destRect.height());
- // Clip to image bounds
- Common::Point subRectOrigOrigin(subRectangle.left, subRectangle.top);
- subRectangle.clip(surface.w, surface.h);
-
- // If the image is to be wrapped, check if it's smaller than destRect
- // If it is, then call renderSubRectToScreen with a subRect representing wrapping
- if (wrap && subRectangle.width() < destRect.width()) {
- uint32 wrapDestX;
- uint32 wrapDestY;
- Common::Rect wrapSubRect;
-
- if (_backgroundWidth - subRectangle.left < destRect.width()) {
- wrapDestX = destRect.left + subRectangle.width();
- wrapDestY = destRect.top;
- wrapSubRect = Common::Rect(0, 0, destRect.width() - subRectangle.width(), subRectangle.bottom);
- } else {
- wrapDestX = destRect.left;
- wrapDestY = destRect.top;
- wrapSubRect = Common::Rect(_backgroundWidth - subRectangle.width(), 0, _backgroundWidth - 1, subRectangle.bottom);
+ if (destinationX > 0) {
+ // Move destinationX to 0
+ subRectX = surface.w - destinationX;
+ destinationX = 0;
}
- renderSubRectToBackbuffer(surface, wrapDestX, wrapDestY, wrapSubRect, false, isTransposed);
- } else if (wrap && subRectangle.height() < destRect.height()) {
- uint32 wrapDestX;
- uint32 wrapDestY;
- Common::Rect wrapSubRect;
-
- if (_backgroundHeight - subRectangle.top < destRect.height()) {
- wrapDestX = destRect.left;
- wrapDestY = destRect.height() - subRectangle.height();
- wrapSubRect = Common::Rect(0, 0, subRectangle.right, destRect.height() - subRectangle.height());
- } else {
- wrapDestX = destRect.left;
- wrapDestY = destRect.top;
- wrapSubRect = Common::Rect(0, _backgroundHeight - subRectangle.height(), subRectangle.right, _backgroundHeight - 1);
+ if (destinationY > 0) {
+ // Move destinationY to 0
+ subRectX = surface.w - destinationX;
+ destinationY = 0;
}
-
- renderSubRectToBackbuffer(surface, wrapDestX, wrapDestY, wrapSubRect, false, isTransposed);
- } else {
- // Clip destRect to image bounds
- destRect.translate(subRectangle.left - subRectOrigOrigin.x, subRectangle.top - subRectOrigOrigin.y);
- destRect.setWidth(subRectangle.width());
- destRect.setHeight(subRectangle.height());
}
- // Check all Rects for validity
- if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
- return;
+ // Clip subRect to working window bounds
+ Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight);
- if (isTransposed) {
- copyTransposedRectToBackbuffer((uint16 *)surface.getBasePtr(0, 0), surface.h, destRect.left, destRect.top, destRect.width(), destRect.height(), subRectangle);
- } else {
- _backbuffer.copyRectToSurface(surface.getBasePtr(subRectangle.left, subRectangle.top), surface.pitch, destRect.left, destRect.top, destRect.width(), destRect.height());
+ if (!wrap) {
+ // Clip to image bounds
+ subRect.clip(surface.w, surface.h);
}
-}
-void RenderManager::copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int destinationX, int destinationY, int width, int height, const Common::Rect &subRect) {
- uint16 *dest = (uint16 *)_backbuffer.getBasePtr(0, 0);
-
- for (int16 x = subRect.left; x < subRect.right; x++) {
- int16 normalizedX = x - subRect.left + destinationX;
- int columnOffset = x * imageWidth;
+ // Check destRect for validity
+ if (!subRect.isValidRect() || subRect.isEmpty())
+ return;
- for (int16 y = subRect.top; y < subRect.bottom; y++) {
- int16 normalizeY = y - subRect.top + destinationY;
+ if (_renderTable.getRenderState() == RenderTable::FLAT) {
+ _system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
+ } else {
+ _renderTable.mutateImage((uint16 *)surface.getBasePtr(0, 0), _warpedBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap, isTransposed);
- dest[normalizeY * _backbuffer.w + normalizedX] = buffer[columnOffset + y];
- }
+ _system->copyRectToScreen(_warpedBuffer, _workingWidth * sizeof(uint16), destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
}
}
-void RenderManager::renderImageToBackbuffer(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, bool wrap) {
Common::File file;
if (!file.open(fileName)) {
@@ -185,10 +159,10 @@ void RenderManager::renderImageToBackbuffer(const Common::String &fileName, uint
return;
}
- renderImageToBackbuffer(file, destinationX, destinationY, subRectangle);
+ renderImageToScreen(file, destinationX, destinationY);
}
-void RenderManager::renderImageToBackbuffer(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap) {
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
uint32 fileType;
@@ -217,7 +191,7 @@ void RenderManager::renderImageToBackbuffer(Common::SeekableReadStream &stream,
Graphics::Surface surface;
surface.init(imageWidth, imageHeight, pitch, buffer, _pixelFormat);
- renderSubRectToBackbuffer(surface, destinationX, destinationY, subRectangle, wrap, isTransposed);
+ renderSubRectToScreen(surface, destinationX, destinationY, wrap, isTransposed);
// We have to use delete[] instead of calling surface.free() because we created the memory with new[]
delete[] buffer;
@@ -241,7 +215,7 @@ void RenderManager::renderImageToBackbuffer(Common::SeekableReadStream &stream,
tgaSurface.w = temp;
}
- renderSubRectToBackbuffer(tgaSurface, destinationX, destinationY, subRectangle, wrap, isTransposed);
+ renderSubRectToScreen(tgaSurface, destinationX, destinationY, wrap, isTransposed);
tga.destroy();
}
}
@@ -280,15 +254,20 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
}
_currentBackground = file;
- // Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
- renderImageToBackbuffer(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
+ renderImageToScreen(*_currentBackground, _backgroundOffset.x, _backgroundOffset.y, true);
}
void RenderManager::setBackgroundPosition(int offset) {
- if (_renderTable.getRenderState() == RenderTable::TILT) {
- _backgroundOffset = Common::Point(0, offset);
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::TILT) {
+ _backgroundOffset.x = 0;
+ _backgroundOffset.y = _screenCenterY - offset;
+ } else if (state == RenderTable::PANORAMA) {
+ _backgroundOffset.x = _screenCenterX - offset;
+ _backgroundOffset.y = 0;
} else {
- _backgroundOffset = Common::Point(offset, 0);
+ _backgroundOffset.x = 0;
+ _backgroundOffset.y = 0;
}
}
@@ -305,25 +284,20 @@ void RenderManager::setBackgroundVelocity(int velocity) {
}
void RenderManager::moveBackground(int offset) {
- if (_renderTable.getRenderState() == RenderTable::TILT) {
+ _currentBackground->seek(0);
+
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::TILT) {
_backgroundOffset += Common::Point(0, offset);
- } else {
- _backgroundOffset += Common::Point(offset, 0);
- }
- // Make sure the offset is within image bounds
- if (_backgroundOffset.x < 0)
- _backgroundOffset.x += _backgroundWidth;
- if (_backgroundOffset.x > _backgroundWidth)
- _backgroundOffset.x -= _backgroundWidth;
- if (_backgroundOffset.y < 0)
- _backgroundOffset.y += _backgroundHeight;
- if (_backgroundOffset.y > _backgroundHeight)
- _backgroundOffset.y -= _backgroundHeight;
+ renderImageToScreen(*_currentBackground, 0, _backgroundOffset.y, true);
+ } else if (state == RenderTable::PANORAMA) {
+ _backgroundOffset += Common::Point(offset, 0);
- _currentBackground->seek(0);
- // Purposely make the subRectangle empty. renderImageToScreen will then set the width and height automatically.
- renderImageToBackbuffer(*_currentBackground, 0, 0, Common::Rect(_backgroundOffset.x, _backgroundOffset.y, _backgroundOffset.x, _backgroundOffset.y), true);
+ renderImageToScreen(*_currentBackground, _backgroundOffset.x, 0, true);
+ } else {
+ renderImageToScreen(*_currentBackground, 0, 0);
+ }
}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index f59f50d..cdcd52b 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -52,13 +52,17 @@ private:
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
- Graphics::Surface _backbuffer;
- uint16 *_warpedBackbuffer;
+ uint16 *_warpedBuffer;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
/** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
const int _workingHeight;
+ /** Center of the screen in the x direction */
+ const int _screenCenterX;
+ /** Center of the screen in the y direction */
+ const int _screenCenterY;
+
/**
* A Rectangle centered inside the actual window. All in-game coordinates
* are given in this coordinate space. Also, all images are clipped to the
@@ -102,9 +106,8 @@ public:
* @param fileName Name of the image file
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
- * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToBackbuffer(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
+ void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, bool wrap = false);
/**
* Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
@@ -113,9 +116,8 @@ public:
* @param stream Stream to read the image data from
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
- * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space!
*/
- void renderImageToBackbuffer(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool wrap = false);
+ void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, bool wrap = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -169,9 +171,7 @@ private:
* @param subRectangle A rectangle representing the part of the image that should be rendered
* @param wrap Should the image wrap (tile) if it doesn't completely fill the screen?
*/
- void renderSubRectToBackbuffer(Graphics::Surface &surface, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool wrap, bool isTransposed);
-
- void copyTransposedRectToBackbuffer(const uint16 *buffer, int imageWidth, int destinationX, int destinationY, int width, int height, const Common::Rect &subRect);
+ void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap, bool isTransposed);
void moveBackground(int offset);
};
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index a28f82b..23394b7 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -98,22 +98,46 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight) {
- for (uint32 y = 0; y < imageHeight; y++) {
- for (uint32 x = 0; x < imageWidth; x++) {
- uint32 index = y * _numColumns + x;
-
- // RenderTable only stores offsets from the original coordinates
- uint32 sourceYIndex = y + _internalBuffer[index].y;
- uint32 sourceXIndex = x + _internalBuffer[index].x;
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap, bool isTransposed) {
+ for (int16 y = subRect.top; y < subRect.bottom; y++) {
+ uint16 normalizedY = y - subRect.top;
+ uint32 internalColumnIndex = (normalizedY + destinationY) * _numColumns;
+ uint32 destColumnIndex = normalizedY * _numColumns;
- // Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<uint32>(sourceYIndex, 0, imageHeight - 1);
+ for (int16 x = subRect.left; x < subRect.right; x++) {
+ uint16 normalizedX = x - subRect.left;
- // Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<uint32>(sourceXIndex, 0, imageWidth - 1);
+ uint32 index = internalColumnIndex + normalizedX + destinationX;
- destBuffer[index] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
+ // RenderTable only stores offsets from the original coordinates
+ uint16 sourceYIndex = y + _internalBuffer[index].y;
+ uint16 sourceXIndex = x + _internalBuffer[index].x;
+
+ if (wrap) {
+ if (sourceXIndex >= imageWidth) {
+ sourceXIndex -= imageWidth;
+ } else if (sourceXIndex < 0) {
+ sourceXIndex += imageWidth;
+ }
+
+ if (sourceYIndex >= imageHeight) {
+ sourceYIndex -= imageHeight;
+ } else if (sourceYIndex < 0) {
+ sourceYIndex += imageHeight;
+ }
+ } else {
+ // 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);
+ }
+
+ if (isTransposed) {
+ destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceXIndex * imageHeight + sourceYIndex];
+ } else {
+ destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
+ }
}
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 7c04564..bbf5e1b 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap, bool isTransposed);
void generateRenderTable();
void setPanoramaFoV(float fov);
Commit: b22ed391fe35bd999060f5d3b7c87dcbfbca8ab4
https://github.com/scummvm/scummvm/commit/b22ed391fe35bd999060f5d3b7c87dcbfbca8ab4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:54-07:00
Commit Message:
ZVISION: Set the background position after the .scr file has been parsed so we know the RenderState
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 5c0e336..3ca9f01 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -216,9 +216,6 @@ void ScriptManager::changeLocationIntern() {
// Revert to the idle cursor
_engine->getCursorManager()->revertToIdle();
- // Change the background position
- _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
-
// Reset the background velocity
_engine->getRenderManager()->setBackgroundVelocity(0);
@@ -226,6 +223,9 @@ void ScriptManager::changeLocationIntern() {
Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
parseScrFile(fileName);
+ // Change the background position
+ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
+
// Create the puzzle reference table
createReferenceTable();
Commit: bbb8598a3e62e80b1a5efc5de4598276770ca6f1
https://github.com/scummvm/scummvm/commit/bbb8598a3e62e80b1a5efc5de4598276770ca6f1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:54-07:00
Commit Message:
ZVISION: Modify cmdLoadImage to match new render code
Changed paths:
engines/zvision/console.cpp
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index e7c46b9..dfafb26 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -57,11 +57,9 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
bool Console::cmdLoadImage(int argc, const char **argv) {
if (argc == 4)
- _engine->getRenderManager()->renderImageToBackbuffer(argv[1], atoi(argv[2]), atoi(argv[3]));
- else if (argc == 8)
- _engine->getRenderManager()->renderImageToBackbuffer(argv[1], atoi(argv[2]), atoi(argv[3]), Common::Rect(atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), atoi(argv[7])));
+ _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
else {
- DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> [ <subRectX1> <subRectY2> <subRectX2> <subRectY2> ] to load an image to the screen\n");
+ DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
return true;
}
Commit: f2477610cf1c776936e7c959e490120823845897
https://github.com/scummvm/scummvm/commit/f2477610cf1c776936e7c959e490120823845897
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:55-07:00
Commit Message:
VIDEO: Add AVI LIST handling for ZVision custom types
Changed paths:
video/avi_decoder.cpp
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index ff41099..beb68fc 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -65,9 +65,10 @@ namespace Video {
#define ID_VEDT MKTAG('v','e','d','t')
#define ID_IDX1 MKTAG('i','d','x','1')
#define ID_STRD MKTAG('s','t','r','d')
-//#define ID_INFO MKTAG('I','N','F','O')
+#define ID_INFO MKTAG('I','N','F','O')
#define ID_ISFT MKTAG('I','S','F','T')
#define ID_DISP MKTAG('D','I','S','P')
+#define ID_PRMI MKTAG('P','R','M','I')
// Codec tags
#define ID_RLE MKTAG('R','L','E',' ')
@@ -174,15 +175,25 @@ void AVIDecoder::handleList(uint32 listSize) {
debug(0, "Found LIST of type %s", tag2str(listType));
- if (listType == ID_MOVI) {
- // If we found the movie block
+ switch (listType) {
+ case ID_MOVI: // Movie List
+ // We found the movie block
_foundMovieList = true;
_movieListStart = curPos;
_fileStream->skip(listSize);
return;
- } else if (listType == ID_HDRL) {
+ case ID_HDRL: // Header List
// Mark the header as decoded
_decodedHeader = true;
+ break;
+ case ID_INFO: // Metadata
+ case ID_PRMI: // Unknown (ZEngine)
+ // Ignore metadata
+ _fileStream->skip(listSize);
+ return;
+ case ID_STRL: // Stream list
+ default: // (Just hope we can parse it!)
+ break;
}
while ((_fileStream->pos() - curPos) < listSize)
Commit: 8fafde8a33a84fd5819e2a3a9ff9ebf6a66889a5
https://github.com/scummvm/scummvm/commit/8fafde8a33a84fd5819e2a3a9ff9ebf6a66889a5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:55-07:00
Commit Message:
ZVISION: Re-enable video handling now that AVI code is fixed
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 ff7df20..5b8af48 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -251,7 +251,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:streamvideo*", true)) {
- //actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
} else if (line.matchString("*:syncsound*", true)) {
Commit: 7e6a04dc62161f1b013445ba20ee7465b57d6412
https://github.com/scummvm/scummvm/commit/7e6a04dc62161f1b013445ba20ee7465b57d6412
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:56-07:00
Commit Message:
ZVISION: Store the background offset from the center instead of from the top left corner
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index e410610..7d8ba75 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -38,8 +38,8 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
: _system(system),
_workingWidth(workingWindow.width()),
_workingHeight(workingWindow.height()),
- _screenCenterX((workingWindow.left + workingWindow.right) /2),
- _screenCenterY((workingWindow.top + workingWindow.bottom) /2),
+ _screenCenterX(_workingWidth / 2),
+ _screenCenterY(_workingHeight / 2),
_workingWindow(workingWindow),
_pixelFormat(pixelFormat),
_currentBackground(0),
@@ -75,7 +75,7 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
// Choose the direction of movement using the sign of the velocity
- moveBackground(_backgroundInverseVelocity < 0 ? numberOfSteps : -numberOfSteps);
+ moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
}
}
@@ -85,32 +85,20 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
// Take care of negative destinations
if (destinationX < 0) {
- subRectX = destinationX + surface.w;
+ subRectX = -destinationX;
destinationX = 0;
- if (wrap) {
- _backgroundOffset.x += surface.w;
- }
} else if (destinationX >= surface.w) {
// Take care of extreme positive destinations
destinationX -= surface.w;
- if (wrap) {
- _backgroundOffset.x -= surface.w;
- }
}
// Take care of negative destinations
if (destinationY < 0) {
- subRectY = destinationY + surface.h;
+ subRectY = -destinationY;
destinationY = 0;
- if (wrap) {
- _backgroundOffset.y += surface.h;
- }
} else if (destinationY >= surface.h) {
// Take care of extreme positive destinations
destinationY -= surface.h;
- if (wrap) {
- _backgroundOffset.y -= surface.h;
- }
}
if (wrap) {
@@ -224,15 +212,25 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &
// Convert from screen space to working window space
Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
- if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
}
- newPoint -= _backgroundOffset;
+ if (state == RenderTable::PANORAMA) {
+ newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset);
+ } else if (state == RenderTable::TILT) {
+ newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset);
+ }
+
if (newPoint.x < 0)
newPoint.x += _backgroundWidth;
+ else if (newPoint.x >= _backgroundWidth)
+ newPoint.x -= _backgroundWidth;
if (newPoint.y < 0)
newPoint.y += _backgroundHeight;
+ else if (newPoint.y >= _backgroundHeight)
+ newPoint.y -= _backgroundHeight;
return newPoint;
}
@@ -254,16 +252,16 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
}
_currentBackground = file;
- renderImageToScreen(*_currentBackground, _backgroundOffset.x, _backgroundOffset.y, true);
+ moveBackground(0);
}
void RenderManager::setBackgroundPosition(int offset) {
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::TILT) {
_backgroundOffset.x = 0;
- _backgroundOffset.y = _screenCenterY - offset;
+ _backgroundOffset.y = offset;
} else if (state == RenderTable::PANORAMA) {
- _backgroundOffset.x = _screenCenterX - offset;
+ _backgroundOffset.x = offset;
_backgroundOffset.y = 0;
} else {
_backgroundOffset.x = 0;
@@ -290,11 +288,31 @@ void RenderManager::moveBackground(int offset) {
if (state == RenderTable::TILT) {
_backgroundOffset += Common::Point(0, offset);
- renderImageToScreen(*_currentBackground, 0, _backgroundOffset.y, true);
+ if (_backgroundOffset.x <= -_backgroundWidth)
+ _backgroundOffset.x += _backgroundWidth;
+ else if (_backgroundOffset.x >= _backgroundWidth)
+ _backgroundOffset.x += _backgroundWidth;
+
+ if (_backgroundOffset.y <= -_backgroundHeight)
+ _backgroundOffset.y += _backgroundHeight;
+ else if (_backgroundOffset.y >= _backgroundHeight)
+ _backgroundOffset.y += _backgroundHeight;
+
+ renderImageToScreen(*_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
} else if (state == RenderTable::PANORAMA) {
_backgroundOffset += Common::Point(offset, 0);
- renderImageToScreen(*_currentBackground, _backgroundOffset.x, 0, true);
+ if (_backgroundOffset.x <= -_backgroundWidth)
+ _backgroundOffset.x += _backgroundWidth;
+ else if (_backgroundOffset.x >= _backgroundWidth)
+ _backgroundOffset.x += _backgroundWidth;
+
+ if (_backgroundOffset.y <= -_backgroundHeight)
+ _backgroundOffset.y += _backgroundHeight;
+ else if (_backgroundOffset.y >= _backgroundHeight)
+ _backgroundOffset.y += _backgroundHeight;
+
+ renderImageToScreen(*_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
} else {
renderImageToScreen(*_currentBackground, 0, 0);
}
Commit: acea03a9cd9ce14b210fe4b2fc650e34e8ae657b
https://github.com/scummvm/scummvm/commit/acea03a9cd9ce14b210fe4b2fc650e34e8ae657b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:56-07:00
Commit Message:
ZVISION: Allow RenderTable indicies to be negative
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 23394b7..7188530 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -100,18 +100,18 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap, bool isTransposed) {
for (int16 y = subRect.top; y < subRect.bottom; y++) {
- uint16 normalizedY = y - subRect.top;
- uint32 internalColumnIndex = (normalizedY + destinationY) * _numColumns;
- uint32 destColumnIndex = normalizedY * _numColumns;
+ int16 normalizedY = y - subRect.top;
+ int32 internalColumnIndex = (normalizedY + destinationY) * _numColumns;
+ int32 destColumnIndex = normalizedY * _numColumns;
for (int16 x = subRect.left; x < subRect.right; x++) {
- uint16 normalizedX = x - subRect.left;
+ int16 normalizedX = x - subRect.left;
- uint32 index = internalColumnIndex + normalizedX + destinationX;
+ int32 index = internalColumnIndex + normalizedX + destinationX;
// RenderTable only stores offsets from the original coordinates
- uint16 sourceYIndex = y + _internalBuffer[index].y;
- uint16 sourceXIndex = x + _internalBuffer[index].x;
+ int16 sourceYIndex = y + _internalBuffer[index].y;
+ int16 sourceXIndex = x + _internalBuffer[index].x;
if (wrap) {
if (sourceXIndex >= imageWidth) {
@@ -127,10 +127,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 im
}
} else {
// Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<uint32>(sourceYIndex, 0, imageHeight - 1);
+ sourceYIndex = CLIP<int32>(sourceYIndex, 0, imageHeight - 1);
// Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<uint32>(sourceXIndex, 0, imageWidth - 1);
+ sourceXIndex = CLIP<int32>(sourceXIndex, 0, imageWidth - 1);
}
if (isTransposed) {
Commit: 80cba07b311a56a9e3dd6ce5ca5a291299b95a8d
https://github.com/scummvm/scummvm/commit/80cba07b311a56a9e3dd6ce5ca5a291299b95a8d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:57-07:00
Commit Message:
ZVISION: Allow destinations to be negative
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 7d8ba75..932c797 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -139,7 +139,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
}
}
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, bool wrap) {
+void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
Common::File file;
if (!file.open(fileName)) {
@@ -150,7 +150,7 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
renderImageToScreen(file, destinationX, destinationY);
}
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, bool wrap) {
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, int16 destinationX, int16 destinationY, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
uint32 fileType;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index cdcd52b..9683ee0 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -107,7 +107,7 @@ public:
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, bool wrap = false);
+ void renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap = false);
/**
* Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
@@ -117,7 +117,7 @@ public:
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, bool wrap = false);
+ void renderImageToScreen(Common::SeekableReadStream &stream, int16 destinationX, int16 destinationY, bool wrap = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
Commit: f1d44bdf8cbcf69805713f042b16480227e14d6c
https://github.com/scummvm/scummvm/commit/f1d44bdf8cbcf69805713f042b16480227e14d6c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:57-07:00
Commit Message:
ZVISION: Protect against indicies that are more than an imageWidth/Height from the actual image dimensions
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 7188530..ec0cdba 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -114,15 +114,17 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 im
int16 sourceXIndex = x + _internalBuffer[index].x;
if (wrap) {
- if (sourceXIndex >= imageWidth) {
+ while (sourceXIndex >= imageWidth) {
sourceXIndex -= imageWidth;
- } else if (sourceXIndex < 0) {
+ }
+ while (sourceXIndex < 0) {
sourceXIndex += imageWidth;
}
- if (sourceYIndex >= imageHeight) {
+ while (sourceYIndex >= imageHeight) {
sourceYIndex -= imageHeight;
- } else if (sourceYIndex < 0) {
+ }
+ while (sourceYIndex < 0) {
sourceYIndex += imageHeight;
}
} else {
Commit: 77219705e6f225c4296b5d5346b2abd8fe2aaade
https://github.com/scummvm/scummvm/commit/77219705e6f225c4296b5d5346b2abd8fe2aaade
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:58-07:00
Commit Message:
ZVISION: Prevent endless looping due to incorrect file structure
Some of the .scr files don't properly close the last curly brace
Changed paths:
engines/zvision/control.cpp
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 02d15fe..eeba9b3 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -44,7 +44,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
float fov;
sscanf(line.c_str(), "angle(%f)", &fov);
@@ -78,7 +78,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
float fov;
sscanf(line.c_str(), "angle(%f)", &fov);
@@ -110,7 +110,7 @@ void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::Seekab
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.matchString("*_hotspot*", true)) {
uint x;
uint y;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 5b8af48..9c99ce1 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -76,7 +76,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.matchString("criteria {", true)) {
Puzzle::Criteria criteria;
if (parseCriteria(&criteria, stream)) {
@@ -103,7 +103,7 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe
return false;
}
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
// Split the string into tokens using ' ' as a delimiter
Common::StringTokenizer tokenizer(line);
Common::String token;
@@ -147,7 +147,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
trimCommentsAndWhiteSpace(&line);
// TODO: Re-order the if-then statements in order of highest occurrence
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.empty()) {
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -284,7 +284,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- while (!line.contains('}')) {
+ while (!stream.eos() && !line.contains('}')) {
if (line.matchString("ONCE_PER_INST", true)) {
flags |= Puzzle::ONCE_PER_INST;
} else if (line.matchString("DO_ME_NOW", true)) {
Commit: eafd6608cf1e54bb3551671e6fd4a8c6626d44d9
https://github.com/scummvm/scummvm/commit/eafd6608cf1e54bb3551671e6fd4a8c6626d44d9
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:58-07:00
Commit Message:
ZVISION: Change the CLIP template argument to match the type of the indicies
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index ec0cdba..0a8175e 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -129,10 +129,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 im
}
} else {
// Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<int32>(sourceYIndex, 0, imageHeight - 1);
+ sourceYIndex = CLIP<int16>(sourceYIndex, 0, imageHeight - 1);
// Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<int32>(sourceXIndex, 0, imageWidth - 1);
+ sourceXIndex = CLIP<int16>(sourceXIndex, 0, imageWidth - 1);
}
if (isTransposed) {
Commit: c840d082ceee068446176024b86031f24ed0a968
https://github.com/scummvm/scummvm/commit/c840d082ceee068446176024b86031f24ed0a968
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:59-07:00
Commit Message:
ZVISION: Allow ONCE_PER_INST puzzles to be repeated once per room instead of once per game
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 3ca9f01..8a1d1c9 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -108,11 +108,9 @@ void ScriptManager::checkPuzzleCriteria() {
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::ONCE_PER_INST) == Puzzle::ONCE_PER_INST &&
- (puzzle->flags & Puzzle::DISABLED) == 0) {
+ (puzzle->flags & Puzzle::DISABLED) == 0) {
continue;
}
@@ -226,18 +224,28 @@ void ScriptManager::changeLocationIntern() {
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- // Create the puzzle reference table
- createReferenceTable();
-
// Add all the local puzzles to the stack to be checked
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ // Reset any Puzzles that have the flag ONCE_PER_INST
+ if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
+ setStateValue((*iter).key, 0);
+ }
+
_puzzlesToCheck.push(&(*iter));
}
// Add all the global puzzles to the stack to be checked
for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ // Reset any Puzzles that have the flag ONCE_PER_INST
+ if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
+ setStateValue((*iter).key, 0);
+ }
+
_puzzlesToCheck.push(&(*iter));
}
+
+ // Create the puzzle reference table
+ createReferenceTable();
}
} // End of namespace ZVision
Commit: 09ae4443d4d8ea9781ce7c98c26c4010b4a3427a
https://github.com/scummvm/scummvm/commit/09ae4443d4d8ea9781ce7c98c26c4010b4a3427a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:52:59-07:00
Commit Message:
ZVISION: Reset push_toggle controls global state value to 0 during initialization
Changed paths:
engines/zvision/control.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index eeba9b3..b55452c 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -27,6 +27,7 @@
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
#include "zvision/render_table.h"
+#include "zvision/script_manager.h"
#include "zvision/control.h"
#include "zvision/utility.h"
@@ -103,6 +104,8 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
}
void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
+ engine->getScriptManager()->setStateValue(key, 0);
+
Common::Rect hotspot;
Common::String cursorName;
Commit: 589c29e6e15e5d2957b92b1a03c6bf43a327f541
https://github.com/scummvm/scummvm/commit/589c29e6e15e5d2957b92b1a03c6bf43a327f541
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:00-07:00
Commit Message:
ZVISION: Add newlines to console debug statements
Changed paths:
engines/zvision/console.cpp
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index dfafb26..69d19ab 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -168,7 +168,7 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
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");
+ DebugPrintf("Use changelocation <char: world> <char: room> <char:node> <char:view> <int: x position> to change your location\n");
return true;
}
@@ -179,7 +179,7 @@ bool Console::cmdChangeLocation(int argc, const char **argv) {
bool Console::cmdDumpFile(int argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Use dumpfile <fileName> to dump a file");
+ DebugPrintf("Use dumpfile <fileName> to dump a file\n");
return true;
}
Commit: 1f653f9a34e3462c0ab13aeaf5f68b7070f45770
https://github.com/scummvm/scummvm/commit/1f653f9a34e3462c0ab13aeaf5f68b7070f45770
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:00-07:00
Commit Message:
ZVISION: Allow MouseEvents to be unregistered
Changed paths:
engines/zvision/events.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index ca96f52..bea476f 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -39,6 +39,17 @@ void ZVision::registerMouseEvent(const MouseEvent &event) {
_mouseEvents.push_back(event);
}
+bool ZVision::removeMouseEvent(const uint32 key) {
+ for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ if ((*iter)._key == key) {
+ _mouseEvents.erase(iter);
+ return true;
+ }
+ }
+
+ return false;
+}
+
void ZVision::clearAllMouseEvents() {
_mouseEvents.clear();
}
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 58812d4..9e9d5db 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -133,6 +133,9 @@ public:
* @param event The event to register
*/
void registerMouseEvent(const MouseEvent &event);
+
+ bool removeMouseEvent(const uint32 key);
+
/** Remove all MouseEvents from the event system */
void clearAllMouseEvents();
Commit: 9051f6213671316c336242274490e17d356fef0e
https://github.com/scummvm/scummvm/commit/9051f6213671316c336242274490e17d356fef0e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:01-07:00
Commit Message:
ZVISION: Make MousEvent fully public
Changed paths:
engines/zvision/mouse_event.h
diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h
index 5537bcc..90a093f 100644
--- a/engines/zvision/mouse_event.h
+++ b/engines/zvision/mouse_event.h
@@ -34,9 +34,9 @@ class ZVision;
class MouseEvent {
public:
+ MouseEvent() : _key(0) {}
MouseEvent(uint32 key, const Common::Rect &hotspot, const Common::String hoverCursor);
-private:
/** The Control key */
uint32 _key;
/**
@@ -47,7 +47,6 @@ private:
/** The cursor to use when hovering over _hotspot */
Common::String _hoverCursor;
-public:
/**
* Does a simple Rect::contains() using _hotspot
*
Commit: 25deaf3a35efac8e5103e193f5f68409a87047a0
https://github.com/scummvm/scummvm/commit/25deaf3a35efac8e5103e193f5f68409a87047a0
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:01-07:00
Commit Message:
ZVISION: Reset MouseEvent globalStateValue's when clearing them
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index bea476f..f382bb6 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -31,6 +31,7 @@
#include "zvision/cursor_manager.h"
#include "zvision/render_manager.h"
+#include "zvision/script_manager.h"
#include "zvision/mouse_event.h"
namespace ZVision {
@@ -42,6 +43,7 @@ void ZVision::registerMouseEvent(const MouseEvent &event) {
bool ZVision::removeMouseEvent(const uint32 key) {
for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
if ((*iter)._key == key) {
+ _scriptManager->setStateValue((*iter)._key, 0);
_mouseEvents.erase(iter);
return true;
}
@@ -51,6 +53,11 @@ bool ZVision::removeMouseEvent(const uint32 key) {
}
void ZVision::clearAllMouseEvents() {
+ // Clear the state values of all the events
+ for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ _scriptManager->setStateValue((*iter)._key, 0);
+ }
+
_mouseEvents.clear();
}
Commit: 3a23873c45f8b274836eacd8d1de471da6defb5b
https://github.com/scummvm/scummvm/commit/3a23873c45f8b274836eacd8d1de471da6defb5b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:02-07:00
Commit Message:
ZVISION: Convert _activeControls from a List to a HashMap
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 9c99ce1..10e5c8f 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -62,12 +62,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
_activePuzzles.push_back(puzzle);
}
} else if (line.matchString("control:*", true)) {
- Common::SharedPtr<Control> control;
-
- // Some controls don't require nodes. They just initialize the scene
- if (parseControl(line, file, control)) {
- _activeControls.push_back(control);
- }
+ parseControl(line, file);
}
}
}
@@ -300,7 +295,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
return flags;
}
-bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr<Control> &control) {
+void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
uint32 key;
char controlTypeBuffer[20];
@@ -309,21 +304,19 @@ bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
- Control::parsePushToggleControl(key, _engine, stream);
- return false;
+ _activeControls[key] = new PushToggleControl(key, stream);
+ return;
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
- return false;
+ return;
} else if (controlType.equalsIgnoreCase("pana")) {
Control::parsePanoramaControl(_engine, stream);
- return false;
+ return;
}
else if (controlType.equalsIgnoreCase("tilt")) {
Control::parseTiltControl(_engine, stream);
- return false;
+ return;
}
-
- return true;
}
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index c0801ed..3d64727 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -70,7 +70,7 @@ private:
/** Holds the global puzzles */
Common::List<Puzzle>_globalPuzzles;
/** Holds the currently active controls */
- Common::List<Common::SharedPtr<Control> > _activeControls;
+ Common::HashMap<uint32, Control *> _activeControls;
Location _nextLocation;
bool _changeLocation;
@@ -145,7 +145,7 @@ private:
* @param line The line initially read
* @param stream Scr file stream
*/
- bool parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr<Control> &control);
+ void parseControl(Common::String &line, Common::SeekableReadStream &stream);
};
Commit: 908e784957ec3cf01bc54a5c76c18f5ed6a8faa6
https://github.com/scummvm/scummvm/commit/908e784957ec3cf01bc54a5c76c18f5ed6a8faa6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:03-07:00
Commit Message:
ZVISION: Allow controls to be enabled or disabled
Changed paths:
engines/zvision/control.h
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 2d5426c..b374383 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -35,11 +35,16 @@ class ZVision;
class Control {
public:
+ Control() : _key(0), _enabled(false) {}
virtual ~Control() {}
- virtual bool execute(ZVision *engine) = 0;
+ virtual bool enable(ZVision *engine) = 0;
+ virtual bool disable(ZVision *engine) { return true; }
+
+public:
+ uint32 _key;
protected:
- uint32 key;
+ bool _enabled;
// Static member functions
public:
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 8a1d1c9..13f30ca 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -185,6 +185,22 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
_globalState[key] += valueToAdd;
}
+bool ScriptManager::enableControl(uint32 key) {
+ if (!_activeControls.contains(key)) {
+ return false;
+ } else {
+ return _activeControls[key]->enable(_engine);
+ }
+}
+
+bool ScriptManager::disableControl(uint32 key) {
+ if (!_activeControls.contains(key)) {
+ return false;
+ } else {
+ return _activeControls[key]->disable(_engine);
+ }
+}
+
void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
_activeNodes.push_back(node);
}
@@ -225,6 +241,11 @@ void ScriptManager::changeLocationIntern() {
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
// Add all the local puzzles to the stack to be checked
+ // Enable all the controls
+ for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)._value->enable(_engine);
+ }
+
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 3d64727..7012ee0 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -84,6 +84,9 @@ public:
void setStateValue(uint32 key, uint value);
void addToStateValue(uint32 key, uint valueToAdd);
+ bool enableControl(uint32 key);
+ bool disableControl(uint32 key);
+
void addActionNode(const Common::SharedPtr<ActionNode> &node);
void changeLocation(char world, char room, char node, char view, uint32 offset);
Commit: 5a86355e7dae3b00924ce95275f1fea9346a6211
https://github.com/scummvm/scummvm/commit/5a86355e7dae3b00924ce95275f1fea9346a6211
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:03-07:00
Commit Message:
ZVISION: Implement ActionEnableControl and ActionDisableControl
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 504c250..affa8f5 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -111,6 +111,40 @@ bool ActionCrossfade::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionDisableControl
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDisableControl::ActionDisableControl(const Common::String &line) {
+ sscanf(line.c_str(), "%*[^(](%u)", &_key);
+}
+
+bool ActionDisableControl::execute(ZVision *engine) {
+ debug("Disabling control %u", _key);
+
+ engine->getScriptManager()->disableControl(_key);
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionEnableControl
+//////////////////////////////////////////////////////////////////////////////
+
+ActionEnableControl::ActionEnableControl(const Common::String &line) {
+ sscanf(line.c_str(), "%*[^(](%u)", &_key);
+}
+
+bool ActionEnableControl::execute(ZVision *engine) {
+ debug("Enabling control %u", _key);
+
+ engine->getScriptManager()->enableControl(_key);
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index aa67be2..1d87b80 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -168,6 +168,7 @@ public:
bool execute(ZVision *engine);
private:
+ uint32 _key;
};
class ActionDisableVenus : public ResultAction {
@@ -188,10 +189,8 @@ private:
class ActionDissolve : public ResultAction {
public:
- ActionDissolve(const Common::String &line);
+ ActionDissolve();
bool execute(ZVision *engine);
-
-private:
};
class ActionDistort : public ResultAction {
@@ -208,6 +207,7 @@ public:
bool execute(ZVision *engine);
private:
+ uint32 _key;
};
class ActionMusic : public ResultAction {
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 10e5c8f..3fee767 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -177,8 +177,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:disable_control*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionDisableControl(line)));
} else if (line.matchString("*:disable_venus*", true)) {
@@ -192,8 +191,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:enable_control*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionEnableControl(line)));
} else if (line.matchString("*:flush_mouse_events*", true)) {
Commit: 46ab3557660221b2896c0d5cd4a7d3fb0464d1d1
https://github.com/scummvm/scummvm/commit/46ab3557660221b2896c0d5cd4a7d3fb0464d1d1
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:04-07:00
Commit Message:
ZVISION: Allow Puzzles to have mutiple 'sets' of CriteriaEntries
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 e7846f5..36787e7 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -41,7 +41,7 @@ struct Puzzle {
};
/** Criteria for a Puzzle result to be fired */
- struct Criteria {
+ struct CriteriaEntry {
/** The key of a global state */
uint32 key;
/**
@@ -62,7 +62,7 @@ struct Puzzle {
};
uint32 key;
- Common::List<Criteria> criteriaList;
+ Common::List<Common::List <CriteriaEntry> > criteriaList;
// This has to be list of pointers because ResultAction is abstract
Common::List<Common::SharedPtr<ResultAction> > resultActions;
uint flags;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 3fee767..dd2754c 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -73,10 +73,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("criteria {", true)) {
- Puzzle::Criteria criteria;
- if (parseCriteria(&criteria, stream)) {
- puzzle.criteriaList.push_back(criteria);
- }
+ parseCriteria(stream, puzzle.criteriaList);
} else if (line.matchString("results {", true)) {
parseResults(stream, puzzle.resultActions);
} else if (line.matchString("flags {", true)) {
@@ -88,7 +85,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
}
}
-bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const {
+bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -98,37 +95,44 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe
return false;
}
+ // Create a new List to hold the CriteriaEntries
+ criteriaList.push_back(Common::List<Puzzle::CriteriaEntry>());
+
while (!stream.eos() && !line.contains('}')) {
+ Puzzle::CriteriaEntry entry;
+
// 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->key));
+ sscanf(token.c_str(), "[%u]", &(entry.key));
// Parse the operator out of the second token
token = tokenizer.nextToken();
if (token.c_str()[0] == '=')
- criteria->criteriaOperator = Puzzle::EQUAL_TO;
+ entry.criteriaOperator = Puzzle::EQUAL_TO;
else if (token.c_str()[0] == '!')
- criteria->criteriaOperator = Puzzle::NOT_EQUAL_TO;
+ entry.criteriaOperator = Puzzle::NOT_EQUAL_TO;
else if (token.c_str()[0] == '>')
- criteria->criteriaOperator = Puzzle::GREATER_THAN;
+ entry.criteriaOperator = Puzzle::GREATER_THAN;
else if (token.c_str()[0] == '<')
- criteria->criteriaOperator = Puzzle::LESS_THAN;
+ entry.criteriaOperator = Puzzle::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]", &(entry.argument));
+ entry.argumentIsAKey = true;
} else {
- sscanf(token.c_str(), "%u", &(criteria->argument));
- criteria->argumentIsAKey = false;
+ sscanf(token.c_str(), "%u", &(entry.argument));
+ entry.argumentIsAKey = false;
}
+ criteriaList.back().push_back(entry);
+
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 13f30ca..9796a95 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -61,13 +61,16 @@ void ScriptManager::createReferenceTable() {
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<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
- if (criteriaIter->argumentIsAKey)
- _referenceTable[criteriaIter->argument].push_back(puzzlePtr);
+ // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ _referenceTable[entryIter->key].push_back(puzzlePtr);
+
+ // If the argument is a key, add a reference to it as well
+ if (entryIter->argumentIsAKey) {
+ _referenceTable[entryIter->argument].push_back(puzzlePtr);
+ }
+ }
}
}
@@ -75,13 +78,16 @@ void ScriptManager::createReferenceTable() {
for (Common::List<Puzzle>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
Puzzle *puzzlePtr = &(*globalPuzzleIter);
- // Iterate through each Criteria and add a reference from the criteria key to the Puzzle
- for (Common::List<Puzzle::Criteria>::iterator criteriaIter = globalPuzzleIter->criteriaList.begin(); criteriaIter != (*globalPuzzleIter).criteriaList.end(); criteriaIter++) {
- _referenceTable[criteriaIter->key].push_back(puzzlePtr);
+ // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = globalPuzzleIter->criteriaList.begin(); criteriaIter != (*globalPuzzleIter).criteriaList.end(); criteriaIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ _referenceTable[entryIter->key].push_back(puzzlePtr);
- // If the argument is a key, add a reference to it as well
- if (criteriaIter->argumentIsAKey)
- _referenceTable[criteriaIter->argument].push_back(puzzlePtr);
+ // If the argument is a key, add a reference to it as well
+ if (entryIter->argumentIsAKey) {
+ _referenceTable[entryIter->argument].push_back(puzzlePtr);
+ }
+ }
}
}
@@ -115,32 +121,43 @@ void ScriptManager::checkPuzzleCriteria() {
}
// Check each Criteria
+
bool criteriaMet = false;
- 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).argumentIsAKey)
- argumentValue = getStateValue(iter->argument);
- else
- argumentValue = iter->argument;
-
- // Do the comparison
- switch ((*iter).criteriaOperator) {
- case Puzzle::EQUAL_TO:
- criteriaMet = getStateValue(iter->key) == argumentValue;
- break;
- case Puzzle::NOT_EQUAL_TO:
- criteriaMet = getStateValue(iter->key) != argumentValue;
- break;
- case Puzzle::GREATER_THAN:
- criteriaMet = getStateValue(iter->key) > argumentValue;
- break;
- case Puzzle::LESS_THAN:
- criteriaMet = getStateValue(iter->key) < argumentValue;
- break;
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); criteriaIter++) {
+ criteriaMet = false;
+
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ // Get the value to compare against
+ uint argumentValue;
+ if ((*entryIter).argumentIsAKey)
+ argumentValue = getStateValue(entryIter->argument);
+ else
+ argumentValue = entryIter->argument;
+
+ // Do the comparison
+ switch ((*entryIter).criteriaOperator) {
+ case Puzzle::EQUAL_TO:
+ criteriaMet = getStateValue(entryIter->key) == argumentValue;
+ break;
+ case Puzzle::NOT_EQUAL_TO:
+ criteriaMet = getStateValue(entryIter->key) != argumentValue;
+ break;
+ case Puzzle::GREATER_THAN:
+ criteriaMet = getStateValue(entryIter->key) > argumentValue;
+ break;
+ case Puzzle::LESS_THAN:
+ criteriaMet = getStateValue(entryIter->key) < argumentValue;
+ break;
+ }
+
+ // If one check returns false, don't keep checking
+ if (!criteriaMet) {
+ break;
+ }
}
- if (!criteriaMet) {
+ // If any of the Criteria are *fully* met, then execute the results
+ if (criteriaMet) {
break;
}
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 7012ee0..d484531 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -122,7 +122,7 @@ private:
* @param stream Scr file stream
* @return Whether any criteria were read
*/
- bool parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
+ bool parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const;
/**
* Parses the stream into a ResultAction objects
Commit: 6ee93ad5c2b2ea577a587af172a28b100a9956d8
https://github.com/scummvm/scummvm/commit/6ee93ad5c2b2ea577a587af172a28b100a9956d8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:04-07:00
Commit Message:
ZVISION: Convert _puzzlesToCheck to a Queue instead of a Stack
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 9796a95..8a1b60a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -257,12 +257,12 @@ void ScriptManager::changeLocationIntern() {
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- // Add all the local puzzles to the stack to be checked
// Enable all the controls
for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
(*iter)._value->enable(_engine);
}
+ // Add all the local puzzles to the queue to be checked
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
@@ -272,7 +272,7 @@ void ScriptManager::changeLocationIntern() {
_puzzlesToCheck.push(&(*iter));
}
- // Add all the global puzzles to the stack to be checked
+ // Add all the global puzzles to the queue to be checked
for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index d484531..362c4ef 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -24,7 +24,7 @@
#define ZVISION_SCRIPT_MANAGER_H
#include "common/hashmap.h"
-#include "common/stack.h"
+#include "common/queue.h"
#include "zvision/puzzle.h"
#include "zvision/control.h"
@@ -64,7 +64,7 @@ private:
/** 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;
+ Common::Queue<Puzzle *> _puzzlesToCheck;
/** Holds the currently active puzzles */
Common::List<Puzzle> _activePuzzles;
/** Holds the global puzzles */
Commit: d26c814d1e0ed76b4b4440e5798ccd012bd4858d
https://github.com/scummvm/scummvm/commit/d26c814d1e0ed76b4b4440e5798ccd012bd4858d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:05-07:00
Commit Message:
ZVISION: Force & operator to have precedence over == operator
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 8a1b60a..c80b5a2 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -265,7 +265,7 @@ void ScriptManager::changeLocationIntern() {
// Add all the local puzzles to the queue to be checked
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
- if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
+ if (((*iter).flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter).key, 0);
}
@@ -275,7 +275,7 @@ void ScriptManager::changeLocationIntern() {
// Add all the global puzzles to the queue to be checked
for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
- if ((*iter).flags & Puzzle::ONCE_PER_INST == Puzzle::ONCE_PER_INST) {
+ if (((*iter).flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter).key, 0);
}
Commit: 5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6
https://github.com/scummvm/scummvm/commit/5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:05-07:00
Commit Message:
ZVISION: Reimplement PushToggleControl
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index b55452c..acc970e 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -103,12 +103,15 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
-void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
- engine->getScriptManager()->setStateValue(key, 0);
- Common::Rect hotspot;
- Common::String cursorName;
-
+//////////////////////////////////////////////////////////////////////////////
+// PushToggleControl
+//////////////////////////////////////////////////////////////////////////////
+
+PushToggleControl::PushToggleControl(uint32 key, Common::SeekableReadStream &stream)
+ : Control() {
+ _event._key = _key = key;
+
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -121,23 +124,49 @@ void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::Seekab
uint height;
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
-
- hotspot = Common::Rect(x, y, x + width, y + height);
+
+ _event._hotspot = Common::Rect(x, y, x + width, y + height);
} else if (line.matchString("cursor*", true)) {
char nameBuffer[25];
sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
- cursorName = Common::String(nameBuffer);
+ _event._hoverCursor = Common::String(nameBuffer);
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
- if (!hotspot.isEmpty() && !cursorName.empty()) {
- engine->registerMouseEvent(MouseEvent(key, hotspot, cursorName));
+ if (_event._hotspot.isEmpty() || _event._hoverCursor.empty()) {
+ warning("Push_toggle cursor %u was parsed incorrectly", &key);
+ }
+}
+
+bool PushToggleControl::enable(ZVision *engine) {
+ if (!_enabled) {
+ engine->registerMouseEvent(_event);
+ _enabled = true;
+ return true;
+ }
+
+ debug("Control %u is already enabled", _key);
+ return false;
+}
+
+bool PushToggleControl::disable(ZVision *engine) {
+ if (_enabled) {
+ engine->removeMouseEvent(_key);
+ _enabled = false;
+ return true;
}
+
+ debug("Control %u is already disabled", _key);
+ return false;
+}
+
+void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
+
}
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index b374383..f17ee77 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,6 +25,8 @@
#include "common/types.h"
+#include "zvision/mouse_event.h"
+
namespace Common {
class SeekableReadStream;
}
@@ -54,6 +56,16 @@ public:
static void parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream);
};
+class PushToggleControl : public Control {
+public:
+ PushToggleControl(uint32 key, Common::SeekableReadStream &stream);
+ bool enable(ZVision *engine);
+ bool disable(ZVision *engine);
+
+private:
+ MouseEvent _event;
+};
+
} // End of namespace ZVision
#endif
Commit: 4d5914ac2157073339b0c348345dedbffd5ee030
https://github.com/scummvm/scummvm/commit/4d5914ac2157073339b0c348345dedbffd5ee030
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:06-07:00
Commit Message:
ZVISION: Fix argument passing for warning()
Changed paths:
engines/zvision/control.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index acc970e..106d938 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -139,7 +139,7 @@ PushToggleControl::PushToggleControl(uint32 key, Common::SeekableReadStream &str
}
if (_event._hotspot.isEmpty() || _event._hoverCursor.empty()) {
- warning("Push_toggle cursor %u was parsed incorrectly", &key);
+ warning("Push_toggle cursor %u was parsed incorrectly", key);
}
}
Commit: 2fcba2743c1670ba8a7428945714e896238e082e
https://github.com/scummvm/scummvm/commit/2fcba2743c1670ba8a7428945714e896238e082e
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:06-07:00
Commit Message:
ZVISION: Don't cast away const qualifier
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 28c26f6..4066c5d 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -148,10 +148,10 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
if (frame) {
if (scale != 1) {
- scaleBuffer((byte *)frame->getBasePtr(0, 0), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
+ scaleBuffer((const byte *)frame->getBasePtr(0, 0), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
- _system->copyRectToScreen((byte *)frame->getBasePtr(0, 0), pitch, x, y, finalWidth, finalHeight);
+ _system->copyRectToScreen((const byte *)frame->getBasePtr(0, 0), pitch, x, y, finalWidth, finalHeight);
}
_system->updateScreen();
Commit: b0635edff8c0d5b05cef8a22c74c569921a8346b
https://github.com/scummvm/scummvm/commit/b0635edff8c0d5b05cef8a22c74c569921a8346b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-18T17:53:07-07:00
Commit Message:
ZVISION: Revert to normal pointers instead of shared pointers
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 36787e7..227183a 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -64,7 +64,7 @@ struct Puzzle {
uint32 key;
Common::List<Common::List <CriteriaEntry> > criteriaList;
// This has to be list of pointers because ResultAction is abstract
- Common::List<Common::SharedPtr<ResultAction> > resultActions;
+ Common::List<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 dd2754c..eb15d04 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -140,7 +140,7 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li
return true;
}
-void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<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);
@@ -156,13 +156,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
// Parse for the action type
if (line.matchString("*:add*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionAdd(line)));
+ actionList.push_back(new ActionAdd(line));
} else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPlayAnimation(line)));
+ actionList.push_back(new ActionPlayAnimation(line));
} else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPreloadAnimation(line)));
+ actionList.push_back(new ActionPreloadAnimation(line));
} else if (line.matchString("*:animunload*", true)) {
- //actionList.push_back(Common::SharedPtr<ResultAction>(new ActionUnloadAnimation(line)));
+ //actionList.push_back(new ActionUnloadAnimation(line));
} else if (line.matchString("*:attenuate*", true)) {
@@ -170,7 +170,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:change_location*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionChangeLocation(line)));
+ actionList.push_back(new ActionChangeLocation(line));
} else if (line.matchString("*:crossfade*", true)) {
@@ -181,7 +181,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:disable_control*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionDisableControl(line)));
+ actionList.push_back(new ActionDisableControl(line));
} else if (line.matchString("*:disable_venus*", true)) {
@@ -195,7 +195,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:enable_control*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionEnableControl(line)));
+ actionList.push_back(new ActionEnableControl(line));
} else if (line.matchString("*:flush_mouse_events*", true)) {
@@ -209,7 +209,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:music*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionMusic(line)));
+ actionList.push_back(new ActionMusic(line));
} else if (line.matchString("*:pan_track*", true)) {
@@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:quit*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionQuit()));
+ actionList.push_back(new ActionQuit());
} else if (line.matchString("*:random*", true)) {
@@ -240,7 +240,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)));
+ actionList.push_back(new ActionSetScreen(line));
} else if (line.matchString("*:set_venus*", true)) {
@@ -248,7 +248,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:streamvideo*", true)) {
- actionList.push_back(Common::SharedPtr<ResultAction>(new ActionStreamVideo(line)));
+ actionList.push_back(new ActionStreamVideo(line));
} else if (line.matchString("*:syncsound*", true)) {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index c80b5a2..6a1794d 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -167,7 +167,7 @@ void ScriptManager::checkPuzzleCriteria() {
debug("Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
bool shouldContinue = true;
- for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+ for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 362c4ef..884699a 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -132,7 +132,7 @@ private:
* @param actionList The list where the results will be added
* @return Created Results object
*/
- void parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<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: 695257cb79f8666a74d4bc67996234eab391c67c
https://github.com/scummvm/scummvm/commit/695257cb79f8666a74d4bc67996234eab391c67c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:07-07:00
Commit Message:
ZVISION: Create class to parse RLF animation files
Changed paths:
A engines/zvision/rlf_animation.cpp
A engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
new file mode 100644
index 0000000..abc31c1
--- /dev/null
+++ b/engines/zvision/rlf_animation.cpp
@@ -0,0 +1,230 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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/str.h"
+#include "common/file.h"
+#include "common/textconsole.h"
+#include "common/debug.h"
+#include "common/endian.h"
+
+#include "zvision/rlf_animation.h"
+
+
+namespace ZVision {
+
+RlfAnimation::RlfAnimation(const Common::String &fileName)
+ : _frames(0) {
+ Common::File file;
+ if (!file.open(fileName)) {
+ warning("RLF animation file %s could not be opened", fileName.c_str());
+ return;
+ }
+
+ if (file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
+ warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str());
+ return;
+ }
+
+ // Read the header
+ file.readUint32LE(); // Size1
+ file.readUint32LE(); // Unknown1
+ file.readUint32LE(); // Unknown2
+ _frameCount = file.readUint32LE(); // Frame count
+
+ // Since we don't need any of the data, we can just seek right to the
+ // entries we need rather than read in all the individual entries.
+ file.seek(136, file.pos());
+
+ //// Read CIN header
+ //file.readUint32BE(); // Magic number FNIC
+ //file.readUint32LE(); // Size2
+ //file.readUint32LE(); // Unknown3
+ //file.readUint32LE(); // Unknown4
+ //file.readUint32LE(); // Unknown5
+ //file.seek(0x18, file.pos()); // VRLE
+ //file.readUint32LE(); // LRVD
+ //file.readUint32LE(); // Unknown6
+ //file.seek(0x18, file.pos()); // HRLE
+ //file.readUint32LE(); // ELHD
+ //file.readUint32LE(); // Unknown7
+ //file.seek(0x18, file.pos()); // HKEY
+ //file.readUint32LE(); // ELRH
+
+ //// Read MIN info header
+ //file.readUint32BE(); // Magic number FNIM
+ //file.readUint32LE(); // Size3
+ //file.readUint32LE(); // OEDV
+ //file.readUint32LE(); // Unknown8
+ //file.readUint32LE(); // Unknown9
+ //file.readUint32LE(); // Unknown10
+ _width = file.readUint32LE(); // Width
+ _height = file.readUint32LE(); // Height
+
+ // Read time header
+ file.readUint32BE(); // Magic number EMIT
+ file.readUint32LE(); // Size4
+ file.readUint32LE(); // Unknown11
+ _frameTime = file.readUint32LE() / 10; // Frame time in microseconds
+
+ // Read in each frame
+ _frames = new uint16 *[_frameCount];
+ for (uint i = 0; i < _frameCount; i++) {
+ file.readUint32BE(); // Magic number MARF
+ uint32 size = file.readUint32LE(); // Size
+ file.readUint32LE(); // Unknown1
+ file.readUint32LE(); // Unknown2
+ uint32 type = file.readUint32BE(); // Either ELHD or ELRH
+ uint32 offset = file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
+ file.readUint32LE(); // Unknown3
+
+ int8 *buffer = new int8[size - headerSize];
+ file.read(buffer, size - headerSize);
+
+ _frames[i] = new uint16[_width * _height];
+ uint frameByteSize = _width * _height * sizeof(uint16);
+ memset(_frames[i], 0x7C00, frameByteSize);
+ // Decode the data
+ debug("Decoding frame %u", i);
+ if (type == MKTAG('E', 'L', 'H', 'D')) {
+ debug("Decoding with masked RLE");
+ decodeMaskedRunLengthEncoding(buffer, (int8 *)_frames[i], size - headerSize, frameByteSize);
+ } else if (type == MKTAG('E', 'L', 'R', 'H')) {
+ debug("Decoding with simple RLE");
+ decodeSimpleRunLengthEncoding(buffer, (int8 *)_frames[i], size - headerSize, frameByteSize);
+ } else {
+ warning("Frame %u of %s doesn't have type that can be decoded", i, fileName.c_str());
+ return;
+ }
+
+ // Cleanup
+ delete[] buffer;
+ }
+};
+
+RlfAnimation::~RlfAnimation() {
+ if (_frames != 0) {
+ delete[] _frames;
+ }
+}
+
+
+
+void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
+ uint32 sourceOffset = 0;
+ uint32 destOffset = 0;
+
+ while (sourceOffset < sourceSize) {
+ int8 numberOfSamples = source[sourceOffset];
+ sourceOffset++;
+
+ // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
+ // be copied directly from source to dest
+ if (numberOfSamples < 0) {
+ numberOfSamples = abs(numberOfSamples);
+
+ while (numberOfSamples > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+
+ sourceOffset += 2;
+ destOffset += 2;
+ numberOfSamples--;
+ }
+
+ // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
+ // This function assumes the dest buffer has been memset with 0's.
+ } else {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ destOffset += (numberOfSamples * 2) + 2;
+ }
+ }
+}
+
+void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
+ uint32 sourceOffset = 0;
+ uint32 destOffset = 0;
+
+ while (sourceOffset < sourceSize) {
+ int8 numberOfSamples = source[sourceOffset];
+ sourceOffset++;
+
+ // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
+ // be copied directly from source to dest
+ if (numberOfSamples < 0) {
+ numberOfSamples = abs(numberOfSamples);
+
+ while (numberOfSamples > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+
+ sourceOffset += 2;
+ destOffset += 2;
+ numberOfSamples--;
+ }
+
+ // If numberOfSamples is >= 0, copy one sample from source to the
+ // next (numberOfSamples + 2) dest spots
+ } else {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ }
+
+ uint16 sampleColor = READ_LE_UINT16(source + sourceOffset);
+ sourceOffset += 2;
+
+ numberOfSamples += 2;
+ while (numberOfSamples > 0) {
+ if (destOffset + 1 >= destSize) {
+ warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, sampleColor);
+ destOffset += 2;
+ numberOfSamples--;
+ }
+ }
+ }
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
new file mode 100644
index 0000000..7ece4e5
--- /dev/null
+++ b/engines/zvision/rlf_animation.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_RLF_ANIMATION_H
+#define ZVISION_RLF_ANIMATION_H
+
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class RlfAnimation {
+public:
+ RlfAnimation(const Common::String &fileName);
+ ~RlfAnimation();
+
+private:
+private:
+ uint _frameCount;
+ uint _width;
+ uint _height;
+ uint32 _frameTime; // In milliseconds
+ uint16 **_frames;
+
+public:
+ uint frameCount() { return _frameCount; }
+ uint width() { return _width; }
+ uint height() { return _height; }
+ uint32 frameTime() { return _frameTime; }
+ const uint16 *getFrameData(uint frameNumber) const { return _frames[frameNumber]; }
+
+private:
+ void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
+ void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 760dd3e63202ff92d206fb83015f8b05e4aa969c
https://github.com/scummvm/scummvm/commit/760dd3e63202ff92d206fb83015f8b05e4aa969c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:34-07:00
Commit Message:
ZVISION: Rename _warpedBuffer to _workingWindowBuffer
To better represent its function
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 932c797..4e67cbb 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -50,7 +50,7 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
_accumulatedVelocityMilliseconds(0),
_renderTable(_workingWidth, _workingHeight) {
- _warpedBuffer = new uint16[_workingWidth *_workingHeight];
+ _workingWindowBuffer = new uint16[_workingWidth *_workingHeight];
}
RenderManager::~RenderManager() {
@@ -58,7 +58,7 @@ RenderManager::~RenderManager() {
delete _currentBackground;
}
- delete[] _warpedBuffer;
+ delete[] _workingWindowBuffer;
}
void RenderManager::update(uint deltaTimeInMillis) {
@@ -133,9 +133,9 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (_renderTable.getRenderState() == RenderTable::FLAT) {
_system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
} else {
- _renderTable.mutateImage((uint16 *)surface.getBasePtr(0, 0), _warpedBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap, isTransposed);
+ _renderTable.mutateImage((uint16 *)surface.getBasePtr(0, 0), _workingWindowBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap, isTransposed);
- _system->copyRectToScreen(_warpedBuffer, _workingWidth * sizeof(uint16), destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
+ _system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
}
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 9683ee0..5b51703 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -52,7 +52,9 @@ private:
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
- uint16 *_warpedBuffer;
+ // A buffer the exact same size as the workingWindow
+ // It's used for panorama/tilt warping and for clearing the workingWindow to a single color
+ uint16 *_workingWindowBuffer;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
@@ -88,6 +90,7 @@ private:
/** Holds any 'leftover' milliseconds between frames */
uint _accumulatedVelocityMilliseconds;
+ // TODO: Potentially merge this buffer and _workingWindowBuffer
byte *_scaledVideoFrameBuffer;
public:
Commit: 7c02b66b2e556816c70b75e69e53ba1fb3d1b895
https://github.com/scummvm/scummvm/commit/7c02b66b2e556816c70b75e69e53ba1fb3d1b895
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:34-07:00
Commit Message:
ZVISION: Create method to clear the working window area of the screen to a single color
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 4e67cbb..6c006d9 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -79,6 +79,16 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
}
+void RenderManager::clearWorkingWindowToColor(uint16 color) {
+ uint32 workingWindowSize = _workingWidth * _workingHeight;
+
+ for (uint32 i = 0; i < workingWindowSize; i++) {
+ _workingWindowBuffer[i] = color;
+ }
+
+ _system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), _workingWindow.left, _workingWindow.top, _workingWidth, _workingHeight);
+}
+
void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap, bool isTransposed) {
int16 subRectX = 0;
int16 subRectY = 0;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 5b51703..d82e40f 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -103,6 +103,13 @@ public:
void update(uint deltaTimeInMillis);
/**
+ * Fills the entire workingWindow with the specified color
+ *
+ * @param color The color to fill the working window with. (In RGB 555)
+ */
+ void clearWorkingWindowToColor(uint16 color);
+
+ /**
* Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
* The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
Commit: 683e24cd75e629061a7f5d0733b29daf10bba2ec
https://github.com/scummvm/scummvm/commit/683e24cd75e629061a7f5d0733b29daf10bba2ec
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:35-07:00
Commit Message:
ZVISION: Implement ActionSetPartialScreen
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index affa8f5..1649913 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -267,6 +267,36 @@ bool ActionRandom::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionSetPartialScreen
+//////////////////////////////////////////////////////////////////////////////
+
+ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
+ char fileName[25];
+ uint color;
+
+ sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color);
+
+ _fileName = Common::String(fileName);
+
+ if (color > 0xFFFF) {
+ warning("Background color for ActionSetPartialScreen is bigger than a uint16");
+ }
+ _backgroundColor = color;
+}
+
+bool ActionSetPartialScreen::execute(ZVision *engine) {
+ RenderManager *renderManager = engine->getRenderManager();
+
+ if (_backgroundColor > 0) {
+ renderManager->clearWorkingWindowToColor(_backgroundColor);
+ }
+ renderManager->renderImageToScreen(_fileName, _x, _y);
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionSetScreen
//////////////////////////////////////////////////////////////////////////////
@@ -278,8 +308,7 @@ ActionSetScreen::ActionSetScreen(const Common::String &line) {
}
bool ActionSetScreen::execute(ZVision *engine) {
- RenderManager *renderManager = engine->getRenderManager();
- renderManager->setBackgroundImage(_fileName);
+ engine->getRenderManager()->setBackgroundImage(_fileName);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 1d87b80..5e7c2c6 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -277,6 +277,18 @@ private:
uint _max;
};
+class ActionSetPartialScreen : public ResultAction {
+public:
+ ActionSetPartialScreen(const Common::String &line);
+ bool execute(ZVision *engine);
+
+private:
+ uint _x;
+ uint _y;
+ Common::String _fileName;
+ uint16 _backgroundColor;
+};
+
class ActionSetScreen : public ResultAction {
public:
ActionSetScreen(const Common::String &line);
Commit: 6e427ebef8b29e48b679c7c19ed4b715c7dfaef8
https://github.com/scummvm/scummvm/commit/6e427ebef8b29e48b679c7c19ed4b715c7dfaef8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:36-07:00
Commit Message:
ZVISION: Create method to play RlfAnimations
Changed paths:
A engines/zvision/animation.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation.cpp b/engines/zvision/animation.cpp
new file mode 100644
index 0000000..7c41c23
--- /dev/null
+++ b/engines/zvision/animation.cpp
@@ -0,0 +1,90 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "common/system.h"
+
+#include "zvision/zvision.h"
+#include "zvision/rlf_animation.h"
+
+
+namespace ZVision {
+
+void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) {
+ uint currentFrame = 0;
+ uint lastFrame = animation->frameCount();
+ bool skip = false;
+ uint32 frameTime = animation->frameTime();
+ uint width = animation->width();
+ uint height = animation->height();
+
+ uint16 newX = x + _workingWindow.left;
+ uint16 newY = y + _workingWindow.top;
+
+ uint32 accumulatedTime = 0;
+
+ // Only continue while the video is still playing
+ while (!shouldQuit() && !skip && currentFrame < lastFrame) {
+ _clock.update();
+ uint32 currentTime = _clock.getLastMeasuredTime();
+ accumulatedTime += _clock.getDeltaTime();
+
+ // 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:
+ skip = true;
+ break;
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if (accumulatedTime >= frameTime) {
+ accumulatedTime -= frameTime;
+
+ _system->copyRectToScreen(animation->getFrameData(currentFrame), width * sizeof(uint16), newX, newY, width, height);
+ currentFrame++;
+ }
+
+ // Always update the screen so the mouse continues to render
+ _system->updateScreen();
+
+ // Calculate the frame delay based off a desired frame time
+ int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
+ // Ensure non-negative
+ delay = delay < 0 ? 0 : delay;
+ _system->delayMillis(delay);
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 9e9d5db..366e96f 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -49,6 +49,7 @@ class Console;
class ScriptManager;
class RenderManager;
class CursorManager;
+class RlfAnimation;
// our engine debug channels
enum {
@@ -126,6 +127,8 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
+ void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+
/**
* Register a MouseEvent with the event system. These will be checked at every
* MOUSE_UP, MOUSE_DOWN, MOUSE_MOVE, etc.
Commit: 9294c5eac969967a294abd97982e5baed6507355
https://github.com/scummvm/scummvm/commit/9294c5eac969967a294abd97982e5baed6507355
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:44-07:00
Commit Message:
ZVISION: Initialize inline with construction
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 6c006d9..ac02cc2 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -163,8 +163,7 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, int16 de
void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, int16 destinationX, int16 destinationY, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
- uint32 fileType;
- fileType = stream.readUint32BE();
+ uint32 fileType = stream.readUint32BE();
// Check for TGZ files
if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
Commit: 6c7303995f6fb4eb488ef8a7bba6fc60bc765d04
https://github.com/scummvm/scummvm/commit/6c7303995f6fb4eb488ef8a7bba6fc60bc765d04
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:45-07:00
Commit Message:
ZVISION: Always update the screen to ensure the mouse continues to render
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 4066c5d..377b24a 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -153,11 +153,12 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
} else {
_system->copyRectToScreen((const byte *)frame->getBasePtr(0, 0), pitch, x, y, finalWidth, finalHeight);
}
-
- _system->updateScreen();
}
}
+ // Always update the screen so the mouse continues to render
+ _system->updateScreen();
+
_system->delayMillis(videoDecoder.getTimeToNextFrame());
}
Commit: 7dcfa9ef4c849251e32b60f5d3cd609fb0fd2921
https://github.com/scummvm/scummvm/commit/7dcfa9ef4c849251e32b60f5d3cd609fb0fd2921
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:45-07:00
Commit Message:
ZVISION: Call RenderManager::update() before ScriptManager::update()
This ensures the background will be rendered before anything from Puzzles or Controls
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 080c763..c32e782 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -135,8 +135,10 @@ Common::Error ZVision::run() {
processEvents();
- _scriptManager->update(deltaTime);
+ // Call _renderManager->update() first so the background renders
+ // before anything that puzzles/controls will render
_renderManager->update(deltaTime);
+ _scriptManager->update(deltaTime);
// Update the screen
_system->updateScreen();
Commit: 94a55024ac9384747130aa1cd94d4cb36f35e922
https://github.com/scummvm/scummvm/commit/94a55024ac9384747130aa1cd94d4cb36f35e922
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:46-07:00
Commit Message:
ZVISION: Fix seek() whence argument
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index abc31c1..8a087c1 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -54,7 +54,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
// Since we don't need any of the data, we can just seek right to the
// entries we need rather than read in all the individual entries.
- file.seek(136, file.pos());
+ file.seek(136, SEEK_CUR);
//// Read CIN header
//file.readUint32BE(); // Magic number FNIC
@@ -62,13 +62,13 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
//file.readUint32LE(); // Unknown3
//file.readUint32LE(); // Unknown4
//file.readUint32LE(); // Unknown5
- //file.seek(0x18, file.pos()); // VRLE
+ //file.seek(0x18, SEEK_CUR); // VRLE
//file.readUint32LE(); // LRVD
//file.readUint32LE(); // Unknown6
- //file.seek(0x18, file.pos()); // HRLE
+ //file.seek(0x18, SEEK_CUR); // HRLE
//file.readUint32LE(); // ELHD
//file.readUint32LE(); // Unknown7
- //file.seek(0x18, file.pos()); // HKEY
+ //file.seek(0x18, SEEK_CUR); // HKEY
//file.readUint32LE(); // ELRH
//// Read MIN info header
Commit: 4bd7951840b7e995b4857ee6ee1c6288668cd66f
https://github.com/scummvm/scummvm/commit/4bd7951840b7e995b4857ee6ee1c6288668cd66f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:46-07:00
Commit Message:
ZVISION: Normalize comment alignment
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 8a087c1..c072aaf 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -47,56 +47,56 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
}
// Read the header
- file.readUint32LE(); // Size1
- file.readUint32LE(); // Unknown1
- file.readUint32LE(); // Unknown2
- _frameCount = file.readUint32LE(); // Frame count
+ file.readUint32LE(); // Size1
+ file.readUint32LE(); // Unknown1
+ file.readUint32LE(); // Unknown2
+ _frameCount = file.readUint32LE(); // Frame count
// Since we don't need any of the data, we can just seek right to the
// entries we need rather than read in all the individual entries.
file.seek(136, SEEK_CUR);
//// Read CIN header
- //file.readUint32BE(); // Magic number FNIC
- //file.readUint32LE(); // Size2
- //file.readUint32LE(); // Unknown3
- //file.readUint32LE(); // Unknown4
- //file.readUint32LE(); // Unknown5
- //file.seek(0x18, SEEK_CUR); // VRLE
- //file.readUint32LE(); // LRVD
- //file.readUint32LE(); // Unknown6
- //file.seek(0x18, SEEK_CUR); // HRLE
- //file.readUint32LE(); // ELHD
- //file.readUint32LE(); // Unknown7
- //file.seek(0x18, SEEK_CUR); // HKEY
- //file.readUint32LE(); // ELRH
+ //file.readUint32BE(); // Magic number FNIC
+ //file.readUint32LE(); // Size2
+ //file.readUint32LE(); // Unknown3
+ //file.readUint32LE(); // Unknown4
+ //file.readUint32LE(); // Unknown5
+ //file.seek(0x18, SEEK_CUR); // VRLE
+ //file.readUint32LE(); // LRVD
+ //file.readUint32LE(); // Unknown6
+ //file.seek(0x18, SEEK_CUR); // HRLE
+ //file.readUint32LE(); // ELHD
+ //file.readUint32LE(); // Unknown7
+ //file.seek(0x18, SEEK_CUR); // HKEY
+ //file.readUint32LE(); // ELRH
//// Read MIN info header
- //file.readUint32BE(); // Magic number FNIM
- //file.readUint32LE(); // Size3
- //file.readUint32LE(); // OEDV
- //file.readUint32LE(); // Unknown8
- //file.readUint32LE(); // Unknown9
- //file.readUint32LE(); // Unknown10
- _width = file.readUint32LE(); // Width
- _height = file.readUint32LE(); // Height
+ //file.readUint32BE(); // Magic number FNIM
+ //file.readUint32LE(); // Size3
+ //file.readUint32LE(); // OEDV
+ //file.readUint32LE(); // Unknown8
+ //file.readUint32LE(); // Unknown9
+ //file.readUint32LE(); // Unknown10
+ _width = file.readUint32LE(); // Width
+ _height = file.readUint32LE(); // Height
// Read time header
- file.readUint32BE(); // Magic number EMIT
- file.readUint32LE(); // Size4
- file.readUint32LE(); // Unknown11
- _frameTime = file.readUint32LE() / 10; // Frame time in microseconds
+ file.readUint32BE(); // Magic number EMIT
+ file.readUint32LE(); // Size4
+ file.readUint32LE(); // Unknown11
+ _frameTime = file.readUint32LE() / 10; // Frame time in microseconds
// Read in each frame
_frames = new uint16 *[_frameCount];
for (uint i = 0; i < _frameCount; i++) {
- file.readUint32BE(); // Magic number MARF
- uint32 size = file.readUint32LE(); // Size
- file.readUint32LE(); // Unknown1
- file.readUint32LE(); // Unknown2
- uint32 type = file.readUint32BE(); // Either ELHD or ELRH
- uint32 offset = file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
- file.readUint32LE(); // Unknown3
+ file.readUint32BE(); // Magic number MARF
+ uint32 size = file.readUint32LE(); // Size
+ file.readUint32LE(); // Unknown1
+ file.readUint32LE(); // Unknown2
+ uint32 type = file.readUint32BE(); // Either ELHD or ELRH
+ uint32 headerSize = file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
+ file.readUint32LE(); // Unknown3
int8 *buffer = new int8[size - headerSize];
file.read(buffer, size - headerSize);
Commit: 6f080b3631c8dc111bc6775877b58a9e5d783565
https://github.com/scummvm/scummvm/commit/6f080b3631c8dc111bc6775877b58a9e5d783565
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:41:47-07:00
Commit Message:
ZVISION: Create keypress event to test rlf animation
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index f382bb6..798d75b 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -33,6 +33,7 @@
#include "zvision/render_manager.h"
#include "zvision/script_manager.h"
#include "zvision/mouse_event.h"
+#include "zvision/rlf_animation.h"
namespace ZVision {
@@ -95,6 +96,12 @@ void ZVision::processEvents() {
case Common::KEYCODE_F1:
cycleThroughCursors();
break;
+ case Common::KEYCODE_F2:
+ {
+ RlfAnimation *animation = new RlfAnimation("te2ea21c.rlf");
+ playAnimation(animation, 0, 0);
+ break;
+ }
default:
break;
}
Commit: 610b563790ded5c43f757675a9acdc49ce555a1d
https://github.com/scummvm/scummvm/commit/610b563790ded5c43f757675a9acdc49ce555a1d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T09:55:08-07:00
Commit Message:
ZVISION: Convert abs() to ABS() to ensure portability
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index c072aaf..26ce2e2 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -141,7 +141,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
// If numberOfSamples is negative, the next abs(numberOfSamples) samples should
// be copied directly from source to dest
if (numberOfSamples < 0) {
- numberOfSamples = abs(numberOfSamples);
+ numberOfSamples = ABS(numberOfSamples);
while (numberOfSamples > 0) {
if (sourceOffset + 1 >= sourceSize) {
@@ -184,7 +184,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
// If numberOfSamples is negative, the next abs(numberOfSamples) samples should
// be copied directly from source to dest
if (numberOfSamples < 0) {
- numberOfSamples = abs(numberOfSamples);
+ numberOfSamples = ABS(numberOfSamples);
while (numberOfSamples > 0) {
if (sourceOffset + 1 >= sourceSize) {
Commit: 9af92b8723bdba3b9e540d9e0ba3a9142bc2e480
https://github.com/scummvm/scummvm/commit/9af92b8723bdba3b9e540d9e0ba3a9142bc2e480
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T13:55:42-07:00
Commit Message:
ZVISION: Handle rlf frame transitions internally
Animations use incremental frame changes. That is, only a few frames
are complete (I-frames), the rest are just the pixels that change between the current
frame and both the previous frame and the next frame (B-frames). See
https://en.wikipedia.org/wiki/Video_compression_picture_types
Changed paths:
engines/zvision/animation.cpp
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/animation.cpp b/engines/zvision/animation.cpp
index 7c41c23..8ca892d 100644
--- a/engines/zvision/animation.cpp
+++ b/engines/zvision/animation.cpp
@@ -31,8 +31,6 @@
namespace ZVision {
void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) {
- uint currentFrame = 0;
- uint lastFrame = animation->frameCount();
bool skip = false;
uint32 frameTime = animation->frameTime();
uint width = animation->width();
@@ -44,7 +42,7 @@ void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, Dispose
uint32 accumulatedTime = 0;
// Only continue while the video is still playing
- while (!shouldQuit() && !skip && currentFrame < lastFrame) {
+ while (!shouldQuit() && !skip && !animation->endOfAnimation()) {
_clock.update();
uint32 currentTime = _clock.getLastMeasuredTime();
accumulatedTime += _clock.getDeltaTime();
@@ -69,11 +67,10 @@ void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, Dispose
}
}
- if (accumulatedTime >= frameTime) {
+ while (accumulatedTime >= frameTime && !animation->endOfAnimation()) {
accumulatedTime -= frameTime;
- _system->copyRectToScreen(animation->getFrameData(currentFrame), width * sizeof(uint16), newX, newY, width, height);
- currentFrame++;
+ _system->copyRectToScreen(animation->getNextFrame(), width * sizeof(uint16), newX, newY, width, height);
}
// Always update the screen so the mouse continues to render
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 26ce2e2..90086e9 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -34,7 +34,14 @@
namespace ZVision {
RlfAnimation::RlfAnimation(const Common::String &fileName)
- : _frames(0) {
+ : _frameCount(0),
+ _width(0),
+ _height(0),
+ _frameTime(0),
+ _frames(0),
+ _currentFrameBuffer(0),
+ _currentFrame(-1),
+ _frameBufferByteSize(0) {
Common::File file;
if (!file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
@@ -87,8 +94,11 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
file.readUint32LE(); // Unknown11
_frameTime = file.readUint32LE() / 10; // Frame time in microseconds
+ _frames = new Frame[_frameCount];
+ _currentFrameBuffer = new uint16[_width * _height];
+ _frameBufferByteSize = _width * _height * sizeof(uint16);
+
// Read in each frame
- _frames = new uint16 *[_frameCount];
for (uint i = 0; i < _frameCount; i++) {
file.readUint32BE(); // Magic number MARF
uint32 size = file.readUint32LE(); // Size
@@ -98,27 +108,19 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
uint32 headerSize = file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
file.readUint32LE(); // Unknown3
- int8 *buffer = new int8[size - headerSize];
- file.read(buffer, size - headerSize);
-
- _frames[i] = new uint16[_width * _height];
- uint frameByteSize = _width * _height * sizeof(uint16);
- memset(_frames[i], 0x7C00, frameByteSize);
- // Decode the data
- debug("Decoding frame %u", i);
+ _frames[i].encodedSize = size - headerSize;
+ _frames[i].encodedData = new int8[_frames[i].encodedSize];
+ file.read(_frames[i].encodedData, _frames[i].encodedSize);
+
if (type == MKTAG('E', 'L', 'H', 'D')) {
- debug("Decoding with masked RLE");
- decodeMaskedRunLengthEncoding(buffer, (int8 *)_frames[i], size - headerSize, frameByteSize);
+ _frames[i].type = Masked;
} else if (type == MKTAG('E', 'L', 'R', 'H')) {
- debug("Decoding with simple RLE");
- decodeSimpleRunLengthEncoding(buffer, (int8 *)_frames[i], size - headerSize, frameByteSize);
+ _frames[i].type = Simple;
+ _completeFrames.push_back(i);
} else {
warning("Frame %u of %s doesn't have type that can be decoded", i, fileName.c_str());
return;
}
-
- // Cleanup
- delete[] buffer;
}
};
@@ -126,9 +128,58 @@ RlfAnimation::~RlfAnimation() {
if (_frames != 0) {
delete[] _frames;
}
+ if (_currentFrameBuffer != 0) {
+ delete[] _currentFrameBuffer;
+ }
+}
+
+const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
+ assert(frameNumber < _frameCount && frameNumber >= 0);
+
+ if (frameNumber == _currentFrame) {
+ return _currentFrameBuffer;
+ }
+
+ uint closestFrame = _currentFrame;
+ uint distance = ABS(_currentFrame - frameNumber);
+ for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) {
+ uint newDistance = ABS((*iter) - frameNumber);
+ if (closestFrame == -1 || newDistance < distance) {
+ closestFrame = (*iter);
+ distance = newDistance;
+ }
+ }
+
+ bool forwards = frameNumber > closestFrame;
+ if (forwards) {
+ for (uint i = closestFrame; i <= frameNumber; i++) {
+ applyFrameToCurrent(i);
+ }
+ } else {
+ for (uint i = closestFrame; i >= frameNumber; i--) {
+ applyFrameToCurrent(i);
+ }
+ }
+
+ return _currentFrameBuffer;
}
+const uint16 *RlfAnimation::getNextFrame() {
+ assert(_currentFrame + 1 < _frameCount);
+ applyFrameToCurrent(_currentFrame + 1);
+ return _currentFrameBuffer;
+}
+
+void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
+ if (_frames[frameNumber].type == Masked) {
+ decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ } else if (_frames[frameNumber].type == Simple) {
+ decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ }
+
+ _currentFrame = frameNumber;
+}
void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
uint32 sourceOffset = 0;
@@ -226,5 +277,4 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
}
}
-
} // End of namespace ZVision
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 7ece4e5..e204a50 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -36,21 +36,41 @@ public:
~RlfAnimation();
private:
+ enum EncodingType {
+ Masked,
+ Simple
+ };
+
+ struct Frame {
+ EncodingType type;
+ int8 *encodedData;
+ uint32 encodedSize;
+ };
+
private:
uint _frameCount;
uint _width;
uint _height;
uint32 _frameTime; // In milliseconds
- uint16 **_frames;
+ Frame *_frames;
+ Common::List<uint> _completeFrames;
+
+ int _currentFrame;
+ uint16 *_currentFrameBuffer;
+ uint32 _frameBufferByteSize;
public:
uint frameCount() { return _frameCount; }
uint width() { return _width; }
uint height() { return _height; }
uint32 frameTime() { return _frameTime; }
- const uint16 *getFrameData(uint frameNumber) const { return _frames[frameNumber]; }
+ const uint16 *getFrameData(uint frameNumber);
+ const uint16 *getNextFrame();
+ bool endOfAnimation() { return _currentFrame == _frameCount - 1; }
private:
+ void applyFrameToCurrent(uint frameNumber);
+
void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
};
Commit: cf8a8df776a28d5c4474848448b231d55b0c0c71
https://github.com/scummvm/scummvm/commit/cf8a8df776a28d5c4474848448b231d55b0c0c71
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:28:00-07:00
Commit Message:
ZVISION: Remove superfluous file
Changed paths:
R engines/zvision/tests.h
diff --git a/engines/zvision/tests.h b/engines/zvision/tests.h
deleted file mode 100644
index 14f80ed..0000000
--- a/engines/zvision/tests.h
+++ /dev/null
@@ -1,54 +0,0 @@
-
-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
Commit: 1251da96e22e56c13c81e4fa6f08efe99cbcbbb3
https://github.com/scummvm/scummvm/commit/1251da96e22e56c13c81e4fa6f08efe99cbcbbb3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:28:36-07:00
Commit Message:
ZVISION: Add animation.o and rlf_animation.o to module.mk
Changed paths:
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index f072520..317e4b1 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 \
+ animation.o \
clock.o \
console.o \
control.o \
@@ -14,6 +15,7 @@ MODULE_OBJS := \
mouse_event.o \
render_manager.o \
render_table.o \
+ rlf_animation.o \
scr_file_handling.o \
script_manager.o \
scripts.o \
Commit: aba3ba634cbadd6f245580171322fa5debc6ffd3
https://github.com/scummvm/scummvm/commit/aba3ba634cbadd6f245580171322fa5debc6ffd3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:29:28-07:00
Commit Message:
ZVISION: Add TODO's of what is left for the engine to be complete
Changed paths:
A engines/zvision/inventory_manager.h
A engines/zvision/menu.h
A engines/zvision/save_manager.h
A engines/zvision/subtitles.h
engines/zvision/control.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index f17ee77..e3cb0d4 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -66,6 +66,16 @@ private:
MouseEvent _event;
};
+// TODO: Implement InputControl
+// TODO: Implement SaveControl
+// TODO: Implement SlotControl
+// TODO: Implement LeverControl
+// TODO: Implement SafeControl
+// TODO: Implement FistControl
+// TODO: Implement HotMovieControl
+// TODO: Implement PaintControl
+// TODO: Implement TilterControl
+
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/inventory_manager.h b/engines/zvision/inventory_manager.h
new file mode 100644
index 0000000..ae6d116
--- /dev/null
+++ b/engines/zvision/inventory_manager.h
@@ -0,0 +1,28 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_INVENTORY_MANAGER_H
+#define ZVISION_INVENTORY_MANAGER_H
+
+// TODO: Implement InventoryManager
+
+#endif
diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h
new file mode 100644
index 0000000..affc69a
--- /dev/null
+++ b/engines/zvision/menu.h
@@ -0,0 +1,28 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_MENU_H
+#define ZVISION_MENU_H
+
+// TODO: Implement MenuHandler
+
+#endif
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
new file mode 100644
index 0000000..487cf20
--- /dev/null
+++ b/engines/zvision/save_manager.h
@@ -0,0 +1,28 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_SAVE_MANAGER_H
+#define ZVISION_SAVE_MANAGER_H
+
+// TODO: Implement SaveManager
+
+#endif
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index eb15d04..f4d4563 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -164,103 +164,75 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:animunload*", true)) {
//actionList.push_back(new ActionUnloadAnimation(line));
} else if (line.matchString("*:attenuate*", true)) {
-
-
+ // TODO: Implement ActionAttenuate
} else if (line.matchString("*:assign*", true)) {
-
-
+ // TODO: Implement ActionAssign
} else if (line.matchString("*:change_location*", true)) {
actionList.push_back(new ActionChangeLocation(line));
} else if (line.matchString("*:crossfade*", true)) {
-
-
+ // TODO: Implement ActionCrossfade
} else if (line.matchString("*:debug*", true)) {
-
-
+ // TODO: Implement ActionDebug
} else if (line.matchString("*:delay_render*", true)) {
-
-
+ // TODO: Implement ActionDelayRender
} else if (line.matchString("*:disable_control*", true)) {
actionList.push_back(new ActionDisableControl(line));
} else if (line.matchString("*:disable_venus*", true)) {
-
-
+ // TODO: Implement ActionDisableVenus
} else if (line.matchString("*:display_message*", true)) {
-
-
+ // TODO: Implement ActionDisplayMessage
} else if (line.matchString("*:dissolve*", true)) {
-
-
+ // TODO: Implement ActionDissolve
} else if (line.matchString("*:distort*", true)) {
-
-
+ // TODO: Implement ActionDistort
} else if (line.matchString("*:enable_control*", true)) {
actionList.push_back(new ActionEnableControl(line));
} else if (line.matchString("*:flush_mouse_events*", true)) {
-
-
+ // TODO: Implement ActionFlushMouseEvents
} else if (line.matchString("*:inventory*", true)) {
-
-
+ // TODO: Implement ActionInventory
} else if (line.matchString("*:kill*", true)) {
-
-
+ // TODO: Implement ActionKill
} else if (line.matchString("*:menu_bar_enable*", true)) {
-
-
+ // TODO: Implement ActionMenuBarEnable
} else if (line.matchString("*:music*", true)) {
actionList.push_back(new ActionMusic(line));
} else if (line.matchString("*:pan_track*", true)) {
-
-
+ // TODO: Implement ActionPanTrack
} else if (line.matchString("*:playpreload*", true)) {
-
-
+ // TODO: Implement ActionPlayPreload
} else if (line.matchString("*:preferences*", true)) {
-
-
+ // TODO: Implement ActionPreferences
} else if (line.matchString("*:quit*", true)) {
actionList.push_back(new ActionQuit());
} else if (line.matchString("*:random*", true)) {
-
-
+ // TODO: Implement ActionRandom
} else if (line.matchString("*:region*", true)) {
-
-
+ // TODO: Implement ActionRegion
} else if (line.matchString("*:restore_game*", true)) {
-
-
+ // TODO: Implement ActionRestoreGame
} else if (line.matchString("*:rotate_to*", true)) {
-
-
+ // TODO: Implement ActionRotateTo
} else if (line.matchString("*:save_game*", true)) {
-
-
+ // TODO: Implement ActionSaveGame
} else if (line.matchString("*:set_partial_screen*", true)) {
-
-
+ actionList.push_back(new ActionSetPartialScreen(line));
} else if (line.matchString("*:set_screen*", true)) {
actionList.push_back(new ActionSetScreen(line));
} else if (line.matchString("*:set_venus*", true)) {
-
-
+ // TODO: Implement ActionSetVenus
} else if (line.matchString("*:stop*", true)) {
-
-
+ // TODO: Implement ActionStop
} else if (line.matchString("*:streamvideo*", true)) {
actionList.push_back(new ActionStreamVideo(line));
} else if (line.matchString("*:syncsound*", true)) {
-
-
+ // TODO: Implement ActionSyncSound
} else if (line.matchString("*:timer*", true)) {
-
-
+ // TODO: Implement ActionTimer
} else if (line.matchString("*:ttytext*", true)) {
-
-
+ // TODO: Implement ActionTTYText
} else if (line.matchString("*:universe_music*", true)) {
-
-
+ // TODO: Implement ActionUniverseMusic
} else if (line.matchString("*:copy_file*", true)) {
// Not used. Purposely left empty
} else {
diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h
new file mode 100644
index 0000000..00eeef2
--- /dev/null
+++ b/engines/zvision/subtitles.h
@@ -0,0 +1,29 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_SUBTITLES_H
+#define ZVISION_SUBTITLES_H
+
+// Implement Subtitles
+
+#endif
\ No newline at end of file
Commit: ad5756fa31113b88fb486c679adfe2197daeca08
https://github.com/scummvm/scummvm/commit/ad5756fa31113b88fb486c679adfe2197daeca08
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:48:34-07:00
Commit Message:
ZVISION: Add a destructor to Puzzle
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 227183a..371af83 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -27,11 +27,17 @@
#include "common/list.h"
#include "common/ptr.h"
-namespace ZVision {
+#include "zvision/actions.h"
-class ResultAction;
+namespace ZVision {
struct Puzzle {
+ ~Puzzle() {
+ for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+ delete (*iter);
+ }
+ }
+
/** How criteria should be decided */
enum CriteriaOperator {
EQUAL_TO,
Commit: 35622827f8e8b507e6c2450773857975f2864a56
https://github.com/scummvm/scummvm/commit/35622827f8e8b507e6c2450773857975f2864a56
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:50:14-07:00
Commit Message:
ZVISION: Store the Puzzles in _activePuzzles and _globalPuzzles on the heap
This allows List::push_back() to not cause a data copy
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 f4d4563..7ccd939 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -52,8 +52,8 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
continue;
if (line.matchString("puzzle:*", true)) {
- Puzzle puzzle;
- sscanf(line.c_str(),"puzzle:%u",&(puzzle.key));
+ Puzzle *puzzle = new Puzzle();
+ sscanf(line.c_str(),"puzzle:%u",&(puzzle->key));
parsePuzzle(puzzle, file);
if (isGlobal) {
@@ -67,17 +67,17 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
}
}
-void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
+void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("criteria {", true)) {
- parseCriteria(stream, puzzle.criteriaList);
+ parseCriteria(stream, puzzle->criteriaList);
} else if (line.matchString("results {", true)) {
- parseResults(stream, puzzle.resultActions);
+ parseResults(stream, puzzle->resultActions);
} else if (line.matchString("flags {", true)) {
- puzzle.flags = parseFlags(stream);
+ puzzle->flags = parseFlags(stream);
}
line = stream.readLine();
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 6a1794d..390fe0d 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -41,6 +41,15 @@ ScriptManager::ScriptManager(ZVision *engine)
_changeLocation(false) {
}
+ScriptManager::~ScriptManager() {
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ delete (*iter);
+ }
+ for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ delete (*iter);
+ }
+}
+
void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
changeLocation('g', 'a', 'r', 'y', 0);
@@ -58,11 +67,11 @@ void ScriptManager::update(uint deltaTimeMillis) {
void ScriptManager::createReferenceTable() {
// Iterate through each local Puzzle
- for (Common::List<Puzzle>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
- Puzzle *puzzlePtr = &(*activePuzzleIter);
+ for (Common::List<Puzzle *>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
+ Puzzle *puzzlePtr = (*activePuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); criteriaIter++) {
for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
@@ -75,11 +84,11 @@ void ScriptManager::createReferenceTable() {
}
// Iterate through each global Puzzle
- for (Common::List<Puzzle>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
- Puzzle *puzzlePtr = &(*globalPuzzleIter);
+ for (Common::List<Puzzle *>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
+ Puzzle *puzzlePtr = (*globalPuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = globalPuzzleIter->criteriaList.begin(); criteriaIter != (*globalPuzzleIter).criteriaList.end(); criteriaIter++) {
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); criteriaIter++) {
for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
@@ -263,23 +272,23 @@ void ScriptManager::changeLocationIntern() {
}
// Add all the local puzzles to the queue to be checked
- for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
- if (((*iter).flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
- setStateValue((*iter).key, 0);
+ if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
+ setStateValue((*iter)->key, 0);
}
- _puzzlesToCheck.push(&(*iter));
+ _puzzlesToCheck.push((*iter));
}
// Add all the global puzzles to the queue to be checked
- for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
// Reset any Puzzles that have the flag ONCE_PER_INST
- if (((*iter).flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
- setStateValue((*iter).key, 0);
+ if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
+ setStateValue((*iter)->key, 0);
}
- _puzzlesToCheck.push(&(*iter));
+ _puzzlesToCheck.push((*iter));
}
// Create the puzzle reference table
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 884699a..2372703 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -50,6 +50,7 @@ struct Location {
class ScriptManager {
public:
ScriptManager(ZVision *engine);
+ ~ScriptManager();
private:
ZVision *_engine;
@@ -66,9 +67,9 @@ private:
/** Holds the Puzzles that should be checked this frame */
Common::Queue<Puzzle *> _puzzlesToCheck;
/** Holds the currently active puzzles */
- Common::List<Puzzle> _activePuzzles;
+ Common::List<Puzzle *> _activePuzzles;
/** Holds the global puzzles */
- Common::List<Puzzle>_globalPuzzles;
+ Common::List<Puzzle *>_globalPuzzles;
/** Holds the currently active controls */
Common::HashMap<uint32, Control *> _activeControls;
@@ -112,7 +113,7 @@ private:
* @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);
/**
* Parses the stream into a Criteria object
Commit: 8e22af36b7e1500fa8ccca971225d87066cb9e26
https://github.com/scummvm/scummvm/commit/8e22af36b7e1500fa8ccca971225d87066cb9e26
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:51:00-07:00
Commit Message:
ZVISION: Add TODO to subtitles
Changed paths:
engines/zvision/subtitles.h
diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h
index 00eeef2..e8810832 100644
--- a/engines/zvision/subtitles.h
+++ b/engines/zvision/subtitles.h
@@ -24,6 +24,6 @@
#ifndef ZVISION_SUBTITLES_H
#define ZVISION_SUBTITLES_H
-// Implement Subtitles
+// TODO: Implement Subtitles
#endif
\ No newline at end of file
Commit: ac7b2251bb3cb41b10d2b69b3d3540895db057d8
https://github.com/scummvm/scummvm/commit/ac7b2251bb3cb41b10d2b69b3d3540895db057d8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T18:55:00-07:00
Commit Message:
ZVISION: Delete Puzzles from heap before clearing _activePuzzles
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 390fe0d..c217cb8 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -248,6 +248,9 @@ void ScriptManager::changeLocationIntern() {
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ delete (*iter);
+ }
_activePuzzles.clear();
// We can clear without deleting from the heap because we use SharedPtr
_activeControls.clear();
Commit: fa7fb2e029adec318cf963292b4b9b375189b487
https://github.com/scummvm/scummvm/commit/fa7fb2e029adec318cf963292b4b9b375189b487
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T19:26:53-07:00
Commit Message:
ZVISION: Initialize Puzzle::key and Puzzle::flags
Some Puzzles don't have flags, which caused it to never be initialized
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 371af83..512a963 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -32,6 +32,8 @@
namespace ZVision {
struct Puzzle {
+ Puzzle() : key(0), flags(0) {}
+
~Puzzle() {
for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
delete (*iter);
Commit: ca5066db526d3fc8cc9f45f494da29a34bd41537
https://github.com/scummvm/scummvm/commit/ca5066db526d3fc8cc9f45f494da29a34bd41537
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T21:04:16-07:00
Commit Message:
ZVISION: Remove static Control::parsePushToggleControl
The code was moved to the class PushToggleControl
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 106d938..94e0c47 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -165,8 +165,4 @@ bool PushToggleControl::disable(ZVision *engine) {
return false;
}
-void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
-
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index e3cb0d4..32a2b86 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -53,7 +53,6 @@ public:
static void parseFlatControl(ZVision *engine);
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
- static void parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream);
};
class PushToggleControl : public Control {
Commit: 25f95ebdcd2c269cf4016748dc51584aaa9125c5
https://github.com/scummvm/scummvm/commit/25f95ebdcd2c269cf4016748dc51584aaa9125c5
Author: richiesams (adastley at gmail.com)
Date: 2013-08-20T21:05:01-07:00
Commit Message:
ZVISION: Implement streaming support for RlfAnimations
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 90086e9..2b37ff1 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -33,8 +33,10 @@
namespace ZVision {
-RlfAnimation::RlfAnimation(const Common::String &fileName)
- : _frameCount(0),
+RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
+ : _stream(stream),
+ _lastFrameRead(0),
+ _frameCount(0),
_width(0),
_height(0),
_frameTime(0),
@@ -42,84 +44,25 @@ RlfAnimation::RlfAnimation(const Common::String &fileName)
_currentFrameBuffer(0),
_currentFrame(-1),
_frameBufferByteSize(0) {
- Common::File file;
- if (!file.open(fileName)) {
+ if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
return;
}
- if (file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
+ if (!readHeader()) {
warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str());
return;
}
- // Read the header
- file.readUint32LE(); // Size1
- file.readUint32LE(); // Unknown1
- file.readUint32LE(); // Unknown2
- _frameCount = file.readUint32LE(); // Frame count
-
- // Since we don't need any of the data, we can just seek right to the
- // entries we need rather than read in all the individual entries.
- file.seek(136, SEEK_CUR);
-
- //// Read CIN header
- //file.readUint32BE(); // Magic number FNIC
- //file.readUint32LE(); // Size2
- //file.readUint32LE(); // Unknown3
- //file.readUint32LE(); // Unknown4
- //file.readUint32LE(); // Unknown5
- //file.seek(0x18, SEEK_CUR); // VRLE
- //file.readUint32LE(); // LRVD
- //file.readUint32LE(); // Unknown6
- //file.seek(0x18, SEEK_CUR); // HRLE
- //file.readUint32LE(); // ELHD
- //file.readUint32LE(); // Unknown7
- //file.seek(0x18, SEEK_CUR); // HKEY
- //file.readUint32LE(); // ELRH
-
- //// Read MIN info header
- //file.readUint32BE(); // Magic number FNIM
- //file.readUint32LE(); // Size3
- //file.readUint32LE(); // OEDV
- //file.readUint32LE(); // Unknown8
- //file.readUint32LE(); // Unknown9
- //file.readUint32LE(); // Unknown10
- _width = file.readUint32LE(); // Width
- _height = file.readUint32LE(); // Height
-
- // Read time header
- file.readUint32BE(); // Magic number EMIT
- file.readUint32LE(); // Size4
- file.readUint32LE(); // Unknown11
- _frameTime = file.readUint32LE() / 10; // Frame time in microseconds
-
- _frames = new Frame[_frameCount];
_currentFrameBuffer = new uint16[_width * _height];
_frameBufferByteSize = _width * _height * sizeof(uint16);
- // Read in each frame
- for (uint i = 0; i < _frameCount; i++) {
- file.readUint32BE(); // Magic number MARF
- uint32 size = file.readUint32LE(); // Size
- file.readUint32LE(); // Unknown1
- file.readUint32LE(); // Unknown2
- uint32 type = file.readUint32BE(); // Either ELHD or ELRH
- uint32 headerSize = file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
- file.readUint32LE(); // Unknown3
-
- _frames[i].encodedSize = size - headerSize;
- _frames[i].encodedData = new int8[_frames[i].encodedSize];
- file.read(_frames[i].encodedData, _frames[i].encodedSize);
-
- if (type == MKTAG('E', 'L', 'H', 'D')) {
- _frames[i].type = Masked;
- } else if (type == MKTAG('E', 'L', 'R', 'H')) {
- _frames[i].type = Simple;
- _completeFrames.push_back(i);
- } else {
- warning("Frame %u of %s doesn't have type that can be decoded", i, fileName.c_str());
- return;
+ if (!stream) {
+ _frames = new Frame[_frameCount];
+
+ // Read in each frame
+ for (uint i = 0; i < _frameCount; i++) {
+ _frames[i] = readNextFrame();
}
}
};
@@ -133,7 +76,85 @@ RlfAnimation::~RlfAnimation() {
}
}
+bool RlfAnimation::readHeader() {
+ if (_file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
+ return false;
+ }
+
+ // Read the header
+ _file.readUint32LE(); // Size1
+ _file.readUint32LE(); // Unknown1
+ _file.readUint32LE(); // Unknown2
+ _frameCount = _file.readUint32LE(); // Frame count
+
+ // Since we don't need any of the data, we can just seek right to the
+ // entries we need rather than read in all the individual entries.
+ _file.seek(136, SEEK_CUR);
+
+ //// Read CIN header
+ //_file.readUint32BE(); // Magic number FNIC
+ //_file.readUint32LE(); // Size2
+ //_file.readUint32LE(); // Unknown3
+ //_file.readUint32LE(); // Unknown4
+ //_file.readUint32LE(); // Unknown5
+ //_file.seek(0x18, SEEK_CUR); // VRLE
+ //_file.readUint32LE(); // LRVD
+ //_file.readUint32LE(); // Unknown6
+ //_file.seek(0x18, SEEK_CUR); // HRLE
+ //_file.readUint32LE(); // ELHD
+ //_file.readUint32LE(); // Unknown7
+ //_file.seek(0x18, SEEK_CUR); // HKEY
+ //_file.readUint32LE(); // ELRH
+
+ //// Read MIN info header
+ //_file.readUint32BE(); // Magic number FNIM
+ //_file.readUint32LE(); // Size3
+ //_file.readUint32LE(); // OEDV
+ //_file.readUint32LE(); // Unknown8
+ //_file.readUint32LE(); // Unknown9
+ //_file.readUint32LE(); // Unknown10
+ _width = _file.readUint32LE(); // Width
+ _height = _file.readUint32LE(); // Height
+
+ // Read time header
+ _file.readUint32BE(); // Magic number EMIT
+ _file.readUint32LE(); // Size4
+ _file.readUint32LE(); // Unknown11
+ _frameTime = _file.readUint32LE() / 10; // Frame time in microseconds
+
+ return true;
+}
+
+RlfAnimation::Frame RlfAnimation::readNextFrame() {
+ RlfAnimation::Frame frame;
+
+ _file.readUint32BE(); // Magic number MARF
+ uint32 size = _file.readUint32LE(); // Size
+ _file.readUint32LE(); // Unknown1
+ _file.readUint32LE(); // Unknown2
+ uint32 type = _file.readUint32BE(); // Either ELHD or ELRH
+ uint32 headerSize = _file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
+ _file.readUint32LE(); // Unknown3
+
+ frame.encodedSize = size - headerSize;
+ frame.encodedData = new int8[frame.encodedSize];
+ _file.read(frame.encodedData, frame.encodedSize);
+
+ if (type == MKTAG('E', 'L', 'H', 'D')) {
+ frame.type = Masked;
+ } else if (type == MKTAG('E', 'L', 'R', 'H')) {
+ frame.type = Simple;
+ _completeFrames.push_back(_lastFrameRead);
+ } else {
+ warning("Frame %u doesn't have type that can be decoded", _lastFrameRead);
+ }
+
+ _lastFrameRead++;
+ return frame;
+}
+
const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
+ assert(!_stream);
assert(frameNumber < _frameCount && frameNumber >= 0);
if (frameNumber == _currentFrame) {
@@ -161,13 +182,29 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
}
}
+ _currentFrame = frameNumber;
return _currentFrameBuffer;
}
const uint16 *RlfAnimation::getNextFrame() {
assert(_currentFrame + 1 < _frameCount);
- applyFrameToCurrent(_currentFrame + 1);
+ if (_stream) {
+ applyFrameToCurrent(readNextFrame());
+ } else {
+ applyFrameToCurrent(_currentFrame + 1);
+ }
+
+ _currentFrame -= 1;
+ return _currentFrameBuffer;
+}
+
+const uint16 *RlfAnimation::getPreviousFrame() {
+ assert(!_stream);
+ assert(_currentFrame - 1 >= 0);
+
+ applyFrameToCurrent(_currentFrame - 1);
+ _currentFrame =- 1;
return _currentFrameBuffer;
}
@@ -177,8 +214,14 @@ void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
} else if (_frames[frameNumber].type == Simple) {
decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
}
+}
- _currentFrame = frameNumber;
+void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) {
+ if (frame.type == Masked) {
+ decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer, frame.encodedSize, _frameBufferByteSize);
+ } else if (frame.type == Simple) {
+ decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer, frame.encodedSize, _frameBufferByteSize);
+ }
}
void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index e204a50..09d0bac 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -23,6 +23,10 @@
#ifndef ZVISION_RLF_ANIMATION_H
#define ZVISION_RLF_ANIMATION_H
+#include "common/types.h"
+
+#include "common/file.h"
+
namespace Common {
class String;
@@ -32,7 +36,7 @@ namespace ZVision {
class RlfAnimation {
public:
- RlfAnimation(const Common::String &fileName);
+ RlfAnimation(const Common::String &fileName, bool stream = true);
~RlfAnimation();
private:
@@ -48,6 +52,10 @@ private:
};
private:
+ Common::File _file;
+ bool _stream;
+ uint _lastFrameRead;
+
uint _frameCount;
uint _width;
uint _height;
@@ -64,12 +72,20 @@ public:
uint width() { return _width; }
uint height() { return _height; }
uint32 frameTime() { return _frameTime; }
+
const uint16 *getFrameData(uint frameNumber);
+
const uint16 *getNextFrame();
+ const uint16 *getPreviousFrame();
+
bool endOfAnimation() { return _currentFrame == _frameCount - 1; }
private:
+ bool readHeader();
+ Frame readNextFrame();
+
void applyFrameToCurrent(uint frameNumber);
+ void applyFrameToCurrent(const RlfAnimation::Frame &frame);
void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
Commit: f759584d3b4bf802163fde9c721fda5c6f36ff4d
https://github.com/scummvm/scummvm/commit/f759584d3b4bf802163fde9c721fda5c6f36ff4d
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T21:50:33-07:00
Commit Message:
ZVISION: Make ZVision::_workingWindow and ZVision::_pixelFormat public
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 366e96f..844b8ad 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -64,6 +64,15 @@ public:
ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
~ZVision();
+public:
+ /**
+ * A Rectangle centered inside the actual window. All in-game coordinates
+ * are given in this coordinate space. Also, all images are clipped to the
+ * edges of this Rectangle
+ */
+ const Common::Rect _workingWindow;
+ const Graphics::PixelFormat _pixelFormat;
+
private:
enum {
WINDOW_WIDTH = 640,
@@ -72,18 +81,11 @@ private:
WORKING_WINDOW_HEIGHT = 320,
ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 150 // Pixels per second
+ MAX_ROTATION_SPEED = 250 // Pixels per second
};
Console *_console;
const ZVisionGameDescription *_gameDescription;
- /**
- * A Rectangle centered inside the actual window. All in-game coordinates
- * are given in this coordinate space. Also, all images are clipped to the
- * edges of this Rectangle
- */
- const Common::Rect _workingWindow;
- const Graphics::PixelFormat _pixelFormat;
const int _desiredFrameTime;
Commit: b28d502288fe96657fadbf9679f67601583036b3
https://github.com/scummvm/scummvm/commit/b28d502288fe96657fadbf9679f67601583036b3
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:01:42-07:00
Commit Message:
ZVISION: Convert ScriptManager::_activeNodes to normal pointers instead of SharedPtrs
Changed paths:
engines/zvision/actions.cpp
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 1649913..baa89aa 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -354,7 +354,7 @@ ActionTimer::ActionTimer(const Common::String &line) {
}
bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addActionNode(Common::SharedPtr<ActionNode>(new NodeTimer(_key, _time)));
+ engine->getScriptManager()->addActionNode(new TimerNode(engine, _key, _time));
return true;
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index c217cb8..9a4e9d1 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -108,9 +108,10 @@ void ScriptManager::createReferenceTable() {
void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
- for (Common::List<Common::SharedPtr<ActionNode> >::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
- if ((*iter)->process(_engine, deltaTimeMillis)) {
- // Remove the node from _activeNodes, the SharedPtr destructor will delete the actual ActionNode
+ for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) {
+ if ((*iter)->process(deltaTimeMillis)) {
+ // Delete the node then remove the pointer
+ delete (*iter);
iter = _activeNodes.erase(iter);
} else {
iter++;
@@ -223,11 +224,11 @@ bool ScriptManager::disableControl(uint32 key) {
if (!_activeControls.contains(key)) {
return false;
} else {
- return _activeControls[key]->disable(_engine);
+ return _activeControls[key]->disable();
}
}
-void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
+void ScriptManager::addActionNode(ActionNode *node) {
_activeNodes.push_back(node);
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 2372703..28bce07 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -61,7 +61,7 @@ private:
*/
Common::HashMap<uint32, uint> _globalState;
/** Holds the currently active ActionNodes */
- Common::List<Common::SharedPtr<ActionNode> > _activeNodes;
+ 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 */
@@ -88,7 +88,7 @@ public:
bool enableControl(uint32 key);
bool disableControl(uint32 key);
- void addActionNode(const Common::SharedPtr<ActionNode> &node);
+ void addActionNode(ActionNode *node);
void changeLocation(char world, char room, char node, char view, uint32 offset);
Commit: adb3bd7b711ba9daf62e06bbe55d2ca55e5219b4
https://github.com/scummvm/scummvm/commit/adb3bd7b711ba9daf62e06bbe55d2ca55e5219b4
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:11:46-07:00
Commit Message:
ZVISION: Make MouseEvent purely virtual
Changed paths:
R engines/zvision/mouse_event.cpp
engines/zvision/module.mk
engines/zvision/mouse_event.h
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 317e4b1..a4b7c68 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -12,7 +12,6 @@ MODULE_OBJS := \
detection.o \
events.o \
lzss_read_stream.o \
- mouse_event.o \
render_manager.o \
render_table.o \
rlf_animation.o \
diff --git a/engines/zvision/mouse_event.cpp b/engines/zvision/mouse_event.cpp
deleted file mode 100644
index a7c9fe5..0000000
--- a/engines/zvision/mouse_event.cpp
+++ /dev/null
@@ -1,45 +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"
-#include "zvision/script_manager.h"
-#include "zvision/mouse_event.h"
-
-namespace ZVision {
-
-MouseEvent::MouseEvent(uint32 key, const Common::Rect &hotspot, const Common::String hoverCursor)
- : _key(key),
- _hotspot(hotspot),
- _hoverCursor(hoverCursor) {
-}
-
-bool MouseEvent::withinHotspot(const Common::Point &point) {
- return _hotspot.contains(point);
-}
-
-void MouseEvent::onClick(ZVision *engine) {
- engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h
index 90a093f..fe81ada 100644
--- a/engines/zvision/mouse_event.h
+++ b/engines/zvision/mouse_event.h
@@ -35,37 +35,35 @@ class ZVision;
class MouseEvent {
public:
MouseEvent() : _key(0) {}
- MouseEvent(uint32 key, const Common::Rect &hotspot, const Common::String hoverCursor);
+ MouseEvent(uint32 key) : _key(key) {}
+ virtual ~MouseEvent() {}
- /** The Control key */
+public:
uint32 _key;
- /**
- * The area that will trigger the event
- * This is in image space coordinates, NOT screen space
- */
- Common::Rect _hotspot;
- /** The cursor to use when hovering over _hotspot */
- Common::String _hoverCursor;
+public:
/**
- * Does a simple Rect::contains() using _hotspot
+ * Called when LeftMouse is pushed.
*
- * @param point The point to check against _hotspot
- * @return The point is inside _hotspot (true) or not (false)
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
*/
- bool withinHotspot(const Common::Point &point);
+ virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
/**
- * Calls ScriptManager::setStateValue(_key, 1)
+ * Called when LeftMouse is lifted.
*
- * @param engine The base engine
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
*/
- void onClick(ZVision *engine);
+ virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
/**
- * Gets the name of the cursor that should be displayed when withinHotspot returns true
+ * Called on every MouseMove.
*
- * @return The name of the cursor. This should correspond to one of the names in CursorManager::_cursorNames[]
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
*/
- const Common::String getHoverCursor() { return _hoverCursor; }
+ virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
};
} // End of namespace ZVision
Commit: 2431f60c02197585bd252393a013f8e50a2ae30a
https://github.com/scummvm/scummvm/commit/2431f60c02197585bd252393a013f8e50a2ae30a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:32-07:00
Commit Message:
ZVISION: Make Control purely virtual
Changed paths:
engines/zvision/control.h
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 32a2b86..17408c7 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -37,13 +37,10 @@ class ZVision;
class Control {
public:
- Control() : _key(0), _enabled(false) {}
+ Control() : _enabled(false) {}
virtual ~Control() {}
- virtual bool enable(ZVision *engine) = 0;
- virtual bool disable(ZVision *engine) { return true; }
-
-public:
- uint32 _key;
+ virtual bool enable() = 0;
+ virtual bool disable() = 0;
protected:
bool _enabled;
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 9a4e9d1..d671c61 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -216,7 +216,7 @@ bool ScriptManager::enableControl(uint32 key) {
if (!_activeControls.contains(key)) {
return false;
} else {
- return _activeControls[key]->enable(_engine);
+ return _activeControls[key]->enable();
}
}
@@ -272,7 +272,7 @@ void ScriptManager::changeLocationIntern() {
// Enable all the controls
for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
- (*iter)._value->enable(_engine);
+ (*iter)._value->enable();
}
// Add all the local puzzles to the queue to be checked
Commit: 7095e613d59630ec03dbf8a17e18ae9b4aabf289
https://github.com/scummvm/scummvm/commit/7095e613d59630ec03dbf8a17e18ae9b4aabf289
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:40-07:00
Commit Message:
ZVISION: Keep a member variable ZVision pointer instead of passing it in every process()
Changed paths:
engines/zvision/action_node.cpp
engines/zvision/action_node.h
diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
index 1a51690..f51801a 100644
--- a/engines/zvision/action_node.cpp
+++ b/engines/zvision/action_node.cpp
@@ -28,14 +28,15 @@
namespace ZVision {
-NodeTimer::NodeTimer(uint32 key, uint timeInSeconds)
- : _key(key), _timeLeft(timeInSeconds * 1000) {}
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : _engine(engine), _key(key), _timeLeft(timeInSeconds * 1000) {
+}
-bool NodeTimer::process(ZVision *engine, uint32 deltaTimeInMillis) {
+bool TimerNode::process(uint32 deltaTimeInMillis) {
_timeLeft -= deltaTimeInMillis;
if (_timeLeft <= 0) {
- engine->getScriptManager()->setStateValue(_key, 0);
+ _engine->getScriptManager()->setStateValue(_key, 0);
return true;
}
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index 5b4430c..9a5ca0b 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -32,23 +32,29 @@ class ZVision;
class ActionNode {
public:
virtual ~ActionNode() {}
- virtual bool process(ZVision *engine, uint32 deltaTimeInMillis) = 0;
+ /**
+ * Processes the node given the deltaTime since last frame
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ virtual bool process(uint32 deltaTimeInMillis) = 0;
};
-class NodeTimer : public ActionNode {
+class TimerNode : public ActionNode {
public:
- NodeTimer(uint32 key, uint timeInSeconds);
+ TimerNode(ZVision *engine, 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
*
- * @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)
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
*/
- bool process(ZVision *engine, uint32 deltaTimeInMillis);
+ bool process(uint32 deltaTimeInMillis);
private:
+ ZVision *_engine;
uint32 _key;
uint32 _timeLeft;
};
Commit: 3054489a8bcc9604028ac16a0b074e13bff258eb
https://github.com/scummvm/scummvm/commit/3054489a8bcc9604028ac16a0b074e13bff258eb
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:41-07:00
Commit Message:
ZVISION: Have PushToggleControl inherit from MouseEvent and handle the methods internally.
Rather than creating an instance of MouseEvent and passing argument around.
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 94e0c47..ff76786 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -108,10 +108,9 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
// PushToggleControl
//////////////////////////////////////////////////////////////////////////////
-PushToggleControl::PushToggleControl(uint32 key, Common::SeekableReadStream &stream)
- : Control() {
- _event._key = _key = key;
-
+PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : MouseEvent(key),
+ _engine(engine) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -125,27 +124,27 @@ PushToggleControl::PushToggleControl(uint32 key, Common::SeekableReadStream &str
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
- _event._hotspot = Common::Rect(x, y, x + width, y + height);
+ _hotspot = Common::Rect(x, y, x + width, y + height);
} else if (line.matchString("cursor*", true)) {
char nameBuffer[25];
sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
- _event._hoverCursor = Common::String(nameBuffer);
+ _hoverCursor = Common::String(nameBuffer);
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
- if (_event._hotspot.isEmpty() || _event._hoverCursor.empty()) {
+ if (_hotspot.isEmpty() || _hoverCursor.empty()) {
warning("Push_toggle cursor %u was parsed incorrectly", key);
}
}
-bool PushToggleControl::enable(ZVision *engine) {
+bool PushToggleControl::enable() {
if (!_enabled) {
- engine->registerMouseEvent(_event);
+ _engine->registerMouseEvent(this);
_enabled = true;
return true;
}
@@ -154,9 +153,9 @@ bool PushToggleControl::enable(ZVision *engine) {
return false;
}
-bool PushToggleControl::disable(ZVision *engine) {
+bool PushToggleControl::disable() {
if (_enabled) {
- engine->removeMouseEvent(_key);
+ _engine->removeMouseEvent(_key);
_enabled = false;
return true;
}
@@ -165,4 +164,16 @@ bool PushToggleControl::disable(ZVision *engine) {
return false;
}
+void PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_hoverCursor);
+ return true;
+ }
+
+ return false;
+}
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 17408c7..28079d5 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -52,14 +52,51 @@ public:
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
};
-class PushToggleControl : public Control {
+
+class PushToggleControl : public Control, public MouseEvent {
+public:
+ PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ bool enable();
+ bool disable();
+
+ /**
+ * Called when LeftMouse is pushed. Calls ScriptManager::setStateValue(_key, 1);
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ /**
+ * Called when LeftMouse is lifted. Does nothing
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {}
+ /**
+ * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
+ *
+ * @param engine The base engine
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+
+private:
+ ZVision * _engine;
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _hotspot;
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+};
+
public:
- PushToggleControl(uint32 key, Common::SeekableReadStream &stream);
- bool enable(ZVision *engine);
- bool disable(ZVision *engine);
private:
- MouseEvent _event;
};
// TODO: Implement InputControl
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 7ccd939..921c1d5 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -278,7 +278,7 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
- _activeControls[key] = new PushToggleControl(key, stream);
+ _activeControls[key] = new PushToggleControl(_engine, key, stream);
return;
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
Commit: 0da3d3e5eb3c332f943a63fea4e3777fb24ba577
https://github.com/scummvm/scummvm/commit/0da3d3e5eb3c332f943a63fea4e3777fb24ba577
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:41-07:00
Commit Message:
ZVISION: Convert _mouseEvents to pointers since MouseEvent is now abstract
Changed paths:
engines/zvision/events.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 798d75b..f751d02 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -37,14 +37,14 @@
namespace ZVision {
-void ZVision::registerMouseEvent(const MouseEvent &event) {
+void ZVision::registerMouseEvent(MouseEvent *event) {
_mouseEvents.push_back(event);
}
bool ZVision::removeMouseEvent(const uint32 key) {
- for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- if ((*iter)._key == key) {
- _scriptManager->setStateValue((*iter)._key, 0);
+ for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ if ((*iter)->_key == key) {
+ _scriptManager->setStateValue((*iter)->_key, 0);
_mouseEvents.erase(iter);
return true;
}
@@ -55,8 +55,10 @@ bool ZVision::removeMouseEvent(const uint32 key) {
void ZVision::clearAllMouseEvents() {
// Clear the state values of all the events
- for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- _scriptManager->setStateValue((*iter)._key, 0);
+ // Then delete the nodes
+ for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ _scriptManager->setStateValue((*iter)->_key, 0);
+ delete (*iter);
}
_mouseEvents.clear();
@@ -117,6 +119,12 @@ void ZVision::processEvents() {
void ZVision::onMouseDown(const Common::Point &pos) {
_cursorManager->cursorDown(true);
+
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
+
+ for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ (*iter)->onMouseDown(pos, imageCoord);
+ }
}
void ZVision::onMouseUp(const Common::Point &pos) {
@@ -124,10 +132,8 @@ void ZVision::onMouseUp(const Common::Point &pos) {
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- if (iter->withinHotspot(imageCoord)) {
- iter->onClick(this);
- }
+ for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ (*iter)->onMouseUp(pos, imageCoord);
}
}
@@ -135,13 +141,8 @@ void ZVision::onMouseMove(const Common::Point &pos) {
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
bool isWithinAHotspot = false;
- if (_workingWindow.contains(pos)) {
- for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- if (iter->withinHotspot(imageCoord)) {
- _cursorManager->changeCursor(iter->getHoverCursor());
- isWithinAHotspot = true;
- }
- }
+ for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
+ cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(pos, imageCoord);
}
// Graph of the function governing rotation velocity:
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 844b8ad..84e4da9 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -101,7 +101,7 @@ private:
Clock _clock;
// To store the current mouse events
- Common::List<MouseEvent> _mouseEvents;
+ Common::List<MouseEvent *> _mouseEvents;
// To prevent allocation every time we process events
Common::Event _event;
@@ -137,7 +137,7 @@ public:
*
* @param event The event to register
*/
- void registerMouseEvent(const MouseEvent &event);
+ void registerMouseEvent(MouseEvent *event);
bool removeMouseEvent(const uint32 key);
Commit: aed38867ceb4fc13f221322aae15054fece7cff2
https://github.com/scummvm/scummvm/commit/aed38867ceb4fc13f221322aae15054fece7cff2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:42-07:00
Commit Message:
ZVISION: Change variable name to match its purpose
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index f751d02..94e8f08 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -140,7 +140,7 @@ void ZVision::onMouseUp(const Common::Point &pos) {
void ZVision::onMouseMove(const Common::Point &pos) {
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- bool isWithinAHotspot = false;
+ bool cursorWasChanged = false;
for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(pos, imageCoord);
}
@@ -184,14 +184,14 @@ void ZVision::onMouseMove(const Common::Point &pos) {
Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED;
_renderManager->setBackgroundVelocity(velocity.toInt());
_cursorManager->setLeftCursor();
- isWithinAHotspot = true;
+ cursorWasChanged = true;
} else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) {
// Linear function of distance to the right edge (y = mx)
// We use fixed point math to get better accuracy
Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET);
_renderManager->setBackgroundVelocity(velocity.toInt());
_cursorManager->setRightCursor();
- isWithinAHotspot = true;
+ cursorWasChanged = true;
} else {
_renderManager->setBackgroundVelocity(0);
}
@@ -202,14 +202,14 @@ void ZVision::onMouseMove(const Common::Point &pos) {
Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED;
_renderManager->setBackgroundVelocity(velocity.toInt());
_cursorManager->setUpCursor();
- isWithinAHotspot = true;
+ cursorWasChanged = true;
} else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) {
// Linear function of distance to the bottom edge (y = mx)
// We use fixed point math to get better accuracy
Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET);
_renderManager->setBackgroundVelocity(velocity.toInt());
_cursorManager->setDownCursor();
- isWithinAHotspot = true;
+ cursorWasChanged = true;
} else {
_renderManager->setBackgroundVelocity(0);
}
@@ -218,7 +218,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
_renderManager->setBackgroundVelocity(0);
}
- if (!isWithinAHotspot) {
+ if (!cursorWasChanged) {
_cursorManager->revertToIdle();
}
}
Commit: 6610ca1b82a1e335eecf139aaa4ba062574f48b7
https://github.com/scummvm/scummvm/commit/6610ca1b82a1e335eecf139aaa4ba062574f48b7
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:42-07:00
Commit Message:
ZVISION: Fix error: decrementing instead of incrementing
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 2b37ff1..52ca96f 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -195,7 +195,7 @@ const uint16 *RlfAnimation::getNextFrame() {
applyFrameToCurrent(_currentFrame + 1);
}
- _currentFrame -= 1;
+ _currentFrame++;
return _currentFrameBuffer;
}
@@ -204,7 +204,7 @@ const uint16 *RlfAnimation::getPreviousFrame() {
assert(_currentFrame - 1 >= 0);
applyFrameToCurrent(_currentFrame - 1);
- _currentFrame =- 1;
+ _currentFrame--;
return _currentFrameBuffer;
}
Commit: c6242e71344d260af49cf5b2368a16d8679aac45
https://github.com/scummvm/scummvm/commit/c6242e71344d260af49cf5b2368a16d8679aac45
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:43-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 09d0bac..d49e6a9 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -78,7 +78,7 @@ public:
const uint16 *getNextFrame();
const uint16 *getPreviousFrame();
- bool endOfAnimation() { return _currentFrame == _frameCount - 1; }
+ bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
private:
bool readHeader();
Commit: d2df3eb24ea68eec5538fac73829b168f747e7a6
https://github.com/scummvm/scummvm/commit/d2df3eb24ea68eec5538fac73829b168f747e7a6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:43-07:00
Commit Message:
ZVISION: Check if we can use getNextFrame() or getPreviousFrame() before using getFrameData()
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 52ca96f..5c0a88a 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -157,8 +157,14 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
assert(!_stream);
assert(frameNumber < _frameCount && frameNumber >= 0);
+ // Since this method is so expensive, first check to see if we can use
+ // getNextFrame() or getPreviousFrame() since they are cheap.
if (frameNumber == _currentFrame) {
return _currentFrameBuffer;
+ } else if (_currentFrame + 1 == frameNumber) {
+ return getNextFrame();
+ } else if (_currentFrame - 1 == frameNumber) {
+ return getPreviousFrame();
}
uint closestFrame = _currentFrame;
Commit: 0ed7df9a3632207d65f3aef11d5f07e185484207
https://github.com/scummvm/scummvm/commit/0ed7df9a3632207d65f3aef11d5f07e185484207
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:23:44-07:00
Commit Message:
ZVISION: Add TODO's about the verbosity of the frame decoding overflow warning
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 5c0a88a..905a540 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -247,6 +247,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
+ // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -264,6 +265,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
+ // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -290,6 +292,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
+ // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -314,6 +317,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
numberOfSamples += 2;
while (numberOfSamples > 0) {
if (destOffset + 1 >= destSize) {
+ // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
Commit: fc5727c522d4313ab1912a52898405d083c60363
https://github.com/scummvm/scummvm/commit/fc5727c522d4313ab1912a52898405d083c60363
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:24:43-07:00
Commit Message:
ZVISION: Fix memory leak
We no longer use SharedPtr
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index d671c61..bcede20 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -253,7 +253,9 @@ void ScriptManager::changeLocationIntern() {
delete (*iter);
}
_activePuzzles.clear();
- // We can clear without deleting from the heap because we use SharedPtr
+ for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ delete (*iter)._value;
+ }
_activeControls.clear();
_engine->clearAllMouseEvents();
Commit: a9db1e17124639dfbd856f59afbf396d3c60452b
https://github.com/scummvm/scummvm/commit/a9db1e17124639dfbd856f59afbf396d3c60452b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:25:01-07:00
Commit Message:
ZVISION: Add note about _activeNodes
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index bcede20..50d7e58 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -258,6 +258,7 @@ void ScriptManager::changeLocationIntern() {
}
_activeControls.clear();
_engine->clearAllMouseEvents();
+ // TODO: See if we need to clear _activeNodes as well. And if so, remember to delete the nodes before clearing the list
// Revert to the idle cursor
_engine->getCursorManager()->revertToIdle();
Commit: a596d1241cf0b443d3c2f8099546bc620116dcb2
https://github.com/scummvm/scummvm/commit/a596d1241cf0b443d3c2f8099546bc620116dcb2
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:25:21-07:00
Commit Message:
ZVISION: Add console method to dump all .lev files
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 69d19ab..fd8347e 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -53,6 +53,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
DCmd_Register("dumpcursorfilenames", WRAP_METHOD(Console, cmdDumpAllCursorFileNames));
DCmd_Register("showcursor", WRAP_METHOD(Console, cmdShowCursor));
+ DCmd_Register("dumpalllevfiles", WRAP_METHOD(Console, cmdDumpAllLevFiles));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -212,4 +213,16 @@ bool Console::cmdShowCursor(int argc, const char **argv) {
return true;
}
+bool Console::cmdDumpAllLevFiles(int argc, const char **argv) {
+ Common::ArchiveMemberList list;
+ SearchMan.listMatchingMembers(list, "*.lev");
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String fileName = (*iter)->getName();
+ writeFileContentsToFile(fileName, fileName);
+ }
+
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 995c418..e518467 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -49,6 +49,7 @@ private:
bool cmdDumpFile(int argc, const char **argv);
bool cmdDumpAllCursorFileNames(int argc, const char **argv);
bool cmdShowCursor(int argc, const char **argv);
+ bool cmdDumpAllLevFiles(int argc, const char **argv);
};
} // End of namespace ZVision
Commit: 7d48a3e4b129784c7870472cbbaf6fa9488fffe6
https://github.com/scummvm/scummvm/commit/7d48a3e4b129784c7870472cbbaf6fa9488fffe6
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:25:55-07:00
Commit Message:
ZVISION: Partially implement LeverControl
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index ff76786..9a1d52b 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -23,16 +23,25 @@
#include "common/scummsys.h"
#include "common/stream.h"
+#include "common/system.h"
+#include "common/tokenizer.h"
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
#include "zvision/render_table.h"
#include "zvision/script_manager.h"
+#include "zvision/cursor_manager.h"
#include "zvision/control.h"
#include "zvision/utility.h"
+#include "zvision/rlf_animation.h"
+#include "zvision/zork_avi_decoder.h"
namespace ZVision {
+//////////////////////////////////////////////////////////////////////////////
+// Static member functions
+//////////////////////////////////////////////////////////////////////////////
+
void Control::parseFlatControl(ZVision *engine) {
engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
}
@@ -176,4 +185,318 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
return false;
}
+
+//////////////////////////////////////////////////////////////////////////////
+// LeverControl
+//////////////////////////////////////////////////////////////////////////////
+
+LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : MouseEvent(key),
+ _engine(engine),
+ _frameInfo(0),
+ _frameCount(0),
+ _startFrame(0),
+ _currentFrame(0),
+ _mouseIsCaptured(false),
+ _isReturning(false) {
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.matchString("*descfile*", true)) {
+ char levFileName[25];
+ sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName);
+
+ parseLevFile(levFileName);
+ } else if (line.matchString("*cursor*", true)) {
+ char cursorName[25];
+ sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName);
+
+ _cursorName = Common::String(cursorName);
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ renderFrame(_currentFrame);
+
+ _engine->getScriptManager()->addActionNode(this);
+}
+
+LeverControl::~LeverControl() {
+ if (_fileType == AVI) {
+ delete _animation.avi;
+ } else if (_fileType == RLF) {
+ delete _animation.rlf;
+ }
+ if (_frameInfo != 0) {
+ delete[] _frameInfo;
+ }
+}
+
+void LeverControl::parseLevFile(const Common::String &fileName) {
+ Common::File file;
+ if (!file.open(fileName)) {
+ warning("LEV file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line = file.readLine();
+
+ while (!file.eos()) {
+ if (line.matchString("*animation_id*", true)) {
+ // Not used
+ } else if (line.matchString("*filename*", true)) {
+ char fileNameBuffer[25];
+ sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
+
+ Common::String fileName(fileNameBuffer);
+
+ if (fileName.hasSuffix(".avi")) {
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadFile(fileName);
+ } else if (fileName.hasSuffix(".rlf")) {
+ _animation.rlf = new RlfAnimation(fileNameBuffer, false);
+ }
+ } else if (line.matchString("*skipcolor*", true)) {
+ // Not used
+ } else if (line.matchString("*anim_coords*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u %u %u %u~", &_animationCoords.left, &_animationCoords.top, &_animationCoords.right, &_animationCoords.bottom);
+ } else if (line.matchString("*mirrored*", true)) {
+ uint mirrored;
+ sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
+
+ _mirrored = mirrored == 0 ? false : true;
+ } else if (line.matchString("*frames*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
+
+ _frameInfo = new FrameInfo[_frameCount];
+ } else if (line.matchString("*elsewhere*", true)) {
+ // Not used
+ } else if (line.matchString("*out_of_control*", true)) {
+ // Not used
+ } else if (line.matchString("*start_pos*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
+ _currentFrame = _startFrame;
+ } else if (line.matchString("*hotspot_deltas*", true)) {
+ uint x;
+ uint y;
+ sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
+
+ _hotspotDelta.x = x;
+ _hotspotDelta.y = y;
+ } else {
+ uint frameNumber;
+ uint x, y;
+
+ if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
+ _frameInfo[frameNumber].hotspot.left = x;
+ _frameInfo[frameNumber].hotspot.top = y;
+ _frameInfo[frameNumber].hotspot.right = x + _hotspotDelta.x;
+ _frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
+ }
+
+ Common::StringTokenizer tokenizer(line, " ^=");
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+
+ Common::String token = tokenizer.nextToken();
+ while (!tokenizer.empty()) {
+ if (token == "D") {
+ token = tokenizer.nextToken();
+
+ uint angle;
+ uint toFrame;
+ sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
+
+ _frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
+ } else if (token.hasPrefix("P")) {
+ uint to;
+ sscanf(token.c_str(), "P(%*u to %u)", &to);
+
+ _frameInfo[frameNumber].returnRoute.push_back(to);
+ }
+
+ token = tokenizer.nextToken();
+ }
+ }
+
+ line = file.readLine();
+ }
+}
+
+void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ _mouseIsCaptured = true;
+ _lastMousePos = backgroundImageSpacePos;
+ }
+}
+
+void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ _mouseIsCaptured = false;
+ _engine->getScriptManager()->setStateValue(_key, _currentFrame);
+
+ if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+
+ }
+
+ // TODO: Animation reversal back to origin
+}
+
+bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ bool cursorWasChanged = false;
+
+ if (_mouseIsCaptured) {
+ // Make sure the square distance between the last point and the current point is greater than 64
+ // This is a heuristic. This determines how responsive the lever is to mouse movement.
+ // TODO: Fiddle with the heuristic to get a good lever responsiveness 'feel'
+ if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 64) {
+ int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
+ _lastMousePos = backgroundImageSpacePos;
+
+ for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
+ if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle) {
+ _currentFrame = (*iter).toFrame;
+ renderFrame(_currentFrame);
+ break;
+ }
+ }
+ }
+ } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursorName);
+ }
+
+ return cursorWasChanged;
+}
+
+bool LeverControl::process(uint32 deltaTimeInMillis) {
+ // TODO: Implement reversal over time
+
+ return false;
+}
+
+int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo) {
+ // Check for the easy angles first
+ if (pointOne.x == pointTwo.x && pointOne.y == pointTwo.y)
+ return -1; // This should never happen
+ else if (pointOne.x == pointTwo.x) {
+ if (pointTwo.y > pointOne.y)
+ return 90;
+ else
+ return 270;
+ } else if (pointOne.y == pointTwo.y) {
+ if (pointTwo.x > pointOne.x)
+ return 0;
+ else
+ return 180;
+ } else {
+ // Calculate the angle with trig
+ int16 xDist = pointTwo.x - pointOne.x;
+ int16 yDist = pointTwo.y - pointOne.y;
+
+ int angle = int(atan((float)yDist / (float)xDist));
+
+ // Convert to degrees. (180 / 3.14159 = 57.2958)
+ angle *= 57;
+
+ // Calculate what quadrant pointTwo is in
+ uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
+
+ // Explanation of quadrants:
+ //
+ // yDist > 0 | xDist < 0 | Quadrant number
+ // 0 | 0 | 0
+ // 0 | 1 | 1
+ // 1 | 0 | 2
+ // 1 | 1 | 3
+ //
+ // Note: I know this doesn't line up with traditional mathematical quadrants
+ // but doing it this way allows you can use a switch and is a bit cleaner IMO.
+ //
+ // The graph below shows the 4 quadrants pointTwo can end up in as well
+ // as what the angle as calculated above refers to.
+ // Note: The calculated angle in quadrants 0 and 3 is negative
+ // due to arctan(-x) = -theta
+ //
+ // Origin => (pointOne.x, pointOne.y)
+ // * => (pointTwo.x, pointTwo.y)
+ //
+ // 90
+ // ^
+ // * | *
+ // \ | /
+ // \ | /
+ // \ | /
+ // Quadrant 3 \ | / Quadrant 2
+ // \ | /
+ // \ | /
+ // -angle ( \|/ ) angle
+ // 180 <----------------------------------------> 0
+ // angle ( /|\ ) -angle
+ // / | \
+ // / | \
+ // Quadrant 1 / | \ Quadrant 0
+ // / | \
+ // / | \
+ // / | \
+ // * | *
+ // ^
+ // 270
+
+ // Convert the local angles to unit circle angles
+ switch (quadrant) {
+ case 0:
+ angle = 360 + angle;
+ break;
+ case 1:
+ angle = 180 + angle;
+ break;
+ case 2:
+ angle = 180 + angle;
+ break;
+ case 3:
+ // Do nothing
+ break;
+ }
+
+ return angle;
+ }
+}
+
+void LeverControl::renderFrame(uint frameNumber) {
+ const uint16 *frameData;
+ int pitch;
+ int x;
+ int y;
+ int width;
+ int height;
+
+ if (_fileType == RLF) {
+ // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
+ frameData = _animation.rlf->getFrameData(_currentFrame);
+ pitch = _animation.rlf->width() * sizeof(uint16);
+ x = _animationCoords.left;
+ y = _animationCoords.right;
+ width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
+ height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
+ } else if (_fileType == AVI) {
+ // Cry because AVI seeking isn't implemented (yet)
+ }
+
+ _engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
+}
+
+bool LeverControl::enable() {
+ // TODO: Implement
+ return true;
+}
+
+bool LeverControl::disable() {
+ // TODO: Implement
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 28079d5..d764f91 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -26,6 +26,7 @@
#include "common/types.h"
#include "zvision/mouse_event.h"
+#include "zvision/action_node.h"
namespace Common {
class SeekableReadStream;
@@ -34,6 +35,8 @@ class SeekableReadStream;
namespace ZVision {
class ZVision;
+class RlfAnimation;
+class ZorkAVIDecoder;
class Control {
public:
@@ -94,15 +97,98 @@ private:
Common::String _hoverCursor;
};
+
+class LeverControl : public Control, public MouseEvent, public ActionNode {
public:
+ LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~LeverControl();
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+ struct Direction {
+ Direction(uint angle, uint toFrame) : angle(angle), toFrame(toFrame) {}
+
+ uint angle;
+ uint toFrame;
+ };
+
+ struct FrameInfo {
+ Common::Rect hotspot;
+ Common::List<Direction> directions;
+ Common::List<uint> returnRoute;
+ };
+
+ enum {
+ ANGLE_DELTA = 30 // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA)
+ };
private:
+ ZVision *_engine;
+
+ union {
+ RlfAnimation *rlf;
+ ZorkAVIDecoder *avi;
+ } _animation;
+ FileType _fileType;
+
+ Common::String _cursorName;
+ Common::Rect _animationCoords;
+ bool _mirrored;
+ uint _frameCount;
+ uint _startFrame;
+ Common::Point _hotspotDelta;
+ FrameInfo *_frameInfo;
+
+ uint _currentFrame;
+ bool _mouseIsCaptured;
+ bool _isReturning;
+ Common::Point _lastMousePos;
+ Common::List<uint>::iterator _returnRoutesCurrentProgress;
+
+public:
+ bool enable();
+ bool disable();
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ void parseLevFile(const Common::String &fileName);
+ /**
+ * Calculates the angle a vector makes with the negative y-axis
+ *
+ * 90
+ * pointTwo * ^
+ * \ |
+ * \ |
+ * \ |
+ * \ |
+ * angle ( \|pointOne
+ * 180 <-----------*-----------> 0
+ * |
+ * |
+ * |
+ * |
+ * |
+ * ^
+ * 270
+ *
+ * @param pointOne The origin of the vector
+ * @param pointTwo The end of the vector
+ * @return The angle the vector makes with the negative y-axis
+ */
+ static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
+ void renderFrame(uint frameNumber);
};
// TODO: Implement InputControl
// TODO: Implement SaveControl
// TODO: Implement SlotControl
-// TODO: Implement LeverControl
// TODO: Implement SafeControl
// TODO: Implement FistControl
// TODO: Implement HotMovieControl
Commit: af762dc41799bd08138a1f8fbcb7b441c4a03480
https://github.com/scummvm/scummvm/commit/af762dc41799bd08138a1f8fbcb7b441c4a03480
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T22:32:33-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 905a540..c95a864 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -159,11 +159,11 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
// Since this method is so expensive, first check to see if we can use
// getNextFrame() or getPreviousFrame() since they are cheap.
- if (frameNumber == _currentFrame) {
+ if ((int)frameNumber == _currentFrame) {
return _currentFrameBuffer;
- } else if (_currentFrame + 1 == frameNumber) {
+ } else if (_currentFrame + 1 == (int)frameNumber) {
return getNextFrame();
- } else if (_currentFrame - 1 == frameNumber) {
+ } else if (_currentFrame - 1 == (int)frameNumber) {
return getPreviousFrame();
}
Commit: 5ff032c27d5110ebd8b6f73e0c822eba2245246b
https://github.com/scummvm/scummvm/commit/5ff032c27d5110ebd8b6f73e0c822eba2245246b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T23:11:10-07:00
Commit Message:
ZVISION: Cast completeFrame and frameNumber to int so their difference can go negative
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index c95a864..ff855a1 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -168,9 +168,9 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
}
uint closestFrame = _currentFrame;
- uint distance = ABS(_currentFrame - frameNumber);
+ int distance = ABS(_currentFrame - (int)frameNumber);
for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) {
- uint newDistance = ABS((*iter) - frameNumber);
+ int newDistance = ABS((int)(*iter) - (int)frameNumber);
if (closestFrame == -1 || newDistance < distance) {
closestFrame = (*iter);
distance = newDistance;
Commit: 9d8243245c8b7f21333a54479a9c5354686faa03
https://github.com/scummvm/scummvm/commit/9d8243245c8b7f21333a54479a9c5354686faa03
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T23:11:25-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index ff855a1..6b6120f 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -193,7 +193,7 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
}
const uint16 *RlfAnimation::getNextFrame() {
- assert(_currentFrame + 1 < _frameCount);
+ assert(_currentFrame + 1 < (int)_frameCount);
if (_stream) {
applyFrameToCurrent(readNextFrame());
Commit: ff97bb2eadcd26abb9a085f266e33b76594d2a21
https://github.com/scummvm/scummvm/commit/ff97bb2eadcd26abb9a085f266e33b76594d2a21
Author: richiesams (adastley at gmail.com)
Date: 2013-08-23T23:47:12-07:00
Commit Message:
ZVISION: Move PushToggleControl and LeverControl to their own files
Changed paths:
A engines/zvision/lever_control.cpp
A engines/zvision/lever_control.h
A engines/zvision/push_toggle_control.cpp
A engines/zvision/push_toggle_control.h
engines/zvision/control.cpp
engines/zvision/control.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 9a1d52b..1cef2a0 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -23,24 +23,14 @@
#include "common/scummsys.h"
#include "common/stream.h"
-#include "common/system.h"
-#include "common/tokenizer.h"
+#include "zvision/control.h"
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
-#include "zvision/render_table.h"
-#include "zvision/script_manager.h"
-#include "zvision/cursor_manager.h"
-#include "zvision/control.h"
#include "zvision/utility.h"
-#include "zvision/rlf_animation.h"
-#include "zvision/zork_avi_decoder.h"
-namespace ZVision {
-//////////////////////////////////////////////////////////////////////////////
-// Static member functions
-//////////////////////////////////////////////////////////////////////////////
+namespace ZVision {
void Control::parseFlatControl(ZVision *engine) {
engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
@@ -112,391 +102,4 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
-
-//////////////////////////////////////////////////////////////////////////////
-// PushToggleControl
-//////////////////////////////////////////////////////////////////////////////
-
-PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : MouseEvent(key),
- _engine(engine) {
- // Loop until we find the closing brace
- Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
-
- while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*_hotspot*", true)) {
- uint x;
- uint y;
- uint width;
- uint height;
-
- sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
-
- _hotspot = Common::Rect(x, y, x + width, y + height);
- } else if (line.matchString("cursor*", true)) {
- char nameBuffer[25];
-
- sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
-
- _hoverCursor = Common::String(nameBuffer);
- }
-
- line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
- }
-
- if (_hotspot.isEmpty() || _hoverCursor.empty()) {
- warning("Push_toggle cursor %u was parsed incorrectly", key);
- }
-}
-
-bool PushToggleControl::enable() {
- if (!_enabled) {
- _engine->registerMouseEvent(this);
- _enabled = true;
- return true;
- }
-
- debug("Control %u is already enabled", _key);
- return false;
-}
-
-bool PushToggleControl::disable() {
- if (_enabled) {
- _engine->removeMouseEvent(_key);
- _enabled = false;
- return true;
- }
-
- debug("Control %u is already disabled", _key);
- return false;
-}
-
-void PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_hoverCursor);
- return true;
- }
-
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// LeverControl
-//////////////////////////////////////////////////////////////////////////////
-
-LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : MouseEvent(key),
- _engine(engine),
- _frameInfo(0),
- _frameCount(0),
- _startFrame(0),
- _currentFrame(0),
- _mouseIsCaptured(false),
- _isReturning(false) {
-
- // Loop until we find the closing brace
- Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
-
- while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*descfile*", true)) {
- char levFileName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName);
-
- parseLevFile(levFileName);
- } else if (line.matchString("*cursor*", true)) {
- char cursorName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName);
-
- _cursorName = Common::String(cursorName);
- }
-
- line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
- }
-
- renderFrame(_currentFrame);
-
- _engine->getScriptManager()->addActionNode(this);
-}
-
-LeverControl::~LeverControl() {
- if (_fileType == AVI) {
- delete _animation.avi;
- } else if (_fileType == RLF) {
- delete _animation.rlf;
- }
- if (_frameInfo != 0) {
- delete[] _frameInfo;
- }
-}
-
-void LeverControl::parseLevFile(const Common::String &fileName) {
- Common::File file;
- if (!file.open(fileName)) {
- warning("LEV file %s could could be opened", fileName.c_str());
- return;
- }
-
- Common::String line = file.readLine();
-
- while (!file.eos()) {
- if (line.matchString("*animation_id*", true)) {
- // Not used
- } else if (line.matchString("*filename*", true)) {
- char fileNameBuffer[25];
- sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
-
- Common::String fileName(fileNameBuffer);
-
- if (fileName.hasSuffix(".avi")) {
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
- } else if (fileName.hasSuffix(".rlf")) {
- _animation.rlf = new RlfAnimation(fileNameBuffer, false);
- }
- } else if (line.matchString("*skipcolor*", true)) {
- // Not used
- } else if (line.matchString("*anim_coords*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u %u %u %u~", &_animationCoords.left, &_animationCoords.top, &_animationCoords.right, &_animationCoords.bottom);
- } else if (line.matchString("*mirrored*", true)) {
- uint mirrored;
- sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
-
- _mirrored = mirrored == 0 ? false : true;
- } else if (line.matchString("*frames*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
-
- _frameInfo = new FrameInfo[_frameCount];
- } else if (line.matchString("*elsewhere*", true)) {
- // Not used
- } else if (line.matchString("*out_of_control*", true)) {
- // Not used
- } else if (line.matchString("*start_pos*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
- _currentFrame = _startFrame;
- } else if (line.matchString("*hotspot_deltas*", true)) {
- uint x;
- uint y;
- sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
-
- _hotspotDelta.x = x;
- _hotspotDelta.y = y;
- } else {
- uint frameNumber;
- uint x, y;
-
- if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
- _frameInfo[frameNumber].hotspot.left = x;
- _frameInfo[frameNumber].hotspot.top = y;
- _frameInfo[frameNumber].hotspot.right = x + _hotspotDelta.x;
- _frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
- }
-
- Common::StringTokenizer tokenizer(line, " ^=");
- tokenizer.nextToken();
- tokenizer.nextToken();
-
- Common::String token = tokenizer.nextToken();
- while (!tokenizer.empty()) {
- if (token == "D") {
- token = tokenizer.nextToken();
-
- uint angle;
- uint toFrame;
- sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
-
- _frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
- } else if (token.hasPrefix("P")) {
- uint to;
- sscanf(token.c_str(), "P(%*u to %u)", &to);
-
- _frameInfo[frameNumber].returnRoute.push_back(to);
- }
-
- token = tokenizer.nextToken();
- }
- }
-
- line = file.readLine();
- }
-}
-
-void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _mouseIsCaptured = true;
- _lastMousePos = backgroundImageSpacePos;
- }
-}
-
-void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- _mouseIsCaptured = false;
- _engine->getScriptManager()->setStateValue(_key, _currentFrame);
-
- if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
-
- }
-
- // TODO: Animation reversal back to origin
-}
-
-bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- bool cursorWasChanged = false;
-
- if (_mouseIsCaptured) {
- // Make sure the square distance between the last point and the current point is greater than 64
- // This is a heuristic. This determines how responsive the lever is to mouse movement.
- // TODO: Fiddle with the heuristic to get a good lever responsiveness 'feel'
- if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 64) {
- int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
- _lastMousePos = backgroundImageSpacePos;
-
- for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
- if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle) {
- _currentFrame = (*iter).toFrame;
- renderFrame(_currentFrame);
- break;
- }
- }
- }
- } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_cursorName);
- }
-
- return cursorWasChanged;
-}
-
-bool LeverControl::process(uint32 deltaTimeInMillis) {
- // TODO: Implement reversal over time
-
- return false;
-}
-
-int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo) {
- // Check for the easy angles first
- if (pointOne.x == pointTwo.x && pointOne.y == pointTwo.y)
- return -1; // This should never happen
- else if (pointOne.x == pointTwo.x) {
- if (pointTwo.y > pointOne.y)
- return 90;
- else
- return 270;
- } else if (pointOne.y == pointTwo.y) {
- if (pointTwo.x > pointOne.x)
- return 0;
- else
- return 180;
- } else {
- // Calculate the angle with trig
- int16 xDist = pointTwo.x - pointOne.x;
- int16 yDist = pointTwo.y - pointOne.y;
-
- int angle = int(atan((float)yDist / (float)xDist));
-
- // Convert to degrees. (180 / 3.14159 = 57.2958)
- angle *= 57;
-
- // Calculate what quadrant pointTwo is in
- uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
-
- // Explanation of quadrants:
- //
- // yDist > 0 | xDist < 0 | Quadrant number
- // 0 | 0 | 0
- // 0 | 1 | 1
- // 1 | 0 | 2
- // 1 | 1 | 3
- //
- // Note: I know this doesn't line up with traditional mathematical quadrants
- // but doing it this way allows you can use a switch and is a bit cleaner IMO.
- //
- // The graph below shows the 4 quadrants pointTwo can end up in as well
- // as what the angle as calculated above refers to.
- // Note: The calculated angle in quadrants 0 and 3 is negative
- // due to arctan(-x) = -theta
- //
- // Origin => (pointOne.x, pointOne.y)
- // * => (pointTwo.x, pointTwo.y)
- //
- // 90
- // ^
- // * | *
- // \ | /
- // \ | /
- // \ | /
- // Quadrant 3 \ | / Quadrant 2
- // \ | /
- // \ | /
- // -angle ( \|/ ) angle
- // 180 <----------------------------------------> 0
- // angle ( /|\ ) -angle
- // / | \
- // / | \
- // Quadrant 1 / | \ Quadrant 0
- // / | \
- // / | \
- // / | \
- // * | *
- // ^
- // 270
-
- // Convert the local angles to unit circle angles
- switch (quadrant) {
- case 0:
- angle = 360 + angle;
- break;
- case 1:
- angle = 180 + angle;
- break;
- case 2:
- angle = 180 + angle;
- break;
- case 3:
- // Do nothing
- break;
- }
-
- return angle;
- }
-}
-
-void LeverControl::renderFrame(uint frameNumber) {
- const uint16 *frameData;
- int pitch;
- int x;
- int y;
- int width;
- int height;
-
- if (_fileType == RLF) {
- // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- frameData = _animation.rlf->getFrameData(_currentFrame);
- pitch = _animation.rlf->width() * sizeof(uint16);
- x = _animationCoords.left;
- y = _animationCoords.right;
- width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
- height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
- } else if (_fileType == AVI) {
- // Cry because AVI seeking isn't implemented (yet)
- }
-
- _engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
-}
-
-bool LeverControl::enable() {
- // TODO: Implement
- return true;
-}
-
-bool LeverControl::disable() {
- // TODO: Implement
- return true;
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index d764f91..616589f 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,9 +25,6 @@
#include "common/types.h"
-#include "zvision/mouse_event.h"
-#include "zvision/action_node.h"
-
namespace Common {
class SeekableReadStream;
}
@@ -35,8 +32,6 @@ class SeekableReadStream;
namespace ZVision {
class ZVision;
-class RlfAnimation;
-class ZorkAVIDecoder;
class Control {
public:
@@ -55,137 +50,6 @@ public:
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
};
-
-class PushToggleControl : public Control, public MouseEvent {
-public:
- PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
- bool enable();
- bool disable();
-
- /**
- * Called when LeftMouse is pushed. Calls ScriptManager::setStateValue(_key, 1);
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- */
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- /**
- * Called when LeftMouse is lifted. Does nothing
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- */
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {}
- /**
- * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
- *
- * @param engine The base engine
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- * @return Was the cursor changed?
- */
- bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
-
-private:
- ZVision * _engine;
- /**
- * The area that will trigger the event
- * This is in image space coordinates, NOT screen space
- */
- Common::Rect _hotspot;
- /** The cursor to use when hovering over _hotspot */
- Common::String _hoverCursor;
-};
-
-
-class LeverControl : public Control, public MouseEvent, public ActionNode {
-public:
- LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
- ~LeverControl();
-
-private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
-
- struct Direction {
- Direction(uint angle, uint toFrame) : angle(angle), toFrame(toFrame) {}
-
- uint angle;
- uint toFrame;
- };
-
- struct FrameInfo {
- Common::Rect hotspot;
- Common::List<Direction> directions;
- Common::List<uint> returnRoute;
- };
-
- enum {
- ANGLE_DELTA = 30 // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA)
- };
-
-private:
- ZVision *_engine;
-
- union {
- RlfAnimation *rlf;
- ZorkAVIDecoder *avi;
- } _animation;
- FileType _fileType;
-
- Common::String _cursorName;
- Common::Rect _animationCoords;
- bool _mirrored;
- uint _frameCount;
- uint _startFrame;
- Common::Point _hotspotDelta;
- FrameInfo *_frameInfo;
-
- uint _currentFrame;
- bool _mouseIsCaptured;
- bool _isReturning;
- Common::Point _lastMousePos;
- Common::List<uint>::iterator _returnRoutesCurrentProgress;
-
-public:
- bool enable();
- bool disable();
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- bool process(uint32 deltaTimeInMillis);
-
-private:
- void parseLevFile(const Common::String &fileName);
- /**
- * Calculates the angle a vector makes with the negative y-axis
- *
- * 90
- * pointTwo * ^
- * \ |
- * \ |
- * \ |
- * \ |
- * angle ( \|pointOne
- * 180 <-----------*-----------> 0
- * |
- * |
- * |
- * |
- * |
- * ^
- * 270
- *
- * @param pointOne The origin of the vector
- * @param pointTwo The end of the vector
- * @return The angle the vector makes with the negative y-axis
- */
- static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
- void renderFrame(uint frameNumber);
-};
-
// TODO: Implement InputControl
// TODO: Implement SaveControl
// TODO: Implement SlotControl
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
new file mode 100644
index 0000000..34877cd
--- /dev/null
+++ b/engines/zvision/lever_control.cpp
@@ -0,0 +1,349 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "common/file.h"
+#include "common/tokenizer.h"
+#include "common/system.h"
+
+#include "zvision/lever_control.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/cursor_manager.h"
+#include "zvision/rlf_animation.h"
+#include "zvision/zork_avi_decoder.h"
+#include "zvision/utility.h"
+
+namespace ZVision {
+
+LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : MouseEvent(key),
+ _engine(engine),
+ _frameInfo(0),
+ _frameCount(0),
+ _startFrame(0),
+ _currentFrame(0),
+ _mouseIsCaptured(false),
+ _isReturning(false) {
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.matchString("*descfile*", true)) {
+ char levFileName[25];
+ sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName);
+
+ parseLevFile(levFileName);
+ } else if (line.matchString("*cursor*", true)) {
+ char cursorName[25];
+ sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName);
+
+ _cursorName = Common::String(cursorName);
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ renderFrame(_currentFrame);
+
+ _engine->getScriptManager()->addActionNode(this);
+}
+
+LeverControl::~LeverControl() {
+ if (_fileType == AVI) {
+ delete _animation.avi;
+ } else if (_fileType == RLF) {
+ delete _animation.rlf;
+ }
+ if (_frameInfo != 0) {
+ delete[] _frameInfo;
+ }
+}
+
+void LeverControl::parseLevFile(const Common::String &fileName) {
+ Common::File file;
+ if (!file.open(fileName)) {
+ warning("LEV file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line = file.readLine();
+
+ while (!file.eos()) {
+ if (line.matchString("*animation_id*", true)) {
+ // Not used
+ } else if (line.matchString("*filename*", true)) {
+ char fileNameBuffer[25];
+ sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
+
+ Common::String fileName(fileNameBuffer);
+
+ if (fileName.hasSuffix(".avi")) {
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadFile(fileName);
+ } else if (fileName.hasSuffix(".rlf")) {
+ _animation.rlf = new RlfAnimation(fileNameBuffer, false);
+ }
+ } else if (line.matchString("*skipcolor*", true)) {
+ // Not used
+ } else if (line.matchString("*anim_coords*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u %u %u %u~", &_animationCoords.left, &_animationCoords.top, &_animationCoords.right, &_animationCoords.bottom);
+ } else if (line.matchString("*mirrored*", true)) {
+ uint mirrored;
+ sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
+
+ _mirrored = mirrored == 0 ? false : true;
+ } else if (line.matchString("*frames*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
+
+ _frameInfo = new FrameInfo[_frameCount];
+ } else if (line.matchString("*elsewhere*", true)) {
+ // Not used
+ } else if (line.matchString("*out_of_control*", true)) {
+ // Not used
+ } else if (line.matchString("*start_pos*", true)) {
+ sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
+ _currentFrame = _startFrame;
+ } else if (line.matchString("*hotspot_deltas*", true)) {
+ uint x;
+ uint y;
+ sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
+
+ _hotspotDelta.x = x;
+ _hotspotDelta.y = y;
+ } else {
+ uint frameNumber;
+ uint x, y;
+
+ if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
+ _frameInfo[frameNumber].hotspot.left = x;
+ _frameInfo[frameNumber].hotspot.top = y;
+ _frameInfo[frameNumber].hotspot.right = x + _hotspotDelta.x;
+ _frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
+ }
+
+ Common::StringTokenizer tokenizer(line, " ^=");
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+
+ Common::String token = tokenizer.nextToken();
+ while (!tokenizer.empty()) {
+ if (token == "D") {
+ token = tokenizer.nextToken();
+
+ uint angle;
+ uint toFrame;
+ sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
+
+ _frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
+ } else if (token.hasPrefix("P")) {
+ uint to;
+ sscanf(token.c_str(), "P(%*u to %u)", &to);
+
+ _frameInfo[frameNumber].returnRoute.push_back(to);
+ }
+
+ token = tokenizer.nextToken();
+ }
+ }
+
+ line = file.readLine();
+ }
+}
+
+void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ _mouseIsCaptured = true;
+ _lastMousePos = backgroundImageSpacePos;
+ }
+}
+
+void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ _mouseIsCaptured = false;
+ _engine->getScriptManager()->setStateValue(_key, _currentFrame);
+
+ if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+
+ }
+
+ // TODO: Animation reversal back to origin
+}
+
+bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ bool cursorWasChanged = false;
+
+ if (_mouseIsCaptured) {
+ // Make sure the square distance between the last point and the current point is greater than 64
+ // This is a heuristic. This determines how responsive the lever is to mouse movement.
+ // TODO: Fiddle with the heuristic to get a good lever responsiveness 'feel'
+ if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 64) {
+ int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
+ _lastMousePos = backgroundImageSpacePos;
+
+ for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
+ if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle) {
+ _currentFrame = (*iter).toFrame;
+ renderFrame(_currentFrame);
+ break;
+ }
+ }
+ }
+ } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursorName);
+ }
+
+ return cursorWasChanged;
+}
+
+bool LeverControl::process(uint32 deltaTimeInMillis) {
+ // TODO: Implement reversal over time
+
+ return false;
+}
+
+int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo) {
+ // Check for the easy angles first
+ if (pointOne.x == pointTwo.x && pointOne.y == pointTwo.y)
+ return -1; // This should never happen
+ else if (pointOne.x == pointTwo.x) {
+ if (pointTwo.y > pointOne.y)
+ return 90;
+ else
+ return 270;
+ } else if (pointOne.y == pointTwo.y) {
+ if (pointTwo.x > pointOne.x)
+ return 0;
+ else
+ return 180;
+ } else {
+ // Calculate the angle with trig
+ int16 xDist = pointTwo.x - pointOne.x;
+ int16 yDist = pointTwo.y - pointOne.y;
+
+ int angle = int(atan((float)yDist / (float)xDist));
+
+ // Convert to degrees. (180 / 3.14159 = 57.2958)
+ angle *= 57;
+
+ // Calculate what quadrant pointTwo is in
+ uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
+
+ // Explanation of quadrants:
+ //
+ // yDist > 0 | xDist < 0 | Quadrant number
+ // 0 | 0 | 0
+ // 0 | 1 | 1
+ // 1 | 0 | 2
+ // 1 | 1 | 3
+ //
+ // Note: I know this doesn't line up with traditional mathematical quadrants
+ // but doing it this way allows you can use a switch and is a bit cleaner IMO.
+ //
+ // The graph below shows the 4 quadrants pointTwo can end up in as well
+ // as what the angle as calculated above refers to.
+ // Note: The calculated angle in quadrants 0 and 3 is negative
+ // due to arctan(-x) = -theta
+ //
+ // Origin => (pointOne.x, pointOne.y)
+ // * => (pointTwo.x, pointTwo.y)
+ //
+ // 90
+ // ^
+ // * | *
+ // \ | /
+ // \ | /
+ // \ | /
+ // Quadrant 3 \ | / Quadrant 2
+ // \ | /
+ // \ | /
+ // -angle ( \|/ ) angle
+ // 180 <----------------------------------------> 0
+ // angle ( /|\ ) -angle
+ // / | \
+ // / | \
+ // Quadrant 1 / | \ Quadrant 0
+ // / | \
+ // / | \
+ // / | \
+ // * | *
+ // ^
+ // 270
+
+ // Convert the local angles to unit circle angles
+ switch (quadrant) {
+ case 0:
+ angle = 360 + angle;
+ break;
+ case 1:
+ angle = 180 + angle;
+ break;
+ case 2:
+ angle = 180 + angle;
+ break;
+ case 3:
+ // Do nothing
+ break;
+ }
+
+ return angle;
+ }
+}
+
+void LeverControl::renderFrame(uint frameNumber) {
+ const uint16 *frameData;
+ int pitch;
+ int x;
+ int y;
+ int width;
+ int height;
+
+ if (_fileType == RLF) {
+ // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
+ frameData = _animation.rlf->getFrameData(_currentFrame);
+ pitch = _animation.rlf->width() * sizeof(uint16);
+ x = _animationCoords.left;
+ y = _animationCoords.right;
+ width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
+ height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
+ } else if (_fileType == AVI) {
+ // Cry because AVI seeking isn't implemented (yet)
+ }
+
+ _engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
+}
+
+bool LeverControl::enable() {
+ // TODO: Implement
+ return true;
+}
+
+bool LeverControl::disable() {
+ // TODO: Implement
+ return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
new file mode 100644
index 0000000..dbfd172
--- /dev/null
+++ b/engines/zvision/lever_control.h
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_PUSH_TOGGLE_CONTROL_H
+#define ZVISION_PUSH_TOGGLE_CONTROL_H
+
+#include "common/types.h"
+
+#include "common/list.h"
+
+#include "zvision/control.h"
+#include "zvision/mouse_event.h"
+#include "zvision/action_node.h"
+
+
+namespace ZVision {
+
+class ZorkAVIDecoder;
+class RlfAnimation;
+
+class LeverControl : public Control, public MouseEvent, public ActionNode {
+public:
+ LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~LeverControl();
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+ struct Direction {
+ Direction(uint angle, uint toFrame) : angle(angle), toFrame(toFrame) {}
+
+ uint angle;
+ uint toFrame;
+ };
+
+ struct FrameInfo {
+ Common::Rect hotspot;
+ Common::List<Direction> directions;
+ Common::List<uint> returnRoute;
+ };
+
+ enum {
+ ANGLE_DELTA = 30 // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA)
+ };
+
+private:
+ ZVision *_engine;
+
+ union {
+ RlfAnimation *rlf;
+ ZorkAVIDecoder *avi;
+ } _animation;
+ FileType _fileType;
+
+ Common::String _cursorName;
+ Common::Rect _animationCoords;
+ bool _mirrored;
+ uint _frameCount;
+ uint _startFrame;
+ Common::Point _hotspotDelta;
+ FrameInfo *_frameInfo;
+
+ uint _currentFrame;
+ bool _mouseIsCaptured;
+ bool _isReturning;
+ Common::Point _lastMousePos;
+ Common::List<uint>::iterator _returnRoutesCurrentProgress;
+
+public:
+ bool enable();
+ bool disable();
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ void parseLevFile(const Common::String &fileName);
+ /**
+ * Calculates the angle a vector makes with the negative y-axis
+ *
+ * 90
+ * pointTwo * ^
+ * \ |
+ * \ |
+ * \ |
+ * \ |
+ * angle ( \|pointOne
+ * 180 <-----------*-----------> 0
+ * |
+ * |
+ * |
+ * |
+ * |
+ * ^
+ * 270
+ *
+ * @param pointOne The origin of the vector
+ * @param pointTwo The end of the vector
+ * @return The angle the vector makes with the negative y-axis
+ */
+ static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
+ void renderFrame(uint frameNumber);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index a4b7c68..7412ad8 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -11,7 +11,9 @@ MODULE_OBJS := \
cursor_manager.o \
detection.o \
events.o \
+ lever_control.o \
lzss_read_stream.o \
+ push_toggle_control.o \
render_manager.o \
render_table.o \
rlf_animation.o \
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
new file mode 100644
index 0000000..9e68bdb
--- /dev/null
+++ b/engines/zvision/push_toggle_control.cpp
@@ -0,0 +1,104 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/stream.h"
+
+#include "zvision/push_toggle_control.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/cursor_manager.h"
+#include "zvision/utility.h"
+
+namespace ZVision {
+
+PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : MouseEvent(key),
+ _engine(engine) {
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.matchString("*_hotspot*", true)) {
+ uint x;
+ uint y;
+ uint width;
+ uint height;
+
+ sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
+
+ _hotspot = Common::Rect(x, y, x + width, y + height);
+ } else if (line.matchString("cursor*", true)) {
+ char nameBuffer[25];
+
+ sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
+
+ _hoverCursor = Common::String(nameBuffer);
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ if (_hotspot.isEmpty() || _hoverCursor.empty()) {
+ warning("Push_toggle cursor %u was parsed incorrectly", key);
+ }
+}
+
+ bool PushToggleControl::enable() {
+ if (!_enabled) {
+ _engine->registerMouseEvent(this);
+ _enabled = true;
+ return true;
+ }
+
+ debug("Control %u is already enabled", _key);
+ return false;
+ }
+
+ bool PushToggleControl::disable() {
+ if (_enabled) {
+ _engine->removeMouseEvent(_key);
+ _enabled = false;
+ return true;
+ }
+
+ debug("Control %u is already disabled", _key);
+ return false;
+ }
+
+ void PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ _engine->getScriptManager()->setStateValue(_key, 1);
+ }
+
+ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_hoverCursor);
+ return true;
+ }
+
+ return false;
+ }
+
+} // End of namespace ZVision
diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h
new file mode 100644
index 0000000..9384a43
--- /dev/null
+++ b/engines/zvision/push_toggle_control.h
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_PUSH_TOGGLE_CONTROL_H
+#define ZVISION_PUSH_TOGGLE_CONTROL_H
+
+#include "common/types.h"
+
+#include "zvision/control.h"
+#include "zvision/mouse_event.h"
+
+
+namespace ZVision {
+
+class PushToggleControl : public Control, public MouseEvent {
+public:
+ PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ bool enable();
+ bool disable();
+
+ /**
+ * Called when LeftMouse is pushed. Calls ScriptManager::setStateValue(_key, 1);
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ /**
+ * Called when LeftMouse is lifted. Does nothing
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {}
+ /**
+ * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
+ *
+ * @param engine The base engine
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+
+private:
+ ZVision * _engine;
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _hotspot;
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 921c1d5..c4aed70 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -26,6 +26,7 @@
#include "zvision/utility.h"
#include "zvision/puzzle.h"
#include "zvision/actions.h"
+#include "zvision/push_toggle_control.h"
#include "common/textconsole.h"
#include "common/file.h"
Commit: 5e1215837ae29899dbb759a55b3de10b3dc0bee8
https://github.com/scummvm/scummvm/commit/5e1215837ae29899dbb759a55b3de10b3dc0bee8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:18-07:00
Commit Message:
ZVISION: Fixed signed/unsigned mismatch
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index ac02cc2..fa45a6f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -66,7 +66,7 @@ void RenderManager::update(uint deltaTimeInMillis) {
if (_backgroundInverseVelocity != 0) {
_accumulatedVelocityMilliseconds += deltaTimeInMillis;
- int absVelocity = abs(_backgroundInverseVelocity);
+ uint absVelocity = uint(abs(_backgroundInverseVelocity));
int numberOfSteps = 0;
while (_accumulatedVelocityMilliseconds >= absVelocity) {
Commit: 52af1f7f1019ddb2f95d1cff034d58f3cffd224a
https://github.com/scummvm/scummvm/commit/52af1f7f1019ddb2f95d1cff034d58f3cffd224a
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:19-07:00
Commit Message:
ZVISION: Bake ActionNode and MouseEvent into Control
This makes memory management a lot easier as well as removes the need for
multiple lists that point to the same objects. However, there will be quite a few Controls
that don't need all the functionality of ActionNode and MouseEvent, so the default
implementations are No Op.
Changed paths:
R engines/zvision/mouse_event.h
engines/zvision/action_node.h
engines/zvision/control.h
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index 9a5ca0b..9df06c7 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -29,17 +29,6 @@ namespace ZVision {
class ZVision;
-class ActionNode {
-public:
- virtual ~ActionNode() {}
- /**
- * Processes the node given the deltaTime since last frame
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- virtual bool process(uint32 deltaTimeInMillis) = 0;
-};
class TimerNode : public ActionNode {
public:
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 616589f..8d4ea9f 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,8 +25,10 @@
#include "common/types.h"
+
namespace Common {
class SeekableReadStream;
+struct Point;
}
namespace ZVision {
@@ -35,12 +37,47 @@ class ZVision;
class Control {
public:
- Control() : _enabled(false) {}
+ Control() : _engine(0), _key(0), _enabled(false) {}
+ Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
virtual ~Control() {}
virtual bool enable() = 0;
virtual bool disable() = 0;
+ uint32 getKey() { return _key; }
+
+ /**
+ * Called when LeftMouse is pushed. Default is NOP.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {}
+ /**
+ * Called when LeftMouse is lifted. Default is NOP.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {}
+ /**
+ * Called on every MouseMove. Default is NOP.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { return false; }
+ /**
+ * Processes the node given the deltaTime since last frame. Default is NOP.
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ virtual bool process(uint32 deltaTimeInMillis) { return false; }
+
protected:
+ ZVision * _engine;
+ uint32 _key;
bool _enabled;
// Static member functions
diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h
deleted file mode 100644
index fe81ada..0000000
--- a/engines/zvision/mouse_event.h
+++ /dev/null
@@ -1,71 +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_MOUSE_EVENT_H
-#define ZVISION_MOUSE_EVENT_H
-
-#include "common/types.h"
-#include "common/rect.h"
-#include "common/str.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class MouseEvent {
-public:
- MouseEvent() : _key(0) {}
- MouseEvent(uint32 key) : _key(key) {}
- virtual ~MouseEvent() {}
-
-public:
- uint32 _key;
-
-public:
- /**
- * Called when LeftMouse is pushed.
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- */
- virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
- /**
- * Called when LeftMouse is lifted.
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- */
- virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
- /**
- * Called on every MouseMove.
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- * @return Was the cursor changed?
- */
- virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0;
-};
-
-} // End of namespace ZVision
-
-#endif
Commit: 93bc3570ea33e3f5d21d5b14fe081800f9c7e700
https://github.com/scummvm/scummvm/commit/93bc3570ea33e3f5d21d5b14fe081800f9c7e700
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:19-07:00
Commit Message:
ZVISION: Create the default implementation for Control::enable()/disable()
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 1cef2a0..ad0a4c5 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -32,6 +32,24 @@
namespace ZVision {
+void Control::enable() {
+ if (!_enabled) {
+ _enabled = true;
+ return;
+ }
+
+ debug("Control %u is already enabled", _key);
+}
+
+void Control::disable() {
+ if (_enabled) {
+ _enabled = false;
+ return;
+ }
+
+ debug("Control %u is already disabled", _key);
+}
+
void Control::parseFlatControl(ZVision *engine) {
engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
}
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 8d4ea9f..b16ca7f 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -40,11 +40,11 @@ public:
Control() : _engine(0), _key(0), _enabled(false) {}
Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
virtual ~Control() {}
- virtual bool enable() = 0;
- virtual bool disable() = 0;
uint32 getKey() { return _key; }
+ virtual void enable();
+ virtual void disable();
/**
* Called when LeftMouse is pushed. Default is NOP.
*
Commit: 3263ab7390fe2197983f28012cfc7199cd3ec500
https://github.com/scummvm/scummvm/commit/3263ab7390fe2197983f28012cfc7199cd3ec500
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:20-07:00
Commit Message:
ZVISION: Modify TimerNode to use Control base class
Changed paths:
engines/zvision/action_node.cpp
engines/zvision/action_node.h
engines/zvision/actions.cpp
diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
index f51801a..8e35460 100644
--- a/engines/zvision/action_node.cpp
+++ b/engines/zvision/action_node.cpp
@@ -29,7 +29,7 @@
namespace ZVision {
TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : _engine(engine), _key(key), _timeLeft(timeInSeconds * 1000) {
+ : Control(engine, key), _timeLeft(timeInSeconds * 1000) {
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
index 9df06c7..b0b8cae 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -25,14 +25,16 @@
#include "common/types.h"
+#include "zvision/control.h"
+
namespace ZVision {
class ZVision;
-
-class TimerNode : public ActionNode {
+class TimerNode : public Control {
public:
TimerNode(ZVision *engine, 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
@@ -43,8 +45,6 @@ public:
bool process(uint32 deltaTimeInMillis);
private:
- ZVision *_engine;
- uint32 _key;
uint32 _timeLeft;
};
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index baa89aa..d039f04 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -354,7 +354,7 @@ ActionTimer::ActionTimer(const Common::String &line) {
}
bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addActionNode(new TimerNode(engine, _key, _time));
+ engine->getScriptManager()->addControl(new TimerNode(engine, _key, _time));
return true;
}
Commit: 4d344cb5a8eb2f0b66262deb9b1ff6b9112e64d8
https://github.com/scummvm/scummvm/commit/4d344cb5a8eb2f0b66262deb9b1ff6b9112e64d8
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:20-07:00
Commit Message:
ZVISION: Change LeverControl to comply with the new Control base class
Changed paths:
engines/zvision/lever_control.cpp
engines/zvision/lever_control.h
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 34877cd..5d9ea4d 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -38,8 +38,7 @@
namespace ZVision {
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : MouseEvent(key),
- _engine(engine),
+ : Control(engine, key),
_frameInfo(0),
_frameCount(0),
_startFrame(0),
@@ -69,8 +68,6 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
renderFrame(_currentFrame);
-
- _engine->getScriptManager()->addActionNode(this);
}
LeverControl::~LeverControl() {
@@ -175,14 +172,14 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
}
-void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
}
}
-void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
_mouseIsCaptured = false;
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
@@ -193,7 +190,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
// TODO: Animation reversal back to origin
}
-bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
bool cursorWasChanged = false;
if (_mouseIsCaptured) {
@@ -336,14 +333,4 @@ void LeverControl::renderFrame(uint frameNumber) {
_engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
}
-bool LeverControl::enable() {
- // TODO: Implement
- return true;
-}
-
-bool LeverControl::disable() {
- // TODO: Implement
- return true;
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index dbfd172..42577a1 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -26,10 +26,9 @@
#include "common/types.h"
#include "common/list.h"
+#include "common/rect.h"
#include "zvision/control.h"
-#include "zvision/mouse_event.h"
-#include "zvision/action_node.h"
namespace ZVision {
@@ -37,7 +36,7 @@ namespace ZVision {
class ZorkAVIDecoder;
class RlfAnimation;
-class LeverControl : public Control, public MouseEvent, public ActionNode {
+class LeverControl : public Control {
public:
LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
~LeverControl();
@@ -66,8 +65,6 @@ private:
};
private:
- ZVision *_engine;
-
union {
RlfAnimation *rlf;
ZorkAVIDecoder *avi;
@@ -89,11 +86,9 @@ private:
Common::List<uint>::iterator _returnRoutesCurrentProgress;
public:
- bool enable();
- bool disable();
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool process(uint32 deltaTimeInMillis);
private:
Commit: 7fb024c7fccb58442440f06af1bbd32b95122d72
https://github.com/scummvm/scummvm/commit/7fb024c7fccb58442440f06af1bbd32b95122d72
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:21-07:00
Commit Message:
ZVISION: Change PushToggleControl to comply with new Control base class
Changed paths:
engines/zvision/push_toggle_control.cpp
engines/zvision/push_toggle_control.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 9e68bdb..be038e7 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -33,8 +33,7 @@
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : MouseEvent(key),
- _engine(engine) {
+ : Control(engine, key) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -66,39 +65,24 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
}
}
- bool PushToggleControl::enable() {
- if (!_enabled) {
- _engine->registerMouseEvent(this);
- _enabled = true;
- return true;
- }
-
- debug("Control %u is already enabled", _key);
- return false;
- }
-
- bool PushToggleControl::disable() {
- if (_enabled) {
- _engine->removeMouseEvent(_key);
- _enabled = false;
- return true;
- }
-
- debug("Control %u is already disabled", _key);
- return false;
- }
+PushToggleControl::~PushToggleControl() {
+ // Clear the state value back to 0
+ _engine->getScriptManager()->setStateValue(_key, 0);
+}
- void PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
+void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
}
+}
- bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {
- if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_hoverCursor);
- return true;
- }
-
- return false;
+bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_hoverCursor);
+ return true;
}
+ return false;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h
index 9384a43..8ab6f61 100644
--- a/engines/zvision/push_toggle_control.h
+++ b/engines/zvision/push_toggle_control.h
@@ -25,32 +25,25 @@
#include "common/types.h"
+#include "common/rect.h"
+
#include "zvision/control.h"
-#include "zvision/mouse_event.h"
namespace ZVision {
-class PushToggleControl : public Control, public MouseEvent {
+class PushToggleControl : public Control {
public:
PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
- bool enable();
- bool disable();
+ ~PushToggleControl();
/**
- * Called when LeftMouse is pushed. Calls ScriptManager::setStateValue(_key, 1);
- *
- * @param screenSpacePos The position of the mouse in screen space
- * @param backgroundImageSpacePos The position of the mouse in background image space
- */
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
- /**
- * Called when LeftMouse is lifted. Does nothing
+ * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1);
*
* @param screenSpacePos The position of the mouse in screen space
* @param backgroundImageSpacePos The position of the mouse in background image space
*/
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {}
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
/**
* Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
*
@@ -59,10 +52,9 @@ public:
* @param backgroundImageSpacePos The position of the mouse in background image space
* @return Was the cursor changed?
*/
- bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
private:
- ZVision * _engine;
/**
* The area that will trigger the event
* This is in image space coordinates, NOT screen space
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index c4aed70..212d714 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -279,7 +279,7 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
- _activeControls[key] = new PushToggleControl(_engine, key, stream);
+ _activeControls.push_back(new PushToggleControl(_engine, key, stream));
return;
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
Commit: e32f6f7e38a8fde2283dcefa2042056778cb4579
https://github.com/scummvm/scummvm/commit/e32f6f7e38a8fde2283dcefa2042056778cb4579
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:21-07:00
Commit Message:
ZVISION: Remove extraneous semicolon
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 6b6120f..f58aa0c 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -65,7 +65,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_frames[i] = readNextFrame();
}
}
-};
+}
RlfAnimation::~RlfAnimation() {
if (_frames != 0) {
Commit: a1d11054b52822e3d85e0ad88e6d2ebbbeca8518
https://github.com/scummvm/scummvm/commit/a1d11054b52822e3d85e0ad88e6d2ebbbeca8518
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:22-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index f58aa0c..77c1a50 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -155,7 +155,7 @@ RlfAnimation::Frame RlfAnimation::readNextFrame() {
const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
assert(!_stream);
- assert(frameNumber < _frameCount && frameNumber >= 0);
+ assert(frameNumber < _frameCount);
// Since this method is so expensive, first check to see if we can use
// getNextFrame() or getPreviousFrame() since they are cheap.
@@ -167,7 +167,7 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
return getPreviousFrame();
}
- uint closestFrame = _currentFrame;
+ int closestFrame = _currentFrame;
int distance = ABS(_currentFrame - (int)frameNumber);
for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) {
int newDistance = ABS((int)(*iter) - (int)frameNumber);
@@ -177,7 +177,7 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
}
}
- bool forwards = frameNumber > closestFrame;
+ bool forwards = (int)frameNumber > closestFrame;
if (forwards) {
for (uint i = closestFrame; i <= frameNumber; i++) {
applyFrameToCurrent(i);
Commit: b66700212479bb05ce1367a43fe6341cdfca1b00
https://github.com/scummvm/scummvm/commit/b66700212479bb05ce1367a43fe6341cdfca1b00
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:22-07:00
Commit Message:
ZVISION: Update ScriptManager::enableControl()/disableControl() to fit new Control syntax
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 50d7e58..dcfcf02 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -212,24 +212,28 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
_globalState[key] += valueToAdd;
}
-bool ScriptManager::enableControl(uint32 key) {
- if (!_activeControls.contains(key)) {
- return false;
- } else {
- return _activeControls[key]->enable();
+void ScriptManager::addControl(Control *control) {
+ _activeControls.push_back(control);
+}
+
+void ScriptManager::enableControl(uint32 key) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ if ((*iter)->getKey() == key) {
+ (*iter)->enable();
+ break;
+ }
}
}
-bool ScriptManager::disableControl(uint32 key) {
- if (!_activeControls.contains(key)) {
- return false;
- } else {
- return _activeControls[key]->disable();
+void ScriptManager::disableControl(uint32 key) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ if ((*iter)->getKey() == key) {
+ (*iter)->disable();
+ break;
+ }
}
}
-void ScriptManager::addActionNode(ActionNode *node) {
- _activeNodes.push_back(node);
}
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 28bce07..27e2e61 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -85,10 +85,10 @@ public:
void setStateValue(uint32 key, uint value);
void addToStateValue(uint32 key, uint valueToAdd);
- bool enableControl(uint32 key);
- bool disableControl(uint32 key);
+ void addControl(Control *control);
- void addActionNode(ActionNode *node);
+ void enableControl(uint32 key);
+ void disableControl(uint32 key);
void changeLocation(char world, char room, char node, char view, uint32 offset);
Commit: a6b2bb75819554a779b238045c21867943ce5f6c
https://github.com/scummvm/scummvm/commit/a6b2bb75819554a779b238045c21867943ce5f6c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:23-07:00
Commit Message:
ZVISION: Remove ScriptManager::_activeNodes and change all iterators to iterate over _activeControls
We also change _activeControls to a List instead of a HashMap because a List should have
slightly better iteration time.
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 dcfcf02..3cc4c92 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -108,11 +108,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<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
if ((*iter)->process(deltaTimeMillis)) {
- // Delete the node then remove the pointer
- delete (*iter);
- iter = _activeNodes.erase(iter);
+ // Remove the node
+ iter = _activeControls.erase(iter);
} else {
iter++;
}
@@ -257,12 +256,10 @@ void ScriptManager::changeLocationIntern() {
delete (*iter);
}
_activePuzzles.clear();
- for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
- delete (*iter)._value;
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ delete (*iter);
}
_activeControls.clear();
- _engine->clearAllMouseEvents();
- // TODO: See if we need to clear _activeNodes as well. And if so, remember to delete the nodes before clearing the list
// Revert to the idle cursor
_engine->getCursorManager()->revertToIdle();
@@ -278,8 +275,8 @@ void ScriptManager::changeLocationIntern() {
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
// Enable all the controls
- for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
- (*iter)._value->enable();
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->enable();
}
// Add all the local puzzles to the queue to be checked
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 27e2e61..0f3ea43 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -37,7 +37,6 @@ class SeekableReadStream;
namespace ZVision {
class ZVision;
-class ActionNode;
struct Location {
char world;
@@ -60,8 +59,6 @@ private:
* particular state key are checked after the key is modified.
*/
Common::HashMap<uint32, uint> _globalState;
- /** 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 */
@@ -71,13 +68,12 @@ private:
/** Holds the global puzzles */
Common::List<Puzzle *>_globalPuzzles;
/** Holds the currently active controls */
- Common::HashMap<uint32, Control *> _activeControls;
+ Common::List<Control *> _activeControls;
Location _nextLocation;
bool _changeLocation;
public:
-
void initialize();
void update(uint deltaTimeMillis);
Commit: e3b08793dddbf8cf8214328b4b3780995496645c
https://github.com/scummvm/scummvm/commit/e3b08793dddbf8cf8214328b4b3780995496645c
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:23-07:00
Commit Message:
ZVISION: Add ScriptManager mouse event handlers
This allows the main engine to pass mouse events to Controls
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 3cc4c92..98bc2e3 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -233,6 +233,25 @@ void ScriptManager::disableControl(uint32 key) {
}
}
+void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
+ }
+}
+
+void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
+ }
+}
+
+bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ bool cursorWasChanged = false;
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
+ }
+
+ return cursorWasChanged;
}
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 0f3ea43..9b47637 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -86,6 +86,29 @@ public:
void enableControl(uint32 key);
void disableControl(uint32 key);
+ /**
+ * Called when LeftMouse is pushed.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
+ * Called when LeftMouse is lifted.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
+ * Called on every MouseMove.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+
void changeLocation(char world, char room, char node, char view, uint32 offset);
private:
Commit: 84c645968c9e93ca343e7c80c6f4546a793c2d41
https://github.com/scummvm/scummvm/commit/84c645968c9e93ca343e7c80c6f4546a793c2d41
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:24-07:00
Commit Message:
ZVISION: Remove ZVision::_mousEvents and all associated functions
Instead, pass all mouse events to ScriptManager
Changed paths:
engines/zvision/events.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 94e8f08..9283328 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -32,38 +32,10 @@
#include "zvision/cursor_manager.h"
#include "zvision/render_manager.h"
#include "zvision/script_manager.h"
-#include "zvision/mouse_event.h"
#include "zvision/rlf_animation.h"
namespace ZVision {
-void ZVision::registerMouseEvent(MouseEvent *event) {
- _mouseEvents.push_back(event);
-}
-
-bool ZVision::removeMouseEvent(const uint32 key) {
- for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- if ((*iter)->_key == key) {
- _scriptManager->setStateValue((*iter)->_key, 0);
- _mouseEvents.erase(iter);
- return true;
- }
- }
-
- return false;
-}
-
-void ZVision::clearAllMouseEvents() {
- // Clear the state values of all the events
- // Then delete the nodes
- for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- _scriptManager->setStateValue((*iter)->_key, 0);
- delete (*iter);
- }
-
- _mouseEvents.clear();
-}
-
void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
@@ -121,29 +93,20 @@ void ZVision::onMouseDown(const Common::Point &pos) {
_cursorManager->cursorDown(true);
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
-
- for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- (*iter)->onMouseDown(pos, imageCoord);
- }
+ _scriptManager->onMouseDown(pos, imageCoord);
}
void ZVision::onMouseUp(const Common::Point &pos) {
_cursorManager->cursorDown(false);
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
-
- for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- (*iter)->onMouseUp(pos, imageCoord);
- }
+ _scriptManager->onMouseUp(pos, imageCoord);
}
void ZVision::onMouseMove(const Common::Point &pos) {
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- bool cursorWasChanged = false;
- for (Common::List<MouseEvent *>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) {
- cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(pos, imageCoord);
- }
+ bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
// Graph of the function governing rotation velocity:
//
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 84e4da9..6bf6d2a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -33,7 +33,6 @@
#include "zvision/detection.h"
#include "zvision/clock.h"
-#include "zvision/mouse_event.h"
#include "gui/debugger.h"
@@ -100,9 +99,6 @@ private:
// Clock
Clock _clock;
- // To store the current mouse events
- Common::List<MouseEvent *> _mouseEvents;
-
// To prevent allocation every time we process events
Common::Event _event;
@@ -132,19 +128,6 @@ public:
void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
/**
- * Register a MouseEvent with the event system. These will be checked at every
- * MOUSE_UP, MOUSE_DOWN, MOUSE_MOVE, etc.
- *
- * @param event The event to register
- */
- void registerMouseEvent(MouseEvent *event);
-
- bool removeMouseEvent(const uint32 key);
-
- /** Remove all MouseEvents from the event system */
- void clearAllMouseEvents();
-
- /**
* Utility method to cycle through all the cursors in the game. After
* calling, use Left and Right arrows to cycle. Esc to quit. This is a
* blocking function call.
Commit: 610eb118246531e38173d67d6790b4737b1a6744
https://github.com/scummvm/scummvm/commit/610eb118246531e38173d67d6790b4737b1a6744
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:24-07:00
Commit Message:
ZVISION: Prevent variable shadowing
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 5d9ea4d..847defd 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -97,13 +97,13 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
char fileNameBuffer[25];
sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
- Common::String fileName(fileNameBuffer);
+ Common::String animationFileName(fileNameBuffer);
- if (fileName.hasSuffix(".avi")) {
+ if (animationFileName.hasSuffix(".avi")) {
_animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
- } else if (fileName.hasSuffix(".rlf")) {
- _animation.rlf = new RlfAnimation(fileNameBuffer, false);
+ _animation.avi->loadFile(animationFileName);
+ } else if (animationFileName.hasSuffix(".rlf")) {
+ _animation.rlf = new RlfAnimation(animationFileName, false);
}
} else if (line.matchString("*skipcolor*", true)) {
// Not used
Commit: da3f137b6b4c4c1a06b206d47f8818868cc227ff
https://github.com/scummvm/scummvm/commit/da3f137b6b4c4c1a06b206d47f8818868cc227ff
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:25-07:00
Commit Message:
ZVISION: sscanf to ints before storing them in Rect coords
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 847defd..6555fe5 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -108,7 +108,13 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
} else if (line.matchString("*skipcolor*", true)) {
// Not used
} else if (line.matchString("*anim_coords*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u %u %u %u~", &_animationCoords.left, &_animationCoords.top, &_animationCoords.right, &_animationCoords.bottom);
+ int left, top, right, bottom;
+ sscanf(line.c_str(), "%*[^:]:%d %d %d %d~", &left, &top, &right, &bottom);
+
+ _animationCoords.left = left;
+ _animationCoords.top = top;
+ _animationCoords.right = right;
+ _animationCoords.bottom = bottom;
} else if (line.matchString("*mirrored*", true)) {
uint mirrored;
sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
Commit: f60b054b490ca13f79f849b5981e15140a239434
https://github.com/scummvm/scummvm/commit/f60b054b490ca13f79f849b5981e15140a239434
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:25-07:00
Commit Message:
ZVISION: Fix comment spacing
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 6555fe5..15b0bf7 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -287,12 +287,12 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// 180 <----------------------------------------> 0
// angle ( /|\ ) -angle
// / | \
- // / | \
- // Quadrant 1 / | \ Quadrant 0
+ // / | \
+ // Quadrant 1 / | \ Quadrant 0
// / | \
- // / | \
- // / | \
- // * | *
+ // / | \
+ // / | \
+ // * | *
// ^
// 270
Commit: b317ea45fed9cdf444bba3b972ff1e12c12717ad
https://github.com/scummvm/scummvm/commit/b317ea45fed9cdf444bba3b972ff1e12c12717ad
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:26-07:00
Commit Message:
ZVISION: Allow a angle buffer zone on *both* sides of the actual angle
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 15b0bf7..08a620f 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -208,7 +208,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
_lastMousePos = backgroundImageSpacePos;
for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
- if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle) {
+ if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle + ANGLE_DELTA) {
_currentFrame = (*iter).toFrame;
renderFrame(_currentFrame);
break;
Commit: 3a9b3841149d22d9a8221a8ae32d2b0feca0b14f
https://github.com/scummvm/scummvm/commit/3a9b3841149d22d9a8221a8ae32d2b0feca0b14f
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:26-07:00
Commit Message:
ZVISION: Round to int *after* converting to degrees
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 08a620f..71b284c 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -247,10 +247,9 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
int16 xDist = pointTwo.x - pointOne.x;
int16 yDist = pointTwo.y - pointOne.y;
- int angle = int(atan((float)yDist / (float)xDist));
-
- // Convert to degrees. (180 / 3.14159 = 57.2958)
- angle *= 57;
+ // Calculate the angle using arctan
+ // Then convert to degrees. (180 / 3.14159 = 57.2958)
+ int angle = int(atan((float)yDist / (float)xDist) * 57);
// Calculate what quadrant pointTwo is in
uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
Commit: ab18d20ead93b5e1f65f474fe73212724394c1fc
https://github.com/scummvm/scummvm/commit/ab18d20ead93b5e1f65f474fe73212724394c1fc
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:27-07:00
Commit Message:
ZVISION: Fix the quadrant numbers in angle calculations
Because y increases as you go down, not up
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 71b284c..3c5b637 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -233,7 +233,7 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
if (pointOne.x == pointTwo.x && pointOne.y == pointTwo.y)
return -1; // This should never happen
else if (pointOne.x == pointTwo.x) {
- if (pointTwo.y > pointOne.y)
+ if (pointTwo.y < pointOne.y)
return 90;
else
return 270;
@@ -279,15 +279,15 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// \ | /
// \ | /
// \ | /
- // Quadrant 3 \ | / Quadrant 2
+ // Quadrant 1 \ | / Quadrant 0
// \ | /
// \ | /
- // -angle ( \|/ ) angle
+ // angle ( \|/ ) -angle
// 180 <----------------------------------------> 0
- // angle ( /|\ ) -angle
+ // -angle ( /|\ ) angle
// / | \
// / | \
- // Quadrant 1 / | \ Quadrant 0
+ // Quadrant 3 / | \ Quadrant 2
// / | \
// / | \
// / | \
@@ -298,16 +298,16 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Convert the local angles to unit circle angles
switch (quadrant) {
case 0:
- angle = 360 + angle;
+ angle = 180 + angle;
break;
case 1:
- angle = 180 + angle;
+ // Do nothing
break;
case 2:
angle = 180 + angle;
break;
case 3:
- // Do nothing
+ angle = 360 + angle;
break;
}
Commit: 3e6144970e2674380a8adab3b17e5bd1ce24ffea
https://github.com/scummvm/scummvm/commit/3e6144970e2674380a8adab3b17e5bd1ce24ffea
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:28-07:00
Commit Message:
ZVISION: Implement avi frame seeking
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 3c5b637..7592968 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -27,6 +27,8 @@
#include "common/tokenizer.h"
#include "common/system.h"
+#include "graphics/surface.h"
+
#include "zvision/lever_control.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
@@ -318,21 +320,24 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
void LeverControl::renderFrame(uint frameNumber) {
const uint16 *frameData;
int pitch;
- int x;
- int y;
+ int x = _animationCoords.left;
+ int y = _animationCoords.top;
int width;
int height;
if (_fileType == RLF) {
// getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- frameData = _animation.rlf->getFrameData(_currentFrame);
+ frameData = _animation.rlf->getFrameData(frameNumber);
pitch = _animation.rlf->width() * sizeof(uint16);
- x = _animationCoords.left;
- y = _animationCoords.right;
width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
} else if (_fileType == AVI) {
- // Cry because AVI seeking isn't implemented (yet)
+ _animation.avi->seekToFrame(frameNumber);
+ const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
+ frameData = (const uint16 *)surface->getBasePtr(0, 0);
+ pitch = surface->pitch;
+ width = surface->w;
+ height = surface->h;
}
_engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
Commit: 945982c8577b9c8a34333898841b5ffcfaa7138b
https://github.com/scummvm/scummvm/commit/945982c8577b9c8a34333898841b5ffcfaa7138b
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:39-07:00
Commit Message:
ZVISION: Add support for animation 'mirroring'
If an animation is 'mirrored', it doesn't have B-frames, only I-frames. However the animations are built
so the last half of the animation is the reverse of the first half
Changed paths:
engines/zvision/lever_control.cpp
engines/zvision/lever_control.h
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 7592968..4ed3f10 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -45,6 +45,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_frameCount(0),
_startFrame(0),
_currentFrame(0),
+ _lastRenderedFrame(0),
_mouseIsCaptured(false),
_isReturning(false) {
@@ -318,6 +319,10 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
}
void LeverControl::renderFrame(uint frameNumber) {
+ if (frameNumber < _lastRenderedFrame && _mirrored) {
+ frameNumber = (_frameCount * 2) - 1 - frameNumber;
+ }
+
const uint16 *frameData;
int pitch;
int x = _animationCoords.left;
@@ -341,6 +346,7 @@ void LeverControl::renderFrame(uint frameNumber) {
}
_engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
+ _lastRenderedFrame = frameNumber;
}
} // End of namespace ZVision
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 42577a1..cf41aac 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -80,6 +80,7 @@ private:
FrameInfo *_frameInfo;
uint _currentFrame;
+ uint _lastRenderedFrame;
bool _mouseIsCaptured;
bool _isReturning;
Common::Point _lastMousePos;
Commit: a1a70170d4a28a426fe916225a2aa9adbdcf5f95
https://github.com/scummvm/scummvm/commit/a1a70170d4a28a426fe916225a2aa9adbdcf5f95
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:39-07:00
Commit Message:
ZVISION: Remove RlfAnimation::getPreviousFrame()
I realized that RlfAnimations don't use B-frames, therefore, can not easily go backwards.
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 77c1a50..90b39dc 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -158,34 +158,25 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
assert(frameNumber < _frameCount);
// Since this method is so expensive, first check to see if we can use
- // getNextFrame() or getPreviousFrame() since they are cheap.
+ // getNextFrame() it's cheap.
if ((int)frameNumber == _currentFrame) {
return _currentFrameBuffer;
} else if (_currentFrame + 1 == (int)frameNumber) {
return getNextFrame();
- } else if (_currentFrame - 1 == (int)frameNumber) {
- return getPreviousFrame();
}
int closestFrame = _currentFrame;
- int distance = ABS(_currentFrame - (int)frameNumber);
+ int distance = (int)frameNumber - _currentFrame;
for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) {
- int newDistance = ABS((int)(*iter) - (int)frameNumber);
- if (closestFrame == -1 || newDistance < distance) {
+ int newDistance = (int)frameNumber - (int)(*iter);
+ if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
closestFrame = (*iter);
distance = newDistance;
}
}
- bool forwards = (int)frameNumber > closestFrame;
- if (forwards) {
- for (uint i = closestFrame; i <= frameNumber; i++) {
- applyFrameToCurrent(i);
- }
- } else {
- for (uint i = closestFrame; i >= frameNumber; i--) {
- applyFrameToCurrent(i);
- }
+ for (uint i = closestFrame; i <= frameNumber; i++) {
+ applyFrameToCurrent(i);
}
_currentFrame = frameNumber;
@@ -205,15 +196,6 @@ const uint16 *RlfAnimation::getNextFrame() {
return _currentFrameBuffer;
}
-const uint16 *RlfAnimation::getPreviousFrame() {
- assert(!_stream);
- assert(_currentFrame - 1 >= 0);
-
- applyFrameToCurrent(_currentFrame - 1);
- _currentFrame--;
- return _currentFrameBuffer;
-}
-
void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
if (_frames[frameNumber].type == Masked) {
decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index d49e6a9..5091185 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -74,9 +74,7 @@ public:
uint32 frameTime() { return _frameTime; }
const uint16 *getFrameData(uint frameNumber);
-
const uint16 *getNextFrame();
- const uint16 *getPreviousFrame();
bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
Commit: 7d255c3d8014987b76d8ef974af1c9c7f536d396
https://github.com/scummvm/scummvm/commit/7d255c3d8014987b76d8ef974af1c9c7f536d396
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:40-07:00
Commit Message:
ZVISION: Fix: Signal a cursor change
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 4ed3f10..97e1f66 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -220,6 +220,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
} else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_cursorName);
+ cursorWasChanged = true;
}
return cursorWasChanged;
Commit: ce9e9a55c6969ca1127f00f5d5a22e0c0c0bc046
https://github.com/scummvm/scummvm/commit/ce9e9a55c6969ca1127f00f5d5a22e0c0c0bc046
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:40-07:00
Commit Message:
ZVISION: Fix: Store what type of animation file is used
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 97e1f66..d515f9e 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -105,8 +105,10 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
if (animationFileName.hasSuffix(".avi")) {
_animation.avi = new ZorkAVIDecoder();
_animation.avi->loadFile(animationFileName);
+ _fileType = AVI;
} else if (animationFileName.hasSuffix(".rlf")) {
_animation.rlf = new RlfAnimation(animationFileName, false);
+ _fileType = RLF;
}
} else if (line.matchString("*skipcolor*", true)) {
// Not used
Commit: 952fb83793fb99a3e8d7db849a4b66f830e4e3ad
https://github.com/scummvm/scummvm/commit/952fb83793fb99a3e8d7db849a4b66f830e4e3ad
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:41-07:00
Commit Message:
ZVISION: Fix: Change infndef to correct constant
Changed paths:
engines/zvision/lever_control.h
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index cf41aac..d359318 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ZVISION_PUSH_TOGGLE_CONTROL_H
-#define ZVISION_PUSH_TOGGLE_CONTROL_H
+#ifndef ZVISION_LEVER_CONTROL_H
+#define ZVISION_LEVER_CONTROL_H
#include "common/types.h"
Commit: f1f36e7c9db0b78a5ae04ebdadebe431e2840bfc
https://github.com/scummvm/scummvm/commit/f1f36e7c9db0b78a5ae04ebdadebe431e2840bfc
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:41-07:00
Commit Message:
ZVISION: Add LeverControl to scr file parsing
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 212d714..06767c5 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -27,6 +27,7 @@
#include "zvision/puzzle.h"
#include "zvision/actions.h"
#include "zvision/push_toggle_control.h"
+#include "zvision/lever_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -287,10 +288,12 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
} else if (controlType.equalsIgnoreCase("pana")) {
Control::parsePanoramaControl(_engine, stream);
return;
- }
- else if (controlType.equalsIgnoreCase("tilt")) {
+ } else if (controlType.equalsIgnoreCase("tilt")) {
Control::parseTiltControl(_engine, stream);
return;
+ } else if (controlType.equalsIgnoreCase("lever")) {
+ _activeControls.push_back(new LeverControl(_engine, key, stream));
+ return;
}
}
Commit: f3514534ce46bad5e3ffadfdf0b3af403045e5ef
https://github.com/scummvm/scummvm/commit/f3514534ce46bad5e3ffadfdf0b3af403045e5ef
Author: richiesams (adastley at gmail.com)
Date: 2013-08-28T14:44:42-07:00
Commit Message:
ZVISION: Increase background rotation speed
This could probably still go higher. The DOS version is *very* sensitive, too sensitive.
But this is still a bit slow.
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 6bf6d2a..a02fecc 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -80,7 +80,7 @@ private:
WORKING_WINDOW_HEIGHT = 320,
ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 250 // Pixels per second
+ MAX_ROTATION_SPEED = 400 // Pixels per second
};
Console *_console;
Commit: 6417192584873f98737a0928adefeb9aa9cad894
https://github.com/scummvm/scummvm/commit/6417192584873f98737a0928adefeb9aa9cad894
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2013-09-24T04:55:54-07:00
Commit Message:
Merge branch 'master' into zvision
Conflicts:
video/avi_decoder.cpp
Changed paths:
A audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
A audio/softsynth/mt32/LA32FloatWaveGenerator.h
R audio/softsynth/mt32/AReverbModel.cpp
R audio/softsynth/mt32/AReverbModel.h
R audio/softsynth/mt32/DelayReverb.cpp
R audio/softsynth/mt32/DelayReverb.h
R audio/softsynth/mt32/FreeverbModel.cpp
R audio/softsynth/mt32/FreeverbModel.h
R audio/softsynth/mt32/LegacyWaveGenerator.cpp
R audio/softsynth/mt32/LegacyWaveGenerator.h
R audio/softsynth/mt32/freeverb.cpp
R audio/softsynth/mt32/freeverb.h
AUTHORS
audio/softsynth/mt32/BReverbModel.cpp
audio/softsynth/mt32/BReverbModel.h
audio/softsynth/mt32/LA32WaveGenerator.cpp
audio/softsynth/mt32/LA32WaveGenerator.h
audio/softsynth/mt32/Part.cpp
audio/softsynth/mt32/Part.h
audio/softsynth/mt32/Partial.cpp
audio/softsynth/mt32/Partial.h
audio/softsynth/mt32/PartialManager.cpp
audio/softsynth/mt32/PartialManager.h
audio/softsynth/mt32/Poly.cpp
audio/softsynth/mt32/Poly.h
audio/softsynth/mt32/Structures.h
audio/softsynth/mt32/Synth.cpp
audio/softsynth/mt32/Synth.h
audio/softsynth/mt32/TVP.cpp
audio/softsynth/mt32/Tables.h
audio/softsynth/mt32/module.mk
audio/softsynth/mt32/mt32emu.h
backends/platform/tizen/application.cpp
backends/platform/tizen/audio.cpp
backends/platform/tizen/audio.h
backends/platform/tizen/form.cpp
backends/platform/tizen/form.h
backends/platform/tizen/fs.cpp
backends/platform/tizen/graphics.cpp
backends/platform/tizen/sscanf.cpp
backends/platform/tizen/system.cpp
backends/vkeybd/virtual-keyboard-gui.cpp
backends/vkeybd/virtual-keyboard-gui.h
backends/vkeybd/virtual-keyboard.h
devtools/create_mortdat/create_mortdat.cpp
devtools/create_mortdat/create_mortdat.h
devtools/create_mortdat/gametext.h
devtools/create_mortdat/menudata.h
devtools/create_project/msbuild.cpp
devtools/create_project/visualstudio.cpp
devtools/credits.pl
devtools/scumm-md5.txt
dists/engine-data/mort.dat
engines/agi/detection_tables.h
engines/agos/agos.h
engines/agos/saveload.cpp
engines/agos/script_pn.cpp
engines/drascula/actors.cpp
engines/drascula/animation.cpp
engines/drascula/console.cpp
engines/drascula/converse.cpp
engines/drascula/drascula.cpp
engines/drascula/drascula.h
engines/drascula/graphics.cpp
engines/drascula/interface.cpp
engines/drascula/objects.cpp
engines/drascula/rooms.cpp
engines/drascula/saveload.cpp
engines/drascula/sound.cpp
engines/drascula/talk.cpp
engines/mohawk/myst.cpp
engines/mohawk/myst_stacks/myst.cpp
engines/mortevielle/actions.cpp
engines/mortevielle/detection.cpp
engines/mortevielle/detection_tables.h
engines/mortevielle/dialogs.cpp
engines/mortevielle/dialogs.h
engines/mortevielle/graphics.cpp
engines/mortevielle/menu.cpp
engines/mortevielle/menu.h
engines/mortevielle/mortevielle.cpp
engines/mortevielle/mortevielle.h
engines/mortevielle/mouse.cpp
engines/mortevielle/outtext.cpp
engines/mortevielle/saveload.cpp
engines/mortevielle/saveload.h
engines/mortevielle/sound.cpp
engines/mortevielle/utils.cpp
engines/sci/detection.cpp
engines/sci/detection_tables.h
engines/sci/engine/features.cpp
engines/sci/engine/script_patches.cpp
engines/sci/engine/vm_types.cpp
engines/sci/engine/vm_types.h
engines/sci/engine/workarounds.cpp
engines/sci/graphics/picture.cpp
engines/sci/sci.h
engines/scumm/actor.cpp
engines/scumm/detection_tables.h
engines/scumm/gfx.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v70he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/insane/insane_enemy.cpp
engines/scumm/script_v6.cpp
engines/scumm/scumm-md5.h
engines/scumm/scumm.h
engines/scumm/vars.cpp
engines/testbed/graphics.cpp
engines/tinsel/detection_tables.h
engines/tsage/blue_force/blueforce_scenes0.cpp
engines/tsage/blue_force/blueforce_scenes1.cpp
engines/tsage/blue_force/blueforce_scenes5.cpp
engines/tsage/blue_force/blueforce_scenes5.h
engines/tsage/converse.cpp
engines/tsage/core.cpp
engines/tsage/globals.cpp
engines/tsage/globals.h
engines/tsage/graphics.cpp
engines/tsage/ringworld2/ringworld2_dialogs.cpp
engines/tsage/ringworld2/ringworld2_logic.cpp
engines/tsage/ringworld2/ringworld2_logic.h
engines/tsage/ringworld2/ringworld2_scenes0.cpp
engines/tsage/ringworld2/ringworld2_scenes0.h
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/tsage/ringworld2/ringworld2_scenes1.h
engines/tsage/ringworld2/ringworld2_scenes2.cpp
engines/tsage/ringworld2/ringworld2_scenes3.cpp
engines/tsage/ringworld2/ringworld2_speakers.cpp
engines/tsage/ringworld2/ringworld2_speakers.h
engines/tsage/staticres.cpp
engines/tsage/staticres.h
engines/tsage/user_interface.cpp
engines/tsage/user_interface.h
engines/wintermute/base/font/base_font_truetype.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/detection_tables.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
engines/wintermute/utils/string_util.cpp
engines/wintermute/wintermute.cpp
graphics/VectorRenderer.h
graphics/VectorRendererSpec.cpp
graphics/VectorRendererSpec.h
graphics/font.cpp
gui/ThemeEngine.cpp
gui/ThemeEngine.h
gui/about.cpp
gui/credits.h
gui/object.cpp
gui/object.h
gui/themes/default.inc
gui/themes/scummclassic.zip
gui/themes/scummmodern.zip
gui/themes/scummmodern/scummmodern_gfx.stx
gui/themes/scummtheme.py
gui/widgets/editable.cpp
gui/widgets/edittext.cpp
video/avi_decoder.cpp
video/avi_decoder.h
video/video_decoder.cpp
video/video_decoder.h
diff --cc video/avi_decoder.h
index f7259bf,fffcbfb..80c11b1
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@@ -66,9 -66,15 +66,14 @@@ public
uint16 getWidth() const { return _header.width; }
uint16 getHeight() const { return _header.height; }
+ bool rewind();
+ bool isRewindable() const { return true; }
+ bool isSeekable() const;
+
protected:
void readNextPacket();
+ bool seekIntern(const Audio::Timestamp &time);
-private:
struct BitmapInfoHeader {
uint32 size;
uint32 width;
@@@ -191,8 -203,13 +202,13 @@@
AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType);
~AVIAudioTrack();
- void queueSound(Common::SeekableReadStream *stream);
+ virtual void queueSound(Common::SeekableReadStream *stream);
Audio::Mixer::SoundType getSoundType() const { return _soundType; }
+ void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime);
+ void resetStream();
+
+ bool isRewindable() const { return true; }
+ bool rewind();
protected:
Audio::AudioStream *getAudioStream() const;
Commit: bb77333d4f4025b053ad311092ad0390368522ea
https://github.com/scummvm/scummvm/commit/bb77333d4f4025b053ad311092ad0390368522ea
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Create console method for parsing ALL .scr files
Useful for putting a breakpoint at certain ResultActions/Controls to
test out different instances of them.
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
engines/zvision/script_manager.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index fd8347e..8b4dffa 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -54,6 +54,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("dumpcursorfilenames", WRAP_METHOD(Console, cmdDumpAllCursorFileNames));
DCmd_Register("showcursor", WRAP_METHOD(Console, cmdShowCursor));
DCmd_Register("dumpalllevfiles", WRAP_METHOD(Console, cmdDumpAllLevFiles));
+ DCmd_Register("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -225,4 +226,15 @@ bool Console::cmdDumpAllLevFiles(int argc, const char **argv) {
return true;
}
+bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
+ Common::ArchiveMemberList list;
+ SearchMan.listMatchingMembers(list, "*.scr");
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ _engine->getScriptManager()->parseScrFile((*iter)->getName());
+ }
+
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index e518467..612e5ee 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -50,6 +50,7 @@ private:
bool cmdDumpAllCursorFileNames(int argc, const char **argv);
bool cmdShowCursor(int argc, const char **argv);
bool cmdDumpAllLevFiles(int argc, const char **argv);
+ bool cmdParseAllScrFiles(int argc, const char **argv);
};
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 9b47637..1a272f1 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -117,6 +117,8 @@ private:
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
+// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
+public:
/**
* Parses a script file into triggers and events
*
@@ -125,6 +127,7 @@ private:
*/
void parseScrFile(const Common::String &fileName, bool isGlobal = false);
+private:
/**
* Parses the stream into a Puzzle object
* Helper method for parseScrFile.
Commit: a81c9a52a34cba1ecf358d612ddbcd6e517a2830
https://github.com/scummvm/scummvm/commit/a81c9a52a34cba1ecf358d612ddbcd6e517a2830
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Fix LeverControl 'mirrored' support
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index d515f9e..7d23b68 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -322,8 +322,13 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
}
void LeverControl::renderFrame(uint frameNumber) {
- if (frameNumber < _lastRenderedFrame && _mirrored) {
- frameNumber = (_frameCount * 2) - 1 - frameNumber;
+ if (frameNumber == 0) {
+ _lastRenderedFrame = frameNumber;
+ } else if (frameNumber < _lastRenderedFrame && _mirrored) {
+ _lastRenderedFrame = frameNumber;
+ frameNumber = (_frameCount * 2) - frameNumber - 1;
+ } else {
+ _lastRenderedFrame = frameNumber;
}
const uint16 *frameData;
@@ -342,14 +347,13 @@ void LeverControl::renderFrame(uint frameNumber) {
} else if (_fileType == AVI) {
_animation.avi->seekToFrame(frameNumber);
const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
- frameData = (const uint16 *)surface->getBasePtr(0, 0);
+ frameData = (const uint16 *)surface->getPixels();
pitch = surface->pitch;
width = surface->w;
height = surface->h;
}
_engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
- _lastRenderedFrame = frameNumber;
}
} // End of namespace ZVision
Commit: c15454d7d4a8b670f6e71f035f5b8439166e71e1
https://github.com/scummvm/scummvm/commit/c15454d7d4a8b670f6e71f035f5b8439166e71e1
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Keep a Graphics::Surface of the current background instead of re-reading the file each time
This is both more efficient and is part of the process of converting the entire game to RBG 565
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 fa45a6f..99c987f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -42,7 +42,6 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
_screenCenterY(_workingHeight / 2),
_workingWindow(workingWindow),
_pixelFormat(pixelFormat),
- _currentBackground(0),
_backgroundWidth(0),
_backgroundHeight(0),
_backgroundInverseVelocity(0),
@@ -54,10 +53,6 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
}
RenderManager::~RenderManager() {
- if (_currentBackground != 0) {
- delete _currentBackground;
- }
-
delete[] _workingWindowBuffer;
}
@@ -89,7 +84,7 @@ void RenderManager::clearWorkingWindowToColor(uint16 color) {
_system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), _workingWindow.left, _workingWindow.top, _workingWidth, _workingHeight);
}
-void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap, bool isTransposed) {
+void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
int16 subRectX = 0;
int16 subRectY = 0;
@@ -143,13 +138,24 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (_renderTable.getRenderState() == RenderTable::FLAT) {
_system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
} else {
- _renderTable.mutateImage((uint16 *)surface.getBasePtr(0, 0), _workingWindowBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap, isTransposed);
+ _renderTable.mutateImage((uint16 *)surface.getPixels(), _workingWindowBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap);
_system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
}
}
void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
+
+ renderSubRectToScreen(surface, destinationX, destinationY, wrap);
+}
+
+void RenderManager::renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
+ renderSubRectToScreen(surface, destinationX, destinationY, wrap);
+}
+
+void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
Common::File file;
if (!file.open(fileName)) {
@@ -157,62 +163,85 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, int16 de
return;
}
- renderImageToScreen(file, destinationX, destinationY);
-}
-
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, int16 destinationX, int16 destinationY, bool wrap) {
// Read the magic number
// Some files are true TGA, while others are TGZ
- uint32 fileType = stream.readUint32BE();
+ uint32 fileType = file.readUint32BE();
+
+ uint32 imageWidth;
+ uint32 imageHeight;
+ Graphics::TGADecoder tga;
+ uint16 *buffer;
+ bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
+ // All ZVision images are in RGB 555
+ Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ destination.format = pixelFormat555;
+
+ bool isTGZ;
// Check for TGZ files
if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
+ isTGZ = true;
+
// TGZ files have a header and then Bitmap data that is compressed with LZSS
- uint32 decompressedSize = stream.readSint32LE();
- uint32 imageWidth = stream.readSint32LE();
- uint32 imageHeight = stream.readSint32LE();
+ uint32 decompressedSize = file.readSint32LE();
+ imageWidth = file.readSint32LE();
+ imageHeight = file.readSint32LE();
- LzssReadStream lzssStream(&stream);
- byte *buffer = new byte[decompressedSize];
+ LzssReadStream lzssStream(&file);
+ buffer = (uint16 *)(new uint16[decompressedSize]);
lzssStream.read(buffer, decompressedSize);
-
- uint32 pitch = imageWidth * sizeof(uint16);
- bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
-
- if (isTransposed) {
- uint16 temp = imageHeight;
- imageHeight = imageWidth;
- imageWidth = temp;
- }
-
- Graphics::Surface surface;
- surface.init(imageWidth, imageHeight, pitch, buffer, _pixelFormat);
-
- renderSubRectToScreen(surface, destinationX, destinationY, wrap, isTransposed);
-
- // We have to use delete[] instead of calling surface.free() because we created the memory with new[]
- delete[] buffer;
} else {
+ isTGZ = false;
+
// Reset the cursor
- stream.seek(0);
+ file.seek(0);
// Decode
- Graphics::TGADecoder tga;
- if (!tga.loadStream(stream)) {
+ if (!tga.loadStream(file)) {
warning("Error while reading TGA image");
return;
}
Graphics::Surface tgaSurface = *(tga.getSurface());
- bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
+ imageWidth = tgaSurface.w;
+ imageHeight = tgaSurface.h;
+
+ buffer = (uint16 *)tgaSurface.getPixels();
+ }
+
+ // Flip the width and height if transposed
+ if (isTransposed) {
+ uint16 temp = imageHeight;
+ imageHeight = imageWidth;
+ imageWidth = temp;
+ }
+
+ // If the destination internal buffer is the same size as what we're copying into it,
+ // there is no need to free() and re-create
+ if (imageWidth != destination.w || imageHeight != destination.h) {
+ destination.create(imageWidth, imageHeight, pixelFormat555);
+ }
- if (isTransposed) {
- uint16 temp = tgaSurface.h;
- tgaSurface.h = tgaSurface.w;
- tgaSurface.w = temp;
+ // If transposed, 'un-transpose' the data while copying it to the destination
+ // Otherwise, just do a simple copy
+ if (isTransposed) {
+ uint16 *dest = (uint16 *)destination.getPixels();
+
+ for (uint32 y = 0; y < imageHeight; y++) {
+ uint32 columnIndex = y * imageWidth;
+
+ for (uint32 x = 0; x < imageWidth; x++) {
+ dest[columnIndex + x] = buffer[x * imageHeight + y];
+ }
}
+ } else {
+ memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel);
+ }
- renderSubRectToScreen(tgaSurface, destinationX, destinationY, wrap, isTransposed);
+ // Cleanup
+ if (isTGZ) {
+ delete[] buffer;
+ } else {
tga.destroy();
}
}
@@ -256,10 +285,7 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
return;
}
- if (_currentBackground != 0) {
- delete _currentBackground;
- }
- _currentBackground = file;
+ readImageToSurface(fileName, _currentBackground);
moveBackground(0);
}
@@ -291,8 +317,6 @@ void RenderManager::setBackgroundVelocity(int velocity) {
}
void RenderManager::moveBackground(int offset) {
- _currentBackground->seek(0);
-
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::TILT) {
_backgroundOffset += Common::Point(0, offset);
@@ -307,7 +331,7 @@ void RenderManager::moveBackground(int offset) {
else if (_backgroundOffset.y >= _backgroundHeight)
_backgroundOffset.y += _backgroundHeight;
- renderImageToScreen(*_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
+ renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
} else if (state == RenderTable::PANORAMA) {
_backgroundOffset += Common::Point(offset, 0);
@@ -321,9 +345,9 @@ void RenderManager::moveBackground(int offset) {
else if (_backgroundOffset.y >= _backgroundHeight)
_backgroundOffset.y += _backgroundHeight;
- renderImageToScreen(*_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
+ renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
} else {
- renderImageToScreen(*_currentBackground, 0, 0);
+ renderImageToScreen(_currentBackground, 0, 0);
}
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index d82e40f..41dedab 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -74,7 +74,7 @@ private:
/** Used to warp the background image */
RenderTable _renderTable;
- Common::SeekableReadStream *_currentBackground;
+ Graphics::Surface _currentBackground;
/** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
Common::Point _backgroundOffset;
/** The width of the current background image */
@@ -123,11 +123,11 @@ public:
* Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
* The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
*
- * @param stream Stream to read the image data from
+ * @param stream Surface to read the image data from
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(Common::SeekableReadStream &stream, int16 destinationX, int16 destinationY, bool wrap = false);
+ void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -181,7 +181,9 @@ private:
* @param subRectangle A rectangle representing the part of the image that should be rendered
* @param wrap Should the image wrap (tile) if it doesn't completely fill the screen?
*/
- void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap, bool isTransposed);
+ void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap);
+
+ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
void moveBackground(int offset);
};
Commit: 0271a2c59dd553b79cae95376b40654a70190089
https://github.com/scummvm/scummvm/commit/0271a2c59dd553b79cae95376b40654a70190089
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Transpose is done in RenderManager::readImageToSurface(), so remove it from mutateImage
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 0a8175e..ee36282 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -98,7 +98,7 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap, bool isTransposed) {
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap) {
for (int16 y = subRect.top; y < subRect.bottom; y++) {
int16 normalizedY = y - subRect.top;
int32 internalColumnIndex = (normalizedY + destinationY) * _numColumns;
@@ -135,11 +135,7 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 im
sourceXIndex = CLIP<int16>(sourceXIndex, 0, imageWidth - 1);
}
- if (isTransposed) {
- destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceXIndex * imageHeight + sourceYIndex];
- } else {
- destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
- }
+ destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
}
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index bbf5e1b..e582080 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap, bool isTransposed);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap);
void generateRenderTable();
void setPanoramaFoV(float fov);
Commit: 94378d064405992905a9ffcb24c72f0c86d51bd4
https://github.com/scummvm/scummvm/commit/94378d064405992905a9ffcb24c72f0c86d51bd4
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Force comparison to be between signed ints and ensure CLIP happens on a signed int
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index ee36282..55285b4 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -62,9 +62,9 @@ void RenderTable::setRenderState(RenderState newState) {
const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Point &point) {
// If we're outside the range of the RenderTable, no warping is happening. Return the maximum image coords
- if (point.x >= _numColumns || point.y >= _numRows) {
- int16 x = CLIP<int16>(point.x, 0, _numColumns);
- int16 y = CLIP<int16>(point.y, 0, _numRows);
+ if (point.x >= (int16)_numColumns || point.y >= (int16)_numRows || point.x < 0 || point.y , 0) {
+ int16 x = CLIP<int16>(point.x, 0, (int16)_numColumns);
+ int16 y = CLIP<int16>(point.y, 0, (int16)_numRows);
return Common::Point(x, y);
}
Commit: 07770eeafbf72fa4ffcee2f474b212d2a67ee234
https://github.com/scummvm/scummvm/commit/07770eeafbf72fa4ffcee2f474b212d2a67ee234
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Convert cursors to RBG 565
This is part of a series of commits converting all game assets to RBG 565 from
RBG 555. The argument is that certain backends do not support RGB 555.
Changed paths:
engines/zvision/cursor.cpp
engines/zvision/cursor.h
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index 601c58f..57859b9 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -34,16 +34,14 @@ ZorkCursor::ZorkCursor()
: _width(0),
_height(0),
_hotspotX(0),
- _hotspotY(0),
- _surface(0) {
+ _hotspotY(0) {
}
ZorkCursor::ZorkCursor(const Common::String &fileName)
: _width(0),
_height(0),
_hotspotX(0),
- _hotspotY(0),
- _surface(0) {
+ _hotspotY(0) {
Common::File file;
if (!file.open(fileName))
return;
@@ -59,10 +57,13 @@ ZorkCursor::ZorkCursor(const Common::String &fileName)
_width = file.readUint16LE();
_height = file.readUint16LE();
- uint dataSize = _width * _height * 2;
- _surface = new byte[dataSize];
- uint32 bytesRead = file.read(_surface, dataSize);
+ uint dataSize = _width * _height * sizeof(uint16);
+ _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
+ uint32 bytesRead = file.read(_surface.getPixels(), dataSize);
assert(bytesRead == dataSize);
+
+ // Convert to RGB 565
+ _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 6, 0, 11, 5, 0, 0));
}
ZorkCursor::ZorkCursor(const ZorkCursor &other) {
@@ -71,10 +72,7 @@ ZorkCursor::ZorkCursor(const ZorkCursor &other) {
_hotspotX = other._hotspotX;
_hotspotY = other._hotspotY;
- uint dataSize = _width * _height * 2;
- _surface = new byte[dataSize];
-
- memcpy(_surface, other._surface, dataSize);
+ _surface.copyFrom(other._surface);
}
ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
@@ -83,18 +81,9 @@ ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
_hotspotX = other._hotspotX;
_hotspotY = other._hotspotY;
- uint dataSize = _width * _height * 2;
- _surface = new byte[dataSize];
-
- memcpy(_surface, other._surface, dataSize);
+ _surface.copyFrom(other._surface);
return *this;
}
-ZorkCursor::~ZorkCursor() {
- if (_surface != 0) {
- delete[] _surface;
- }
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 9a561fc..ec9f5ed 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -25,7 +25,7 @@
#include "common/types.h"
-#include "graphics/cursor.h"
+#include "graphics/surface.h"
namespace Common {
class String;
@@ -42,14 +42,13 @@ public:
ZorkCursor();
ZorkCursor(const Common::String &fileName);
ZorkCursor(const ZorkCursor &other);
- ~ZorkCursor();
private:
uint16 _width;
uint16 _height;
uint16 _hotspotX;
uint16 _hotspotY;
- byte *_surface;
+ Graphics::Surface _surface;
public:
ZorkCursor &operator=(const ZorkCursor &other);
@@ -59,7 +58,7 @@ public:
uint16 getHotspotX() const { return _hotspotX; }
uint16 getHotspotY() const { return _hotspotY; }
byte getKeyColor() const { return 0; }
- const byte *getSurface() const { return _surface; }
+ const byte *getSurface() const { return (const byte *)_surface.getPixels(); }
};
} // End of namespace ZVision
Commit: f146a0209fdc3bf0dd5e26dbca8b5257b6ee7c0e
https://github.com/scummvm/scummvm/commit/f146a0209fdc3bf0dd5e26dbca8b5257b6ee7c0e
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Convert image rendering to RBG 565
This is part of a series of commits converting all game assets to RBG 565 from
RBG 555. The argument is that certain backends do not support RGB 555.
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 99c987f..b1282dc 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -244,6 +244,9 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
} else {
tga.destroy();
}
+
+ // Convert in place to RGB 565 from RGB 555
+ destination.convertToInPlace(_pixelFormat);
}
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
Commit: cdc484218186daa9a4f60792a2070ad089b7853e
https://github.com/scummvm/scummvm/commit/cdc484218186daa9a4f60792a2070ad089b7853e
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Convert RLF animations to RBG 565
This is part of a series of commits converting all game assets to RBG 565 from
RBG 555. The argument is that certain backends do not support RGB 555.
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 90b39dc..df1fe11 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -33,6 +33,9 @@
namespace ZVision {
+const Graphics::PixelFormat RlfAnimation::_pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+const Graphics::PixelFormat RlfAnimation::_pixelFormat565 = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+
RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
: _stream(stream),
_lastFrameRead(0),
@@ -41,8 +44,8 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_height(0),
_frameTime(0),
_frames(0),
- _currentFrameBuffer(0),
_currentFrame(-1),
+ _currentFrameBuffer(0),
_frameBufferByteSize(0) {
if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
@@ -68,12 +71,8 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
}
RlfAnimation::~RlfAnimation() {
- if (_frames != 0) {
- delete[] _frames;
- }
- if (_currentFrameBuffer != 0) {
- delete[] _currentFrameBuffer;
- }
+ delete[] _currentFrameBuffer;
+ delete[] _frames;
}
bool RlfAnimation::readHeader() {
@@ -230,11 +229,14 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
- WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
destOffset += 2;
@@ -248,7 +250,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -275,11 +277,14 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
- WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
destOffset += 2;
@@ -293,14 +298,16 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
}
- uint16 sampleColor = READ_LE_UINT16(source + sourceOffset);
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 sampleColor = _pixelFormat565.RGBToColor(r, g, b);
sourceOffset += 2;
numberOfSamples += 2;
while (numberOfSamples > 0) {
if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 5091185..6f93934 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -26,6 +26,7 @@
#include "common/types.h"
#include "common/file.h"
+#include "graphics/surface.h"
namespace Common {
@@ -51,6 +52,9 @@ private:
uint32 encodedSize;
};
+ const static Graphics::PixelFormat _pixelFormat555;
+ const static Graphics::PixelFormat _pixelFormat565;
+
private:
Common::File _file;
bool _stream;
Commit: 4288c4fa0e36d2274257154c5365f71f6f6dd015
https://github.com/scummvm/scummvm/commit/4288c4fa0e36d2274257154c5365f71f6f6dd015
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:38-07:00
Commit Message:
ZVISION: Remove unnecessary pixel format switching from video code
This is part of a series of commits converting all game assets to RBG 565 from
RBG 555. The argument is that certain backends do not support RGB 555. AVI
videos are already in RGB 565, so we just need to remove the code that switched
the pixelFormat during videos.
Changed paths:
engines/zvision/video.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 377b24a..d0dbbc5 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -77,11 +77,6 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
}
void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
- // Videos use a different pixel format
- Common::List<Graphics::PixelFormat> formats;
- formats.push_back(videoDecoder.getPixelFormat());
- initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, formats);
-
byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
uint16 origWidth = videoDecoder.getWidth();
@@ -167,9 +162,6 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
if (scale != 1) {
delete[] scaledVideoFrameBuffer;
}
-
- // Reset the pixel format to the original state
- initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
}
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index c32e782..b5cae8a 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -50,9 +50,10 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
: Engine(syst),
_gameDescription(gameDesc),
_workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT),
- _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /*RGB 555*/
+ _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
_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().
Commit: fa578497b3ceb745c31f789a40b95b4a15f1cbe0
https://github.com/scummvm/scummvm/commit/fa578497b3ceb745c31f789a40b95b4a15f1cbe0
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Use Surface::getPixels() rather than getBasePtr(0, 0)
Prevents unnecessary algebra
Changed paths:
engines/zvision/video.cpp
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index d0dbbc5..5230653 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -143,10 +143,10 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
if (frame) {
if (scale != 1) {
- scaleBuffer((const byte *)frame->getBasePtr(0, 0), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
+ scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
- _system->copyRectToScreen((const byte *)frame->getBasePtr(0, 0), pitch, x, y, finalWidth, finalHeight);
+ _system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight);
}
}
}
Commit: 03d3646f8463cddddb17f043b7b827be1ca1bb39
https://github.com/scummvm/scummvm/commit/03d3646f8463cddddb17f043b7b827be1ca1bb39
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Remove unnecessary check if a pointer was non-NULL before deleting.
I found out that you can call delete/free/delete[] on NULL and the function's defined
behavior is to do nothing.
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 7d23b68..45c21ef 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -79,9 +79,8 @@ LeverControl::~LeverControl() {
} else if (_fileType == RLF) {
delete _animation.rlf;
}
- if (_frameInfo != 0) {
- delete[] _frameInfo;
- }
+
+ delete[] _frameInfo;
}
void LeverControl::parseLevFile(const Common::String &fileName) {
Commit: 7d1dca9ad10c3121fc44f991e6b21c68db939344
https://github.com/scummvm/scummvm/commit/7d1dca9ad10c3121fc44f991e6b21c68db939344
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Implement enabled/disabled support in Controls
Changed paths:
engines/zvision/lever_control.cpp
engines/zvision/push_toggle_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 45c21ef..2a5fe4f 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -183,6 +183,10 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (!_enabled) {
+ return;
+ }
+
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
@@ -190,6 +194,10 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common
}
void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (!_enabled) {
+ return;
+ }
+
_mouseIsCaptured = false;
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
@@ -201,6 +209,10 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (!_enabled) {
+ return false;
+ }
+
bool cursorWasChanged = false;
if (_mouseIsCaptured) {
@@ -228,6 +240,10 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
bool LeverControl::process(uint32 deltaTimeInMillis) {
+ if (!_enabled) {
+ return false;
+ }
+
// TODO: Implement reversal over time
return false;
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index be038e7..f4c0bc9 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -71,12 +71,20 @@ PushToggleControl::~PushToggleControl() {
}
void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (!_enabled) {
+ return;
+ }
+
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
}
}
bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (!_enabled) {
+ return false;
+ }
+
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_hoverCursor);
return true;
Commit: ef3e26a0730b070d2026641f554b525ae9f4b138
https://github.com/scummvm/scummvm/commit/ef3e26a0730b070d2026641f554b525ae9f4b138
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Fix typo in PixelFormat
Changed paths:
engines/zvision/cursor.cpp
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index 57859b9..4731d29 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -63,7 +63,7 @@ ZorkCursor::ZorkCursor(const Common::String &fileName)
assert(bytesRead == dataSize);
// Convert to RGB 565
- _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 6, 0, 11, 5, 0, 0));
+ _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
}
ZorkCursor::ZorkCursor(const ZorkCursor &other) {
Commit: 21474d32ab2d2de784c6cd12f85e0f9ad68bcea4
https://github.com/scummvm/scummvm/commit/21474d32ab2d2de784c6cd12f85e0f9ad68bcea4
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Fix error is RenderManager backgroundOffset handling
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b1282dc..96030ba 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -118,7 +118,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (destinationY > 0) {
// Move destinationY to 0
- subRectX = surface.w - destinationX;
+ subRectY = surface.h - destinationY;
destinationY = 0;
}
}
@@ -327,12 +327,12 @@ void RenderManager::moveBackground(int offset) {
if (_backgroundOffset.x <= -_backgroundWidth)
_backgroundOffset.x += _backgroundWidth;
else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
+ _backgroundOffset.x -= _backgroundWidth;
if (_backgroundOffset.y <= -_backgroundHeight)
_backgroundOffset.y += _backgroundHeight;
else if (_backgroundOffset.y >= _backgroundHeight)
- _backgroundOffset.y += _backgroundHeight;
+ _backgroundOffset.y -= _backgroundHeight;
renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
} else if (state == RenderTable::PANORAMA) {
@@ -341,12 +341,12 @@ void RenderManager::moveBackground(int offset) {
if (_backgroundOffset.x <= -_backgroundWidth)
_backgroundOffset.x += _backgroundWidth;
else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
+ _backgroundOffset.x -= _backgroundWidth;
if (_backgroundOffset.y <= -_backgroundHeight)
_backgroundOffset.y += _backgroundHeight;
else if (_backgroundOffset.y >= _backgroundHeight)
- _backgroundOffset.y += _backgroundHeight;
+ _backgroundOffset.y -= _backgroundHeight;
renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
} else {
Commit: dfe143137aa89909c9bf0fd24a359be8af9c2834
https://github.com/scummvm/scummvm/commit/dfe143137aa89909c9bf0fd24a359be8af9c2834
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Remove extraneous TODO
After redoing the math, I now know that the algorithm requires for(x) { for(y) {}}
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 55285b4..a4dfe67 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -163,7 +163,6 @@ void RenderTable::generatePanoramaLookupTable() {
float fovInRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
float cylinderRadius = halfHeight / tan(fovInRadians);
- // 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 (uint x = 0; x < _numColumns; x++) {
// Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
// Alpha represents the horizontal angle between the viewer at the center of a cylinder and x
@@ -173,7 +172,6 @@ void RenderTable::generatePanoramaLookupTable() {
// We also scale it by _panoramaOptions.linearScale
int32 xInCylinderCoords = int32(floor((cylinderRadius * _panoramaOptions.linearScale * alpha) + halfWidth));
-
float cosAlpha = cos(alpha);
for (uint y = 0; y < _numRows; y++) {
Commit: 3c3a6bd93542ad82bd7972050db141628b413b30
https://github.com/scummvm/scummvm/commit/3c3a6bd93542ad82bd7972050db141628b413b30
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Fix typo in point range clipping
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index a4dfe67..0a83d5e 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -62,7 +62,7 @@ void RenderTable::setRenderState(RenderState newState) {
const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Point &point) {
// If we're outside the range of the RenderTable, no warping is happening. Return the maximum image coords
- if (point.x >= (int16)_numColumns || point.y >= (int16)_numRows || point.x < 0 || point.y , 0) {
+ if (point.x >= (int16)_numColumns || point.y >= (int16)_numRows || point.x < 0 || point.y < 0) {
int16 x = CLIP<int16>(point.x, 0, (int16)_numColumns);
int16 y = CLIP<int16>(point.y, 0, (int16)_numRows);
return Common::Point(x, y);
Commit: 94f350b1542e3129ad6c9597fe3fefdface444ae
https://github.com/scummvm/scummvm/commit/94f350b1542e3129ad6c9597fe3fefdface444ae
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Implement TILT RenderTable creation
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 0a83d5e..b457ae0 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -189,12 +189,35 @@ void RenderTable::generatePanoramaLookupTable() {
}
void RenderTable::generateTiltLookupTable() {
- for (uint x = 0; x < _numColumns; x++) {
- for (uint y = 0; y < _numRows; y++) {
- uint32 index = y * _numColumns + x;
+ float halfWidth = (float)_numColumns / 2.0f;
+ float halfHeight = (float)_numRows / 2.0f;
+
+ float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f);
+ float cylinderRadius = halfWidth / tan(fovInRadians);
+
+ for (uint y = 0; y < _numRows; y++) {
+
+ // Add an offset of 0.01 to overcome zero tan/atan issue (horizontal line on half of screen)
+ // Alpha represents the horizontal angle between the viewer at the center of a cylinder and y
+ float alpha = atan(((float)y - halfHeight + 0.01f) / cylinderRadius);
+
+ // To get y in cylinder coordinates, we just need to calculate the arc length
+ // We also scale it by _tiltOptions.linearScale
+ int32 yInCylinderCoords = int32(floor((cylinderRadius * _tiltOptions.linearScale * alpha) + halfHeight));
- _internalBuffer[index].x = 0;
- _internalBuffer[index].y = 0;
+ float cosAlpha = cos(alpha);
+ uint32 columnIndex = y * _numColumns;
+
+ for (uint x = 0; x < _numColumns; x++) {
+ // To calculate x in cylinder coordinates, we can do similar triangles comparison,
+ // comparing the triangle from the center to the screen and from the center to the edge of the cylinder
+ int32 xInCylinderCoords = int32(floor(halfWidth + ((float)x - halfWidth) * cosAlpha));
+
+ uint32 index = columnIndex + x;
+
+ // Only store the (x,y) offsets instead of the absolute positions
+ _internalBuffer[index].x = xInCylinderCoords - x;
+ _internalBuffer[index].y = yInCylinderCoords - y;
}
}
}
Commit: 97b0d5988ade1a2453e268706343d6aaacceb5de
https://github.com/scummvm/scummvm/commit/97b0d5988ade1a2453e268706343d6aaacceb5de
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Fix how LeverControl return routes are parsed
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 2a5fe4f..3c452c3 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -153,7 +153,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
_frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
}
- Common::StringTokenizer tokenizer(line, " ^=");
+ Common::StringTokenizer tokenizer(line, " ^=()");
tokenizer.nextToken();
tokenizer.nextToken();
@@ -168,8 +168,11 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
_frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
} else if (token.hasPrefix("P")) {
- uint to;
- sscanf(token.c_str(), "P(%*u to %u)", &to);
+ // Format: P(<from> to <to>)
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+ token = tokenizer.nextToken();
+ uint to = atoi(token.c_str());
_frameInfo[frameNumber].returnRoute.push_back(to);
}
Commit: 1ad594bd30e238f4da7f686d2680abbc1e1450bd
https://github.com/scummvm/scummvm/commit/1ad594bd30e238f4da7f686d2680abbc1e1450bd
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:39-07:00
Commit Message:
ZVISION: Add default values for tilt options
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index b457ae0..1f3e556 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -52,7 +52,9 @@ void RenderTable::setRenderState(RenderState newState) {
_panoramaOptions.reverse = false;
break;
case TILT:
-
+ _tiltOptions.fieldOfView = 27.0f;
+ _tiltOptions.linearScale = 0.55f;
+ _tiltOptions.reverse = false;
break;
case FLAT:
// Intentionally left empty
Commit: d2d375500954100cbb32a052baa00349ce1d3ec1
https://github.com/scummvm/scummvm/commit/d2d375500954100cbb32a052baa00349ce1d3ec1
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Fix tilt render table comment
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 1f3e556..5fd7a16 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -200,7 +200,7 @@ void RenderTable::generateTiltLookupTable() {
for (uint y = 0; y < _numRows; y++) {
// Add an offset of 0.01 to overcome zero tan/atan issue (horizontal line on half of screen)
- // Alpha represents the horizontal angle between the viewer at the center of a cylinder and y
+ // Alpha represents the vertical angle between the viewer at the center of a cylinder and y
float alpha = atan(((float)y - halfHeight + 0.01f) / cylinderRadius);
// To get y in cylinder coordinates, we just need to calculate the arc length
Commit: 04bf6f79e93d3a86e6ec2e8c391e59a5f1dd230c
https://github.com/scummvm/scummvm/commit/04bf6f79e93d3a86e6ec2e8c391e59a5f1dd230c
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Implement return pathing for LeverControls
Changed paths:
engines/zvision/lever_control.cpp
engines/zvision/lever_control.h
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 3c452c3..91e5407 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -47,7 +47,9 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_currentFrame(0),
_lastRenderedFrame(0),
_mouseIsCaptured(false),
- _isReturning(false) {
+ _isReturning(false),
+ _accumulatedTime(0),
+ _returnRoutesCurrentFrame(0) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
@@ -204,11 +206,9 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
_mouseIsCaptured = false;
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
- if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
-
- }
-
- // TODO: Animation reversal back to origin
+ _isReturning = true;
+ _returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
+ _returnRoutesCurrentFrame = _currentFrame;
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
@@ -247,8 +247,31 @@ bool LeverControl::process(uint32 deltaTimeInMillis) {
return false;
}
- // TODO: Implement reversal over time
+ if (_isReturning) {
+ _accumulatedTime += deltaTimeInMillis;
+ while (_accumulatedTime >= ANIMATION_FRAME_TIME) {
+ _accumulatedTime -= ANIMATION_FRAME_TIME;
+ if (_returnRoutesCurrentFrame == *_returnRoutesCurrentProgress) {
+ _returnRoutesCurrentProgress++;
+ }
+ if (_returnRoutesCurrentProgress == _frameInfo[_currentFrame].returnRoute.end()) {
+ _isReturning = false;
+ _currentFrame = _returnRoutesCurrentFrame;
+ _engine->getScriptManager()->setStateValue(_key, _currentFrame);
+ return false;
+ }
+ uint toFrame = *_returnRoutesCurrentProgress;
+ if (_returnRoutesCurrentFrame < toFrame) {
+ _returnRoutesCurrentFrame++;
+ } else if (_returnRoutesCurrentFrame > toFrame) {
+ _returnRoutesCurrentFrame--;
+ }
+
+ renderFrame(_returnRoutesCurrentFrame);
+ }
+ }
+
return false;
}
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index d359318..b5677a2 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -61,7 +61,8 @@ private:
};
enum {
- ANGLE_DELTA = 30 // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA)
+ ANGLE_DELTA = 30, // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA)
+ ANIMATION_FRAME_TIME = 30 // In millis
};
private:
@@ -85,6 +86,8 @@ private:
bool _isReturning;
Common::Point _lastMousePos;
Common::List<uint>::iterator _returnRoutesCurrentProgress;
+ uint _returnRoutesCurrentFrame;
+ uint32 _accumulatedTime;
public:
void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
Commit: 07fdcdf312e5498508affe825db37a6f1644f738
https://github.com/scummvm/scummvm/commit/07fdcdf312e5498508affe825db37a6f1644f738
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Only do return pathing after the mouse is captured
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 91e5407..744fde1 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -203,12 +203,14 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
return;
}
- _mouseIsCaptured = false;
- _engine->getScriptManager()->setStateValue(_key, _currentFrame);
+ if (_mouseIsCaptured) {
+ _mouseIsCaptured = false;
+ _engine->getScriptManager()->setStateValue(_key, _currentFrame);
- _isReturning = true;
- _returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
- _returnRoutesCurrentFrame = _currentFrame;
+ _isReturning = true;
+ _returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
+ _returnRoutesCurrentFrame = _currentFrame;
+ }
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
Commit: 2ad40edd47098144cecb808cf308bca8329479ff
https://github.com/scummvm/scummvm/commit/2ad40edd47098144cecb808cf308bca8329479ff
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Limit tilt movement to the size of the image
// TODO: Remove image wrapping logic for the vertical direction since this can never happen now
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 96030ba..ea34469 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -324,15 +324,7 @@ void RenderManager::moveBackground(int offset) {
if (state == RenderTable::TILT) {
_backgroundOffset += Common::Point(0, offset);
- if (_backgroundOffset.x <= -_backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
- else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x -= _backgroundWidth;
-
- if (_backgroundOffset.y <= -_backgroundHeight)
- _backgroundOffset.y += _backgroundHeight;
- else if (_backgroundOffset.y >= _backgroundHeight)
- _backgroundOffset.y -= _backgroundHeight;
+ _backgroundOffset.y = CLIP<int16>(_backgroundOffset.y, _screenCenterY, (int16)_backgroundHeight - _screenCenterY);
renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
} else if (state == RenderTable::PANORAMA) {
@@ -343,11 +335,6 @@ void RenderManager::moveBackground(int offset) {
else if (_backgroundOffset.x >= _backgroundWidth)
_backgroundOffset.x -= _backgroundWidth;
- if (_backgroundOffset.y <= -_backgroundHeight)
- _backgroundOffset.y += _backgroundHeight;
- else if (_backgroundOffset.y >= _backgroundHeight)
- _backgroundOffset.y -= _backgroundHeight;
-
renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
} else {
renderImageToScreen(_currentBackground, 0, 0);
Commit: f1bd8de21dd504fd9b8fa07c76ab75b5c40d29cd
https://github.com/scummvm/scummvm/commit/f1bd8de21dd504fd9b8fa07c76ab75b5c40d29cd
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Overload ZVision::playAnimation to support general video files
Changed paths:
engines/zvision/animation.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation.cpp b/engines/zvision/animation.cpp
index 8ca892d..f43e854 100644
--- a/engines/zvision/animation.cpp
+++ b/engines/zvision/animation.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "common/system.h"
+#include "video/video_decoder.h"
#include "zvision/zvision.h"
#include "zvision/rlf_animation.h"
@@ -84,4 +85,47 @@ void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, Dispose
}
}
+void ZVision::playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) {
+ _clock.stop();
+ animation->start();
+
+ // Only continue while the video is still playing
+ while (!shouldQuit() && !animation->endOfVideo() && animation->isPlaying()) {
+ // Check for engine quit and video stop key presses
+ while (!animation->endOfVideo() && animation->isPlaying() && _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:
+ animation->stop();
+ break;
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if (animation->needsUpdate()) {
+ const Graphics::Surface *frame = animation->decodeNextFrame();
+
+ if (frame) {
+ _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+ }
+ }
+
+ // Always update the screen so the mouse continues to render
+ _system->updateScreen();
+
+ _system->delayMillis(animation->getTimeToNextFrame());
+ }
+
+ _clock.start();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index a02fecc..f961f1f 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -126,6 +126,7 @@ public:
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+ void playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
/**
* Utility method to cycle through all the cursors in the game. After
Commit: c3fcff96124190e847e714fbed23c60c1785c169
https://github.com/scummvm/scummvm/commit/c3fcff96124190e847e714fbed23c60c1785c169
Author: richiesams (adastley at gmail.com)
Date: 2013-09-24T04:59:40-07:00
Commit Message:
ZVISION: Move TimerNode to it's own file
Changed paths:
A engines/zvision/timer_node.cpp
A engines/zvision/timer_node.h
engines/zvision/action_node.cpp
engines/zvision/action_node.h
engines/zvision/actions.cpp
engines/zvision/module.mk
diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
index 8e35460..eeb8930 100644
--- a/engines/zvision/action_node.cpp
+++ b/engines/zvision/action_node.cpp
@@ -28,19 +28,6 @@
namespace ZVision {
-TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : Control(engine, key), _timeLeft(timeInSeconds * 1000) {
-}
-bool TimerNode::process(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
index b0b8cae..c9beb7b 100644
--- a/engines/zvision/action_node.h
+++ b/engines/zvision/action_node.h
@@ -29,24 +29,7 @@
namespace ZVision {
-class ZVision;
-
-class TimerNode : public Control {
-public:
- TimerNode(ZVision *engine, 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
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-
-private:
- uint32 _timeLeft;
-};
+
} // End of namespace ZVision
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index d039f04..0265ebd 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,6 +33,7 @@
#include "zvision/action_node.h"
#include "zvision/zork_raw.h"
#include "zvision/zork_avi_decoder.h"
+#include "zvision/timer_node.h"
namespace ZVision {
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 7412ad8..48b8a66 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS := \
script_manager.o \
scripts.o \
single_value_container.o \
+ timer_node.o \
utility.o \
video.o \
zvision.o \
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
new file mode 100644
index 0000000..c9ef9d2
--- /dev/null
+++ b/engines/zvision/timer_node.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/timer_node.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+
+namespace ZVision {
+
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : Control(engine, key), _timeLeft(timeInSeconds * 1000) {
+}
+
+bool TimerNode::process(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/timer_node.h b/engines/zvision/timer_node.h
new file mode 100644
index 0000000..d692f1f
--- /dev/null
+++ b/engines/zvision/timer_node.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_TIMER_NODE_H
+#define ZVISION_TIMER_NODE_H
+
+#include "common/types.h"
+
+#include "zvision/control.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class TimerNode : public Control {
+public:
+ TimerNode(ZVision *engine, 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
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ uint32 _timeLeft;
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: a76f852c385576a84f613489417d71b3ec49b2c6
https://github.com/scummvm/scummvm/commit/a76f852c385576a84f613489417d71b3ec49b2c6
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T16:59:42-07:00
Commit Message:
Merge branch 'master' into zvision
Changed paths:
engines/kyra/text_rpg.cpp
engines/mortevielle/mortevielle.cpp
engines/mortevielle/mortevielle.h
engines/mortevielle/utils.cpp
engines/toltecs/detection.cpp
engines/tsage/blue_force/blueforce_logic.cpp
engines/tsage/blue_force/blueforce_scenes1.cpp
engines/tsage/blue_force/blueforce_scenes5.cpp
engines/tsage/blue_force/blueforce_scenes8.cpp
engines/tsage/core.cpp
engines/tsage/events.cpp
engines/tsage/globals.cpp
engines/tsage/globals.h
engines/tsage/ringworld2/ringworld2_logic.cpp
engines/tsage/ringworld2/ringworld2_logic.h
engines/tsage/ringworld2/ringworld2_scenes0.cpp
engines/tsage/ringworld2/ringworld2_scenes0.h
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/tsage/ringworld2/ringworld2_scenes1.h
engines/tsage/ringworld2/ringworld2_scenes2.cpp
engines/tsage/ringworld2/ringworld2_scenes3.cpp
Commit: 78d5a41cd0812353e0dbc675f010540dc630f343
https://github.com/scummvm/scummvm/commit/78d5a41cd0812353e0dbc675f010540dc630f343
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:26:13-07:00
Commit Message:
ZVISION: Call Surface::free() in the cursor destructor
Changed paths:
engines/zvision/cursor.cpp
engines/zvision/cursor.h
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index 4731d29..bb0700c 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -81,9 +81,14 @@ ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
_hotspotX = other._hotspotX;
_hotspotY = other._hotspotY;
+ _surface.free();
_surface.copyFrom(other._surface);
return *this;
}
+ZorkCursor::~ZorkCursor() {
+ _surface.free();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index ec9f5ed..805a8e7 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -42,6 +42,7 @@ public:
ZorkCursor();
ZorkCursor(const Common::String &fileName);
ZorkCursor(const ZorkCursor &other);
+ ~ZorkCursor();
private:
uint16 _width;
Commit: 34dcea106a2d1d7a7ba3412ef43ca547e67a66dd
https://github.com/scummvm/scummvm/commit/34dcea106a2d1d7a7ba3412ef43ca547e67a66dd
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:27:03-07:00
Commit Message:
ZVISION: Cleanup _activeControls in ScriptManager destructor
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 98bc2e3..b95f263 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -48,6 +48,9 @@ ScriptManager::~ScriptManager() {
for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
delete (*iter);
}
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ delete (*iter);
+ }
}
void ScriptManager::initialize() {
Commit: 4d86061b5714ea7e27edffc343572eb85c57a674
https://github.com/scummvm/scummvm/commit/4d86061b5714ea7e27edffc343572eb85c57a674
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:31:44-07:00
Commit Message:
ZVISION: Cleanup all used memory in RLF animations
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index df1fe11..73fbe05 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -72,6 +72,9 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
RlfAnimation::~RlfAnimation() {
delete[] _currentFrameBuffer;
+ for (int i = 0; i < _frameCount; i++) {
+ delete[] _frames[i].encodedData;
+ }
delete[] _frames;
}
Commit: 98dc015dc1329ef233d4fe9606ab98c26b0f8438
https://github.com/scummvm/scummvm/commit/98dc015dc1329ef233d4fe9606ab98c26b0f8438
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:32:12-07:00
Commit Message:
ZVISION: Free the _currentBackground Surface in RenderManager destructor
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index ea34469..463faef 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -54,6 +54,7 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
RenderManager::~RenderManager() {
delete[] _workingWindowBuffer;
+ _currentBackground.free();
}
void RenderManager::update(uint deltaTimeInMillis) {
Commit: efb0495758b8f5ee5f59d148a15cf03265cd6c2d
https://github.com/scummvm/scummvm/commit/efb0495758b8f5ee5f59d148a15cf03265cd6c2d
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:34:01-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 73fbe05..ffc272c 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -72,7 +72,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
RlfAnimation::~RlfAnimation() {
delete[] _currentFrameBuffer;
- for (int i = 0; i < _frameCount; i++) {
+ for (uint i = 0; i < _frameCount; i++) {
delete[] _frames[i].encodedData;
}
delete[] _frames;
Commit: b3a32746162399d065efc33b71770ddb6e3eeab0
https://github.com/scummvm/scummvm/commit/b3a32746162399d065efc33b71770ddb6e3eeab0
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T22:39:39-07:00
Commit Message:
ZVISION: Remove unnecessary file.open()
It's done inside readImageToSurface() and it no longer needs
to be on the heap
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 463faef..837e388 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -282,13 +282,6 @@ RenderTable *RenderManager::getRenderTable() {
}
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;
- }
-
readImageToSurface(fileName, _currentBackground);
moveBackground(0);
Commit: 5d86eb4a4af6416b8c40a6cb5aaf234bddabde95
https://github.com/scummvm/scummvm/commit/5d86eb4a4af6416b8c40a6cb5aaf234bddabde95
Author: richiesams (adastley at gmail.com)
Date: 2013-09-02T23:23:17-07:00
Commit Message:
ZVISION: Change ActionPlayAnimation::_loop refer to a count rather than a boolean
_loopCount refers to the number of times an animation should be played, where 0
corresponds to infinite.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 0265ebd..4c532eb 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -224,15 +224,13 @@ 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, &_loopCount, &_mask, &_framerate);
_fileName = Common::String(fileName);
- _loop = loop == 1 ? true : false;
}
bool ActionPlayAnimation::execute(ZVision *engine) {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 5e7c2c6..b36e277 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -239,7 +239,7 @@ private:
uint32 _end;
uint _mask;
uint _framerate;
- bool _loop;
+ uint _loopCount;
};
class ActionPreloadAnimation : public ResultAction {
Commit: 9ea91f5c9c311276339e93ef64eaa53fd4435692
https://github.com/scummvm/scummvm/commit/9ea91f5c9c311276339e93ef64eaa53fd4435692
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T21:44:26-07:00
Commit Message:
ZVISION: Convert ZVision singleton accessors to be inline
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b5cae8a..eb474c7 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -164,24 +164,8 @@ void ZVision::pauseEngineIntern(bool pause) {
}
}
-ScriptManager *ZVision::getScriptManager() const {
- return _scriptManager;
}
-RenderManager *ZVision::getRenderManager() const {
- return _renderManager;
-}
-
-CursorManager *ZVision::getCursorManager() const {
- return _cursorManager;
-}
-
-Common::RandomSource *ZVision::getRandomSource() const {
- return _rnd;
-}
-
-ZVisionGameId ZVision::getGameId() const {
- return _gameDescription->gameId;
}
void ZVision::cycleThroughCursors() {
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index f961f1f..331fa2a 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -108,11 +108,11 @@ public:
Common::Error run();
void pauseEngineIntern(bool pause);
- ScriptManager *getScriptManager() const;
- RenderManager *getRenderManager() const;
- CursorManager *getCursorManager() const;
- Common::RandomSource *getRandomSource() const;
- ZVisionGameId getGameId() const;
+ ScriptManager *getScriptManager() const { return _scriptManager; }
+ RenderManager *getRenderManager() const { return _renderManager; }
+ CursorManager *getCursorManager() const { return _cursorManager; }
+ Common::RandomSource *getRandomSource() const { return _rnd; }
+ ZVisionGameId getGameId() const { return _gameDescription->gameId; }
/**
* Play a video until it is finished. This is a blocking call. It will call
Commit: 117eea1be6231ad26fe43f9080fa572b4deb73cb
https://github.com/scummvm/scummvm/commit/117eea1be6231ad26fe43f9080fa572b4deb73cb
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T21:54:29-07:00
Commit Message:
ZVISION: Allow changeLocation to be executed right away instead of next frame
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 b95f263..f3c945d 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -181,6 +181,9 @@ void ScriptManager::checkPuzzleCriteria() {
bool shouldContinue = true;
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
+ if (!shouldContinue) {
+ break;
+ }
}
// Set the puzzle as completed
@@ -258,18 +261,11 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo
}
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
- _nextLocation.world = world;
- _nextLocation.room = room;
- _nextLocation.node = node;
- _nextLocation.view = view;
- _nextLocation.offset = offset;
-
- _changeLocation = true;
-}
+ assert(world != 0);
+ debug("Changing location to: %c %c %c %c %u", world, room, node, view, offset);
-void ScriptManager::changeLocationIntern() {
- assert(_nextLocation.world != 0);
- debug("Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
+ // Auto save
+ _engine->getSaveManager()->autoSave();
// Clear all the containers
_referenceTable.clear();
@@ -290,11 +286,11 @@ void ScriptManager::changeLocationIntern() {
_engine->getRenderManager()->setBackgroundVelocity(0);
// Parse into puzzles and controls
- Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
parseScrFile(fileName);
// Change the background position
- _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
+ _engine->getRenderManager()->setBackgroundPosition(offset);
// Enable all the controls
for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 1a272f1..75be66c 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -70,8 +70,7 @@ private:
/** Holds the currently active controls */
Common::List<Control *> _activeControls;
- Location _nextLocation;
- bool _changeLocation;
+ Location _currentLocation;
public:
void initialize();
@@ -113,7 +112,6 @@ public:
private:
void createReferenceTable();
- void changeLocationIntern();
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
Commit: dd307c2484f7d251fa447bc6c05a3c4512928681
https://github.com/scummvm/scummvm/commit/dd307c2484f7d251fa447bc6c05a3c4512928681
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:15:19-07:00
Commit Message:
ZVISION: Create method to get the current background offset
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 837e388..e394baf 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -335,4 +335,16 @@ void RenderManager::moveBackground(int offset) {
}
}
+uint32 RenderManager::getCurrentBackgroundOffset() {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+
+ if (state == RenderTable::PANORAMA) {
+ return _backgroundOffset.x;
+ } else if (state == RenderTable::TILT) {
+ return _backgroundOffset.y;
+ } else {
+ return 0;
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 41dedab..1dcbf76 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -166,6 +166,7 @@ public:
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
RenderTable *getRenderTable();
+ uint32 getCurrentBackgroundOffset();
private:
/**
Commit: 9dd54a16e00be09cf549e38b03387e28efe9195d
https://github.com/scummvm/scummvm/commit/9dd54a16e00be09cf549e38b03387e28efe9195d
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:15:28-07:00
Commit Message:
ZVISION: Remove zero valued entries in the global state table once a frame
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 f3c945d..45e14592 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -196,6 +196,17 @@ void ScriptManager::checkPuzzleCriteria() {
}
}
+void ScriptManager::cleanStateTable() {
+ for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
+ // If the value is equal to zero, we can purge it since getStateValue()
+ // will return zero if _globalState doesn't contain a key
+ if ((*iter)._value == 0) {
+ // Remove the node
+ _globalState.erase(iter);
+ }
+ }
+}
+
uint ScriptManager::getStateValue(uint32 key) {
if (_globalState.contains(key))
return _globalState[key];
@@ -285,6 +296,9 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Reset the background velocity
_engine->getRenderManager()->setBackgroundVelocity(0);
+ // Clean the global state table
+ cleanStateTable();
+
// Parse into puzzles and controls
Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
parseScrFile(fileName);
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 75be66c..723f4fe 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -114,6 +114,7 @@ private:
void createReferenceTable();
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
+ void cleanStateTable();
// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
public:
Commit: b45c9e7c2683ee73ca1f54718b630597e9bc42c9
https://github.com/scummvm/scummvm/commit/b45c9e7c2683ee73ca1f54718b630597e9bc42c9
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:27-07:00
Commit Message:
ZVISION: Create method for getting the current location
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 45e14592..6330e20 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -37,8 +37,7 @@
namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine)
- : _engine(engine),
- _changeLocation(false) {
+ : _engine(engine) {
}
ScriptManager::~ScriptManager() {
@@ -61,11 +60,6 @@ void ScriptManager::initialize() {
void ScriptManager::update(uint deltaTimeMillis) {
updateNodes(deltaTimeMillis);
checkPuzzleCriteria();
-
- if (_changeLocation) {
- changeLocationIntern();
- _changeLocation = false;
- }
}
void ScriptManager::createReferenceTable() {
@@ -333,6 +327,20 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Create the puzzle reference table
createReferenceTable();
+
+ // Update _currentLocation
+ _currentLocation.world = world;
+ _currentLocation.room = room;
+ _currentLocation.node = node;
+ _currentLocation.view = view;
+ _currentLocation.offset = offset;
+}
+
+Location ScriptManager::getCurrentLocation() const {
+ Location location = _currentLocation;
+ location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset();
+
+ return location;
}
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 723f4fe..96123a8 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -110,6 +110,8 @@ public:
void changeLocation(char world, char room, char node, char view, uint32 offset);
+ Location getCurrentLocation() const;
+
private:
void createReferenceTable();
void updateNodes(uint deltaTimeMillis);
Commit: 11bf2405f80378dd49d539d61384bad7b32daad0
https://github.com/scummvm/scummvm/commit/11bf2405f80378dd49d539d61384bad7b32daad0
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:36-07:00
Commit Message:
ZVISION: Create base methods for Control serialization
Changed paths:
engines/zvision/control.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index b16ca7f..9144c32 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -29,6 +29,7 @@
namespace Common {
class SeekableReadStream;
struct Point;
+class WriteStream;
}
namespace ZVision {
@@ -74,6 +75,36 @@ public:
* @return If true, the node can be deleted after process() finishes
*/
virtual bool process(uint32 deltaTimeInMillis) { return false; }
+ /**
+ * Serialize a Control for save game use. This should only be used if a Control needs
+ * to save values that would be different from initialization. AKA a TimerNode needs to
+ * store the amount of time left on the timer. Any Controls overriding this *MUST* write
+ * their key as the first data outputted. The default implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override deserialize()
+ * and needsSerialization()
+ *
+ * @param stream Stream to write any needed data to
+ */
+ virtual void serialize(Common::WriteStream *stream) {}
+ /**
+ * De-serialize data from a save game stream. This should only be implemented if the
+ * Control also implements serialize(). The calling method assumes the size of the
+ * data read from the stream exactly equals that written in serialize(). The default
+ * implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override serialize()
+ * and needsSerialization()
+ *
+ * @param stream Save game file stream
+ */
+ virtual void deserialize(Common::SeekableReadStream *stream) {}
+ /**
+ * If a Control overrides serialize() and deserialize(), this should return true
+ *
+ * @return Does the Control need save game serialization?
+ */
+ virtual inline bool needsSerialization() { return false; }
protected:
ZVision * _engine;
Commit: ac578bf9b7b9c58dbaad58c874517b7af45dfa3f
https://github.com/scummvm/scummvm/commit/ac578bf9b7b9c58dbaad58c874517b7af45dfa3f
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:44-07:00
Commit Message:
ZVISION: Implement TimerNode serialization
Changed paths:
engines/zvision/timer_node.cpp
engines/zvision/timer_node.h
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index c9ef9d2..81468db 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -22,6 +22,8 @@
#include "common/scummsys.h"
+#include "common/stream.h"
+
#include "zvision/timer_node.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
@@ -43,4 +45,13 @@ bool TimerNode::process(uint32 deltaTimeInMillis) {
return false;
}
+void TimerNode::serialize(Common::WriteStream *stream) {
+ stream->writeUint32LE(_key);
+ stream->writeUint32LE(_timeLeft);
+}
+
+void TimerNode::deserialize(Common::SeekableReadStream *stream) {
+ _timeLeft = stream->readUint32LE();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index d692f1f..21c344b 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -43,6 +43,9 @@ public:
* @return If true, the node can be deleted after process() finishes
*/
bool process(uint32 deltaTimeInMillis);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
+ inline bool needsSerialization() { return true; }
private:
uint32 _timeLeft;
Commit: 644af30df572f4965d63e1dba77c574a1d5ad69a
https://github.com/scummvm/scummvm/commit/644af30df572f4965d63e1dba77c574a1d5ad69a
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:45-07:00
Commit Message:
ZVISION: Create ScriptManager state table serialization methods
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 6330e20..25cbc6d 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -25,11 +25,13 @@
#include "common/algorithm.h"
#include "common/hashmap.h"
#include "common/debug.h"
+#include "common/stream.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
#include "zvision/cursor_manager.h"
+#include "zvision/save_manager.h"
#include "zvision/actions.h"
#include "zvision/action_node.h"
#include "zvision/utility.h"
@@ -336,6 +338,28 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
_currentLocation.offset = offset;
}
+void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
+ // Write the number of state value entries
+ stream->writeUint32LE(_globalState.size());
+
+ for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
+ // Write out the key/value pair
+ stream->writeUint32LE((*iter)._key);
+ stream->writeUint32LE((*iter)._value);
+ }
+}
+
+void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
+ // Read the number of key/value pairs
+ uint32 numberOfPairs = stream->readUint32LE();
+
+ for (uint32 i = 0; i < numberOfPairs; i++) {
+ uint32 key = stream->readUint32LE();
+ uint32 value = stream->readUint32LE();
+ setStateValue(key, value);
+ }
+}
+
Location ScriptManager::getCurrentLocation() const {
Location location = _currentLocation;
location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset();
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 96123a8..c537750 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -110,6 +110,8 @@ public:
void changeLocation(char world, char room, char node, char view, uint32 offset);
+ void serializeStateTable(Common::WriteStream *stream);
+ void deserializeStateTable(Common::SeekableReadStream *stream);
Location getCurrentLocation() const;
private:
Commit: 23ae67c7776f5f3a2207109e7d6cdaef16940979
https://github.com/scummvm/scummvm/commit/23ae67c7776f5f3a2207109e7d6cdaef16940979
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:46-07:00
Commit Message:
ZVISION: Create ScriptManager _activeControls serialization methods
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 25cbc6d..d5fcf81 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -360,6 +360,36 @@ void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
}
}
+void ScriptManager::serializeControls(Common::WriteStream *stream) {
+ // Count how many controls need to save their data
+ // Because WriteStream isn't seekable
+ uint32 numberOfControlsNeedingSerialization = 0;
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ if ((*iter)->needsSerialization()) {
+ numberOfControlsNeedingSerialization++;
+ }
+ }
+ stream->writeUint32LE(numberOfControlsNeedingSerialization);
+
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->serialize(stream);
+ }
+}
+
+void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {
+ uint32 numberOfControls = stream->readUint32LE();
+
+ for (uint32 i = 0; i < numberOfControls; i++) {
+ uint32 key = stream->readUint32LE();
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ if ((*iter)->getKey() == key) {
+ (*iter)->deserialize(stream);
+ break;
+ }
+ }
+ }
+}
+
Location ScriptManager::getCurrentLocation() const {
Location location = _currentLocation;
location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset();
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index c537750..d2ad4ac 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -112,6 +112,9 @@ public:
void serializeStateTable(Common::WriteStream *stream);
void deserializeStateTable(Common::SeekableReadStream *stream);
+ void serializeControls(Common::WriteStream *stream);
+ void deserializeControls(Common::SeekableReadStream *stream);
+
Location getCurrentLocation() const;
private:
Commit: 235620750a493afdb592f36521fb693533c6dec0
https://github.com/scummvm/scummvm/commit/235620750a493afdb592f36521fb693533c6dec0
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:16:46-07:00
Commit Message:
ZVISION: Create methods for generating save file names
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index eb474c7..85e357e 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -164,8 +164,12 @@ void ZVision::pauseEngineIntern(bool pause) {
}
}
+Common::String ZVision::generateSaveFileName(uint slot) {
+ return Common::String::format("%s.%02u", _targetName.c_str(), slot);
}
+Common::String ZVision::generateAutoSaveFileName() {
+ return Common::String::format("%s.auto", _targetName.c_str());
}
void ZVision::cycleThroughCursors() {
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 331fa2a..a438557 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -135,6 +135,9 @@ public:
*/
void cycleThroughCursors();
+ Common::String generateSaveFileName(uint slot);
+ Common::String generateAutoSaveFileName();
+
private:
void initialize();
Commit: 488484d2dccc146421da452420a3966a40970c55
https://github.com/scummvm/scummvm/commit/488484d2dccc146421da452420a3966a40970c55
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:17:37-07:00
Commit Message:
ZVISION: Implement SaveManager
Changed paths:
A engines/zvision/save_manager.cpp
engines/zvision/module.mk
engines/zvision/save_manager.h
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 48b8a66..c8c60ca 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
render_manager.o \
render_table.o \
rlf_animation.o \
+ save_manager.o \
scr_file_handling.o \
script_manager.o \
scripts.o \
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
new file mode 100644
index 0000000..9611b9c
--- /dev/null
+++ b/engines/zvision/save_manager.cpp
@@ -0,0 +1,176 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "graphics/surface.h"
+#include "graphics/thumbnail.h"
+
+#include "zvision/save_manager.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+
+
+namespace ZVision {
+
+const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
+
+void SaveManager::saveGame(uint slot, const Common::String &saveName) {
+ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
+
+ // Write out the savegame header
+ file->writeUint32BE(SAVEGAME_ID);
+
+ // Write savegame name
+ file->writeString(saveName);
+ file->writeByte(0);
+
+ // We can't call writeGameSaveData because the save menu is actually
+ // a room, so writeGameSaveData would save us in the save menu.
+ // However, an auto save is performed before each room change, so we
+ // can copy the data from there. We can guarantee that an auto save file will
+ // exist before this is called because the save menu can only be accessed
+ // after the first room (the main menu) has loaded.
+ Common::InSaveFile *autoSaveFile = saveFileManager->openForLoading(_engine->generateAutoSaveFileName());
+
+ // Skip over the header info
+ autoSaveFile->readSint32BE(); // SAVEGAME_ID
+ autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL
+
+ // Read the rest to a buffer
+ uint32 size = autoSaveFile->size() - autoSaveFile->pos();
+ byte *buffer = new byte[size];
+ autoSaveFile->read(buffer, size);
+
+ // Then write the buffer to the new file
+ file->write(buffer, size);
+
+ // Cleanup
+ delete[] buffer;
+ file->finalize();
+}
+
+void SaveManager::autoSave() {
+ Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());
+
+ // Write out the savegame header
+ file->writeUint32BE(SAVEGAME_ID);
+
+ file->writeString("auto");
+ file->writeByte(0);
+
+ writeSaveGameData(file);
+
+ file->finalize();
+}
+
+void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
+ // Create a thumbnail and save it
+ Graphics::saveThumbnail(*file);
+
+ // Write out the save date/time
+ TimeDate td;
+ g_system->getTimeAndDate(td);
+ file->writeSint16LE(td.tm_year + 1900);
+ file->writeSint16LE(td.tm_mon + 1);
+ file->writeSint16LE(td.tm_mday);
+ file->writeSint16LE(td.tm_hour);
+ file->writeSint16LE(td.tm_min);
+
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ // Write out the current location
+ Location currentLocation = scriptManager->getCurrentLocation();
+ file->writeByte(currentLocation.world);
+ file->writeByte(currentLocation.room);
+ file->writeByte(currentLocation.node);
+ file->writeByte(currentLocation.view);
+ file->writeUint32LE(currentLocation.offset);
+
+ // Write out the current state table values
+ scriptManager->serializeStateTable(file);
+
+ // Write out any controls needing to save state
+ scriptManager->serializeControls(file);
+}
+
+Common::Error SaveManager::loadGame(uint slot) {
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
+ if (saveFile == 0) {
+ return Common::kPathDoesNotExist;
+ }
+
+ // Read the header
+ SaveGameHeader header;
+ if (!readSaveGameHeader(saveFile, header)) {
+ return Common::kUnknownError;
+ }
+
+ char world = (char)saveFile->readByte();
+ char room = (char)saveFile->readByte();
+ char node = (char)saveFile->readByte();
+ char view = (char)saveFile->readByte();
+ uint32 offset = (char)saveFile->readUint32LE();
+
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ // Load the room
+ scriptManager->changeLocation(world, room, node, view, offset);
+
+ // Update the state table values
+ scriptManager->deserializeStateTable(saveFile);
+
+ // Update the controls
+ scriptManager->deserializeControls(saveFile);
+
+ return Common::kNoError;
+}
+
+bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
+ if (in->readSint32BE() != SAVEGAME_ID) {
+ warning("File is not a ZVision save file. Aborting load");
+ return false;
+ }
+
+ // Read in the save name
+ header.saveName.clear();
+ char ch;
+ while ((ch = (char)in->readByte()) != '\0')
+ header.saveName += ch;
+
+ // Get the thumbnail
+ header.thumbnail = Graphics::loadThumbnail(*in);
+ if (!header.thumbnail)
+ return false;
+
+ // Read in save date/time
+ header.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
+ header.saveMinutes = in->readSint16LE();
+
+ return true;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 487cf20..ae65750 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -23,6 +23,43 @@
#ifndef ZVISION_SAVE_MANAGER_H
#define ZVISION_SAVE_MANAGER_H
-// TODO: Implement SaveManager
+#include "common/types.h"
+
+#include "common/savefile.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+struct SaveGameHeader {
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+ int saveYear, saveMonth, saveDay;
+ int saveHour, saveMinutes;
+};
+
+class SaveManager {
+public:
+ SaveManager(ZVision *engine);
+
+private:
+ ZVision *_engine;
+ static const uint32 SAVEGAME_ID;
+
+public:
+ void autoSave();
+ void saveGame(uint slot, const Common::String &saveName);
+ Common::Error loadGame(uint slot);
+
+private:
+ void writeSaveGameData(Common::OutSaveFile *file);
+ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
+};
+
+} // End of namespace ZVision
#endif
Commit: 7ff45447adca39bca5be78bac34e8f900644edae
https://github.com/scummvm/scummvm/commit/7ff45447adca39bca5be78bac34e8f900644edae
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:18:05-07:00
Commit Message:
ZVISION: Create an instance of SaveManager
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index a438557..1a259d0 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -48,6 +48,7 @@ class Console;
class ScriptManager;
class RenderManager;
class CursorManager;
+class SaveManager;
class RlfAnimation;
// our engine debug channels
@@ -95,6 +96,7 @@ private:
ScriptManager *_scriptManager;
RenderManager *_renderManager;
CursorManager *_cursorManager;
+ SaveManager *_saveManager;
// Clock
Clock _clock;
@@ -111,6 +113,7 @@ public:
ScriptManager *getScriptManager() const { return _scriptManager; }
RenderManager *getRenderManager() const { return _renderManager; }
CursorManager *getCursorManager() const { return _cursorManager; }
+ SaveManager *getSaveManager() const { return _saveManager; }
Common::RandomSource *getRandomSource() const { return _rnd; }
ZVisionGameId getGameId() const { return _gameDescription->gameId; }
Commit: 150a4793a670fb06b7997d7964f9626f3a238766
https://github.com/scummvm/scummvm/commit/150a4793a670fb06b7997d7964f9626f3a238766
Author: richiesams (adastley at gmail.com)
Date: 2013-09-03T22:19:03-07:00
Commit Message:
ZVISION: Initialize Location to the main menu
This ensures that the first auto save of the game will have a
useful location
Changed paths:
engines/zvision/script_manager.h
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index d2ad4ac..61ad4fa 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -39,6 +39,8 @@ namespace ZVision {
class ZVision;
struct Location {
+ Location() : world('g'), room('a'), node('r'), view('y'), offset(0) {}
+
char world;
char room;
char node;
Commit: 1697a9c83114b181074f43d9f872f6e5c43c0a5f
https://github.com/scummvm/scummvm/commit/1697a9c83114b181074f43d9f872f6e5c43c0a5f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-03T22:35:34-07:00
Commit Message:
Merge branch 'master' into zvision
Changed paths:
engines/sci/engine/workarounds.cpp
video/codecs/truemotion1.cpp
Commit: 2dab04e14b82a110ea8b49b2f6778b5a5fe79375
https://github.com/scummvm/scummvm/commit/2dab04e14b82a110ea8b49b2f6778b5a5fe79375
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:29:19-07:00
Commit Message:
ZVISION: Do full working window warp instead of image at a time
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/render_table.cpp
engines/zvision/render_table.h
engines/zvision/zvision.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index e394baf..6c0e8d2 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -34,7 +34,7 @@
namespace ZVision {
-RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
+RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
: _system(system),
_workingWidth(workingWindow.width()),
_workingHeight(workingWindow.height()),
@@ -49,12 +49,14 @@ RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow,
_accumulatedVelocityMilliseconds(0),
_renderTable(_workingWidth, _workingHeight) {
- _workingWindowBuffer = new uint16[_workingWidth *_workingHeight];
+ _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat);
+ _backBuffer.create(windowWidth, windowHeight, pixelFormat);
}
RenderManager::~RenderManager() {
- delete[] _workingWindowBuffer;
+ _workingWindowBuffer.free();
_currentBackground.free();
+ _backBuffer.free();
}
void RenderManager::update(uint deltaTimeInMillis) {
@@ -75,14 +77,29 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
}
-void RenderManager::clearWorkingWindowToColor(uint16 color) {
+void RenderManager::renderBackbufferToScreen() {
+ //RenderTable::RenderState state = _renderTable.getRenderState();
+ //if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ // _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
+ //} else {
+ //_system->copyRectToScreen(_workingWindowBuffer.getPixels(), _workingWindowBuffer.pitch, _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h);
+ //}
+
+ // TODO: Add menu rendering
+
+ //_system->copyRectToScreen(_backBuffer.getPixels(), _backBuffer.pitch, 0, 0, _backBuffer.w, _backBuffer.h);
+}
+
+void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
uint32 workingWindowSize = _workingWidth * _workingHeight;
+ byte r, g, b;
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b);
+ uint16 colorIn565 = _pixelFormat.RGBToColor(r, g, b);
+ uint16 *bufferPtr = (uint16 *)_workingWindowBuffer.getPixels();
for (uint32 i = 0; i < workingWindowSize; i++) {
- _workingWindowBuffer[i] = color;
+ bufferPtr[i] = color;
}
-
- _system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), _workingWindow.left, _workingWindow.top, _workingWidth, _workingHeight);
}
void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
@@ -136,13 +153,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (!subRect.isValidRect() || subRect.isEmpty())
return;
- if (_renderTable.getRenderState() == RenderTable::FLAT) {
- _system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
- } else {
- _renderTable.mutateImage((uint16 *)surface.getPixels(), _workingWindowBuffer, surface.w, surface.h, destinationX, destinationY, subRect, wrap);
-
- _system->copyRectToScreen(_workingWindowBuffer, _workingWidth * sizeof(uint16), destinationX + _workingWindow.left, destinationY + _workingWindow.top, subRect.width(), subRect.height());
- }
+ _system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX, destinationY, subRect.width(), subRect.height()/*, wrap*/);
}
void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
@@ -250,6 +261,44 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
destination.convertToInPlace(_pixelFormat);
}
+void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 destX, int32 destY, int32 width, int32 height, bool wrap) {
+ uint32 destOffset = 0;
+ uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
+
+ for (int32 y = 0; y < height; y++) {
+ for (int32 x = 0; x < width; x++) {
+ int32 sourceYIndex = y;
+ int32 sourceXIndex = x;
+
+ if (wrap) {
+ while (sourceXIndex >= width) {
+ sourceXIndex -= width;
+ }
+ while (sourceXIndex < 0) {
+ sourceXIndex += width;
+ }
+
+ while (sourceYIndex >= height) {
+ sourceYIndex -= height;
+ }
+ while (sourceYIndex < 0) {
+ sourceYIndex += height;
+ }
+ } else {
+ // Clamp the yIndex to the size of the image
+ sourceYIndex = CLIP<int16>(sourceYIndex, 0, height - 1);
+
+ // Clamp the xIndex to the size of the image
+ sourceXIndex = CLIP<int16>(sourceXIndex, 0, width - 1);
+ }
+
+ workingWindowBufferPtr[destOffset + x] = buffer[sourceYIndex * width + sourceXIndex];
+ }
+
+ destOffset += _workingWidth;
+ }
+}
+
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
// Convert from screen space to working window space
Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 1dcbf76..bf44c88 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -45,7 +45,7 @@ namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
+ RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
~RenderManager();
private:
@@ -54,7 +54,8 @@ private:
// A buffer the exact same size as the workingWindow
// It's used for panorama/tilt warping and for clearing the workingWindow to a single color
- uint16 *_workingWindowBuffer;
+ Graphics::Surface _workingWindowBuffer;
+ Graphics::Surface _backBuffer;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
@@ -90,9 +91,6 @@ private:
/** Holds any 'leftover' milliseconds between frames */
uint _accumulatedVelocityMilliseconds;
- // TODO: Potentially merge this buffer and _workingWindowBuffer
- byte *_scaledVideoFrameBuffer;
-
public:
void initialize();
/**
@@ -103,11 +101,16 @@ public:
void update(uint deltaTimeInMillis);
/**
+ * Renders the current state of the backbuffer to the screen
+ */
+ void renderBackbufferToScreen();
+
+ /**
* Fills the entire workingWindow with the specified color
*
* @param color The color to fill the working window with. (In RGB 555)
*/
- void clearWorkingWindowToColor(uint16 color);
+ void clearWorkingWindowTo555Color(uint16 color);
/**
* Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
@@ -186,6 +189,8 @@ private:
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
+ void renderRectToWorkingWindow(uint16 *buffer, int32 x, int32 y, int32 width, int32 height, bool wrap);
+
void moveBackground(int offset);
};
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 5fd7a16..c72775b 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -100,45 +100,29 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap) {
- for (int16 y = subRect.top; y < subRect.bottom; y++) {
- int16 normalizedY = y - subRect.top;
- int32 internalColumnIndex = (normalizedY + destinationY) * _numColumns;
- int32 destColumnIndex = normalizedY * _numColumns;
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint16 destWidth) {
+ uint32 destColumnOffset = 0;
- for (int16 x = subRect.left; x < subRect.right; x++) {
- int16 normalizedX = x - subRect.left;
+ for (int16 y = 0; y < _numRows; y++) {
+ int32 sourceColumnOffset = y * _numColumns;
- int32 index = internalColumnIndex + normalizedX + destinationX;
+ for (int16 x = 0; x < _numColumns; x++) {
+ int32 index = sourceColumnOffset + x;
// RenderTable only stores offsets from the original coordinates
- int16 sourceYIndex = y + _internalBuffer[index].y;
- int16 sourceXIndex = x + _internalBuffer[index].x;
-
- if (wrap) {
- while (sourceXIndex >= imageWidth) {
- sourceXIndex -= imageWidth;
- }
- while (sourceXIndex < 0) {
- sourceXIndex += imageWidth;
- }
-
- while (sourceYIndex >= imageHeight) {
- sourceYIndex -= imageHeight;
- }
- while (sourceYIndex < 0) {
- sourceYIndex += imageHeight;
- }
- } else {
- // Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<int16>(sourceYIndex, 0, imageHeight - 1);
-
- // Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<int16>(sourceXIndex, 0, imageWidth - 1);
- }
+ int32 sourceYIndex = y + _internalBuffer[index].y;
+ int32 sourceXIndex = x + _internalBuffer[index].x;
+
+ // Clamp the yIndex to the size of the image
+ sourceYIndex = CLIP<int32>(sourceYIndex, 0, _numRows - 1);
+
+ // Clamp the xIndex to the size of the image
+ sourceXIndex = CLIP<int32>(sourceXIndex, 0, _numColumns - 1);
- destBuffer[destColumnIndex + normalizedX] = sourceBuffer[sourceYIndex * imageWidth + sourceXIndex];
+ destBuffer[destColumnOffset + x] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
+
+ destColumnOffset += destWidth;
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index e582080..737fc84 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, int16 imageWidth, int16 imageHeight, int16 destinationX, int16 destinationY, const Common::Rect &subRect, bool wrap);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint16 destWidth);
void generateRenderTable();
void setPanoramaFoV(float fov);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 85e357e..f858070 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -69,7 +69,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, _workingWindow, _pixelFormat);
+ _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
debug("ZVision::ZVision");
}
@@ -141,6 +141,9 @@ Common::Error ZVision::run() {
_renderManager->update(deltaTime);
_scriptManager->update(deltaTime);
+ // Render the backBuffer to the screen
+ _renderManager->renderBackbufferToScreen();
+
// Update the screen
_system->updateScreen();
Commit: 6ce62475ca19e4c395ad0e341d9875fb8825fde4
https://github.com/scummvm/scummvm/commit/6ce62475ca19e4c395ad0e341d9875fb8825fde4
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:29:48-07:00
Commit Message:
ZVISION: Disable saving until it can be fixed
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index d5fcf81..84d39ff 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -272,7 +272,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
debug("Changing location to: %c %c %c %c %u", world, room, node, view, offset);
// Auto save
- _engine->getSaveManager()->autoSave();
+ //_engine->getSaveManager()->autoSave();
// Clear all the containers
_referenceTable.clear();
Commit: b6366a2697f9d604fbb19ed38f1a1e51cf0d2b7f
https://github.com/scummvm/scummvm/commit/b6366a2697f9d604fbb19ed38f1a1e51cf0d2b7f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:50:34-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
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 c72775b..3e7a86e 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -100,24 +100,24 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint16 destWidth) {
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth) {
uint32 destColumnOffset = 0;
- for (int16 y = 0; y < _numRows; y++) {
- int32 sourceColumnOffset = y * _numColumns;
+ for (uint32 y = 0; y < _numRows; y++) {
+ uint32 sourceColumnOffset = y * _numColumns;
- for (int16 x = 0; x < _numColumns; x++) {
- int32 index = sourceColumnOffset + x;
+ for (uint32 x = 0; x < _numColumns; x++) {
+ uint32 index = sourceColumnOffset + x;
// RenderTable only stores offsets from the original coordinates
- int32 sourceYIndex = y + _internalBuffer[index].y;
- int32 sourceXIndex = x + _internalBuffer[index].x;
+ uint32 sourceYIndex = y + _internalBuffer[index].y;
+ uint32 sourceXIndex = x + _internalBuffer[index].x;
// Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<int32>(sourceYIndex, 0, _numRows - 1);
+ sourceYIndex = CLIP<uint32>(sourceYIndex, 0, _numRows - 1);
// Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<int32>(sourceXIndex, 0, _numColumns - 1);
+ sourceXIndex = CLIP<uint32>(sourceXIndex, 0, _numColumns - 1);
destBuffer[destColumnOffset + x] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 737fc84..ba3c7d2 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint16 destWidth);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth);
void generateRenderTable();
void setPanoramaFoV(float fov);
Commit: 2840ce750eee4409dc4926d57dbe686640cac625
https://github.com/scummvm/scummvm/commit/2840ce750eee4409dc4926d57dbe686640cac625
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:50:42-07:00
Commit Message:
ZVISION: Save the Puzzle key, since ChangeLocation could be called
Which wipes all the puzzles
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 84d39ff..860697c 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -174,6 +174,8 @@ void ScriptManager::checkPuzzleCriteria() {
if (puzzle->criteriaList.empty() || criteriaMet) {
debug("Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
+ uint32 key = puzzle->key;
+
bool shouldContinue = true;
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
@@ -183,7 +185,7 @@ void ScriptManager::checkPuzzleCriteria() {
}
// Set the puzzle as completed
- setStateValue(puzzle->key, 1);
+ setStateValue(key, 1);
if (!shouldContinue) {
break;
Commit: e92e3c5b0b59869a78a41fe1013ed73ab6ac59fe
https://github.com/scummvm/scummvm/commit/e92e3c5b0b59869a78a41fe1013ed73ab6ac59fe
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:50:42-07:00
Commit Message:
ZVISION: Delete action_node
Changed paths:
R engines/zvision/action_node.cpp
R engines/zvision/action_node.h
engines/zvision/actions.cpp
engines/zvision/module.mk
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp
deleted file mode 100644
index eeb8930..0000000
--- a/engines/zvision/action_node.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/action_node.h"
-#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-
-namespace ZVision {
-
-
-
-} // End of namespace ZVision
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h
deleted file mode 100644
index c9beb7b..0000000
--- a/engines/zvision/action_node.h
+++ /dev/null
@@ -1,36 +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_ACTION_NODE_H
-#define ZVISION_ACTION_NODE_H
-
-#include "common/types.h"
-
-#include "zvision/control.h"
-
-namespace ZVision {
-
-
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 4c532eb..2a0a72b 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -30,7 +30,6 @@
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
-#include "zvision/action_node.h"
#include "zvision/zork_raw.h"
#include "zvision/zork_avi_decoder.h"
#include "zvision/timer_node.h"
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index c8c60ca..c916ab8 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,7 +1,6 @@
MODULE := engines/zvision
MODULE_OBJS := \
- action_node.o \
actions.o \
animation.o \
clock.o \
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 860697c..0af1ff1 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -33,7 +33,6 @@
#include "zvision/cursor_manager.h"
#include "zvision/save_manager.h"
#include "zvision/actions.h"
-#include "zvision/action_node.h"
#include "zvision/utility.h"
namespace ZVision {
Commit: 558a987143a23826c25779f2a8c139130bf341c0
https://github.com/scummvm/scummvm/commit/558a987143a23826c25779f2a8c139130bf341c0
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:50:43-07:00
Commit Message:
ZVISION: Fix accidental signed read from save file header
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 9611b9c..595a052 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -147,7 +147,7 @@ Common::Error SaveManager::loadGame(uint slot) {
}
bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
- if (in->readSint32BE() != SAVEGAME_ID) {
+ if (in->readUint32BE() != SAVEGAME_ID) {
warning("File is not a ZVision save file. Aborting load");
return false;
}
Commit: db83d1b5e58e461051ec3d74efa89f332ddae1f9
https://github.com/scummvm/scummvm/commit/db83d1b5e58e461051ec3d74efa89f332ddae1f9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-06T20:50:44-07:00
Commit Message:
ZVISION: Actually use the converted color instead of the old one
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 6c0e8d2..b10a35d 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -98,7 +98,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
uint16 *bufferPtr = (uint16 *)_workingWindowBuffer.getPixels();
for (uint32 i = 0; i < workingWindowSize; i++) {
- bufferPtr[i] = color;
+ bufferPtr[i] = colorIn565;
}
}
Commit: 1e1d5cafe50b6860875c2bb392c1180852e5037d
https://github.com/scummvm/scummvm/commit/1e1d5cafe50b6860875c2bb392c1180852e5037d
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T09:52:20-07:00
Commit Message:
ZVISION: Re-enable rendering to the backbuffer
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b10a35d..f528acf 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -78,16 +78,16 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
void RenderManager::renderBackbufferToScreen() {
- //RenderTable::RenderState state = _renderTable.getRenderState();
- //if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- // _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
- //} else {
- //_system->copyRectToScreen(_workingWindowBuffer.getPixels(), _workingWindowBuffer.pitch, _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h);
- //}
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
+ } else {
+ renderRectToWorkingWindow((uint16 *)_workingWindowBuffer.getPixels(), _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h, false);
+ }
// TODO: Add menu rendering
- //_system->copyRectToScreen(_backBuffer.getPixels(), _backBuffer.pitch, 0, 0, _backBuffer.w, _backBuffer.h);
+ _system->copyRectToScreen(_backBuffer.getPixels(), _backBuffer.pitch, 0, 0, _backBuffer.w, _backBuffer.h);
}
void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
@@ -153,7 +153,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (!subRect.isValidRect() || subRect.isEmpty())
return;
- _system->copyRectToScreen(surface.getBasePtr(subRect.left, subRect.top), surface.pitch, destinationX, destinationY, subRect.width(), subRect.height()/*, wrap*/);
+ renderRectToWorkingWindow((uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, subRect.width(), subRect.height(), wrap);
}
void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
Commit: 94268fed060761b85a2d3d848590e658e2a9de8f
https://github.com/scummvm/scummvm/commit/94268fed060761b85a2d3d848590e658e2a9de8f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T09:52:49-07:00
Commit Message:
ZVISION: Update ActionSetPartialScreen to use new function name
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 2a0a72b..d91c3b8 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -286,7 +286,7 @@ bool ActionSetPartialScreen::execute(ZVision *engine) {
RenderManager *renderManager = engine->getRenderManager();
if (_backgroundColor > 0) {
- renderManager->clearWorkingWindowToColor(_backgroundColor);
+ renderManager->clearWorkingWindowTo555Color(_backgroundColor);
}
renderManager->renderImageToScreen(_fileName, _x, _y);
Commit: 2f12ac0d719e38b966c2e2123531364212b3d2db
https://github.com/scummvm/scummvm/commit/2f12ac0d719e38b966c2e2123531364212b3d2db
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T12:07:13-07:00
Commit Message:
ZVISION: Fix pixel copying errors in renderRectToWorkingWindow
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 f528acf..7f79645 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -82,7 +82,7 @@ void RenderManager::renderBackbufferToScreen() {
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
_renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
} else {
- renderRectToWorkingWindow((uint16 *)_workingWindowBuffer.getPixels(), _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h, false);
+ _backBuffer.copyRectToSurface(_workingWindowBuffer.getPixels(), _workingWindowBuffer.pitch, _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h);
}
// TODO: Add menu rendering
@@ -153,7 +153,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (!subRect.isValidRect() || subRect.isEmpty())
return;
- renderRectToWorkingWindow((uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, subRect.width(), subRect.height(), wrap);
+ renderRectToWorkingWindow((uint16 *)surface.getBasePtr(subRect.left, subRect.top), surface.w, destinationX, destinationY, subRect.width(), subRect.height());
}
void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
@@ -261,41 +261,18 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
destination.convertToInPlace(_pixelFormat);
}
-void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 destX, int32 destY, int32 width, int32 height, bool wrap) {
+void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 imageWidth, int32 destX, int32 destY, int32 width, int32 height) {
uint32 destOffset = 0;
+ uint32 sourceOffset = 0;
uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
for (int32 y = 0; y < height; y++) {
for (int32 x = 0; x < width; x++) {
- int32 sourceYIndex = y;
- int32 sourceXIndex = x;
-
- if (wrap) {
- while (sourceXIndex >= width) {
- sourceXIndex -= width;
- }
- while (sourceXIndex < 0) {
- sourceXIndex += width;
- }
-
- while (sourceYIndex >= height) {
- sourceYIndex -= height;
- }
- while (sourceYIndex < 0) {
- sourceYIndex += height;
- }
- } else {
- // Clamp the yIndex to the size of the image
- sourceYIndex = CLIP<int16>(sourceYIndex, 0, height - 1);
-
- // Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<int16>(sourceXIndex, 0, width - 1);
- }
-
- workingWindowBufferPtr[destOffset + x] = buffer[sourceYIndex * width + sourceXIndex];
+ workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x];
}
destOffset += _workingWidth;
+ sourceOffset += imageWidth;
}
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index bf44c88..07b2e85 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -189,7 +189,7 @@ private:
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
- void renderRectToWorkingWindow(uint16 *buffer, int32 x, int32 y, int32 width, int32 height, bool wrap);
+ void renderRectToWorkingWindow(uint16 *buffer, int32 x, int32 y, int32 imageWidth, int32 width, int32 height);
void moveBackground(int offset);
};
Commit: 48745ad197b2986c784bd18c5ae73c569a20b3e9
https://github.com/scummvm/scummvm/commit/48745ad197b2986c784bd18c5ae73c569a20b3e9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T12:32:51-07:00
Commit Message:
ZVISION: Add dirty rectangling support for pure image rendering
Still need to add support for ResultActions and Controls that directly
use OSystem::copyRectToScreen()
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
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 7f79645..bd3e735 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -60,6 +60,10 @@ RenderManager::~RenderManager() {
}
void RenderManager::update(uint deltaTimeInMillis) {
+ // Clear the dirty rects from last frame
+ _workingWindowDirtyRect = Common::Rect();
+ _backBufferDirtyRect = Common::Rect();
+
// An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
if (_backgroundInverseVelocity != 0) {
_accumulatedVelocityMilliseconds += deltaTimeInMillis;
@@ -78,16 +82,25 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
void RenderManager::renderBackbufferToScreen() {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
- } else {
- _backBuffer.copyRectToSurface(_workingWindowBuffer.getPixels(), _workingWindowBuffer.pitch, _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h);
+ if (!_workingWindowDirtyRect.isEmpty()) {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top), _backBuffer.w, _workingWindowDirtyRect);
+ } else {
+ _backBuffer.copyRectToSurface(_workingWindowBuffer.getBasePtr(_workingWindowDirtyRect.left, _workingWindowDirtyRect.top), _workingWindowBuffer.pitch, _workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top, _workingWindowDirtyRect.width(), _workingWindowDirtyRect.height());
+ }
+
+ // Translate the working window dirty rect to screen coords
+ _workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top);
+ // Then extend the backbuffer dirty rect to contain it
+ _backBufferDirtyRect.extend(_workingWindowDirtyRect);
}
// TODO: Add menu rendering
- _system->copyRectToScreen(_backBuffer.getPixels(), _backBuffer.pitch, 0, 0, _backBuffer.w, _backBuffer.h);
+ if (!_backBufferDirtyRect.isEmpty()) {
+ _system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
+ }
}
void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
@@ -274,6 +287,8 @@ void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 imageWidth,
destOffset += _workingWidth;
sourceOffset += imageWidth;
}
+
+ _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
}
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 07b2e85..fd36ab5 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -57,6 +57,9 @@ private:
Graphics::Surface _workingWindowBuffer;
Graphics::Surface _backBuffer;
+ Common::Rect _workingWindowDirtyRect;
+ Common::Rect _backBufferDirtyRect;
+
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
/** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 3e7a86e..5eb208e 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -100,14 +100,15 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth) {
- uint32 destColumnOffset = 0;
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
+ uint32 destOffset = 0;
- for (uint32 y = 0; y < _numRows; y++) {
- uint32 sourceColumnOffset = y * _numColumns;
+ for (uint32 y = subRect.top; y < subRect.bottom; y++) {
+ uint32 sourceOffset = y * _numColumns;
- for (uint32 x = 0; x < _numColumns; x++) {
- uint32 index = sourceColumnOffset + x;
+ for (uint32 x = subRect.left; x < subRect.right; x++) {
+ uint32 normalizedX = x - subRect.left;
+ uint32 index = sourceOffset + x;
// RenderTable only stores offsets from the original coordinates
uint32 sourceYIndex = y + _internalBuffer[index].y;
@@ -119,10 +120,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 d
// Clamp the xIndex to the size of the image
sourceXIndex = CLIP<uint32>(sourceXIndex, 0, _numColumns - 1);
- destBuffer[destColumnOffset + x] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
+ destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
- destColumnOffset += destWidth;
+ destOffset += destWidth;
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index ba3c7d2..7c8e7d6 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect);
void generateRenderTable();
void setPanoramaFoV(float fov);
Commit: 70e75dd6403a25f220e2e5eb0af9c3f0e940288c
https://github.com/scummvm/scummvm/commit/70e75dd6403a25f220e2e5eb0af9c3f0e940288c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:03:25-07:00
Commit Message:
ZVISION: Make the declaration and implementation of copyRectToWorkingWindow be the same
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 bd3e735..3793ea8 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -166,7 +166,7 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (!subRect.isValidRect() || subRect.isEmpty())
return;
- renderRectToWorkingWindow((uint16 *)surface.getBasePtr(subRect.left, subRect.top), surface.w, destinationX, destinationY, subRect.width(), subRect.height());
+ copyRectToWorkingWindow((const uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, surface.w, subRect.width(), subRect.height());
}
void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
@@ -274,7 +274,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
destination.convertToInPlace(_pixelFormat);
}
-void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 imageWidth, int32 destX, int32 destY, int32 width, int32 height) {
+void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index fd36ab5..9881676 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -108,6 +108,8 @@ public:
*/
void renderBackbufferToScreen();
+ void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
+
/**
* Fills the entire workingWindow with the specified color
*
@@ -192,8 +194,6 @@ private:
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
- void renderRectToWorkingWindow(uint16 *buffer, int32 x, int32 y, int32 imageWidth, int32 width, int32 height);
-
void moveBackground(int offset);
};
Commit: 47ee636f0503f39531371e3e611a4b6fb81906e0
https://github.com/scummvm/scummvm/commit/47ee636f0503f39531371e3e611a4b6fb81906e0
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:04:01-07:00
Commit Message:
ZVISION: Make LeverControl render to the working window instead of directly to the screen
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 744fde1..318710e 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -32,6 +32,7 @@
#include "zvision/lever_control.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
#include "zvision/cursor_manager.h"
#include "zvision/rlf_animation.h"
#include "zvision/zork_avi_decoder.h"
@@ -375,7 +376,6 @@ void LeverControl::renderFrame(uint frameNumber) {
}
const uint16 *frameData;
- int pitch;
int x = _animationCoords.left;
int y = _animationCoords.top;
int width;
@@ -384,19 +384,17 @@ void LeverControl::renderFrame(uint frameNumber) {
if (_fileType == RLF) {
// getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
frameData = _animation.rlf->getFrameData(frameNumber);
- pitch = _animation.rlf->width() * sizeof(uint16);
width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
} else if (_fileType == AVI) {
_animation.avi->seekToFrame(frameNumber);
const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
frameData = (const uint16 *)surface->getPixels();
- pitch = surface->pitch;
width = surface->w;
height = surface->h;
}
- _engine->_system->copyRectToScreen(frameData, pitch, x + _engine->_workingWindow.left, y + _engine->_workingWindow.top, width, height);
+ _engine->getRenderManager()->copyRectToWorkingWindow(frameData, x, y, width, width, height);
}
} // End of namespace ZVision
Commit: aea107071350a9566c1bd2a8362c2df937f29f67
https://github.com/scummvm/scummvm/commit/aea107071350a9566c1bd2a8362c2df937f29f67
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:04:42-07:00
Commit Message:
ZVISION: Allow RLF seeking without returning a frame
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index ffc272c..dfd3289 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -155,16 +155,13 @@ RlfAnimation::Frame RlfAnimation::readNextFrame() {
return frame;
}
-const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
+void RlfAnimation::seekToFrame(int frameNumber) {
assert(!_stream);
- assert(frameNumber < _frameCount);
+ assert(frameNumber < _frameCount || frameNumber >= -1);
- // Since this method is so expensive, first check to see if we can use
- // getNextFrame() it's cheap.
- if ((int)frameNumber == _currentFrame) {
- return _currentFrameBuffer;
- } else if (_currentFrame + 1 == (int)frameNumber) {
- return getNextFrame();
+ if (frameNumber == -1) {
+ _currentFrame = -1;
+ return;
}
int closestFrame = _currentFrame;
@@ -182,6 +179,21 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
}
_currentFrame = frameNumber;
+}
+
+const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
+ assert(!_stream);
+ assert(frameNumber < _frameCount);
+
+ // Since this method is so expensive, first check to see if we can use
+ // getNextFrame() it's cheap.
+ if ((int)frameNumber == _currentFrame) {
+ return _currentFrameBuffer;
+ } else if (_currentFrame + 1 == (int)frameNumber) {
+ return getNextFrame();
+ }
+
+ seekToFrame(frameNumber);
return _currentFrameBuffer;
}
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 6f93934..b7d2595 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -77,6 +77,8 @@ public:
uint height() { return _height; }
uint32 frameTime() { return _frameTime; }
+ void seekToFrame(int frameNumber);
+
const uint16 *getFrameData(uint frameNumber);
const uint16 *getNextFrame();
Commit: acfa7ff3e11bf9024451a6e3505f5f07d5646e1f
https://github.com/scummvm/scummvm/commit/acfa7ff3e11bf9024451a6e3505f5f07d5646e1f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:05:15-07:00
Commit Message:
ZVISION: Add scr parse line for ActionAssign
It was already implemented, just not added to the scr parsing
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 06767c5..378408d 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -168,7 +168,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:attenuate*", true)) {
// TODO: Implement ActionAttenuate
} else if (line.matchString("*:assign*", true)) {
- // TODO: Implement ActionAssign
+ actionList.push_back(new ActionAssign(line));
} else if (line.matchString("*:change_location*", true)) {
actionList.push_back(new ActionChangeLocation(line));
} else if (line.matchString("*:crossfade*", true)) {
Commit: 81184d342c6c03932d4c9c4620302283a09273be
https://github.com/scummvm/scummvm/commit/81184d342c6c03932d4c9c4620302283a09273be
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:05:47-07:00
Commit Message:
ZVISION: Delete a Control * when removing it from _activeControls
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 0af1ff1..f499ada 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -108,6 +108,7 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
if ((*iter)->process(deltaTimeMillis)) {
+ delete (*iter);
// Remove the node
iter = _activeControls.erase(iter);
} else {
Commit: eeace477a08d68ead85d39b90084b4e633a6127a
https://github.com/scummvm/scummvm/commit/eeace477a08d68ead85d39b90084b4e633a6127a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-07T16:06:20-07:00
Commit Message:
ZVISION: Set a Puzzle as completed before executing its ResultActions
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index f499ada..4952ebd 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -174,7 +174,8 @@ void ScriptManager::checkPuzzleCriteria() {
if (puzzle->criteriaList.empty() || criteriaMet) {
debug("Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
- uint32 key = puzzle->key;
+ // Set the puzzle as completed
+ setStateValue(puzzle->key, 1);
bool shouldContinue = true;
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
@@ -184,9 +185,6 @@ void ScriptManager::checkPuzzleCriteria() {
}
}
- // Set the puzzle as completed
- setStateValue(key, 1);
-
if (!shouldContinue) {
break;
}
Commit: 6a9572670cf4a325e2f583e492c14f2f9edbd2b9
https://github.com/scummvm/scummvm/commit/6a9572670cf4a325e2f583e492c14f2f9edbd2b9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:28-07:00
Commit Message:
ZVISION: Add method for getting a pointer to a Control
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 4952ebd..b9217e7 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -228,6 +228,14 @@ void ScriptManager::addControl(Control *control) {
_activeControls.push_back(control);
}
+Control *ScriptManager::getControl(uint32 key) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ if ((*iter)->getKey() == key) {
+ return (*iter);
+ }
+ }
+}
+
void ScriptManager::enableControl(uint32 key) {
for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
if ((*iter)->getKey() == key) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 61ad4fa..15d456e 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -83,6 +83,7 @@ public:
void addToStateValue(uint32 key, uint valueToAdd);
void addControl(Control *control);
+ Control *getControl(uint32 key);
void enableControl(uint32 key);
void disableControl(uint32 key);
Commit: 46278f6f59505050d516460094237e30abaa58e0
https://github.com/scummvm/scummvm/commit/46278f6f59505050d516460094237e30abaa58e0
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:35-07:00
Commit Message:
ZVISION: Implement AnimationControl
This handles playing animations asyncronously over numerous frames
Changed paths:
A engines/zvision/animation_control.cpp
A engines/zvision/animation_control.h
engines/zvision/module.mk
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
new file mode 100644
index 0000000..5da39e4
--- /dev/null
+++ b/engines/zvision/animation_control.cpp
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "video/video_decoder.h"
+
+#include "zvision/animation_control.h"
+#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
+#include "zvision/script_manager.h"
+#include "zvision/rlf_animation.h"
+#include "zvision/zork_avi_decoder.h"
+
+
+namespace ZVision {
+
+AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName)
+ : Control(engine, controlKey),
+ _fileType(RLF),
+ _loopCount(1),
+ _currentLoop(0),
+ _accumulatedTime(0) {
+ if (fileName.hasSuffix(".rlf")) {
+ _fileType = RLF;
+ _animation.rlf = new RlfAnimation(fileName, false);
+ } else if (fileName.hasSuffix(".avi")) {
+ _fileType = AVI;
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadFile(fileName);
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+}
+
+AnimationControl::~AnimationControl() {
+ if (_fileType == RLF) {
+ delete _animation.rlf;
+ } else if (_fileType == AVI) {
+ delete _animation.avi;
+ }
+}
+
+bool AnimationControl::process(uint32 deltaTimeInMillis) {
+ if (!_enabled) {
+ return false;
+ }
+
+ bool finished = false;
+
+ if (_fileType == RLF) {
+ _accumulatedTime += deltaTimeInMillis;
+
+ uint32 frameTime = _animation.rlf->frameTime();
+ if (_accumulatedTime >= frameTime) {
+ _accumulatedTime -= frameTime;
+
+ _engine->getRenderManager()->copyRectToWorkingWindow(_animation.rlf->getNextFrame(), _x, _y, _animation.rlf->width(), _animation.rlf->width(), _animation.rlf->height());
+
+ if (_animation.rlf->endOfAnimation()) {
+ _animation.rlf->seekToFrame(-1);
+ if (_loopCount > 0) {
+ _currentLoop++;
+ if (_currentLoop >= _loopCount) {
+ finished = true;
+ }
+ }
+ }
+ }
+ } else if (_fileType == AVI) {
+ if (!_animation.avi->isPlaying()) {
+ _animation.avi->start();
+ }
+
+ if (_animation.avi->needsUpdate()) {
+ const Graphics::Surface *frame = _animation.avi->decodeNextFrame();
+
+ if (frame) {
+ _engine->getRenderManager()->copyRectToWorkingWindow((const uint16 *)frame->getPixels(), _x, _y, frame->w, frame->w, frame->h);
+ }
+ }
+
+ if (_animation.avi->endOfVideo()) {
+ _animation.avi->rewind();
+ if (_loopCount > 0) {
+ _currentLoop++;
+ if (_currentLoop >= _loopCount) {
+ finished = true;
+ }
+ }
+ }
+ }
+
+ if (finished) {
+ _engine->getScriptManager()->setStateValue(_animationKey, 2);
+ disable();
+ _currentLoop = 0;
+ }
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
new file mode 100644
index 0000000..036ce4b
--- /dev/null
+++ b/engines/zvision/animation_control.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_ANIMATION_CONTROL_H
+#define ZVISION_ANIMATION_CONTROL_H
+
+#include "common/types.h"
+
+#include "zvision/control.h"
+
+
+namespace Video {
+class VideoDecoder;
+}
+
+namespace ZVision {
+
+class ZVision;
+class RlfAnimation;
+
+class AnimationControl : public Control {
+public:
+ AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName);
+ ~AnimationControl();
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+private:
+ uint32 _animationKey;
+
+ union {
+ RlfAnimation *rlf;
+ Video::VideoDecoder *avi;
+ } _animation;
+
+ FileType _fileType;
+ uint _loopCount;
+ int32 _x;
+ int32 _y;
+
+ uint _accumulatedTime;
+ uint _currentLoop;
+
+public:
+ bool process(uint32 deltaTimeInMillis);
+
+ void setAnimationKey(uint32 animationKey) { _animationKey = animationKey; }
+ void setLoopCount(uint loopCount) { _loopCount = loopCount; }
+ void setXPos(int32 x) { _x = x; }
+ void setYPost(int32 y) { _y = y; }
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index c916ab8..814a4ba 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/zvision
MODULE_OBJS := \
actions.o \
animation.o \
+ animation_control.o \
clock.o \
console.o \
control.o \
Commit: 5c3cfaa6d2428da3ed33bcdf163008457df8000b
https://github.com/scummvm/scummvm/commit/5c3cfaa6d2428da3ed33bcdf163008457df8000b
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:36-07:00
Commit Message:
ZVISION: Implement ActionPreloadAnimation::execute()
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index d91c3b8..86eca58 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,6 +33,7 @@
#include "zvision/zork_raw.h"
#include "zvision/zork_avi_decoder.h"
#include "zvision/timer_node.h"
+#include "zvision/animation_control.h"
namespace ZVision {
@@ -212,7 +213,13 @@ ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
}
bool ActionPreloadAnimation::execute(ZVision *engine) {
- // TODO: Implement
+ // TODO: We ignore the mask and framerate atm. Mask refers to a key color used for binary alpha. We assume the framerate is the default framerate embedded in the videos
+
+ // TODO: Check if the Control already exists
+
+ // Create the control, but disable it until PlayPreload is called
+ engine->getScriptManager()->addControl(new AnimationControl(engine, _key, _fileName));
+ engine->getScriptManager()->disableControl(_key);
return true;
}
Commit: b1587f8ba0f335aff7133f7422953be83aa4c5ae
https://github.com/scummvm/scummvm/commit/b1587f8ba0f335aff7133f7422953be83aa4c5ae
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:36-07:00
Commit Message:
ZVISION: Implement ActionPlayPreloadAnimation
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 86eca58..3d25fa9 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -246,6 +246,33 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionPlayPreloadAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) {
+ sscanf(line.c_str(),
+ "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)",
+ &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
+}
+
+bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
+ // Find the control
+ AnimationControl *control = (AnimationControl *)engine->getScriptManager()->getControl(_controlKey);
+
+ // Set the needed values within the control
+ control->setAnimationKey(_animationKey);
+ control->setLoopCount(_loopCount);
+ control->setXPos(_x1);
+ control->setYPost(_y1);
+
+ // Enable the control. ScriptManager will take care of the rest
+ control->enable();
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionQuit
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index b36e277..5d7cdad 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -242,6 +242,23 @@ private:
uint _loopCount;
};
+class ActionPlayPreloadAnimation : public ResultAction {
+public:
+ ActionPlayPreloadAnimation(const Common::String &line);
+ bool execute(ZVision *engine);
+
+private:
+ uint32 _animationKey;
+ uint32 _controlKey;
+ uint32 _x1;
+ uint32 _y1;
+ uint32 _x2;
+ uint32 _y2;
+ uint _startFrame;
+ uint _endFrame;
+ uint _loopCount;
+};
+
class ActionPreloadAnimation : public ResultAction {
public:
ActionPreloadAnimation(const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 378408d..3d47185 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -202,7 +202,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:pan_track*", true)) {
// TODO: Implement ActionPanTrack
} else if (line.matchString("*:playpreload*", true)) {
- // TODO: Implement ActionPlayPreload
+ actionList.push_back(new ActionPlayPreloadAnimation(line));
} else if (line.matchString("*:preferences*", true)) {
// TODO: Implement ActionPreferences
} else if (line.matchString("*:quit*", true)) {
Commit: 6e806e51ad38a43fc82fc269ed12151b79ea01bd
https://github.com/scummvm/scummvm/commit/6e806e51ad38a43fc82fc269ed12151b79ea01bd
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:37-07:00
Commit Message:
ZVISION: Stop avi playback once the animation is finished
Changed paths:
engines/zvision/animation_control.cpp
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 5da39e4..2d401d2 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -104,6 +104,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
if (_loopCount > 0) {
_currentLoop++;
if (_currentLoop >= _loopCount) {
+ _animation.avi->stop();
finished = true;
}
}
Commit: 106522661c70e4ff270016f5419cccca5c86820c
https://github.com/scummvm/scummvm/commit/106522661c70e4ff270016f5419cccca5c86820c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:37-07:00
Commit Message:
ZVISION: Create method for rendering to the working window with binary alpha
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 3793ea8..3f19cae 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -291,6 +291,26 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
_workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
}
+void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor) {
+ uint32 destOffset = 0;
+ uint32 sourceOffset = 0;
+ uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
+
+ for (int32 y = 0; y < height; y++) {
+ for (int32 x = 0; x < width; x++) {
+ uint16 color = buffer[sourceOffset + x];
+ if (color != alphaColor) {
+ workingWindowBufferPtr[destOffset + x] = color;
+ }
+ }
+
+ destOffset += _workingWidth;
+ sourceOffset += imageWidth;
+ }
+
+ _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+}
+
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
// Convert from screen space to working window space
Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 9881676..41a11bd 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -109,6 +109,7 @@ public:
void renderBackbufferToScreen();
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
+ void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor);
/**
* Fills the entire workingWindow with the specified color
Commit: 87e78e4c338aa7cde9c53e00eaa6ca1ad97d5d94
https://github.com/scummvm/scummvm/commit/87e78e4c338aa7cde9c53e00eaa6ca1ad97d5d94
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:38-07:00
Commit Message:
ZVISION: Create method for getting the RenderManager backbuffer
Changed paths:
engines/zvision/render_manager.h
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 41a11bd..bb673e9 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -176,6 +176,7 @@ public:
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
+ const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
private:
/**
Commit: af94158723c2698b17faf83fccc585ce747c7e68
https://github.com/scummvm/scummvm/commit/af94158723c2698b17faf83fccc585ce747c7e68
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:38-07:00
Commit Message:
ZVISION: Save a thumbnail of the RenderManager backbuffer instead of the actual screen
This prevents things like the GMM being in the thumbnail
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 595a052..4f8bfeb 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -30,6 +30,7 @@
#include "zvision/save_manager.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
namespace ZVision {
@@ -88,7 +89,7 @@ void SaveManager::autoSave() {
void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
// Create a thumbnail and save it
- Graphics::saveThumbnail(*file);
+ Graphics::saveThumbnail(*file, *_engine->getRenderManager()->getBackBuffer());
// Write out the save date/time
TimeDate td;
Commit: c7358ed4f78437e26aeb05d2113e86ee35d14632
https://github.com/scummvm/scummvm/commit/c7358ed4f78437e26aeb05d2113e86ee35d14632
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:39-07:00
Commit Message:
ZVISION: Create class for rendering TrueType fonts
Changed paths:
A engines/zvision/truetype_font.cpp
A engines/zvision/truetype_font.h
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 814a4ba..9fa119d 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -23,6 +23,7 @@ MODULE_OBJS := \
scripts.o \
single_value_container.o \
timer_node.o \
+ truetype_font.o \
utility.o \
video.o \
zvision.o \
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
new file mode 100644
index 0000000..b3aafc2
--- /dev/null
+++ b/engines/zvision/truetype_font.cpp
@@ -0,0 +1,191 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/debug.h"
+#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/fonts/ttf.h"
+#include "graphics/surface.h"
+
+#include "zvision/truetype_font.h"
+#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
+
+
+namespace ZVision {
+
+TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight, const Graphics::PixelFormat pixelFormat)
+ : _engine(engine),
+ _pixelFormat(pixelFormat),
+ _isBold(false),
+ _isItalic(false),
+ _isStriked(false),
+ _isUnderline(false),
+ _fontHeight(fontHeight),
+ _font(0),
+ _lineHeight(0),
+ _maxCharWidth(0),
+ _maxCharHeight(0) {
+ for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
+ _cachedTexts[i] = 0;
+ }
+}
+
+TruetypeFont::~TruetypeFont(void) {
+ clearCache();
+
+ delete _font;
+}
+
+void TruetypeFont::clearCache() {
+ for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
+ if (_cachedTexts[i]) {
+ delete _cachedTexts[i];
+ }
+ _cachedTexts[i] = 0;
+ }
+}
+
+bool TruetypeFont::loadFile(const Common::String &filename) {
+ Common::File file;
+ if (file.open(filename)) {
+ debug("TTF font file %s could not be opened", filename.c_str());
+ return false;
+ }
+
+ _font = Graphics::loadTTFFont(file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72).
+ _lineHeight = _font->getFontHeight();
+
+ return true;
+}
+
+void TruetypeFont::drawText(const Common::String &text, int x, int y, int width, TextAlign align, int maxHeight) {
+ if (text.equals("")) {
+ return;
+ }
+
+ // Find the cached surface, if it exists
+ uint32 minUseTime = UINT_MAX;
+ int minIndex = -1;
+ Graphics::Surface *surface = nullptr;
+
+ for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
+ if (_cachedTexts[i] == nullptr) {
+ minUseTime = 0;
+ minIndex = i;
+ } else {
+ if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight) {
+ surface = _cachedTexts[i]->_surface;
+ _cachedTexts[i]->_marked = true;
+ _cachedTexts[i]->_lastUsed = g_system->getMillis();
+ break;
+ } else {
+ if (_cachedTexts[i]->_lastUsed < minUseTime) {
+ minUseTime = _cachedTexts[i]->_lastUsed;
+ minIndex = i;
+ }
+ }
+ }
+ }
+
+ // It's not cached, so create one
+ if (!surface) {
+ surface = renderTextToTexture(text, width, align, maxHeight);
+ if (surface) {
+ // Write the new surface to cache
+ if (_cachedTexts[minIndex] != nullptr) {
+ delete _cachedTexts[minIndex];
+ }
+ _cachedTexts[minIndex] = new CachedText;
+
+ _cachedTexts[minIndex]->_surface = surface;
+ _cachedTexts[minIndex]->_align = align;
+ _cachedTexts[minIndex]->_width = width;
+ _cachedTexts[minIndex]->_maxHeight = maxHeight;
+ _cachedTexts[minIndex]->_text = text;
+ _cachedTexts[minIndex]->_marked = true;
+ _cachedTexts[minIndex]->_lastUsed = _engine->_system->getMillis();
+ }
+ }
+
+
+ // Render it to the working window
+ if (surface) {
+ _engine->getRenderManager()->copyRectToWorkingWindow((uint16 *)surface->getPixels(), x, y, surface->w, surface->w, surface->h);
+ }
+}
+
+Graphics::Surface *TruetypeFont::renderTextToTexture(const Common::String &text, int width, TextAlign align, int maxHeight) {
+ Common::Array<Common::String> lines;
+ _font->wordWrapText(text, width, lines);
+
+ while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) {
+ lines.pop_back();
+ }
+ if (lines.size() == 0) {
+ return nullptr;
+ }
+
+ Graphics::TextAlign alignment = Graphics::kTextAlignInvalid;
+ if (align == ALIGN_LEFT) {
+ alignment = Graphics::kTextAlignLeft;
+ } else if (align == ALIGN_CENTER) {
+ alignment = Graphics::kTextAlignCenter;
+ } else if (align == ALIGN_RIGHT) {
+ alignment = Graphics::kTextAlignRight;
+ }
+
+ Graphics::Surface *surface = new Graphics::Surface();
+ surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), _pixelFormat);
+
+ uint32 alphaColor = 0xffffffff;
+ int heightOffset = 0;
+ for (Common::Array<Common::String>::iterator it = lines.begin(); it != lines.end(); it++) {
+ _font->drawString(surface, *it, 0, heightOffset, width, alphaColor, alignment);
+ heightOffset += (int)_lineHeight;
+ }
+
+ return surface;
+ // TODO: _isUnderline, _isBold, _isItalic, _isStriked
+}
+
+void TruetypeFont::measureText(const Common::String &text, int maxWidth, int maxHeight, int &textWidthOut, int &textHeightOut) {
+ if (maxWidth >= 0) {
+ Common::Array<Common::String> lines;
+ _font->wordWrapText(text, maxWidth, lines);
+ Common::Array<Common::String>::iterator it;
+ textWidthOut = 0;
+ for (it = lines.begin(); it != lines.end(); ++it) {
+ textWidthOut = MAX(textWidthOut, _font->getStringWidth(*it));
+ }
+
+ textHeightOut = (int)(lines.size() * getLineHeight());
+ } else {
+ textWidthOut = _font->getStringWidth(text);
+ textHeightOut = _fontHeight;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
new file mode 100644
index 0000000..2618dc4
--- /dev/null
+++ b/engines/zvision/truetype_font.h
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp
+
+#ifndef ZVISION_TRUETYPE_FONT_H
+#define ZVISION_TRUETYPE_FONT_H
+
+#include "common/types.h"
+
+#include "graphics/font.h"
+
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class TruetypeFont {
+public:
+ TruetypeFont(ZVision *engine, int32 fontHeight, const Graphics::PixelFormat pixelFormat);
+ ~TruetypeFont();
+
+public:
+ enum {
+ NUM_CACHED_TEXTS = 30
+ };
+
+ enum TextAlign {
+ ALIGN_LEFT = 0,
+ ALIGN_RIGHT,
+ ALIGN_CENTER
+ };
+
+ class CachedText {
+ public:
+ Common::String _text;
+ int32 _width;
+ TextAlign _align;
+ int32 _maxHeight;
+ Graphics::Surface *_surface;
+ int32 _textOffset;
+ bool _marked;
+ uint32 _lastUsed;
+
+ CachedText() {
+ _width = _maxHeight = -1;
+ _align = ALIGN_LEFT;
+ _surface = 0;
+ _lastUsed = 0;
+ _marked = false;
+ }
+
+ virtual ~CachedText() {
+ delete _surface;
+ }
+ };
+
+private:
+ ZVision *_engine;
+ const Graphics::PixelFormat _pixelFormat;
+
+ Graphics::Font *_font;
+
+ float _lineHeight;
+
+ size_t _maxCharWidth;
+ size_t _maxCharHeight;
+
+ CachedText *_cachedTexts[NUM_CACHED_TEXTS];
+
+public:
+ bool _isBold;
+ bool _isItalic;
+ bool _isUnderline;
+ bool _isStriked;
+ int32 _fontHeight;
+
+ //BaseArray<BaseTTFontLayer *> _layers;
+
+public:
+ int getTextWidth(const byte *text, int maxLength = -1);
+ int getTextHeight(const byte *text, int width);
+ void drawText(const Common::String &text, int x, int y, int width, TextAlign align = ALIGN_LEFT, int max_height = -1);
+ int getLetterHeight();
+
+ void initLoop() {}
+ void afterLoad() {}
+
+ bool loadBuffer(byte *buffer);
+ bool loadFile(const Common::String &filename);
+
+ float getLineHeight() const { return _lineHeight; }
+
+ void clearCache();
+
+ static TruetypeFont *createFromFile(ZVision *game, const Common::String &filename);
+
+private:
+ void measureText(const Common::String &text, int maxWidth, int maxHeight, int &textWidthOut, int &textHeightOut);
+ Graphics::Surface *renderTextToTexture(const Common::String &text, int width, TextAlign align, int maxHeight);
+ bool initFont();
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 511cb7447e6ebd9a0c54c3e767eb8ea754fd5398
https://github.com/scummvm/scummvm/commit/511cb7447e6ebd9a0c54c3e767eb8ea754fd5398
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:39-07:00
Commit Message:
ZVISION: Create method for converting image space to working window space
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 3f19cae..c0554dc 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -338,6 +338,19 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &
return newPoint;
}
+const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) {
+ Common::Point newPoint(point);
+
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA) {
+ newPoint += (Common::Point(_screenCenterX, 0) - _backgroundOffset);
+ } else if (state == RenderTable::TILT) {
+ newPoint += (Common::Point(0, _screenCenterY) - _backgroundOffset);
+ }
+
+ return newPoint;
+}
+
RenderTable *RenderManager::getRenderTable() {
return &_renderTable;
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index bb673e9..0294d6a 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -173,6 +173,15 @@ public:
* @return Point in image coordinate space
*/
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
+ /**
+ * Converts a point in image coordinate space to ***PRE-WARP***
+ * working window coordinate space
+ *
+ * @param point Point in image coordinate space
+ * @return Point in PRE-WARP working window coordinate space
+ */
+ const Common::Point imageSpaceToWorkingWindowSpace(const Common::Point &point);
+
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
Commit: a415964c6da8f36fcf649f7e0f9fb94791cd02ff
https://github.com/scummvm/scummvm/commit/a415964c6da8f36fcf649f7e0f9fb94791cd02ff
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:40-07:00
Commit Message:
ZVISION: Create method for clipping a rect to the working window
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 c0554dc..8ac0763 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -351,6 +351,17 @@ const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::
return newPoint;
}
+bool RenderManager::clipRectToWorkingWindow(Common::Rect &rect) {
+ if (!_workingWindow.contains(rect)) {
+ return false;
+ }
+
+ // We can't clip against the actual working window rect because it's in screen space
+ // But rect is in working window space
+ rect.clip(_workingWidth, _workingHeight);
+ return true;
+}
+
RenderTable *RenderManager::getRenderTable() {
return &_renderTable;
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 0294d6a..cbf69b9 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -182,6 +182,14 @@ public:
*/
const Common::Point imageSpaceToWorkingWindowSpace(const Common::Point &point);
+ /**
+ * Clip a rectangle to the working window. If it returns false, the original rect
+ * is not inside the working window.
+ *
+ * @param rect The rectangle to clip against the working window
+ * @return Is rect at least partially inside the working window (true) or completely outside (false)
+ */
+ bool clipRectToWorkingWindow(Common::Rect &rect);
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
Commit: f9b9bf5b9b5b6a438a12a77aab90bdb77deeca65
https://github.com/scummvm/scummvm/commit/f9b9bf5b9b5b6a438a12a77aab90bdb77deeca65
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:40-07:00
Commit Message:
ZVISION: Create method for transposing a surface
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 8ac0763..441580c 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -432,4 +432,22 @@ uint32 RenderManager::getCurrentBackgroundOffset() {
}
}
+Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surface) {
+ Graphics::Surface *tranposedSurface = new Graphics::Surface();
+ tranposedSurface->create(surface->h, surface->w, surface->format);
+
+ uint16 *source = (uint16 *)surface->getPixels();
+ uint16 *dest = (uint16 *)tranposedSurface->getPixels();
+
+ for (uint32 y = 0; y < tranposedSurface->h; y++) {
+ uint32 columnIndex = y * tranposedSurface->w;
+
+ for (uint32 x = 0; x < tranposedSurface->w; x++) {
+ dest[columnIndex + x] = source[x * surface->w + y];
+ }
+ }
+
+ return tranposedSurface;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index cbf69b9..51636ef 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -195,6 +195,17 @@ public:
uint32 getCurrentBackgroundOffset();
const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
+ /**
+ * Creates a copy of surface and transposes the data.
+ *
+ * Note: The user is responsible for calling free() on the returned surface
+ * and then deleting it
+ *
+ * @param surface The data to be transposed
+ * @return A copy of the surface with the data transposed
+ */
+ static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface);
+
private:
/**
* Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect
Commit: 3b7189993c3fbd6f6f98108b8e1d828964dc84a9
https://github.com/scummvm/scummvm/commit/3b7189993c3fbd6f6f98108b8e1d828964dc84a9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:41-07:00
Commit Message:
ZVISION: Let Rlf animations output Surfaces instead of uint16 arrays
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index dfd3289..0ffeeb0 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -45,7 +45,6 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_frameTime(0),
_frames(0),
_currentFrame(-1),
- _currentFrameBuffer(0),
_frameBufferByteSize(0) {
if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
@@ -57,7 +56,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
return;
}
- _currentFrameBuffer = new uint16[_width * _height];
+ _currentFrameBuffer.create(_width, _height, _pixelFormat565);
_frameBufferByteSize = _width * _height * sizeof(uint16);
if (!stream) {
@@ -71,7 +70,6 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
}
RlfAnimation::~RlfAnimation() {
- delete[] _currentFrameBuffer;
for (uint i = 0; i < _frameCount; i++) {
delete[] _frames[i].encodedData;
}
@@ -181,23 +179,23 @@ void RlfAnimation::seekToFrame(int frameNumber) {
_currentFrame = frameNumber;
}
-const uint16 *RlfAnimation::getFrameData(uint frameNumber) {
+const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
assert(!_stream);
assert(frameNumber < _frameCount);
// Since this method is so expensive, first check to see if we can use
// getNextFrame() it's cheap.
if ((int)frameNumber == _currentFrame) {
- return _currentFrameBuffer;
+ return &_currentFrameBuffer;
} else if (_currentFrame + 1 == (int)frameNumber) {
return getNextFrame();
}
seekToFrame(frameNumber);
- return _currentFrameBuffer;
+ return &_currentFrameBuffer;
}
-const uint16 *RlfAnimation::getNextFrame() {
+const Graphics::Surface *RlfAnimation::getNextFrame() {
assert(_currentFrame + 1 < (int)_frameCount);
if (_stream) {
@@ -207,22 +205,22 @@ const uint16 *RlfAnimation::getNextFrame() {
}
_currentFrame++;
- return _currentFrameBuffer;
+ return &_currentFrameBuffer;
}
void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
if (_frames[frameNumber].type == Masked) {
- decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
} else if (_frames[frameNumber].type == Simple) {
- decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
}
}
void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) {
if (frame.type == Masked) {
- decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer, frame.encodedSize, _frameBufferByteSize);
+ decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize);
} else if (frame.type == Simple) {
- decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer, frame.encodedSize, _frameBufferByteSize);
+ decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize);
}
}
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index b7d2595..133bf39 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -68,7 +68,7 @@ private:
Common::List<uint> _completeFrames;
int _currentFrame;
- uint16 *_currentFrameBuffer;
+ Graphics::Surface _currentFrameBuffer;
uint32 _frameBufferByteSize;
public:
@@ -79,8 +79,8 @@ public:
void seekToFrame(int frameNumber);
- const uint16 *getFrameData(uint frameNumber);
- const uint16 *getNextFrame();
+ const Graphics::Surface *getFrameData(uint frameNumber);
+ const Graphics::Surface *getNextFrame();
bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
Commit: 31cdf227d20906986884113910680e2b22965be8
https://github.com/scummvm/scummvm/commit/31cdf227d20906986884113910680e2b22965be8
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:42-07:00
Commit Message:
ZVISION: Clip animations to the working window
Changed paths:
engines/zvision/animation_control.cpp
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 2d401d2..cd5ebf1 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -71,10 +71,31 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
_accumulatedTime += deltaTimeInMillis;
uint32 frameTime = _animation.rlf->frameTime();
- if (_accumulatedTime >= frameTime) {
+ while (_accumulatedTime >= frameTime) {
_accumulatedTime -= frameTime;
- _engine->getRenderManager()->copyRectToWorkingWindow(_animation.rlf->getNextFrame(), _x, _y, _animation.rlf->width(), _animation.rlf->width(), _animation.rlf->height());
+ RenderManager *renderManager = _engine->getRenderManager();
+ Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
+ Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height());
+
+ // If the clip returns false, it means the animation is outside the working window
+ if (!renderManager->clipRectToWorkingWindow(subRect)) {
+ return false;
+ }
+
+ const Graphics::Surface *frame = _animation.rlf->getNextFrame();
+
+ RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
+ if (state == RenderTable::PANORAMA) {
+ Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
+
+ renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+
+ tranposedFrame->free();
+ delete tranposedFrame;
+ } else {
+ renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+ }
if (_animation.rlf->endOfAnimation()) {
_animation.rlf->seekToFrame(-1);
@@ -95,7 +116,28 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
const Graphics::Surface *frame = _animation.avi->decodeNextFrame();
if (frame) {
- _engine->getRenderManager()->copyRectToWorkingWindow((const uint16 *)frame->getPixels(), _x, _y, frame->w, frame->w, frame->h);
+ RenderManager *renderManager = _engine->getRenderManager();
+ Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
+ Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + frame->w, workingWindowPoint.y + frame->h);
+
+ // If the clip returns false, it means the animation is outside the working window
+ if (!renderManager->clipRectToWorkingWindow(subRect)) {
+ return false;
+ }
+
+ RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
+ if (state == RenderTable::PANORAMA) {
+ Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
+
+ renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
+
+ tranposedFrame->free();
+ delete tranposedFrame;
+ } else {
+ renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
+ }
+
+
}
}
Commit: 8354f236285bfd55536a19b177a4fcfbdd0aaa1b
https://github.com/scummvm/scummvm/commit/8354f236285bfd55536a19b177a4fcfbdd0aaa1b
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:42-07:00
Commit Message:
ZVISION: Add a debug assert to make sure we're not trying to render ouside the working window
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 441580c..04163fa 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -289,6 +289,9 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
}
_workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+
+ // TODO: Remove this from release. It's here to make sure code that uses this function clips their destinations correctly
+ assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight);
}
void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor) {
Commit: 077f0b24912688b53adb24757a2a87ce52175ae9
https://github.com/scummvm/scummvm/commit/077f0b24912688b53adb24757a2a87ce52175ae9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:43-07:00
Commit Message:
ZVISION: Update LeverControl to use the new RlfAnimation outputs
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 318710e..93a6054 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -383,7 +383,7 @@ void LeverControl::renderFrame(uint frameNumber) {
if (_fileType == RLF) {
// getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- frameData = _animation.rlf->getFrameData(frameNumber);
+ frameData = (const uint16 *)_animation.rlf->getFrameData(frameNumber)->getPixels();
width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
} else if (_fileType == AVI) {
Commit: 9e563f01134ec9063d743ef487eb25cae581e2d2
https://github.com/scummvm/scummvm/commit/9e563f01134ec9063d743ef487eb25cae581e2d2
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:43-07:00
Commit Message:
ZVISION: Add comments to AnimationControl::process()
Changed paths:
engines/zvision/animation_control.cpp
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index cd5ebf1..ca3e225 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -74,6 +74,9 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
while (_accumulatedTime >= frameTime) {
_accumulatedTime -= frameTime;
+ // Make sure the frame is inside the working window
+ // If it's not, then just return
+
RenderManager *renderManager = _engine->getRenderManager();
Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height());
@@ -85,18 +88,21 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
const Graphics::Surface *frame = _animation.rlf->getNextFrame();
+ // Animation frames for PANORAMAs are transposed, so un-transpose them
RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
if (state == RenderTable::PANORAMA) {
Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+ // Cleanup
tranposedFrame->free();
delete tranposedFrame;
} else {
renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
}
+ // Check if we should continue looping
if (_animation.rlf->endOfAnimation()) {
_animation.rlf->seekToFrame(-1);
if (_loopCount > 0) {
@@ -116,6 +122,9 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
const Graphics::Surface *frame = _animation.avi->decodeNextFrame();
if (frame) {
+ // Make sure the frame is inside the working window
+ // If it's not, then just return
+
RenderManager *renderManager = _engine->getRenderManager();
Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + frame->w, workingWindowPoint.y + frame->h);
@@ -125,22 +134,23 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
return false;
}
+ // Animation frames for PANORAMAs are transposed, so un-transpose them
RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
if (state == RenderTable::PANORAMA) {
Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
+ // Cleanup
tranposedFrame->free();
delete tranposedFrame;
} else {
renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
}
-
-
}
}
+ // Check if we should continue looping
if (_animation.avi->endOfVideo()) {
_animation.avi->rewind();
if (_loopCount > 0) {
@@ -153,6 +163,8 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
}
}
+ // If we're done, set _animation key = 2 (Why 2? I don't know. It's just the value that they used)
+ // Then disable the control. DON'T delete it. It can be re-used
if (finished) {
_engine->getScriptManager()->setStateValue(_animationKey, 2);
disable();
Commit: edd1a117ae821d96498a78a357ab29018f1c019a
https://github.com/scummvm/scummvm/commit/edd1a117ae821d96498a78a357ab29018f1c019a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:44-07:00
Commit Message:
ZVISION: Cache animation frames so they can be re-rendered when the background moves
Changed paths:
engines/zvision/animation_control.cpp
engines/zvision/animation_control.h
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index ca3e225..8c8f6eb 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -39,7 +39,8 @@ AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Com
_fileType(RLF),
_loopCount(1),
_currentLoop(0),
- _accumulatedTime(0) {
+ _accumulatedTime(0),
+ _cachedFrame(0) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
_animation.rlf = new RlfAnimation(fileName, false);
@@ -50,6 +51,8 @@ AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Com
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
}
+
+ _cachedFrame = new Graphics::Surface();
}
AnimationControl::~AnimationControl() {
@@ -58,6 +61,9 @@ AnimationControl::~AnimationControl() {
} else if (_fileType == AVI) {
delete _animation.avi;
}
+
+ _cachedFrame->free();
+ delete _cachedFrame;
}
bool AnimationControl::process(uint32 deltaTimeInMillis) {
@@ -71,47 +77,75 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
_accumulatedTime += deltaTimeInMillis;
uint32 frameTime = _animation.rlf->frameTime();
- while (_accumulatedTime >= frameTime) {
- _accumulatedTime -= frameTime;
+ if (_accumulatedTime >= frameTime) {
+ while (_accumulatedTime >= frameTime) {
+ _accumulatedTime -= frameTime;
- // Make sure the frame is inside the working window
- // If it's not, then just return
+ // Make sure the frame is inside the working window
+ // If it's not, then just return
- RenderManager *renderManager = _engine->getRenderManager();
- Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
- Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height());
+ RenderManager *renderManager = _engine->getRenderManager();
+ Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
+ Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height());
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
+ // If the clip returns false, it means the animation is outside the working window
+ if (!renderManager->clipRectToWorkingWindow(subRect)) {
+ return false;
+ }
- const Graphics::Surface *frame = _animation.rlf->getNextFrame();
+ const Graphics::Surface *frame = _animation.rlf->getNextFrame();
- // Animation frames for PANORAMAs are transposed, so un-transpose them
- RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
- if (state == RenderTable::PANORAMA) {
- Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
+ // Animation frames for PANORAMAs are transposed, so un-transpose them
+ RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
+ if (state == RenderTable::PANORAMA) {
+ Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
- renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+ renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
- // Cleanup
- tranposedFrame->free();
- delete tranposedFrame;
- } else {
- renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
- }
+ // If the background can move, we need to cache the last frame so it can be rendered during background movement
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _cachedFrame = tranposedFrame;
+ } else {
+ // Cleanup
+ tranposedFrame->free();
+ delete tranposedFrame;
+ }
+ } else {
+ renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+
+ // If the background can move, we need to cache the last frame so it can be rendered during background movement
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _cachedFrame->copyFrom(*frame);
+ }
+ }
- // Check if we should continue looping
- if (_animation.rlf->endOfAnimation()) {
- _animation.rlf->seekToFrame(-1);
- if (_loopCount > 0) {
- _currentLoop++;
- if (_currentLoop >= _loopCount) {
- finished = true;
+ // Check if we should continue looping
+ if (_animation.rlf->endOfAnimation()) {
+ _animation.rlf->seekToFrame(-1);
+ if (_loopCount > 0) {
+ _currentLoop++;
+ if (_currentLoop >= _loopCount) {
+ finished = true;
+ }
}
}
}
+ } else {
+ // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement
+ RenderManager *renderManager = _engine->getRenderManager();
+ RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
+
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
+ Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h);
+
+ // If the clip returns false, it means the animation is outside the working window
+ if (!renderManager->clipRectToWorkingWindow(subRect)) {
+ return false;
+ }
+
+ renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height());
+ }
}
} else if (_fileType == AVI) {
if (!_animation.avi->isPlaying()) {
@@ -141,11 +175,37 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
- // Cleanup
- tranposedFrame->free();
- delete tranposedFrame;
+ // If the background can move, we need to cache the last frame so it can be rendered during background movement
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _cachedFrame = tranposedFrame;
+ } else {
+ // Cleanup
+ tranposedFrame->free();
+ delete tranposedFrame;
+ }
} else {
renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
+
+ // If the background can move, we need to cache the last frame so it can be rendered during background movement
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _cachedFrame->copyFrom(*frame);
+ }
+ }
+ } else {
+ // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement
+ RenderManager *renderManager = _engine->getRenderManager();
+ RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
+
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
+ Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h);
+
+ // If the clip returns false, it means the animation is outside the working window
+ if (!renderManager->clipRectToWorkingWindow(subRect)) {
+ return false;
+ }
+
+ renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height());
}
}
}
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
index 036ce4b..6b104d4 100644
--- a/engines/zvision/animation_control.h
+++ b/engines/zvision/animation_control.h
@@ -64,6 +64,8 @@ private:
uint _accumulatedTime;
uint _currentLoop;
+ Graphics::Surface *_cachedFrame;
+
public:
bool process(uint32 deltaTimeInMillis);
Commit: 072b852cdc627b060505d1a4da4e0bb4a0300c51
https://github.com/scummvm/scummvm/commit/072b852cdc627b060505d1a4da4e0bb4a0300c51
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:44-07:00
Commit Message:
ZVISION: Remove extraneous methods from TrueTypeFont
Changed paths:
engines/zvision/truetype_font.h
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index 2618dc4..4865741 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -106,10 +106,6 @@ public:
void drawText(const Common::String &text, int x, int y, int width, TextAlign align = ALIGN_LEFT, int max_height = -1);
int getLetterHeight();
- void initLoop() {}
- void afterLoad() {}
-
- bool loadBuffer(byte *buffer);
bool loadFile(const Common::String &filename);
float getLineHeight() const { return _lineHeight; }
@@ -121,7 +117,6 @@ public:
private:
void measureText(const Common::String &text, int maxWidth, int maxHeight, int &textWidthOut, int &textHeightOut);
Graphics::Surface *renderTextToTexture(const Common::String &text, int width, TextAlign align, int maxHeight);
- bool initFont();
};
} // End of namespace ZVision
Commit: f5f053d335f019a0c26dc8c11730cf0231d9bc60
https://github.com/scummvm/scummvm/commit/f5f053d335f019a0c26dc8c11730cf0231d9bc60
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:45-07:00
Commit Message:
ZVISION: Use default dpi for font
Changed paths:
engines/zvision/truetype_font.cpp
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index b3aafc2..dacd796 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -75,7 +75,7 @@ bool TruetypeFont::loadFile(const Common::String &filename) {
return false;
}
- _font = Graphics::loadTTFFont(file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72).
+ _font = Graphics::loadTTFFont(file, _fontHeight);
_lineHeight = _font->getFontHeight();
return true;
Commit: 4a4330cec727fd5e08015479bdec94331b2e7662
https://github.com/scummvm/scummvm/commit/4a4330cec727fd5e08015479bdec94331b2e7662
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:45-07:00
Commit Message:
ZVISION: Cleanup the cached frame before loading the next one
Changed paths:
engines/zvision/animation_control.cpp
engines/zvision/animation_control.h
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 8c8f6eb..f80faea0 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -40,7 +40,8 @@ AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Com
_loopCount(1),
_currentLoop(0),
_accumulatedTime(0),
- _cachedFrame(0) {
+ _cachedFrame(0),
+ _cachedFrameNeedsDeletion(false) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
_animation.rlf = new RlfAnimation(fileName, false);
@@ -104,7 +105,13 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (_cachedFrameNeedsDeletion) {
+ _cachedFrame->free();
+ delete _cachedFrame;
+ _cachedFrameNeedsDeletion = false;
+ }
_cachedFrame = tranposedFrame;
+ _cachedFrameNeedsDeletion = true;
} else {
// Cleanup
tranposedFrame->free();
@@ -115,6 +122,11 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (_cachedFrameNeedsDeletion) {
+ _cachedFrame->free();
+ delete _cachedFrame;
+ _cachedFrameNeedsDeletion = false;
+ }
_cachedFrame->copyFrom(*frame);
}
}
@@ -177,7 +189,13 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (_cachedFrameNeedsDeletion) {
+ _cachedFrame->free();
+ delete _cachedFrame;
+ _cachedFrameNeedsDeletion = false;
+ }
_cachedFrame = tranposedFrame;
+ _cachedFrameNeedsDeletion = true;
} else {
// Cleanup
tranposedFrame->free();
@@ -188,6 +206,11 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (_cachedFrameNeedsDeletion) {
+ _cachedFrame->free();
+ delete _cachedFrame;
+ _cachedFrameNeedsDeletion = false;
+ }
_cachedFrame->copyFrom(*frame);
}
}
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
index 6b104d4..935f4ab 100644
--- a/engines/zvision/animation_control.h
+++ b/engines/zvision/animation_control.h
@@ -65,6 +65,7 @@ private:
uint _currentLoop;
Graphics::Surface *_cachedFrame;
+ bool _cachedFrameNeedsDeletion;
public:
bool process(uint32 deltaTimeInMillis);
Commit: 0874212fa72264404803c3ebc0b75fc63f2be754
https://github.com/scummvm/scummvm/commit/0874212fa72264404803c3ebc0b75fc63f2be754
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-09T09:16:46-07:00
Commit Message:
ZVISION: Cleanup _currentFrameBuffer during descruction
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 0ffeeb0..5ce58e6 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -74,6 +74,7 @@ RlfAnimation::~RlfAnimation() {
delete[] _frames[i].encodedData;
}
delete[] _frames;
+ _currentFrameBuffer.free();
}
bool RlfAnimation::readHeader() {
Commit: 6f4e80e36e7729bd2137a1a2bde712521861b0b3
https://github.com/scummvm/scummvm/commit/6f4e80e36e7729bd2137a1a2bde712521861b0b3
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-12T12:07:42-07:00
Commit Message:
ZVISION: Add wrapper function for copyRectToSurface
Also rename some arguments to make them more clear
Changed paths:
graphics/surface.cpp
graphics/surface.h
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index d808121..a8173f0 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -133,17 +133,17 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
-void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height) {
+void Surface::copyRectToSurface(const void *buffer, int pitch, int destX, int destY, int width, int height) {
assert(buffer);
- assert(x >= 0 && x < w);
- assert(y >= 0 && y < h);
- assert(height > 0 && y + height <= h);
- assert(width > 0 && x + width <= w);
+ assert(destX >= 0 && destX < w);
+ assert(destY >= 0 && destY < h);
+ assert(height > 0 && destY + height <= h);
+ assert(width > 0 && destX + width <= w);
// Copy buffer data to internal buffer
const byte *src = (const byte *)buffer;
- byte *dst = (byte *)getBasePtr(x, y);
+ byte *dst = (byte *)getBasePtr(destX, destY);
for (int i = 0; i < height; i++) {
memcpy(dst, src, width * format.bytesPerPixel);
src += pitch;
@@ -151,6 +151,12 @@ void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int
}
}
+void Surface::copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect) {
+ assert(srcSurface.format == format);
+
+ copyRectToSurface(srcSurface.getBasePtr(subRect.left, subRect.top), srcSurface.pitch, destX, destY, subRect.width(), subRect.height());
+}
+
void Surface::hLine(int x, int y, int x2, uint32 color) {
// Clipping
if (y < 0 || y >= h)
diff --git a/graphics/surface.h b/graphics/surface.h
index ad52ed8..1492e71 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -214,12 +214,23 @@ public:
*
* @param buffer The buffer containing the graphics data source
* @param pitch The pitch of the buffer (number of bytes in a scanline)
- * @param x The x coordinate of the destination rectangle
- * @param y The y coordinate of the destination rectangle
+ * @param destX The x coordinate of the destination rectangle
+ * @param destY The y coordinate of the destination rectangle
* @param width The width of the destination rectangle
* @param height The height of the destination rectangle
*/
- void copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height);
+ void copyRectToSurface(const void *buffer, int pitch, int destX, int destY, int width, int height);
+ /**
+ * Copies a bitmap to the Surface internal buffer. The pixel format
+ * of buffer must match the pixel format of the Surface.
+ *
+ * @param srcSurface The source of the bitmap data
+ * @param destX The x coordinate of the destination rectangle
+ * @param destY The y coordinate of the destination rectangle
+ * @param subRect The subRect of surface to be blitted
+ * @return
+ */
+ void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect);
/**
* Convert the data to another pixel format.
Commit: d643ca1571eef1f81b5880fcb796f1ee268ef234
https://github.com/scummvm/scummvm/commit/d643ca1571eef1f81b5880fcb796f1ee268ef234
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T12:04:58-07:00
Commit Message:
ZVISION: Remove unused Console functions
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 8b4dffa..4ea4a8e 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -51,9 +51,6 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
- DCmd_Register("dumpcursorfilenames", WRAP_METHOD(Console, cmdDumpAllCursorFileNames));
- DCmd_Register("showcursor", WRAP_METHOD(Console, cmdShowCursor));
- DCmd_Register("dumpalllevfiles", WRAP_METHOD(Console, cmdDumpAllLevFiles));
DCmd_Register("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
}
@@ -190,42 +187,6 @@ bool Console::cmdDumpFile(int argc, const char **argv) {
return true;
}
-bool Console::cmdDumpAllCursorFileNames(int argc, const char **argv) {
- Common::DumpFile outputFile;
- outputFile.open("cursorFileNames.txt");
-
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.zcr");
-
- // Register the file entries within the zfs archives with the SearchMan
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- outputFile.writeString((*iter)->getName());
- outputFile.writeByte('\n');
- }
-
- return true;
-}
-
-bool Console::cmdShowCursor(int argc, const char **argv) {
- ZorkCursor cursor(argv[1]);
-
- _engine->_system->copyRectToScreen(cursor.getSurface(), cursor.getWidth() * 2, 0, 0, cursor.getWidth(), cursor.getHeight());
-
- return true;
-}
-
-bool Console::cmdDumpAllLevFiles(int argc, const char **argv) {
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.lev");
-
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::String fileName = (*iter)->getName();
- writeFileContentsToFile(fileName, fileName);
- }
-
- return true;
-}
-
bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
Common::ArchiveMemberList list;
SearchMan.listMatchingMembers(list, "*.scr");
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index 612e5ee..fdb2064 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -47,9 +47,6 @@ private:
bool cmdSetPanoramaScale(int argc, const char **argv);
bool cmdChangeLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
- bool cmdDumpAllCursorFileNames(int argc, const char **argv);
- bool cmdShowCursor(int argc, const char **argv);
- bool cmdDumpAllLevFiles(int argc, const char **argv);
bool cmdParseAllScrFiles(int argc, const char **argv);
};
Commit: c20a9ac6ae3cac5ff45d5d2329ff8571d507b01f
https://github.com/scummvm/scummvm/commit/c20a9ac6ae3cac5ff45d5d2329ff8571d507b01f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T12:06:11-07:00
Commit Message:
ZVISION: Add key press support to Controls
Changed paths:
engines/zvision/control.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 9144c32..baa2dfb 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,6 +25,8 @@
#include "common/types.h"
+#include "common/keyboard.h"
+
namespace Common {
class SeekableReadStream;
@@ -69,6 +71,18 @@ public:
*/
virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { return false; }
/**
+ * Called when a key is pressed. Default is NOP.
+ *
+ * @param keycode The key that was pressed
+ */
+ virtual void onKeyDown(Common::KeyState keyState) {}
+ /**
+ * Called when a key is released. Default is NOP.
+ *
+ * @param keycode The key that was pressed
+ */
+ virtual void onKeyUp(Common::KeyState keyState) {}
+ /**
* Processes the node given the deltaTime since last frame. Default is NOP.
*
* @param deltaTimeInMillis The number of milliseconds that have passed since last frame
Commit: d3b6caab2f122f05bc5ecae49bcce1c285cb09de
https://github.com/scummvm/scummvm/commit/d3b6caab2f122f05bc5ecae49bcce1c285cb09de
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T12:07:02-07:00
Commit Message:
ZVISION: Remove unused key functions
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 9283328..ae84a22 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -67,15 +67,6 @@ void ZVision::processEvents() {
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
- case Common::KEYCODE_F1:
- cycleThroughCursors();
- break;
- case Common::KEYCODE_F2:
- {
- RlfAnimation *animation = new RlfAnimation("te2ea21c.rlf");
- playAnimation(animation, 0, 0);
- break;
- }
default:
break;
}
Commit: 752807b4710ae7ff5c96f3ced985a56da0227d7c
https://github.com/scummvm/scummvm/commit/752807b4710ae7ff5c96f3ced985a56da0227d7c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:32-07:00
Commit Message:
ZVISION: Add method to copy a portion of the working window to a surface
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 04163fa..38807a7 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -311,6 +311,20 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
sourceOffset += imageWidth;
}
+void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const {
+ uint32 destOffset = 0;
+ uint32 sourceOffset = 0;
+ uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(subRect.left, subRect.top);
+ uint16 *destPtr = (uint16 *)destSurface->getBasePtr(destX, destY);
+
+ for (int32 y = 0; y < subRect.height(); y++) {
+ for (int32 x = 0; x < subRect.width(); x++) {
+ destPtr[destOffset + x] = workingWindowBufferPtr[sourceOffset + x];
+ }
+
+ destOffset += destSurface->w;
+ sourceOffset += _workingWidth;
+ }
_workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 51636ef..ce5c774 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -194,6 +194,7 @@ public:
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
+ void copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const;
/**
* Creates a copy of surface and transposes the data.
Commit: b50afa2b154c412c40b534a41e9654da8786f5e6
https://github.com/scummvm/scummvm/commit/b50afa2b154c412c40b534a41e9654da8786f5e6
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:40-07:00
Commit Message:
ZVISION: Remove unused function
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f858070..09f5ea3 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -175,59 +175,4 @@ Common::String ZVision::generateAutoSaveFileName() {
return Common::String::format("%s.auto", _targetName.c_str());
}
-void ZVision::cycleThroughCursors() {
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.zcr");
-
- Common::ArchiveMemberList::iterator iter = list.begin();
- ZorkCursor cursor;
- bool cursorChanged = false;
-
- _system->showMouse(true);
-
- bool done = false;
- while (!done && !shouldQuit()) {
- _clock.update();
- uint32 currentTime = _clock.getLastMeasuredTime();
-
- while (_eventMan->pollEvent(_event)) {
- if (_event.type == Common::EVENT_KEYDOWN) {
- switch (_event.kbd.keycode) {
- case Common::KEYCODE_LEFT:
- --iter;
- cursorChanged = true;
- break;
- case Common::KEYCODE_RIGHT:
- ++iter;
- cursorChanged = true;
- break;
- case Common::KEYCODE_RETURN:
- debug("%s", (*iter)->getName().c_str());
- break;
- case Common::KEYCODE_ESCAPE:
- done = true;
- break;
- default:
- break;
- }
- }
- }
-
- if (cursorChanged) {
- cursor = ZorkCursor((*iter)->getName());
-
- _system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getHeight(), true, &_pixelFormat);
- cursorChanged = false;
- }
-
- _system->updateScreen();
-
- // Calculate the frame delay based off a desired frame time
- int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
- // Ensure non-negative
- delay = delay < 0 ? 0 : delay;
- _system->delayMillis(delay);
- }
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 1a259d0..2e5359b 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -131,18 +131,14 @@ public:
void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
void playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
- /**
- * Utility method to cycle through all the cursors in the game. After
- * calling, use Left and Right arrows to cycle. Esc to quit. This is a
- * blocking function call.
- */
- void cycleThroughCursors();
-
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
private:
void initialize();
+ void initFonts();
+
+ void parseStrFile(const Common::String fileName);
/** Called every frame from ZVision::run() to process any events from EventMan */
void processEvents();
Commit: 0eeeeded920d50444b0e8ca865725231dffb0961
https://github.com/scummvm/scummvm/commit/0eeeeded920d50444b0e8ca865725231dffb0961
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:41-07:00
Commit Message:
ZVISION: Add ScriptManager support for key press events
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 b9217e7..8dd944b 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -275,6 +275,18 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo
return cursorWasChanged;
}
+void ScriptManager::onKeyDown(Common::KeyState keyState) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->onKeyDown(keyState);
+ }
+}
+
+void ScriptManager::onKeyUp(Common::KeyState keyState) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ (*iter)->onKeyUp(keyState);
+ }
+}
+
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
assert(world != 0);
debug("Changing location to: %c %c %c %c %u", world, room, node, view, offset);
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 15d456e..274905f 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -110,6 +110,18 @@ public:
* @return Was the cursor changed?
*/
bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
+ * Called when a key is pressed.
+ *
+ * @param keycode The key that was pressed
+ */
+ void onKeyDown(Common::KeyState keyState);
+ /**
+ * Called when a key is released.
+ *
+ * @param keycode The key that was pressed
+ */
+ void onKeyUp(Common::KeyState keyState);
void changeLocation(char world, char room, char node, char view, uint32 offset);
Commit: 8ba295d7103322a5193cc051da81ae82ccf5947b
https://github.com/scummvm/scummvm/commit/8ba295d7103322a5193cc051da81ae82ccf5947b
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:42-07:00
Commit Message:
ZVISION: Add key press support to the main event loop
Changed paths:
engines/zvision/events.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index ae84a22..1b6b2c2 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -71,9 +71,11 @@ void ZVision::processEvents() {
break;
}
- onKeyDown(_event.kbd.keycode);
+ _scriptManager->onKeyDown(_event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ _scriptManager->onKeyUp(_event.kbd);
break;
-
default:
break;
}
@@ -177,8 +179,4 @@ void ZVision::onMouseMove(const Common::Point &pos) {
}
}
-void ZVision::onKeyDown(uint keyCode) {
-
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 2e5359b..94bcfdf 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -146,7 +146,6 @@ private:
void onMouseDown(const Common::Point &pos);
void onMouseUp(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
- void onKeyDown(uint keyCode);
};
} // End of namespace ZVision
Commit: 466eba1e9fb271b3d6b3a4e9f02a30a9333f68da
https://github.com/scummvm/scummvm/commit/466eba1e9fb271b3d6b3a4e9f02a30a9333f68da
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:53-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 5ce58e6..7963851 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -156,7 +156,7 @@ RlfAnimation::Frame RlfAnimation::readNextFrame() {
void RlfAnimation::seekToFrame(int frameNumber) {
assert(!_stream);
- assert(frameNumber < _frameCount || frameNumber >= -1);
+ assert(frameNumber < (int)_frameCount || frameNumber >= -1);
if (frameNumber == -1) {
_currentFrame = -1;
@@ -173,7 +173,7 @@ void RlfAnimation::seekToFrame(int frameNumber) {
}
}
- for (uint i = closestFrame; i <= frameNumber; i++) {
+ for (int i = closestFrame; i <= frameNumber; i++) {
applyFrameToCurrent(i);
}
Commit: 3986f333eff094d3104feae263b42e6e9ed85968
https://github.com/scummvm/scummvm/commit/3986f333eff094d3104feae263b42e6e9ed85968
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:54-07:00
Commit Message:
ZVISION: Move dirty rect extension to the correct function
Source control mishap
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 38807a7..6258032 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -311,6 +311,8 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
sourceOffset += imageWidth;
}
+ _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+}
void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
@@ -325,7 +327,6 @@ void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSur
destOffset += destSurface->w;
sourceOffset += _workingWidth;
}
- _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
}
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
Commit: 36a0b666b3096da5a7ef169c598897be1cb06078
https://github.com/scummvm/scummvm/commit/36a0b666b3096da5a7ef169c598897be1cb06078
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:54-07:00
Commit Message:
ZVISION: Add better alpha support for blitting
Instead of blitting directly to the working window, we cache the alpha pixels,
then blit directly to the backbuffer instead of to the working window. This
ensures that if the alpha'd content changes, the old changes won't appear
in any new frames
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 6258032..72fa5d3 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -98,11 +98,37 @@ void RenderManager::renderBackbufferToScreen() {
// TODO: Add menu rendering
+ // Render alpha entries
+ processAlphaEntries();
+
if (!_backBufferDirtyRect.isEmpty()) {
_system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
}
}
+void RenderManager::processAlphaEntries() {
+ for (Common::List<AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ uint32 destOffset = 0;
+ uint32 sourceOffset = 0;
+ uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top);
+ uint16 *entryPtr = (uint16 *)(*iter).data->getPixels();
+
+ for (int32 y = 0; y < (*iter).height; y++) {
+ for (int32 x = 0; x < (*iter).width; x++) {
+ uint16 color = entryPtr[sourceOffset + x];
+ if (color != (*iter).alphaColor) {
+ backbufferPtr[destOffset + x] = color;
+ }
+ }
+
+ destOffset += _workingWidth;
+ sourceOffset += (*iter).width;
+ }
+
+ _backBufferDirtyRect.extend(Common::Rect((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top, (*iter).destX + _workingWindow.left + (*iter).width, (*iter).destY + _workingWindow.top + (*iter).height));
+ }
+}
+
void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
uint32 workingWindowSize = _workingWidth * _workingHeight;
byte r, g, b;
@@ -295,24 +321,31 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
}
void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor) {
- uint32 destOffset = 0;
+ AlphaDataEntry entry;
+ entry.alphaColor = alphaColor;
+ entry.data = new Graphics::Surface();
+ entry.data->create(width, height, _pixelFormat);
+ entry.destX = destX;
+ entry.destY = destY;
+ entry.width = width;
+ entry.height = height;
+
uint32 sourceOffset = 0;
- uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
+ uint32 destOffset = 0;
+ uint16 *surfacePtr = (uint16 *)entry.data->getPixels();
for (int32 y = 0; y < height; y++) {
for (int32 x = 0; x < width; x++) {
- uint16 color = buffer[sourceOffset + x];
- if (color != alphaColor) {
- workingWindowBufferPtr[destOffset + x] = color;
- }
+ surfacePtr[destOffset + x] = buffer[sourceOffset + x];
}
- destOffset += _workingWidth;
+ destOffset += width;
sourceOffset += imageWidth;
}
- _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+ _alphaDataEntries.push_back(entry);
}
+
void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index ce5c774..f6106b3 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -49,6 +49,16 @@ public:
~RenderManager();
private:
+ struct AlphaDataEntry {
+ Graphics::Surface *data;
+ uint16 alphaColor;
+ uint16 destX;
+ uint16 destY;
+ uint16 width;
+ uint16 height;
+ };
+
+private:
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
@@ -56,6 +66,7 @@ private:
// It's used for panorama/tilt warping and for clearing the workingWindow to a single color
Graphics::Surface _workingWindowBuffer;
Graphics::Surface _backBuffer;
+ Common::List<AlphaDataEntry> _alphaDataEntries;
Common::Rect _workingWindowDirtyRect;
Common::Rect _backBufferDirtyRect;
@@ -108,6 +119,8 @@ public:
*/
void renderBackbufferToScreen();
+ void processAlphaEntries();
+
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor);
Commit: 259d11762dbf32ec1db6869510657331bb8c88e9
https://github.com/scummvm/scummvm/commit/259d11762dbf32ec1db6869510657331bb8c88e9
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:55-07:00
Commit Message:
ZVISION: Add support for ActionRandom and ActionTimer
They were already implemented, they just weren't being used
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 3d47185..fa89f75 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -208,7 +208,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:quit*", true)) {
actionList.push_back(new ActionQuit());
} else if (line.matchString("*:random*", true)) {
- // TODO: Implement ActionRandom
+ actionList.push_back(new ActionRandom(line));
} else if (line.matchString("*:region*", true)) {
// TODO: Implement ActionRegion
} else if (line.matchString("*:restore_game*", true)) {
@@ -230,7 +230,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:syncsound*", true)) {
// TODO: Implement ActionSyncSound
} else if (line.matchString("*:timer*", true)) {
- // TODO: Implement ActionTimer
+ actionList.push_back(new ActionTimer(line));
} else if (line.matchString("*:ttytext*", true)) {
// TODO: Implement ActionTTYText
} else if (line.matchString("*:universe_music*", true)) {
Commit: 0d78208562ad1709170734195587ac6e6a597dae
https://github.com/scummvm/scummvm/commit/0d78208562ad1709170734195587ac6e6a597dae
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:56-07:00
Commit Message:
ZVISION: Add focus support for Controls
Changed paths:
engines/zvision/control.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index baa2dfb..a279381 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -48,6 +48,8 @@ public:
virtual void enable();
virtual void disable();
+ virtual void focus() {}
+ virtual void unfocus() {}
/**
* Called when LeftMouse is pushed. Default is NOP.
*
Commit: 6ee253a4d8dce2f8c45f8d8256b49505db9eff4e
https://github.com/scummvm/scummvm/commit/6ee253a4d8dce2f8c45f8d8256b49505db9eff4e
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:56-07:00
Commit Message:
ZVISION: Add focus support for the ScriptManager
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 8dd944b..3126aee 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -38,7 +38,8 @@
namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine)
- : _engine(engine) {
+ : _engine(engine),
+ _currentlyFocusedControl(0) {
}
ScriptManager::~ScriptManager() {
@@ -254,6 +255,20 @@ void ScriptManager::disableControl(uint32 key) {
}
}
+void ScriptManager::focusControl(uint32 key) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ uint32 controlKey = (*iter)->getKey();
+
+ if (controlKey == key) {
+ (*iter)->focus();
+ } else if (controlKey == _currentlyFocusedControl) {
+ (*iter)->unfocus();
+ }
+ }
+
+ _currentlyFocusedControl = key;
+}
+
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
(*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 274905f..349f259 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -74,6 +74,8 @@ private:
Location _currentLocation;
+ uint32 _currentlyFocusedControl;
+
public:
void initialize();
void update(uint deltaTimeMillis);
@@ -88,6 +90,8 @@ public:
void enableControl(uint32 key);
void disableControl(uint32 key);
+ void focusControl(uint32 key);
+
/**
* Called when LeftMouse is pushed.
*
Commit: 5cd1d2d1c2d9fc754450f548cff9aa8afaffd975
https://github.com/scummvm/scummvm/commit/5cd1d2d1c2d9fc754450f548cff9aa8afaffd975
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:57-07:00
Commit Message:
ZVISION: Ensure getControl always returns something
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 3126aee..1acbcdf 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -235,6 +235,8 @@ Control *ScriptManager::getControl(uint32 key) {
return (*iter);
}
}
+
+ return nullptr;
}
void ScriptManager::enableControl(uint32 key) {
Commit: 2900aaa90a87a1821578cadd457ba2465f02de01
https://github.com/scummvm/scummvm/commit/2900aaa90a87a1821578cadd457ba2465f02de01
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:57-07:00
Commit Message:
ZVISION: Add a reminder for how inventory is accessed
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 1b6b2c2..c1b894c 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -48,6 +48,7 @@ void ZVision::processEvents() {
break;
case Common::EVENT_RBUTTONDOWN:
+ // TODO: Inventory logic
break;
case Common::EVENT_MOUSEMOVE:
Commit: a2d19c7a6e5f80d8a3a6e0fa296e45c24442ed5f
https://github.com/scummvm/scummvm/commit/a2d19c7a6e5f80d8a3a6e0fa296e45c24442ed5f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:58-07:00
Commit Message:
ZVISION: Actually store the ZVision pointer
Changed paths:
engines/zvision/save_manager.h
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index ae65750..219a8e7 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -44,7 +44,7 @@ struct SaveGameHeader {
class SaveManager {
public:
- SaveManager(ZVision *engine);
+ SaveManager(ZVision *engine) : _engine(engine) {}
private:
ZVision *_engine;
Commit: f6c36aa14ce31340694292063722e1e7d0ba6840
https://github.com/scummvm/scummvm/commit/f6c36aa14ce31340694292063722e1e7d0ba6840
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:58-07:00
Commit Message:
ZVISION: Create an instance of the SaveManager
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 09f5ea3..f1e525d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -39,6 +39,7 @@
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
#include "zvision/cursor_manager.h"
+#include "zvision/save_manager.h"
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
@@ -71,6 +72,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_scriptManager = new ScriptManager(this);
_renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
+ _saveManager = new SaveManager(this);
debug("ZVision::ZVision");
}
Commit: c643718dae5ca7f7fce8672ffa6000661e9fceaa
https://github.com/scummvm/scummvm/commit/c643718dae5ca7f7fce8672ffa6000661e9fceaa
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:59-07:00
Commit Message:
ZVISION: Clean up the TruetypeFont class and add alpha support
Remove caching. We don't render font enough to warrant it. Use
Graphics::TextAlign instead of rolling our own. Remove methods
we don't use.
Changed paths:
engines/zvision/truetype_font.cpp
engines/zvision/truetype_font.h
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index dacd796..d88f22a 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -26,6 +26,7 @@
#include "common/file.h"
#include "common/system.h"
+#include "graphics/font.h"
#include "graphics/fonts/ttf.h"
#include "graphics/surface.h"
@@ -36,43 +37,27 @@
namespace ZVision {
-TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight, const Graphics::PixelFormat pixelFormat)
+TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight)
: _engine(engine),
- _pixelFormat(pixelFormat),
- _isBold(false),
- _isItalic(false),
- _isStriked(false),
- _isUnderline(false),
_fontHeight(fontHeight),
_font(0),
_lineHeight(0),
_maxCharWidth(0),
_maxCharHeight(0) {
- for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
- _cachedTexts[i] = 0;
- }
}
TruetypeFont::~TruetypeFont(void) {
- clearCache();
-
delete _font;
}
-void TruetypeFont::clearCache() {
- for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
- if (_cachedTexts[i]) {
- delete _cachedTexts[i];
- }
- _cachedTexts[i] = 0;
- }
-}
-
bool TruetypeFont::loadFile(const Common::String &filename) {
Common::File file;
- if (file.open(filename)) {
- debug("TTF font file %s could not be opened", filename.c_str());
- return false;
+
+ if (!Common::File::exists(filename)) {
+ debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str());
+ file.open("arial.ttf");
+ } else {
+ file.open(filename);
}
_font = Graphics::loadTTFFont(file, _fontHeight);
@@ -81,65 +66,25 @@ bool TruetypeFont::loadFile(const Common::String &filename) {
return true;
}
-void TruetypeFont::drawText(const Common::String &text, int x, int y, int width, TextAlign align, int maxHeight) {
+Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
if (text.equals("")) {
- return;
- }
-
- // Find the cached surface, if it exists
- uint32 minUseTime = UINT_MAX;
- int minIndex = -1;
- Graphics::Surface *surface = nullptr;
-
- for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
- if (_cachedTexts[i] == nullptr) {
- minUseTime = 0;
- minIndex = i;
- } else {
- if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight) {
- surface = _cachedTexts[i]->_surface;
- _cachedTexts[i]->_marked = true;
- _cachedTexts[i]->_lastUsed = g_system->getMillis();
- break;
- } else {
- if (_cachedTexts[i]->_lastUsed < minUseTime) {
- minUseTime = _cachedTexts[i]->_lastUsed;
- minIndex = i;
- }
- }
- }
+ return nullptr;
}
- // It's not cached, so create one
- if (!surface) {
- surface = renderTextToTexture(text, width, align, maxHeight);
- if (surface) {
- // Write the new surface to cache
- if (_cachedTexts[minIndex] != nullptr) {
- delete _cachedTexts[minIndex];
- }
- _cachedTexts[minIndex] = new CachedText;
-
- _cachedTexts[minIndex]->_surface = surface;
- _cachedTexts[minIndex]->_align = align;
- _cachedTexts[minIndex]->_width = width;
- _cachedTexts[minIndex]->_maxHeight = maxHeight;
- _cachedTexts[minIndex]->_text = text;
- _cachedTexts[minIndex]->_marked = true;
- _cachedTexts[minIndex]->_lastUsed = _engine->_system->getMillis();
- }
- }
+ Graphics::Surface *surface = new Graphics::Surface();
+ if (!wrap) {
+ int width = MIN(_font->getStringWidth(text), maxWidth);
+ surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ // Copy the pixels from the RenderManager::_workingWindow, so we can get nice antialiasing
+ _engine->getRenderManager()->copyWorkingWindowSubRectToSurface(surface, 0, 0, Common::Rect(destX, destY, destX + width, destY + _lineHeight));
- // Render it to the working window
- if (surface) {
- _engine->getRenderManager()->copyRectToWorkingWindow((uint16 *)surface->getPixels(), x, y, surface->w, surface->w, surface->h);
+ _font->drawString(surface, text, destX, destY, maxWidth, textColor, align);
+ return surface;
}
-}
-Graphics::Surface *TruetypeFont::renderTextToTexture(const Common::String &text, int width, TextAlign align, int maxHeight) {
Common::Array<Common::String> lines;
- _font->wordWrapText(text, width, lines);
+ _font->wordWrapText(text, maxWidth, lines);
while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) {
lines.pop_back();
@@ -148,44 +93,17 @@ Graphics::Surface *TruetypeFont::renderTextToTexture(const Common::String &text,
return nullptr;
}
- Graphics::TextAlign alignment = Graphics::kTextAlignInvalid;
- if (align == ALIGN_LEFT) {
- alignment = Graphics::kTextAlignLeft;
- } else if (align == ALIGN_CENTER) {
- alignment = Graphics::kTextAlignCenter;
- } else if (align == ALIGN_RIGHT) {
- alignment = Graphics::kTextAlignRight;
- }
-
- Graphics::Surface *surface = new Graphics::Surface();
- surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), _pixelFormat);
+ surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ // Copy the pixels from the RenderManager::_workingWindow, so we can get nice antialiasing
+ _engine->getRenderManager()->copyWorkingWindowSubRectToSurface(surface, 0, 0, Common::Rect(destX, destY, destX + maxWidth, destY + lines.size() * _lineHeight));
- uint32 alphaColor = 0xffffffff;
int heightOffset = 0;
for (Common::Array<Common::String>::iterator it = lines.begin(); it != lines.end(); it++) {
- _font->drawString(surface, *it, 0, heightOffset, width, alphaColor, alignment);
+ _font->drawString(surface, *it, destX, destY + heightOffset, maxWidth, textColor, align);
heightOffset += (int)_lineHeight;
}
return surface;
- // TODO: _isUnderline, _isBold, _isItalic, _isStriked
-}
-
-void TruetypeFont::measureText(const Common::String &text, int maxWidth, int maxHeight, int &textWidthOut, int &textHeightOut) {
- if (maxWidth >= 0) {
- Common::Array<Common::String> lines;
- _font->wordWrapText(text, maxWidth, lines);
- Common::Array<Common::String>::iterator it;
- textWidthOut = 0;
- for (it = lines.begin(); it != lines.end(); ++it) {
- textWidthOut = MAX(textWidthOut, _font->getStringWidth(*it));
- }
-
- textHeightOut = (int)(lines.size() * getLineHeight());
- } else {
- textWidthOut = _font->getStringWidth(text);
- textHeightOut = _fontHeight;
- }
}
} // End of namespace ZVision
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index 4865741..c8d0a95 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -28,7 +28,7 @@
#include "common/types.h"
#include "graphics/font.h"
-
+#include "graphics/pixelformat.h"
namespace Graphics {
struct Surface;
@@ -40,83 +40,24 @@ class ZVision;
class TruetypeFont {
public:
- TruetypeFont(ZVision *engine, int32 fontHeight, const Graphics::PixelFormat pixelFormat);
+ TruetypeFont(ZVision *engine, int32 fontHeight);
~TruetypeFont();
-public:
- enum {
- NUM_CACHED_TEXTS = 30
- };
-
- enum TextAlign {
- ALIGN_LEFT = 0,
- ALIGN_RIGHT,
- ALIGN_CENTER
- };
-
- class CachedText {
- public:
- Common::String _text;
- int32 _width;
- TextAlign _align;
- int32 _maxHeight;
- Graphics::Surface *_surface;
- int32 _textOffset;
- bool _marked;
- uint32 _lastUsed;
-
- CachedText() {
- _width = _maxHeight = -1;
- _align = ALIGN_LEFT;
- _surface = 0;
- _lastUsed = 0;
- _marked = false;
- }
-
- virtual ~CachedText() {
- delete _surface;
- }
- };
-
private:
ZVision *_engine;
- const Graphics::PixelFormat _pixelFormat;
-
Graphics::Font *_font;
-
float _lineHeight;
size_t _maxCharWidth;
size_t _maxCharHeight;
- CachedText *_cachedTexts[NUM_CACHED_TEXTS];
-
public:
- bool _isBold;
- bool _isItalic;
- bool _isUnderline;
- bool _isStriked;
int32 _fontHeight;
- //BaseArray<BaseTTFontLayer *> _layers;
-
public:
- int getTextWidth(const byte *text, int maxLength = -1);
- int getTextHeight(const byte *text, int width);
- void drawText(const Common::String &text, int x, int y, int width, TextAlign align = ALIGN_LEFT, int max_height = -1);
- int getLetterHeight();
-
bool loadFile(const Common::String &filename);
-
- float getLineHeight() const { return _lineHeight; }
- void clearCache();
-
- static TruetypeFont *createFromFile(ZVision *game, const Common::String &filename);
-
-private:
- void measureText(const Common::String &text, int maxWidth, int maxHeight, int &textWidthOut, int &textHeightOut);
- Graphics::Surface *renderTextToTexture(const Common::String &text, int width, TextAlign align, int maxHeight);
+ Graphics::Surface *drawTextToSurface(const Common::String &text, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
};
} // End of namespace ZVision
Commit: dc8c7ca2c04372a39af5cca80040daa8923e9658
https://github.com/scummvm/scummvm/commit/dc8c7ca2c04372a39af5cca80040daa8923e9658
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:00:59-07:00
Commit Message:
ZVISION: Add RenderManager text support
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 72fa5d3..1c1ce40 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -346,6 +346,22 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
_alphaDataEntries.push_back(entry);
}
+Common::Rect RenderManager::renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
+ AlphaDataEntry entry;
+ entry.alphaColor = 0;
+ entry.destX = destX;
+ entry.destY = destY;
+
+ // Draw the text to the working window
+ entry.data = font->drawTextToSurface(text, destX, destY, textColor, maxWidth, maxHeight, align, wrap);
+ entry.width = entry.data->w;
+ entry.height = entry.data->h;
+
+ _alphaDataEntries.push_back(entry);
+
+ return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
+}
+
void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index f6106b3..84914cc 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -29,6 +29,7 @@
#include "graphics/surface.h"
#include "zvision/render_table.h"
+#include "zvision/truetype_font.h"
class OSystem;
@@ -124,6 +125,8 @@ public:
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor);
+ Common::Rect renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
+
/**
* Fills the entire workingWindow with the specified color
*
Commit: 05b3b170d45125ba52c7b795a89d3ce8141c77ab
https://github.com/scummvm/scummvm/commit/05b3b170d45125ba52c7b795a89d3ce8141c77ab
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:01:00-07:00
Commit Message:
ZVISION: Add more documentation for clearWorkingWindowTo555Color()
Changed paths:
engines/zvision/render_manager.h
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 84914cc..50d2d10 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -128,7 +128,8 @@ public:
Common::Rect renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
/**
- * Fills the entire workingWindow with the specified color
+ * Fills the entire workingWindow with the specified color. Internally, the color
+ * will be converted to RGB 565 and then blitted.
*
* @param color The color to fill the working window with. (In RGB 555)
*/
Commit: 82ea7ca0e7bad570195f41392f717a42254aff5f
https://github.com/scummvm/scummvm/commit/82ea7ca0e7bad570195f41392f717a42254aff5f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:01:00-07:00
Commit Message:
ZVISION: Create the StringManager class
This parses the XXXXX.STR files into styled fonts and phrases. The styles
and the phrases are used in the game for messages to the user and for
general purpose fonts.
Changed paths:
A engines/zvision/string_manager.cpp
A engines/zvision/string_manager.h
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 9fa119d..cb4a360 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
script_manager.o \
scripts.o \
single_value_container.o \
+ string_manager.o \
timer_node.o \
truetype_font.o \
utility.o \
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
new file mode 100644
index 0000000..818b60c
--- /dev/null
+++ b/engines/zvision/string_manager.cpp
@@ -0,0 +1,235 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/tokenizer.h"
+#include "common/debug.h"
+
+#include "graphics/fontman.h"
+
+#include "zvision/string_manager.h"
+#include "zvision/truetype_font.h"
+
+
+namespace ZVision {
+
+const Graphics::PixelFormat StringManager::_pixelFormat565 = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+
+StringManager::StringManager(ZVision *engine)
+ : _engine(engine) {
+}
+
+StringManager::~StringManager() {
+ for (Common::HashMap<Common::String, TruetypeFont *>::iterator iter = _fonts.begin(); iter != _fonts.end(); iter++) {
+ delete (*iter)._value;
+ }
+}
+
+void StringManager::initialize(ZVisionGameId gameId) {
+ if (gameId == ZorkNemesis) {
+ // TODO: Check this hardcoded filename against all versions of Nemesis
+ parseStrFile("nemesis.str");
+ } else if (gameId == ZorkGrandInquisitor) {
+ // TODO: Check this hardcoded filename against all versions of Grand Inquisitor
+ parseStrFile("inquis.str");
+ }
+}
+
+void StringManager::parseStrFile(const Common::String &fileName) {
+ Common::File file;
+ if (!file.open(fileName)) {
+ warning("%s does not exist. String parsing failed", fileName.c_str());
+ return;
+ }
+
+ Common::String line = file.readLine();
+
+ uint lineNumber = 0;
+ while (!file.eos()) {
+ Common::String asciiLine = wideToASCII(line.c_str(), line.size());
+
+ char tagString[150];
+ uint tagStringCursor = 0;
+ char textString[150];
+ uint textStringCursor = 0;
+ bool inTag = false;
+
+ for (uint i = 0; i < asciiLine.size(); i++) {
+ switch (asciiLine[i]) {
+ case '<':
+ inTag = true;
+ break;
+ case '>':
+ inTag = false;
+ parseTag(Common::String(tagString, tagStringCursor), Common::String(textString, textStringCursor), i);
+ tagStringCursor = 0;
+ textStringCursor = 0;
+ break;
+ default:
+ if (inTag) {
+ textString[tagStringCursor] = asciiLine[i];
+ tagStringCursor++;
+ } else {
+ textString[textStringCursor] = asciiLine[i];
+ textStringCursor++;
+ }
+ break;
+ }
+ }
+
+ // STR files add a null character after the CR/LF. We need to skip over that before we can read another line
+ file.readByte();
+
+ line = file.readLine();
+ lineNumber++;
+ }
+}
+
+void StringManager::parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber) {
+ Common::StringTokenizer tokenizer(tagString);
+
+ Common::String token = tokenizer.nextToken();
+
+ Common::String fontName;
+ bool bold = false;
+ Graphics::TextAlign align = Graphics::kTextAlignLeft;
+ int point = 12;
+ int red = 0;
+ int green = 0;
+ int blue = 0;
+
+ while (!token.empty()) {
+ if (token.matchString("font", true)) {
+ fontName = tokenizer.nextToken();
+ } else if (token.matchString("bold", true)) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", false)) {
+ bold = true;
+ }
+ } else if (token.matchString("justify", true)) {
+ token = tokenizer.nextToken();
+ if (token.matchString("center", false)) {
+ align = Graphics::kTextAlignCenter;
+ } else if (token.matchString("right", false)) {
+ align = Graphics::kTextAlignRight;
+ }
+ } else if (token.matchString("point", true)) {
+ point = atoi(tokenizer.nextToken().c_str());
+ } else if (token.matchString("red", true)) {
+ red = atoi(tokenizer.nextToken().c_str());
+ } else if (token.matchString("green", true)) {
+ green = atoi(tokenizer.nextToken().c_str());
+ } else if (token.matchString("blue", true)) {
+ blue = atoi(tokenizer.nextToken().c_str());
+ }
+
+ token = tokenizer.nextToken();
+ }
+
+ Common::String newFontName;
+ if (fontName.matchString("times new roman", true)) {
+ if (bold) {
+ newFontName = "timesbd.ttf";
+ } else {
+ newFontName = "times.ttf";
+ }
+ } else if (fontName.matchString("courier new", true)) {
+ if (bold) {
+ newFontName = "courbd.ttf";
+ } else {
+ newFontName = "cour.ttf";
+ }
+ } else if (fontName.matchString("century schoolbook", true)) {
+ if (bold) {
+ newFontName = "censcbkbd.ttf";
+ } else {
+ newFontName = "censcbk.ttf";
+ }
+ } else if (fontName.matchString("times new roman", true)) {
+ if (bold) {
+ newFontName = "courbd.ttf";
+ } else {
+ newFontName = "cour.ttf";
+ }
+ } else {
+ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
+ if (bold) {
+ newFontName = "zorknorm.ttf";
+ } else {
+ newFontName = "arial.ttf";
+ }
+ }
+
+ // Push an empty TextFragment onto the end of the list
+ // Creating the TextFragement before filling it prevents extra data copying during creation
+ _inGameText->fragments.push_back(TextFragment());
+ TextFragment *fragment = &_inGameText->fragments.back();
+
+ Common::String fontKey = Common::String::format("%s-&d", newFontName.c_str(), point);
+ if (_fonts.contains(fontKey)) {
+ fragment->style.font = _fonts[fontKey];
+ } else {
+ fragment->style.font = new TruetypeFont(_engine, point);
+ fragment->style.font->loadFile(newFontName);
+ }
+
+ fragment->style.align = align;
+ fragment->style.color = _pixelFormat565.ARGBToColor(0, red, green, blue);
+ fragment->text = textString;
+}
+
+Common::String StringManager::wideToASCII(const char *wideStr, uint arrayLength) {
+ // TODO: Contemplate using a largish static buffer instead of a dynamic heap buffer
+ uint newSize = arrayLength / 2;
+ char *asciiString = new char[newSize];
+
+ // Don't spam the user with warnings about UTF-16 support.
+ // Just do one warning per String
+ bool charOverflowWarning = false;
+ // Crush each octet pair to a single octet with a simple cast
+ for (uint i = 0; i < newSize; i++) {
+ uint16 value = READ_LE_UINT16(wideStr + (i * 2));
+ if (value > 255) {
+ charOverflowWarning = true;
+ value = 255;
+ }
+ asciiString[i] = (char)value;
+ }
+
+ if (charOverflowWarning) {
+ warning("UTF-16 is not supported. Characters greater than 255 are clamped to 255");
+ }
+
+ Common::String returnString(asciiString, newSize);
+ // Cleanup. Common::String constructor does a memmove() internally so we can safely delete
+ delete[] asciiString;
+
+ return returnString;
+}
+
+StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
+ return _inGameText[stringNumber].fragments.front().style;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
new file mode 100644
index 0000000..a9d2dc1
--- /dev/null
+++ b/engines/zvision/string_manager.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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_STRING_MANAGER_H
+#define ZVISION_STRING_MANAGER_H
+
+#include "common/types.h"
+
+#include "zvision/detection.h"
+#include "zvision/truetype_font.h"
+
+
+namespace Graphics {
+class FontManager;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class StringManager {
+public:
+ StringManager(ZVision *engine);
+ ~StringManager();
+
+public:
+ struct TextStyle {
+ TruetypeFont *font;
+ uint16 color; // In RBG 565
+ Graphics::TextAlign align;
+ };
+
+ struct TextFragment {
+ TextStyle style;
+ Common::String text;
+ };
+
+private:
+ struct InGameText {
+ Common::List<TextFragment> fragments;
+ };
+
+private:
+ ZVision *_engine;
+ // NOTE: We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56
+ InGameText _inGameText[56];
+ Common::HashMap<Common::String, TruetypeFont *> _fonts;
+
+ static const Graphics::PixelFormat _pixelFormat565;
+
+public:
+ void initialize(ZVisionGameId gameId);
+ StringManager::TextStyle getTextStyle(uint stringNumber);
+
+private:
+ void parseStrFile(const Common::String &fileName);
+ void parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber);
+
+ static Common::String wideToASCII(const char *wideStr, uint arrayLength);
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: c312b147fa7f5a28491975ae0bcc4b419e7e126a
https://github.com/scummvm/scummvm/commit/c312b147fa7f5a28491975ae0bcc4b419e7e126a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T13:01:01-07:00
Commit Message:
ZVISION: Create an instance of StringManager
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f1e525d..dc1cf47 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -40,6 +40,7 @@
#include "zvision/render_manager.h"
#include "zvision/cursor_manager.h"
#include "zvision/save_manager.h"
+#include "zvision/string_manager.h"
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
@@ -71,8 +72,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
_renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
-
_saveManager = new SaveManager(this);
+ _stringManager = new StringManager(this);
debug("ZVision::ZVision");
}
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 94bcfdf..a481aba 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -48,6 +48,7 @@ class Console;
class ScriptManager;
class RenderManager;
class CursorManager;
+class StringManager;
class SaveManager;
class RlfAnimation;
@@ -97,6 +98,7 @@ private:
RenderManager *_renderManager;
CursorManager *_cursorManager;
SaveManager *_saveManager;
+ StringManager *_stringManager;
// Clock
Clock _clock;
@@ -114,6 +116,7 @@ public:
RenderManager *getRenderManager() const { return _renderManager; }
CursorManager *getCursorManager() const { return _cursorManager; }
SaveManager *getSaveManager() const { return _saveManager; }
+ StringManager *getStringManager() const { return _stringManager; }
Common::RandomSource *getRandomSource() const { return _rnd; }
ZVisionGameId getGameId() const { return _gameDescription->gameId; }
Commit: d82ff7aea8d866bf5be2accfab321c39dd727c66
https://github.com/scummvm/scummvm/commit/d82ff7aea8d866bf5be2accfab321c39dd727c66
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T14:26:49-07:00
Commit Message:
ZVISION: Create Console method to render text
Changed paths:
engines/zvision/console.cpp
engines/zvision/console.h
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 4ea4a8e..3969aa1 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -32,6 +32,7 @@
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
+#include "zvision/string_manager.h"
#include "zvision/zork_avi_decoder.h"
#include "zvision/zork_raw.h"
#include "zvision/utility.h"
@@ -52,6 +53,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
DCmd_Register("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
+ DCmd_Register("rendertext", WRAP_METHOD(Console, cmdRenderText));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -198,4 +200,14 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
return true;
}
+bool Console::cmdRenderText(int argc, const char **argv) {
+ if (argc != 7) {
+ DebugPrintf("Use rendertext <text> <fontNumber> <destX> <destY> <maxWidth> <1 or 0: wrap> to render text\n");
+ return true;
+ }
+
+ StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
+ _engine->getRenderManager()->renderTextToWorkingWindow(Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/console.h b/engines/zvision/console.h
index fdb2064..0ca1b8c 100644
--- a/engines/zvision/console.h
+++ b/engines/zvision/console.h
@@ -48,6 +48,7 @@ private:
bool cmdChangeLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
bool cmdParseAllScrFiles(int argc, const char **argv);
+ bool cmdRenderText(int argc, const char **argv);
};
} // End of namespace ZVision
Commit: 2b2f85063afd2fcd5d7b24851ad697de58e9c8a6
https://github.com/scummvm/scummvm/commit/2b2f85063afd2fcd5d7b24851ad697de58e9c8a6
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T14:27:19-07:00
Commit Message:
ZVISION: Clean up StringManager and SaveManager after use
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index dc1cf47..2d14e5d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -83,6 +83,8 @@ ZVision::~ZVision() {
// Dispose of resources
delete _console;
delete _cursorManager;
+ delete _stringManager;
+ delete _saveManager;
delete _renderManager;
delete _scriptManager;
delete _rnd;
Commit: 41afb2dd90caa5dc09a688d253c119e28ef25318
https://github.com/scummvm/scummvm/commit/41afb2dd90caa5dc09a688d253c119e28ef25318
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:00:52-07:00
Commit Message:
ZVISION: Move clearing dirty rects to after they are blitted instead the beginning of each frame
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 1c1ce40..a5c659d 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -60,10 +60,6 @@ RenderManager::~RenderManager() {
}
void RenderManager::update(uint deltaTimeInMillis) {
- // Clear the dirty rects from last frame
- _workingWindowDirtyRect = Common::Rect();
- _backBufferDirtyRect = Common::Rect();
-
// An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
if (_backgroundInverseVelocity != 0) {
_accumulatedVelocityMilliseconds += deltaTimeInMillis;
@@ -93,7 +89,14 @@ void RenderManager::renderBackbufferToScreen() {
// Translate the working window dirty rect to screen coords
_workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top);
// Then extend the backbuffer dirty rect to contain it
- _backBufferDirtyRect.extend(_workingWindowDirtyRect);
+ if (_backBufferDirtyRect.isEmpty()) {
+ _backBufferDirtyRect = _workingWindowDirtyRect;
+ } else {
+ _backBufferDirtyRect.extend(_workingWindowDirtyRect);
+ }
+
+ // Clear the dirty rect
+ _workingWindowDirtyRect = Common::Rect();
}
// TODO: Add menu rendering
@@ -103,6 +106,7 @@ void RenderManager::renderBackbufferToScreen() {
if (!_backBufferDirtyRect.isEmpty()) {
_system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
+ _backBufferDirtyRect = Common::Rect();
}
}
Commit: 7ce6823158122d0b1922e675eccf31fd5382f9ef
https://github.com/scummvm/scummvm/commit/7ce6823158122d0b1922e675eccf31fd5382f9ef
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:02:57-07:00
Commit Message:
ZVISION: Convert _alphaDataEntries to a HashMap
So entries can be easily identified and removed if necessary
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 a5c659d..c25f670 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -111,25 +111,31 @@ void RenderManager::renderBackbufferToScreen() {
}
void RenderManager::processAlphaEntries() {
- for (Common::List<AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
+
+ for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
- uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top);
- uint16 *entryPtr = (uint16 *)(*iter).data->getPixels();
+ uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top);
+ uint16 *entryPtr = (uint16 *)(*iter)._value.data->getPixels();
- for (int32 y = 0; y < (*iter).height; y++) {
- for (int32 x = 0; x < (*iter).width; x++) {
+ for (int32 y = 0; y < (*iter)._value.height; y++) {
+ for (int32 x = 0; x < (*iter)._value.width; x++) {
uint16 color = entryPtr[sourceOffset + x];
- if (color != (*iter).alphaColor) {
+ if (color != (*iter)._value.alphaColor) {
backbufferPtr[destOffset + x] = color;
}
}
- destOffset += _workingWidth;
- sourceOffset += (*iter).width;
+ destOffset += _backBuffer.w;
+ sourceOffset += (*iter)._value.width;
}
- _backBufferDirtyRect.extend(Common::Rect((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top, (*iter).destX + _workingWindow.left + (*iter).width, (*iter).destY + _workingWindow.top + (*iter).height));
+ if (_backBufferDirtyRect.isEmpty()) {
+ _backBufferDirtyRect = Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height);
+ } else {
+ _backBufferDirtyRect.extend(Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height));
+ }
}
}
@@ -324,7 +330,7 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight);
}
-void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor) {
+void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber) {
AlphaDataEntry entry;
entry.alphaColor = alphaColor;
entry.data = new Graphics::Surface();
@@ -347,10 +353,10 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
sourceOffset += imageWidth;
}
- _alphaDataEntries.push_back(entry);
+ _alphaDataEntries[idNumber] = entry;
}
-Common::Rect RenderManager::renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
+Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
AlphaDataEntry entry;
entry.alphaColor = 0;
entry.destX = destX;
@@ -361,7 +367,7 @@ Common::Rect RenderManager::renderTextToWorkingWindow(const Common::String &text
entry.width = entry.data->w;
entry.height = entry.data->h;
- _alphaDataEntries.push_back(entry);
+ _alphaDataEntries[idNumber] = entry;
return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 50d2d10..e7030b0 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -25,6 +25,7 @@
#include "common/types.h"
#include "common/rect.h"
+#include "common/hashmap.h"
#include "graphics/surface.h"
@@ -67,7 +68,7 @@ private:
// It's used for panorama/tilt warping and for clearing the workingWindow to a single color
Graphics::Surface _workingWindowBuffer;
Graphics::Surface _backBuffer;
- Common::List<AlphaDataEntry> _alphaDataEntries;
+ Common::HashMap<uint32, AlphaDataEntry> _alphaDataEntries;
Common::Rect _workingWindowDirtyRect;
Common::Rect _backBufferDirtyRect;
@@ -123,9 +124,9 @@ public:
void processAlphaEntries();
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
- void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor);
+ void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber);
- Common::Rect renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
+ Common::Rect renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
/**
* Fills the entire workingWindow with the specified color. Internally, the color
Commit: cdd793ed224579870daa73061ff0478e179ff21d
https://github.com/scummvm/scummvm/commit/cdd793ed224579870daa73061ff0478e179ff21d
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:03:35-07:00
Commit Message:
ZVISION: Check is a dirty rect is empty before extending it
So extends dont extend from 0,0
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index c25f670..13e8cba 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -324,7 +324,11 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
sourceOffset += imageWidth;
}
- _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+ if (_workingWindowDirtyRect.isEmpty()) {
+ _workingWindowDirtyRect = Common::Rect(destX, destY, destX + width, destY + height);
+ } else {
+ _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+ }
// TODO: Remove this from release. It's here to make sure code that uses this function clips their destinations correctly
assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight);
Commit: 3a6cb86489c7e0a7c171dbb9d317dd2cdbf4cccf
https://github.com/scummvm/scummvm/commit/3a6cb86489c7e0a7c171dbb9d317dd2cdbf4cccf
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:04:03-07:00
Commit Message:
ZVISION: Add methods to clear and remove AlphaEntries
Changed paths:
engines/zvision/render_manager.h
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index e7030b0..2fc3f23 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -122,6 +122,8 @@ public:
void renderBackbufferToScreen();
void processAlphaEntries();
+ void clearAlphaEntries() { _alphaDataEntries.clear(); }
+ void removeAlphaEntry(uint32 idNumber) { _alphaDataEntries.erase(idNumber); }
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber);
Commit: 2187245012c2912fdebc8ec74a52a6488bc6d045
https://github.com/scummvm/scummvm/commit/2187245012c2912fdebc8ec74a52a6488bc6d045
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:04:23-07:00
Commit Message:
ZVISION: Remove all AlphaEntries on room change
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 1acbcdf..e014983 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -329,6 +329,9 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Reset the background velocity
_engine->getRenderManager()->setBackgroundVelocity(0);
+ // Remove any alphaEntries
+ _engine->getRenderManager()->clearAlphaEntries();
+
// Clean the global state table
cleanStateTable();
Commit: 1f9f392279b05433e265711758bc5ecec65eb08b
https://github.com/scummvm/scummvm/commit/1f9f392279b05433e265711758bc5ecec65eb08b
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:04:34-07:00
Commit Message:
ZVISION: Enable auto saving
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index e014983..4b4e0f7 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -309,7 +309,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
debug("Changing location to: %c %c %c %c %u", world, room, node, view, offset);
// Auto save
- //_engine->getSaveManager()->autoSave();
+ _engine->getSaveManager()->autoSave();
// Clear all the containers
_referenceTable.clear();
Commit: 4c4f08a99e0b7ff914c6f9c2cb1b38caeba9009f
https://github.com/scummvm/scummvm/commit/4c4f08a99e0b7ff914c6f9c2cb1b38caeba9009f
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:05:24-07:00
Commit Message:
ZVISION: Convert cmdRenderText to use new function syntax
Changed paths:
engines/zvision/console.cpp
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 3969aa1..0d290a6 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -207,7 +207,9 @@ bool Console::cmdRenderText(int argc, const char **argv) {
}
StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
- _engine->getRenderManager()->renderTextToWorkingWindow(Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true);
+ _engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true);
+
+ return true;
}
} // End of namespace ZVision
Commit: 14cfc65c0d3f3ac678c17614140ea32902abec69
https://github.com/scummvm/scummvm/commit/14cfc65c0d3f3ac678c17614140ea32902abec69
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:09:03-07:00
Commit Message:
ZVISION: Use wide-to-ASCII conversion to read a line instead of stream.readLine()
SeekableReadStream::readLine() wasn't finding the CRLF's properly
Changed paths:
engines/zvision/string_manager.cpp
engines/zvision/string_manager.h
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 818b60c..127b62f 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -98,10 +98,10 @@ void StringManager::parseStrFile(const Common::String &fileName) {
}
}
- // STR files add a null character after the CR/LF. We need to skip over that before we can read another line
- file.readByte();
+ if (textStringCursor > 0) {
+ _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
+ }
- line = file.readLine();
lineNumber++;
}
}
@@ -199,33 +199,43 @@ void StringManager::parseTag(const Common::String &tagString, const Common::Stri
fragment->text = textString;
}
-Common::String StringManager::wideToASCII(const char *wideStr, uint arrayLength) {
- // TODO: Contemplate using a largish static buffer instead of a dynamic heap buffer
- uint newSize = arrayLength / 2;
- char *asciiString = new char[newSize];
+Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
+ // NOTE: Hardcoded size. All strings I've checked are less than 290 chars
+ char asciiString[300];
// Don't spam the user with warnings about UTF-16 support.
// Just do one warning per String
bool charOverflowWarning = false;
- // Crush each octet pair to a single octet with a simple cast
- for (uint i = 0; i < newSize; i++) {
- uint16 value = READ_LE_UINT16(wideStr + (i * 2));
+
+ uint16 value = stream.readUint16LE();
+ uint i = 0;
+ while (!stream.eos()) {
+ // Check for CRLF
+ if (value == 0x0A0D) {
+ // Read in the extra NULL char
+ stream.readByte(); // \0
+ // End of the line. Break
+ break;
+ }
+
+ // Crush each octet pair to a single octet with a simple cast
if (value > 255) {
charOverflowWarning = true;
value = 255;
}
- asciiString[i] = (char)value;
+ char charValue = (char)value;
+
+ asciiString[i] = charValue;
+ i++;
+
+ value = stream.readUint16LE();
}
if (charOverflowWarning) {
warning("UTF-16 is not supported. Characters greater than 255 are clamped to 255");
}
- Common::String returnString(asciiString, newSize);
- // Cleanup. Common::String constructor does a memmove() internally so we can safely delete
- delete[] asciiString;
-
- return returnString;
+ return Common::String(asciiString, i);
}
StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index a9d2dc1..a214c6c 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -76,7 +76,7 @@ private:
void parseStrFile(const Common::String &fileName);
void parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber);
- static Common::String wideToASCII(const char *wideStr, uint arrayLength);
+ static Common::String readWideLine(Common::SeekableReadStream &stream);
};
} // End of namespace ZVision
Commit: d59cf9fda66f8bcd89f12248d7337727d708f425
https://github.com/scummvm/scummvm/commit/d59cf9fda66f8bcd89f12248d7337727d708f425
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:10:35-07:00
Commit Message:
ZVISION: Convert StringManager::parseStr to use readWideLine()
Changed paths:
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 127b62f..1cc3c15 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -63,11 +63,16 @@ void StringManager::parseStrFile(const Common::String &fileName) {
return;
}
- Common::String line = file.readLine();
-
uint lineNumber = 0;
while (!file.eos()) {
- Common::String asciiLine = wideToASCII(line.c_str(), line.size());
+ _lastStyle.align = Graphics::kTextAlignLeft;
+ _lastStyle.color = 0;
+ _lastStyle.font = nullptr;
+
+ Common::String asciiLine = readWideLine(file);
+ if (asciiLine.empty()) {
+ continue;
+ }
char tagString[150];
uint tagStringCursor = 0;
@@ -79,16 +84,19 @@ void StringManager::parseStrFile(const Common::String &fileName) {
switch (asciiLine[i]) {
case '<':
inTag = true;
+ if (!_inGameText[lineNumber].fragments.empty()) {
+ _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
+ textStringCursor = 0;
+ }
break;
case '>':
inTag = false;
- parseTag(Common::String(tagString, tagStringCursor), Common::String(textString, textStringCursor), i);
+ parseTag(Common::String(tagString, tagStringCursor), lineNumber);
tagStringCursor = 0;
- textStringCursor = 0;
break;
default:
if (inTag) {
- textString[tagStringCursor] = asciiLine[i];
+ tagString[tagStringCursor] = asciiLine[i];
tagStringCursor++;
} else {
textString[textStringCursor] = asciiLine[i];
Commit: a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a
https://github.com/scummvm/scummvm/commit/a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:15-07:00
Commit Message:
ZVISION: Fix parseTag font name logic
Changed paths:
engines/zvision/string_manager.cpp
engines/zvision/string_manager.h
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 1cc3c15..4c4fc7b 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -114,15 +114,15 @@ void StringManager::parseStrFile(const Common::String &fileName) {
}
}
-void StringManager::parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber) {
+void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
Common::StringTokenizer tokenizer(tagString);
Common::String token = tokenizer.nextToken();
Common::String fontName;
bool bold = false;
- Graphics::TextAlign align = Graphics::kTextAlignLeft;
- int point = 12;
+ Graphics::TextAlign align = _lastStyle.align;
+ int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12;
int red = 0;
int green = 0;
int blue = 0;
@@ -155,56 +155,60 @@ void StringManager::parseTag(const Common::String &tagString, const Common::Stri
token = tokenizer.nextToken();
}
- Common::String newFontName;
- if (fontName.matchString("times new roman", true)) {
- if (bold) {
- newFontName = "timesbd.ttf";
- } else {
- newFontName = "times.ttf";
- }
- } else if (fontName.matchString("courier new", true)) {
- if (bold) {
- newFontName = "courbd.ttf";
- } else {
- newFontName = "cour.ttf";
- }
- } else if (fontName.matchString("century schoolbook", true)) {
- if (bold) {
- newFontName = "censcbkbd.ttf";
- } else {
- newFontName = "censcbk.ttf";
- }
- } else if (fontName.matchString("times new roman", true)) {
- if (bold) {
- newFontName = "courbd.ttf";
+ TextFragment fragment = _inGameText->fragments.back();
+
+ if (fontName.empty()) {
+ fragment.style.font = _lastStyle.font;
+ } else {
+ Common::String newFontName;
+ if (fontName.matchString("*times new roman*", true)) {
+ if (bold) {
+ newFontName = "timesbd.ttf";
+ } else {
+ newFontName = "times.ttf";
+ }
+ } else if (fontName.matchString("*courier new*", true)) {
+ if (bold) {
+ newFontName = "courbd.ttf";
+ } else {
+ newFontName = "cour.ttf";
+ }
+ } else if (fontName.matchString("*century schoolbook*", true)) {
+ if (bold) {
+ newFontName = "censcbkbd.ttf";
+ } else {
+ newFontName = "censcbk.ttf";
+ }
+ } else if (fontName.matchString("*garamond*", true)) {
+ if (bold) {
+ newFontName = "garabd.ttf";
+ } else {
+ newFontName = "gara.ttf";
+ }
} else {
- newFontName = "cour.ttf";
+ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
+ if (bold) {
+ newFontName = "zorknorm.ttf";
+ } else {
+ newFontName = "arial.ttf";
+ }
}
- } else {
- debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
- if (bold) {
- newFontName = "zorknorm.ttf";
+
+ Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point);
+ if (_fonts.contains(fontKey)) {
+ fragment.style.font = _fonts[fontKey];
} else {
- newFontName = "arial.ttf";
+ fragment.style.font = new TruetypeFont(_engine, point);
+ fragment.style.font->loadFile(newFontName);
+ _fonts[fontKey] = fragment.style.font;
}
}
- // Push an empty TextFragment onto the end of the list
- // Creating the TextFragement before filling it prevents extra data copying during creation
- _inGameText->fragments.push_back(TextFragment());
- TextFragment *fragment = &_inGameText->fragments.back();
-
- Common::String fontKey = Common::String::format("%s-&d", newFontName.c_str(), point);
- if (_fonts.contains(fontKey)) {
- fragment->style.font = _fonts[fontKey];
- } else {
- fragment->style.font = new TruetypeFont(_engine, point);
- fragment->style.font->loadFile(newFontName);
- }
+ fragment.style.align = align;
+ fragment.style.color = _pixelFormat565.ARGBToColor(0, red, green, blue);
+ _inGameText[lineNumber].fragments.push_back(fragment);
- fragment->style.align = align;
- fragment->style.color = _pixelFormat565.ARGBToColor(0, red, green, blue);
- fragment->text = textString;
+ _lastStyle = fragment.style;
}
Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index a214c6c..e3539a7 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -68,13 +68,15 @@ private:
static const Graphics::PixelFormat _pixelFormat565;
+ TextStyle _lastStyle;
+
public:
void initialize(ZVisionGameId gameId);
StringManager::TextStyle getTextStyle(uint stringNumber);
private:
void parseStrFile(const Common::String &fileName);
- void parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber);
+ void parseTag(const Common::String &tagString, uint lineNumber);
static Common::String readWideLine(Common::SeekableReadStream &stream);
};
Commit: c7e2bdd2b2730225d1d76b22c71e7733ed61f23c
https://github.com/scummvm/scummvm/commit/c7e2bdd2b2730225d1d76b22c71e7733ed61f23c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:24-07:00
Commit Message:
ZVISION: Remove extraneous function
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 13e8cba..7f10535 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -376,22 +376,6 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com
return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
}
-void RenderManager::copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const {
- uint32 destOffset = 0;
- uint32 sourceOffset = 0;
- uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(subRect.left, subRect.top);
- uint16 *destPtr = (uint16 *)destSurface->getBasePtr(destX, destY);
-
- for (int32 y = 0; y < subRect.height(); y++) {
- for (int32 x = 0; x < subRect.width(); x++) {
- destPtr[destOffset + x] = workingWindowBufferPtr[sourceOffset + x];
- }
-
- destOffset += destSurface->w;
- sourceOffset += _workingWidth;
- }
-}
-
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
// Convert from screen space to working window space
Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 2fc3f23..b0a42d9 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -214,7 +214,6 @@ public:
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
- void copyWorkingWindowSubRectToSurface(Graphics::Surface *destSurface, uint16 destX, uint16 destY, Common::Rect subRect) const;
/**
* Creates a copy of surface and transposes the data.
Commit: 2b60cc8a0c9bd4e1e95b78c96aafe22e0d17bf3a
https://github.com/scummvm/scummvm/commit/2b60cc8a0c9bd4e1e95b78c96aafe22e0d17bf3a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:24-07:00
Commit Message:
ZVISION: Test for file.open() success before continuing with font loading
Changed paths:
engines/zvision/truetype_font.cpp
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index d88f22a..8c5c279 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -53,11 +53,17 @@ TruetypeFont::~TruetypeFont(void) {
bool TruetypeFont::loadFile(const Common::String &filename) {
Common::File file;
+ bool fileOpened = false;
if (!Common::File::exists(filename)) {
debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str());
- file.open("arial.ttf");
+ fileOpened = file.open("arial.ttf");
} else {
- file.open(filename);
+ fileOpened = file.open(filename);
+ }
+
+ if (!fileOpened) {
+ debug("TTF file could not be opened");
+ return false;
}
_font = Graphics::loadTTFFont(file, _fontHeight);
Commit: ff5b7ba2a8102ae04bc2743d88a6d343b7247210
https://github.com/scummvm/scummvm/commit/ff5b7ba2a8102ae04bc2743d88a6d343b7247210
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:25-07:00
Commit Message:
ZVISION: Draw string to 0, 0 instead of destX, destY
Changed paths:
engines/zvision/truetype_font.cpp
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index 8c5c279..8fd331d 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -82,10 +82,11 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, i
if (!wrap) {
int width = MIN(_font->getStringWidth(text), maxWidth);
surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- // Copy the pixels from the RenderManager::_workingWindow, so we can get nice antialiasing
- _engine->getRenderManager()->copyWorkingWindowSubRectToSurface(surface, 0, 0, Common::Rect(destX, destY, destX + width, destY + _lineHeight));
+ // TODO: Add better alpha support by getting the pixels from the backbuffer.
+ // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background.
+ surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0);
- _font->drawString(surface, text, destX, destY, maxWidth, textColor, align);
+ _font->drawString(surface, text, 0, 0, maxWidth, textColor, align);
return surface;
}
@@ -100,12 +101,11 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, i
}
surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- // Copy the pixels from the RenderManager::_workingWindow, so we can get nice antialiasing
- _engine->getRenderManager()->copyWorkingWindowSubRectToSurface(surface, 0, 0, Common::Rect(destX, destY, destX + maxWidth, destY + lines.size() * _lineHeight));
+ surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0);
int heightOffset = 0;
for (Common::Array<Common::String>::iterator it = lines.begin(); it != lines.end(); it++) {
- _font->drawString(surface, *it, destX, destY + heightOffset, maxWidth, textColor, align);
+ _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align);
heightOffset += (int)_lineHeight;
}
Commit: 0c28fbca7c49ae70779f1e7aa150c42e7ac1276c
https://github.com/scummvm/scummvm/commit/0c28fbca7c49ae70779f1e7aa150c42e7ac1276c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:25-07:00
Commit Message:
ZVISION: Remove extraneous empty line
Changed paths:
engines/zvision/truetype_font.h
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index c8d0a95..ae7732c 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -55,8 +55,7 @@ public:
int32 _fontHeight;
public:
- bool loadFile(const Common::String &filename);
-
+ bool loadFile(const Common::String &filename);
Graphics::Surface *drawTextToSurface(const Common::String &text, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
};
Commit: 035ee29f1d084316cad130fbc9de66073983c47e
https://github.com/scummvm/scummvm/commit/035ee29f1d084316cad130fbc9de66073983c47e
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:26-07:00
Commit Message:
ZVISION: Initialize StringManager
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 2d14e5d..c8a4cbb 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -125,6 +125,7 @@ void ZVision::initialize() {
_cursorManager = new CursorManager(this, &_pixelFormat);
_cursorManager->initialize();
_scriptManager->initialize();
+ _stringManager->initialize(_gameDescription->gameId);
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
Commit: 4af62cfd3a9e0826c7303d3a0759fd103f8c92ea
https://github.com/scummvm/scummvm/commit/4af62cfd3a9e0826c7303d3a0759fd103f8c92ea
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:27-07:00
Commit Message:
ZVISION: Register the "fonts" directory with SearchMan
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index c8a4cbb..b071908 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -103,6 +103,7 @@ void ZVision::initialize() {
SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, true);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true);
// Find zfs archive files
Common::ArchiveMemberList list;
Commit: a0a67a2d470816b13bab10371494652d77b23611
https://github.com/scummvm/scummvm/commit/a0a67a2d470816b13bab10371494652d77b23611
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:17:27-07:00
Commit Message:
ZVISION: Partially implement InputControl
Changed paths:
A engines/zvision/input_control.cpp
A engines/zvision/input_control.h
engines/zvision/module.mk
diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp
new file mode 100644
index 0000000..ab4cc6b
--- /dev/null
+++ b/engines/zvision/input_control.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/str.h"
+#include "common/stream.h"
+#include "common/rect.h"
+
+#include "zvision/input_control.h"
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/string_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/utility.h"
+
+
+namespace ZVision {
+
+InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key),
+ _nextTabstop(0),
+ _focused(false),
+ _textChanged(false),
+ _cursorOffset(0) {
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.matchString("*rectangle*", true)) {
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+
+ sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+
+ _textRectangle = Common::Rect(x1, y1, x2, y2);
+ } else if (line.matchString("*aux_hotspot*", true)) {
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+
+ sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+
+ _headerRectangle = Common::Rect(x1, y1, x2, y2);
+ } else if (line.matchString("*string_init*", true)) {
+ uint fontFormatNumber;
+
+ sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
+
+ _textStyle = _engine->getStringManager()->getTextStyle(fontFormatNumber);
+ } else if (line.matchString("*next_tabstop*", true)) {
+ sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop);
+ } else if (line.matchString("*cursor_animation*", true)) {
+ char fileName[25];
+
+ sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName);
+
+ _cursorAnimationFileName = Common::String(fileName);
+ } else if (line.matchString("*cursor_dimensions*", true)) {
+ // Ignore, use the dimensions in the animation file
+ } else if (line.matchString("*cursor_animation_frames*", true)) {
+ // Ignore, use the frame count in the animation file
+ } else if (line.matchString("*focus*", true)) {
+ _focused = true;
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+}
+
+void InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ _engine->getScriptManager()->focusControl(_key);
+}
+
+void InputControl::onKeyDown(Common::KeyState keyState) {
+ if (!_focused) {
+ return;
+ }
+
+ if (keyState.keycode == Common::KEYCODE_BACKSPACE) {
+ _currentInputText.deleteLastChar();
+ } else if (keyState.keycode == Common::KEYCODE_TAB) {
+ _focused = false;
+ // Focus the next input control
+ _engine->getScriptManager()->focusControl(_nextTabstop);
+ } else {
+ // Otherwise, append the new character to the end of the current text
+
+ uint16 asciiValue = keyState.ascii;
+ // We only care about text values
+ if (asciiValue >= 32 && asciiValue <= 126) {
+ _currentInputText += (char)asciiValue;
+ _textChanged = true;
+ }
+ }
+}
+
+bool InputControl::process(uint32 deltaTimeInMillis) {
+ if (!_focused) {
+ return false;
+ }
+
+ // First see if we need to render the text
+ if (_textChanged) {
+ // Blit the text using the RenderManager
+ Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width());
+
+ _cursorOffset = destRect.left - _textRectangle.left;
+ }
+
+ // Render the next frame of the animation
+ // TODO: Implement animation handling
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h
new file mode 100644
index 0000000..33a1b34
--- /dev/null
+++ b/engines/zvision/input_control.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_INPUT_CONTROL_H
+#define ZVISION_INPUT_CONTROL_H
+
+#include "common/types.h"
+
+#include "zvision/control.h"
+#include "zvision/string_manager.h"
+
+
+namespace ZVision {
+
+class InputControl : public Control {
+public:
+ InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+
+private:
+ Common::Rect _textRectangle;
+ Common::Rect _headerRectangle;
+ StringManager::TextStyle _textStyle;
+ uint32 _nextTabstop;
+ Common::String _cursorAnimationFileName;
+ bool _focused;
+
+ Common::String _currentInputText;
+ bool _textChanged;
+ uint _cursorOffset;
+
+public:
+ void focus() { _focused = true; }
+ void unfocus() { _focused = false; }
+ void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ void onKeyDown(Common::KeyState keyState);
+ bool process(uint32 deltaTimeInMillis);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index cb4a360..2f2929d 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS := \
cursor_manager.o \
detection.o \
events.o \
+ input_control.o \
lever_control.o \
lzss_read_stream.o \
push_toggle_control.o \
Commit: b5c762168edd83a6c5e1b442aee728150b447d98
https://github.com/scummvm/scummvm/commit/b5c762168edd83a6c5e1b442aee728150b447d98
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-15T22:46:19-07:00
Commit Message:
Merge branch 'master' into zvision
Changed paths:
A engines/agi/POTFILES
A engines/agos/POTFILES
A engines/cruise/POTFILES
A engines/drascula/POTFILES
A engines/dreamweb/POTFILES
A engines/fullpipe/behavior.cpp
A engines/fullpipe/behavior.h
A engines/fullpipe/constants.h
A engines/fullpipe/detection.cpp
A engines/fullpipe/fullpipe.cpp
A engines/fullpipe/fullpipe.h
A engines/fullpipe/gameloader.cpp
A engines/fullpipe/gameloader.h
A engines/fullpipe/gfx.cpp
A engines/fullpipe/gfx.h
A engines/fullpipe/init.cpp
A engines/fullpipe/input.cpp
A engines/fullpipe/input.h
A engines/fullpipe/interaction.cpp
A engines/fullpipe/interaction.h
A engines/fullpipe/inventory.cpp
A engines/fullpipe/inventory.h
A engines/fullpipe/lift.cpp
A engines/fullpipe/messages.cpp
A engines/fullpipe/messages.h
A engines/fullpipe/modal.cpp
A engines/fullpipe/modal.h
A engines/fullpipe/module.mk
A engines/fullpipe/motion.cpp
A engines/fullpipe/motion.h
A engines/fullpipe/ngiarchive.cpp
A engines/fullpipe/ngiarchive.h
A engines/fullpipe/objectnames.h
A engines/fullpipe/objects.h
A engines/fullpipe/scene.cpp
A engines/fullpipe/scene.h
A engines/fullpipe/scenes.cpp
A engines/fullpipe/scenes.h
A engines/fullpipe/sound.cpp
A engines/fullpipe/sound.h
A engines/fullpipe/stateloader.cpp
A engines/fullpipe/statics.cpp
A engines/fullpipe/statics.h
A engines/fullpipe/utils.cpp
A engines/fullpipe/utils.h
A engines/gob/POTFILES
A engines/groovie/POTFILES
A engines/kyra/POTFILES
A engines/mohawk/POTFILES
A engines/neverhood/POTFILES
A engines/parallaction/POTFILES
A engines/pegasus/POTFILES
A engines/queen/POTFILES
A engines/sci/POTFILES
A engines/scumm/POTFILES
A engines/scumm/player_ad.cpp
A engines/scumm/player_ad.h
A engines/sky/POTFILES
A engines/sword1/POTFILES
A engines/sword2/POTFILES
A engines/teenagent/POTFILES
A engines/tinsel/POTFILES
A engines/toltecs/POTFILES
.gitignore
devtools/create_project/create_project.cpp
devtools/create_project/create_project.h
devtools/create_project/msbuild.cpp
devtools/create_project/msbuild.h
devtools/create_project/msvc.cpp
devtools/create_project/msvc.h
devtools/create_project/visualstudio.cpp
devtools/create_project/visualstudio.h
devtools/extract_mort/extract_mort.cpp
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/configure.engines
engines/engines.mk
engines/lastexpress/data/scene.h
engines/lastexpress/debug.cpp
engines/lastexpress/game/scenes.cpp
engines/lastexpress/game/state.h
engines/lastexpress/lastexpress.cpp
engines/neverhood/console.cpp
engines/neverhood/console.h
engines/neverhood/module.h
engines/neverhood/modules/module1000.cpp
engines/neverhood/modules/module1000.h
engines/neverhood/navigationscene.cpp
engines/neverhood/navigationscene.h
engines/neverhood/scene.cpp
engines/neverhood/scene.h
engines/neverhood/smackerscene.h
engines/plugins_table.h
engines/sci/sound/midiparser_sci.cpp
engines/sci/sound/music.cpp
engines/sci/sound/music.h
engines/scumm/module.mk
engines/scumm/saveload.h
engines/scumm/scumm.cpp
engines/scumm/sound.cpp
engines/sword25/gfx/microtiles.cpp
engines/tsage/core.cpp
engines/tsage/core.h
engines/tsage/globals.cpp
engines/tsage/globals.h
engines/tsage/ringworld2/ringworld2_dialogs.cpp
engines/tsage/ringworld2/ringworld2_logic.cpp
engines/tsage/ringworld2/ringworld2_scenes0.cpp
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/tsage/ringworld2/ringworld2_scenes1.h
engines/tsage/ringworld2/ringworld2_scenes2.cpp
engines/tsage/ringworld2/ringworld2_scenes2.h
engines/tsage/ringworld2/ringworld2_scenes3.cpp
engines/tsage/ringworld2/ringworld2_scenes3.h
engines/tsage/ringworld2/ringworld2_speakers.cpp
engines/tsage/staticres.cpp
engines/tsage/staticres.h
engines/wintermute/base/base_persistence_manager.cpp
engines/wintermute/base/base_persistence_manager.h
engines/wintermute/base/font/base_font_truetype.cpp
engines/wintermute/base/gfx/base_renderer.h
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
engines/wintermute/base/scriptables/script_engine.cpp
engines/wintermute/base/scriptables/script_value.cpp
engines/wintermute/dcgf.h
gui/EventRecorder.cpp
po/POTFILES
po/module.mk
diff --cc engines/engines.mk
index e399713,5b3eeea..a327000
--- a/engines/engines.mk
+++ b/engines/engines.mk
@@@ -246,8 -251,3 +251,8 @@@ ifdef ENABLE_WINTERMUT
DEFINES += -DENABLE_WINTERMUTE=$(ENABLE_WINTERMUTE)
MODULES += engines/wintermute
endif
+
+ifdef ENABLE_ZVISION
+DEFINES += -DENABLE_ZVISION=$(ENABLE_ZVISION)
+MODULES += engines/zvision
- endif
++endif
Commit: 5ec472ae2fc5d391714617457ec01c24d67057c2
https://github.com/scummvm/scummvm/commit/5ec472ae2fc5d391714617457ec01c24d67057c2
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-16T20:10:26-07:00
Commit Message:
ZVISION: Add version support for save files
Changed paths:
engines/zvision/save_manager.cpp
engines/zvision/save_manager.h
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 4f8bfeb..ff6e1c3 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -44,6 +44,9 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) {
// Write out the savegame header
file->writeUint32BE(SAVEGAME_ID);
+ // Write version
+ file->writeByte(1);
+
// Write savegame name
file->writeString(saveName);
file->writeByte(0);
@@ -58,6 +61,7 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) {
// Skip over the header info
autoSaveFile->readSint32BE(); // SAVEGAME_ID
+ autoSaveFile->readByte(); // Version
autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL
// Read the rest to a buffer
@@ -79,6 +83,9 @@ void SaveManager::autoSave() {
// Write out the savegame header
file->writeUint32BE(SAVEGAME_ID);
+ // Version
+ file->writeByte(1);
+
file->writeString("auto");
file->writeByte(0);
@@ -153,6 +160,9 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea
return false;
}
+ // Read in the version
+ header.version = in->readByte();
+
// Read in the save name
header.saveName.clear();
char ch;
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 219a8e7..864f176 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -36,6 +36,7 @@ namespace ZVision {
class ZVision;
struct SaveGameHeader {
+ byte version;
Common::String saveName;
Graphics::Surface *thumbnail;
int saveYear, saveMonth, saveDay;
Commit: 6664f31ed24b2d8b384221faffdeb6eda0f69835
https://github.com/scummvm/scummvm/commit/6664f31ed24b2d8b384221faffdeb6eda0f69835
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-17T09:03:49-07:00
Commit Message:
ZVISION: Convert the current save version to a const
Changed paths:
engines/zvision/save_manager.cpp
engines/zvision/save_manager.h
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index ff6e1c3..cf2d965 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -45,7 +45,7 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) {
file->writeUint32BE(SAVEGAME_ID);
// Write version
- file->writeByte(1);
+ file->writeByte(SAVE_VERSION);
// Write savegame name
file->writeString(saveName);
@@ -84,7 +84,7 @@ void SaveManager::autoSave() {
file->writeUint32BE(SAVEGAME_ID);
// Version
- file->writeByte(1);
+ file->writeByte(SAVE_VERSION);
file->writeString("auto");
file->writeByte(0);
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 864f176..8d0ebc7 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -51,6 +51,10 @@ private:
ZVision *_engine;
static const uint32 SAVEGAME_ID;
+ enum {
+ SAVE_VERSION = 1
+ };
+
public:
void autoSave();
void saveGame(uint slot, const Common::String &saveName);
Commit: 6148a0a878eb543731653870fcb369a8c86a2dfc
https://github.com/scummvm/scummvm/commit/6148a0a878eb543731653870fcb369a8c86a2dfc
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-17T09:04:41-07:00
Commit Message:
ZVISION: Add a check against reading newer save game versions
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index cf2d965..e09d315 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -27,6 +27,8 @@
#include "graphics/surface.h"
#include "graphics/thumbnail.h"
+#include "gui/message.h"
+
#include "zvision/save_manager.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
@@ -163,6 +165,13 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea
// Read in the version
header.version = in->readByte();
+ // Check that the save version isn't newer than this binary
+ if (header.version > SAVE_VERSION) {
+ uint tempVersion = header.version;
+ GUI::MessageDialog dialog(Common::String::format("This save file uses version %u, but this engine only supports up to version %d. You will need an updated version of the engine to use this save file.", tempVersion, SAVE_VERSION), "OK");
+ dialog.runModal();
+ }
+
// Read in the save name
header.saveName.clear();
char ch;
Commit: d06c64d0762eb5f4b3f32c5402d05e801bb80ed8
https://github.com/scummvm/scummvm/commit/d06c64d0762eb5f4b3f32c5402d05e801bb80ed8
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-17T09:05:49-07:00
Commit Message:
ZVISION: Append chars to a Common::String object instead of using a static buffer
Changed paths:
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 4c4fc7b..8c7e0aa 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -212,15 +212,13 @@ void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
}
Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
- // NOTE: Hardcoded size. All strings I've checked are less than 290 chars
- char asciiString[300];
+ Common::String asciiString;
// Don't spam the user with warnings about UTF-16 support.
// Just do one warning per String
bool charOverflowWarning = false;
uint16 value = stream.readUint16LE();
- uint i = 0;
while (!stream.eos()) {
// Check for CRLF
if (value == 0x0A0D) {
@@ -233,12 +231,11 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
// Crush each octet pair to a single octet with a simple cast
if (value > 255) {
charOverflowWarning = true;
- value = 255;
+ value = '?';
}
char charValue = (char)value;
- asciiString[i] = charValue;
- i++;
+ asciiString += charValue;
value = stream.readUint16LE();
}
@@ -247,7 +244,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
warning("UTF-16 is not supported. Characters greater than 255 are clamped to 255");
}
- return Common::String(asciiString, i);
+ return asciiString;
}
StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
Commit: 8557b06197bde4574be34810bcf59c3530acc326
https://github.com/scummvm/scummvm/commit/8557b06197bde4574be34810bcf59c3530acc326
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:03:49-07:00
Commit Message:
ZVISION: Load the state values before changing location
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index e09d315..70de905 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -144,12 +144,12 @@ Common::Error SaveManager::loadGame(uint slot) {
uint32 offset = (char)saveFile->readUint32LE();
ScriptManager *scriptManager = _engine->getScriptManager();
- // Load the room
- scriptManager->changeLocation(world, room, node, view, offset);
-
// Update the state table values
scriptManager->deserializeStateTable(saveFile);
+ // Load the room
+ scriptManager->changeLocation(world, room, node, view, offset);
+
// Update the controls
scriptManager->deserializeControls(saveFile);
Commit: ca80deea62a0ca675ec53148e0e3237e716c5082
https://github.com/scummvm/scummvm/commit/ca80deea62a0ca675ec53148e0e3237e716c5082
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:04:31-07:00
Commit Message:
ZVISION: Only allow save slots in the range [1, 20]
This is the range supported by the ZNem / ZGI save menus
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 70de905..dbed109 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -40,6 +40,9 @@ namespace ZVision {
const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
void SaveManager::saveGame(uint slot, const Common::String &saveName) {
+ // The games only support 20 slots
+ assert(slot <=1 && slot <= 20);
+
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
@@ -126,6 +129,9 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
}
Common::Error SaveManager::loadGame(uint slot) {
+ // The games only support 20 slots
+ assert(slot <= 1 && slot <= 20);
+
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
if (saveFile == 0) {
return Common::kPathDoesNotExist;
Commit: 51fc627c05e4fdbd240c75399a249ce8378e999a
https://github.com/scummvm/scummvm/commit/51fc627c05e4fdbd240c75399a249ce8378e999a
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:05:38-07:00
Commit Message:
ZVISION: Clear out the current state table values before loading any from a save file
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 4b4e0f7..b968e51 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -390,6 +390,9 @@ void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
}
void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
+ // Clear out the current table values
+ _globalState.clear();
+
// Read the number of key/value pairs
uint32 numberOfPairs = stream->readUint32LE();
Commit: 8f7fa517d627ad81ca6a07b5a86b6de0774713a1
https://github.com/scummvm/scummvm/commit/8f7fa517d627ad81ca6a07b5a86b6de0774713a1
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:08:36-07:00
Commit Message:
ZVISION: Directly access _globalState instead of using setStateValue
setStateValue does a _referenceTable lookup and potentially adds Puzzles
to _puzzlesToCheck. We know that _referenceTable and _puzzlesToCheck
with be cleared during ScriptManager::changeLocation(), so using
setStateValues ends up just being wasteful.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index b968e51..75f88dd 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -399,7 +399,8 @@ void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
for (uint32 i = 0; i < numberOfPairs; i++) {
uint32 key = stream->readUint32LE();
uint32 value = stream->readUint32LE();
- setStateValue(key, value);
+ // Directly access the state table so we don't trigger Puzzle checks
+ _globalState[key] = value;
}
}
Commit: 1ced56fee7a90ff79cf97f34f3721f7234f2f9bc
https://github.com/scummvm/scummvm/commit/1ced56fee7a90ff79cf97f34f3721f7234f2f9bc
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:09:05-07:00
Commit Message:
ZVISION: Add documentation to SaveManager
Changed paths:
engines/zvision/save_manager.h
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 8d0ebc7..6445f10 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -56,8 +56,27 @@ private:
};
public:
+ /**
+ * Called every room change. Saves the state of the room just before
+ * we switched rooms. Uses ZVision::generateAutoSaveFileName() to
+ * create the save file name.
+ */
void autoSave();
+ /**
+ * Copies the data from the last auto-save into a new save file. We
+ * can't use the current state data because the save menu *IS* a room.
+ * The file is named using ZVision::generateSaveFileName(slot)
+ *
+ * @param slot The save slot this save pertains to. Must be [1, 20]
+ * @param saveName The internal name for this save. This is NOT the name of the actual save file.
+ */
void saveGame(uint slot, const Common::String &saveName);
+ /**
+ * Loads the state data from the save file that slot references. Uses
+ * ZVision::generateSaveFileName(slot) to get the save file name.
+ *
+ * @param slot The save slot to load. Must be [1, 20]
+ */
Common::Error loadGame(uint slot);
private:
Commit: 7ff86ba6f9ce7a549a1b327396bce166de083803
https://github.com/scummvm/scummvm/commit/7ff86ba6f9ce7a549a1b327396bce166de083803
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-20T22:31:59-07:00
Commit Message:
ZVISION: Add documentation for RlfAnimation
Changed paths:
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 133bf39..3f205d9 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -77,21 +77,88 @@ public:
uint height() { return _height; }
uint32 frameTime() { return _frameTime; }
+ /**
+ * Seeks to the frameNumber and updates the internal Surface with
+ * the new frame data. If frameNumber == -1, it only sets _currentFrame,
+ * the internal Surface is unchanged. This function requires _stream = false
+ *
+ * @param frameNumber The frame number to seek to
+ */
void seekToFrame(int frameNumber);
+ /**
+ * Returns the pixel data of the frame specified. It will try to use
+ * getNextFrame() if possible. If not, it uses seekToFrame() to
+ * update the internal Surface and then returns a pointer to it.
+ * This function requires _stream = false
+ *
+ * @param frameNumber The frame number to get data for
+ * @return A pointer to the pixel data. Do NOT delete this.
+ */
const Graphics::Surface *getFrameData(uint frameNumber);
+ /**
+ * Returns the pixel data of the next frame. It is up to the user to
+ * check if the next frame is valid before calling this.
+ * IE. Use endOfAnimation()
+ *
+ * @return A pointer to the pixel data. Do NOT delete this.
+ */
const Graphics::Surface *getNextFrame();
+ /**
+ * @return Is the currentFrame is the last frame in the animation?
+ */
bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
private:
+ /**
+ * Reads in the header of the RLF file
+ *
+ * @return Will return false if the header magic number is wrong
+ */
bool readHeader();
+ /**
+ * Reads the next frame from the RLF file, stores the data in
+ * a Frame object, then returns the object
+ *
+ * @return A Frame object representing the frame data
+ */
Frame readNextFrame();
+ /**
+ * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer.
+ * This function requires _stream = false so it can look up the Frame object
+ * referenced by frameNumber.
+ *
+ * @param frameNumber The frame number to apply to _currentFrameBuffer
+ */
void applyFrameToCurrent(uint frameNumber);
+ /**
+ * Applies the data from a Frame object on top of a _currentFrameBuffer.
+ *
+ * @param frame A Frame object to apply to _currentFrameBuffer
+ */
void applyFrameToCurrent(const RlfAnimation::Frame &frame);
+ /**
+ * Decode frame data that uses masked run length encoding. This is the encoding
+ * used by P-frames.
+ *
+ * @param source The source pixel data
+ * @param dest The destination buffer
+ * @param sourceSize The size of the source pixel data
+ * @param destSize The size of the destination buffer
+ */
void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
+ /**
+ * Decode frame data that uses simple run length encoding. This is the encoding
+ * used by I-frames.
+ *
+ * @param source The source pixel data
+ * @param dest The destination buffer
+ * @param sourceSize The size of the source pixel data
+ * @param destSize The size of the destination buffer
+ */
void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
};
Commit: 2d9c9e8c7f26a2c5977d52214283893617d97ffc
https://github.com/scummvm/scummvm/commit/2d9c9e8c7f26a2c5977d52214283893617d97ffc
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-21T11:37:18-07:00
Commit Message:
ZVISION: Remove unused animation functions
Changed paths:
R engines/zvision/animation.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation.cpp b/engines/zvision/animation.cpp
deleted file mode 100644
index f43e854..0000000
--- a/engines/zvision/animation.cpp
+++ /dev/null
@@ -1,131 +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/system.h"
-#include "video/video_decoder.h"
-
-#include "zvision/zvision.h"
-#include "zvision/rlf_animation.h"
-
-
-namespace ZVision {
-
-void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) {
- bool skip = false;
- uint32 frameTime = animation->frameTime();
- uint width = animation->width();
- uint height = animation->height();
-
- uint16 newX = x + _workingWindow.left;
- uint16 newY = y + _workingWindow.top;
-
- uint32 accumulatedTime = 0;
-
- // Only continue while the video is still playing
- while (!shouldQuit() && !skip && !animation->endOfAnimation()) {
- _clock.update();
- uint32 currentTime = _clock.getLastMeasuredTime();
- accumulatedTime += _clock.getDeltaTime();
-
- // 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:
- skip = true;
- break;
- default:
- break;
- }
- default:
- break;
- }
- }
-
- while (accumulatedTime >= frameTime && !animation->endOfAnimation()) {
- accumulatedTime -= frameTime;
-
- _system->copyRectToScreen(animation->getNextFrame(), width * sizeof(uint16), newX, newY, width, height);
- }
-
- // Always update the screen so the mouse continues to render
- _system->updateScreen();
-
- // Calculate the frame delay based off a desired frame time
- int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
- // Ensure non-negative
- delay = delay < 0 ? 0 : delay;
- _system->delayMillis(delay);
- }
-}
-
-void ZVision::playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) {
- _clock.stop();
- animation->start();
-
- // Only continue while the video is still playing
- while (!shouldQuit() && !animation->endOfVideo() && animation->isPlaying()) {
- // Check for engine quit and video stop key presses
- while (!animation->endOfVideo() && animation->isPlaying() && _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:
- animation->stop();
- break;
- default:
- break;
- }
- default:
- break;
- }
- }
-
- if (animation->needsUpdate()) {
- const Graphics::Surface *frame = animation->decodeNextFrame();
-
- if (frame) {
- _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
- }
- }
-
- // Always update the screen so the mouse continues to render
- _system->updateScreen();
-
- _system->delayMillis(animation->getTimeToNextFrame());
- }
-
- _clock.start();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index a481aba..efd94f1 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -131,9 +131,6 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
- void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
- void playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
-
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
Commit: cfe176619a52de5d31eebbca228639db49110102
https://github.com/scummvm/scummvm/commit/cfe176619a52de5d31eebbca228639db49110102
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-21T11:37:38-07:00
Commit Message:
ZVISION: Remove unused function arguments
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/truetype_font.cpp
engines/zvision/truetype_font.h
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 7f10535..dc942fe 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -367,7 +367,7 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com
entry.destY = destY;
// Draw the text to the working window
- entry.data = font->drawTextToSurface(text, destX, destY, textColor, maxWidth, maxHeight, align, wrap);
+ entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap);
entry.width = entry.data->w;
entry.height = entry.data->h;
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index 8fd331d..80d0d6b 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -72,7 +72,7 @@ bool TruetypeFont::loadFile(const Common::String &filename) {
return true;
}
-Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
+Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
if (text.equals("")) {
return nullptr;
}
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index ae7732c..d35da87 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -56,7 +56,7 @@ public:
public:
bool loadFile(const Common::String &filename);
- Graphics::Surface *drawTextToSurface(const Common::String &text, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
+ Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
};
} // End of namespace ZVision
Commit: 7a557c4bcd970582fcd28eacb9644bac5714edbf
https://github.com/scummvm/scummvm/commit/7a557c4bcd970582fcd28eacb9644bac5714edbf
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-21T11:37:38-07:00
Commit Message:
ZVISION: Add documentation to TruetypeFont
Changed paths:
engines/zvision/truetype_font.h
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index d35da87..c7475d1 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -55,7 +55,25 @@ public:
int32 _fontHeight;
public:
+ /**
+ * Loads a .ttf file into memory. This must be called
+ * before any calls to drawTextToSurface
+ *
+ * @param filename The file name of the .ttf file to load
+ */
bool loadFile(const Common::String &filename);
+ /**
+ * Renders the supplied text to a Surface using 0x0 as the
+ * background color.
+ *
+ * @param text The to render
+ * @param textColor The color to render the text with
+ * @param maxWidth The max width the text should take up.
+ * @param maxHeight The max height the text should take up.
+ * @param align The alignment of the text within the bounds of maxWidth
+ * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit
+ * @return A Surface containing the rendered text
+ */
Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
};
Commit: 69bcb76d050c162b02295784f8a3bb83d73d82c8
https://github.com/scummvm/scummvm/commit/69bcb76d050c162b02295784f8a3bb83d73d82c8
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-21T11:37:39-07:00
Commit Message:
ZVISION: Add documentation to RenderManager
Changed paths:
engines/zvision/render_manager.h
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index b0a42d9..71f4807 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -65,12 +65,17 @@ private:
const Graphics::PixelFormat _pixelFormat;
// A buffer the exact same size as the workingWindow
- // It's used for panorama/tilt warping and for clearing the workingWindow to a single color
+ // This buffer stores everything un-warped, then does a warp at the end of the frame
Graphics::Surface _workingWindowBuffer;
+ // A buffer representing the entire screen. Any graphical updates are first done with this buffer
+ // before actually being blitted to the screen
Graphics::Surface _backBuffer;
+ // A list of Alpha Entries that need to be blitted to the backbuffer
Common::HashMap<uint32, AlphaDataEntry> _alphaDataEntries;
+ // A rectangle representing the portion of the working window where the pixels have been changed since last frame
Common::Rect _workingWindowDirtyRect;
+ // A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame
Common::Rect _backBufferDirtyRect;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
@@ -121,13 +126,61 @@ public:
*/
void renderBackbufferToScreen();
+ /**
+ * Renders all AlphaEntries to the backbuffer
+ */
void processAlphaEntries();
+ /**
+ * Clears the AlphaEntry list
+ */
void clearAlphaEntries() { _alphaDataEntries.clear(); }
+ /**
+ * Removes a specific AlphaEntry from the list
+ *
+ * @param idNumber The id number identifing the AlphaEntry
+ */
void removeAlphaEntry(uint32 idNumber) { _alphaDataEntries.erase(idNumber); }
+ /**
+ * Copies a sub-rectangle of a buffer to the working window
+ *
+ * @param buffer The pixel data to copy to the working window
+ * @param destX The X destination in the working window where the subRect of data should be put
+ * @param destY The Y destination in the working window where the subRect of data should be put
+ * @param imageWidth The width of the source image
+ * @param width The width of the sub rectangle
+ * @param height The height of the sub rectangle
+ */
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
+ /**
+ * Copies a sub-rectangle of a buffer to the working window with binary alpha support.
+ *
+ * @param buffer The pixel data to copy to the working window
+ * @param destX The X destination in the working window where the subRect of data should be put
+ * @param destY The Y destination in the working window where the subRect of data should be put
+ * @param imageWidth The width of the source image
+ * @param width The width of the sub rectangle
+ * @param height The height of the sub rectangle
+ * @param alphaColor The color to interpret as meaning 'transparent'
+ * @param idNumber A unique identifier for the data being copied over.
+ */
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber);
+ /**
+ * Renders the supplied text to the working window
+ *
+ * @param idNumber A unique identifier for the text
+ * @param text The text to be rendered
+ * @param font The font to use to render the text
+ * @param destX The X destination in the working window where the text should be rendered
+ * @param destY The Y destination in the working window where the text should be rendered
+ * @param textColor The color to render the text with (in RBG 565)
+ * @param maxWidth The max width the text should take up.
+ * @param maxHeight The max height the text should take up.
+ * @param align The alignment of the text within the bounds of maxWidth
+ * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit
+ * @return A rectangle representing where the text was drawn in the working window
+ */
Common::Rect renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
/**
@@ -242,8 +295,29 @@ private:
*/
void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap);
+ /**
+ * Reads an image file pixel data into a Surface buffer. In the process
+ * it converts the pixel data from RGB 555 to RGB 565. Also, if the image
+ * is transposed, it will un-transpose the pixel data. The function will
+ * call destination::create() if the dimensions of destination do not match
+ * up with the dimensions of the image.
+ *
+ * @param fileName The name of a .tga file
+ * @param destination A reference to the Surface to store the pixel data in
+ */
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
+ /**
+ * Move the background image by an offset. If we are currently in Panorama mode,
+ * the offset will correspond to a horizontal motion. If we are currently in Tilt mode,
+ * the offset will correspond to a vertical motion. This function should not be called
+ * if we are in Flat mode.
+ *
+ * The RenderManager will take care of wrapping the image.
+ * Ex: If the image has width 1400px, it is legal to offset 1500px.
+ *
+ * @param offset The amount to move the background
+ */
void moveBackground(int offset);
};
Commit: 48979c557bc580efa3fc02021fbae955a3ce4f09
https://github.com/scummvm/scummvm/commit/48979c557bc580efa3fc02021fbae955a3ce4f09
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T12:41:56-07:00
Commit Message:
ZVISION: Remove animation.o since animation.cpp is now gone
Changed paths:
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 2f2929d..6a6eedc 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -2,7 +2,6 @@ MODULE := engines/zvision
MODULE_OBJS := \
actions.o \
- animation.o \
animation_control.o \
clock.o \
console.o \
Commit: 9a5305a977b3b4c72c73196c4f67cee4d767fbbe
https://github.com/scummvm/scummvm/commit/9a5305a977b3b4c72c73196c4f67cee4d767fbbe
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T12:55:32-07:00
Commit Message:
ZVISION: Add vertical pipes to prevent multi-line comments
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 93a6054..7f0cd40 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -323,27 +323,27 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Origin => (pointOne.x, pointOne.y)
// * => (pointTwo.x, pointTwo.y)
//
- // 90
- // ^
- // * | *
- // \ | /
- // \ | /
- // \ | /
- // Quadrant 1 \ | / Quadrant 0
- // \ | /
- // \ | /
- // angle ( \|/ ) -angle
- // 180 <----------------------------------------> 0
- // -angle ( /|\ ) angle
- // / | \
- // / | \
- // Quadrant 3 / | \ Quadrant 2
- // / | \
- // / | \
- // / | \
- // * | *
- // ^
- // 270
+ // 90 |
+ // ^ |
+ // * | * |
+ // \ | / |
+ // \ | / |
+ // \ | / |
+ // Quadrant 1 \ | / Quadrant 0 |
+ // \ | / |
+ // \ | / |
+ // angle ( \|/ ) -angle |
+ // 180 <----------------------------------------> 0 |
+ // -angle ( /|\ ) angle |
+ // / | \ |
+ // / | \ |
+ // Quadrant 3 / | \ Quadrant 2 |
+ // / | \ |
+ // / | \ |
+ // / | \ |
+ // * | * |
+ // ^ |
+ // 270 |
// Convert the local angles to unit circle angles
switch (quadrant) {
Commit: 79573d0331b108162149f00f47b208376be2b8a5
https://github.com/scummvm/scummvm/commit/79573d0331b108162149f00f47b208376be2b8a5
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:10:23-07:00
Commit Message:
ZVISION: Fix shadowing in the Direction constructor
Changed paths:
engines/zvision/lever_control.h
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index b5677a2..80fda4f 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -48,7 +48,7 @@ private:
};
struct Direction {
- Direction(uint angle, uint toFrame) : angle(angle), toFrame(toFrame) {}
+ Direction(uint a, uint t) : angle(a), toFrame(t) {}
uint angle;
uint toFrame;
Commit: 9fefed67f420b2097d43592850947144b2630b3d
https://github.com/scummvm/scummvm/commit/9fefed67f420b2097d43592850947144b2630b3d
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:11:38-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 5eb208e..dc5ebdb 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -103,10 +103,10 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
uint32 destOffset = 0;
- for (uint32 y = subRect.top; y < subRect.bottom; y++) {
+ for (int16 y = subRect.top; y < subRect.bottom; y++) {
uint32 sourceOffset = y * _numColumns;
- for (uint32 x = subRect.left; x < subRect.right; x++) {
+ for (int16 x = subRect.left; x < subRect.right; x++) {
uint32 normalizedX = x - subRect.left;
uint32 index = sourceOffset + x;
Commit: 713baa37695104e2aa23c4e821b2aeb5ce41a576
https://github.com/scummvm/scummvm/commit/713baa37695104e2aa23c4e821b2aeb5ce41a576
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:47:16-07:00
Commit Message:
ZVISION: Fix memory leak in SaveManager
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index dbed109..631885e 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -80,6 +80,7 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) {
// Cleanup
delete[] buffer;
file->finalize();
+ delete file;
}
void SaveManager::autoSave() {
@@ -96,7 +97,9 @@ void SaveManager::autoSave() {
writeSaveGameData(file);
+ // Cleanup
file->finalize();
+ delete file;
}
void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
Commit: dd0a6fe0e3258ca1e71051705b5603fd8d9ca3fd
https://github.com/scummvm/scummvm/commit/dd0a6fe0e3258ca1e71051705b5603fd8d9ca3fd
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:52:24-07:00
Commit Message:
ZVISION: Convert hardcoded number to an anonymous enum
Changed paths:
engines/zvision/string_manager.h
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index e3539a7..b67573b 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -60,10 +60,13 @@ private:
Common::List<TextFragment> fragments;
};
+ enum {
+ NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56
+ };
+
private:
ZVision *_engine;
- // NOTE: We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56
- InGameText _inGameText[56];
+ InGameText _inGameText[NUM_TEXT_LINES];
Common::HashMap<Common::String, TruetypeFont *> _fonts;
static const Graphics::PixelFormat _pixelFormat565;
Commit: 9d1b0e1f8bf991abb8eb0cd484ce5025757e1efe
https://github.com/scummvm/scummvm/commit/9d1b0e1f8bf991abb8eb0cd484ce5025757e1efe
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:52:56-07:00
Commit Message:
ZVISION: Assert that we don't exceed our hardcoded number of lines
Changed paths:
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 8c7e0aa..d00ea21 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -111,6 +111,7 @@ void StringManager::parseStrFile(const Common::String &fileName) {
}
lineNumber++;
+ assert(lineNumber <= NUM_TEXT_LINES);
}
}
Commit: 701250efb57ef94e35d2b7b6f0d6d045b713e6f5
https://github.com/scummvm/scummvm/commit/701250efb57ef94e35d2b7b6f0d6d045b713e6f5
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:54:06-07:00
Commit Message:
GRAPHICS: Remove variable shadowing
Changed paths:
graphics/surface.cpp
graphics/surface.h
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index a8173f0..777c105 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -133,7 +133,7 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
-void Surface::copyRectToSurface(const void *buffer, int pitch, int destX, int destY, int width, int height) {
+void Surface::copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height) {
assert(buffer);
assert(destX >= 0 && destX < w);
@@ -146,8 +146,8 @@ void Surface::copyRectToSurface(const void *buffer, int pitch, int destX, int de
byte *dst = (byte *)getBasePtr(destX, destY);
for (int i = 0; i < height; i++) {
memcpy(dst, src, width * format.bytesPerPixel);
- src += pitch;
- dst += this->pitch;
+ src += srcPitch;
+ dst += pitch;
}
}
diff --git a/graphics/surface.h b/graphics/surface.h
index 1492e71..07e289b 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -219,7 +219,7 @@ public:
* @param width The width of the destination rectangle
* @param height The height of the destination rectangle
*/
- void copyRectToSurface(const void *buffer, int pitch, int destX, int destY, int width, int height);
+ void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height);
/**
* Copies a bitmap to the Surface internal buffer. The pixel format
* of buffer must match the pixel format of the Surface.
Commit: a7ffd9ade641a2fd63ea8b04822942bda16a8f4c
https://github.com/scummvm/scummvm/commit/a7ffd9ade641a2fd63ea8b04822942bda16a8f4c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T13:55:22-07:00
Commit Message:
ZVISION: Cleanup all AlphaEntries after use
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index dc942fe..d0356ab 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -57,6 +57,10 @@ RenderManager::~RenderManager() {
_workingWindowBuffer.free();
_currentBackground.free();
_backBuffer.free();
+
+ for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ delete (*iter)._value.data;
+ }
}
void RenderManager::update(uint deltaTimeInMillis) {
Commit: fdd477df616f307bc599c2274d312ae1b62703a2
https://github.com/scummvm/scummvm/commit/fdd477df616f307bc599c2274d312ae1b62703a2
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T15:57:15-07:00
Commit Message:
ZVISION: Free AlphaDataEntry Surfaces before deleting them
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index d0356ab..b3561ff 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -59,6 +59,7 @@ RenderManager::~RenderManager() {
_backBuffer.free();
for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ (*iter)._value.data->free();
delete (*iter)._value.data;
}
}
Commit: dfba1a01446a32245944a86ee08a843587050753
https://github.com/scummvm/scummvm/commit/dfba1a01446a32245944a86ee08a843587050753
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-22T15:57:16-07:00
Commit Message:
ZVISION: Don't cast away const-ness
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b3561ff..55a24c9 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -506,7 +506,7 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa
Graphics::Surface *tranposedSurface = new Graphics::Surface();
tranposedSurface->create(surface->h, surface->w, surface->format);
- uint16 *source = (uint16 *)surface->getPixels();
+ const uint16 *source = (const uint16 *)surface->getPixels();
uint16 *dest = (uint16 *)tranposedSurface->getPixels();
for (uint32 y = 0; y < tranposedSurface->h; y++) {
Commit: 29db14c7ddac3ba0afbe9f40c3f9219392c86f53
https://github.com/scummvm/scummvm/commit/29db14c7ddac3ba0afbe9f40c3f9219392c86f53
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-24T04:49:05-07:00
Commit Message:
ZVISION: Don't cast away const-ness
Changed paths:
engines/zvision/animation_control.cpp
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index f80faea0..bb810a8 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -118,7 +118,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
delete tranposedFrame;
}
} else {
- renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
+ renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
@@ -202,7 +202,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
delete tranposedFrame;
}
} else {
- renderManager->copyRectToWorkingWindow((uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
+ renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
// If the background can move, we need to cache the last frame so it can be rendered during background movement
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
Commit: dfb37fb2f0f38b489d15df56ae71b261d0c0229c
https://github.com/scummvm/scummvm/commit/dfb37fb2f0f38b489d15df56ae71b261d0c0229c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-24T15:34:34-07:00
Commit Message:
ZVISION: Remove CLIPs from mutateImage
Due to the math of the Panorama/Tilt, all pixel offsets are going to be closer
to the center of the image. Also, mutateImage is now being called on a
finished buffer, rather than an image at a time. Therefore, it no longer has to
handle image wrapping. Thus, there is no case in which a pixel offset would
be outside the image bounds.
Changed paths:
engines/zvision/render_table.cpp
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index dc5ebdb..19f95a5 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -113,12 +113,6 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 d
// 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, _numRows - 1);
-
- // Clamp the xIndex to the size of the image
- sourceXIndex = CLIP<uint32>(sourceXIndex, 0, _numColumns - 1);
destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
Commit: d8bee6be1388167b46811abfbec4102cc768df52
https://github.com/scummvm/scummvm/commit/d8bee6be1388167b46811abfbec4102cc768df52
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-25T00:30:02-07:00
Commit Message:
ZVISION: Set the state value at each frame of a return animation
Some Puzzles trigger off the intermediate frames
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 7f0cd40..f3d369f 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -260,7 +260,6 @@ bool LeverControl::process(uint32 deltaTimeInMillis) {
if (_returnRoutesCurrentProgress == _frameInfo[_currentFrame].returnRoute.end()) {
_isReturning = false;
_currentFrame = _returnRoutesCurrentFrame;
- _engine->getScriptManager()->setStateValue(_key, _currentFrame);
return false;
}
@@ -271,6 +270,7 @@ bool LeverControl::process(uint32 deltaTimeInMillis) {
_returnRoutesCurrentFrame--;
}
+ _engine->getScriptManager()->setStateValue(_key, _returnRoutesCurrentFrame);
renderFrame(_returnRoutesCurrentFrame);
}
}
Commit: cd3dc276d9c3f4b2311e86a65e1f16491bf79961
https://github.com/scummvm/scummvm/commit/cd3dc276d9c3f4b2311e86a65e1f16491bf79961
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-25T00:30:37-07:00
Commit Message:
ZVISION: Only save a thumbnail of the backbuffer instead of the whole thing
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 631885e..08a7264 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -104,8 +104,8 @@ void SaveManager::autoSave() {
void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
// Create a thumbnail and save it
- Graphics::saveThumbnail(*file, *_engine->getRenderManager()->getBackBuffer());
-
+ Graphics::saveThumbnail(*file);
+
// Write out the save date/time
TimeDate td;
g_system->getTimeAndDate(td);
Commit: 07c32312146bb7fe5adec41f03a2463893756361
https://github.com/scummvm/scummvm/commit/07c32312146bb7fe5adec41f03a2463893756361
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-25T00:32:42-07:00
Commit Message:
ZVISION: Remove memory corrupting assignment
This was a code error left over from previous changes. We just create a
new TextFramgment each time and hand it to List::push_back()
Changed paths:
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index d00ea21..d069e28 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -156,7 +156,7 @@ void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
token = tokenizer.nextToken();
}
- TextFragment fragment = _inGameText->fragments.back();
+ TextFragment fragment;
if (fontName.empty()) {
fragment.style.font = _lastStyle.font;
Commit: 49d67caa31583478b1b58df19b5739f42d5a4573
https://github.com/scummvm/scummvm/commit/49d67caa31583478b1b58df19b5739f42d5a4573
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-29T16:04:53-07:00
Commit Message:
Merge branch 'master' into zvision
Changed paths:
A engines/neverhood/modules/module2800_sprites.cpp
A engines/neverhood/modules/module2800_sprites.h
NEWS
audio/midiparser.cpp
audio/midiparser.h
audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
audio/softsynth/mt32/LA32WaveGenerator.cpp
audio/softsynth/mt32/LA32WaveGenerator.h
audio/softsynth/mt32/Partial.cpp
audio/softsynth/mt32/Partial.h
audio/softsynth/mt32/Synth.cpp
audio/softsynth/mt32/Synth.h
backends/events/default/default-events.cpp
base/version.cpp
common/coroutines.h
common/dcl.cpp
common/scummsys.h
configure
devtools/convbdf.cpp
devtools/create_mortdat/create_mortdat.cpp
devtools/create_neverhood/create_neverhood.cpp
devtools/create_project/codeblocks.cpp
devtools/create_project/create_project.cpp
devtools/create_project/create_project.h
devtools/create_translations/create_translations.cpp
devtools/create_translations/create_translations.h
devtools/scumm-md5.txt
engines/configure.engines
engines/fullpipe/behavior.cpp
engines/fullpipe/behavior.h
engines/fullpipe/fullpipe.cpp
engines/fullpipe/fullpipe.h
engines/fullpipe/gameloader.cpp
engines/fullpipe/gameloader.h
engines/fullpipe/gfx.cpp
engines/fullpipe/gfx.h
engines/fullpipe/init.cpp
engines/fullpipe/input.cpp
engines/fullpipe/input.h
engines/fullpipe/interaction.cpp
engines/fullpipe/interaction.h
engines/fullpipe/inventory.cpp
engines/fullpipe/inventory.h
engines/fullpipe/messages.cpp
engines/fullpipe/messages.h
engines/fullpipe/modal.cpp
engines/fullpipe/modal.h
engines/fullpipe/motion.cpp
engines/fullpipe/motion.h
engines/fullpipe/objects.h
engines/fullpipe/scene.cpp
engines/fullpipe/scene.h
engines/fullpipe/scenes.cpp
engines/fullpipe/scenes.h
engines/fullpipe/sound.cpp
engines/fullpipe/sound.h
engines/fullpipe/stateloader.cpp
engines/fullpipe/statics.cpp
engines/fullpipe/statics.h
engines/fullpipe/utils.cpp
engines/fullpipe/utils.h
engines/groovie/roq.cpp
engines/neverhood/blbarchive.cpp
engines/neverhood/console.cpp
engines/neverhood/detection.cpp
engines/neverhood/gamemodule.cpp
engines/neverhood/menumodule.cpp
engines/neverhood/menumodule.h
engines/neverhood/module.mk
engines/neverhood/modules/module1000.cpp
engines/neverhood/modules/module1200.h
engines/neverhood/modules/module1300.cpp
engines/neverhood/modules/module2400.h
engines/neverhood/modules/module2800.cpp
engines/neverhood/modules/module2800.h
engines/neverhood/neverhood.cpp
engines/neverhood/neverhood.h
engines/neverhood/palette.cpp
engines/neverhood/resource.cpp
engines/neverhood/resourceman.cpp
engines/neverhood/resourceman.h
engines/neverhood/scene.cpp
engines/neverhood/scene.h
engines/neverhood/screen.cpp
engines/neverhood/sound.cpp
engines/neverhood/sound.h
engines/neverhood/sprite.cpp
engines/sci/detection_tables.h
engines/sci/engine/savegame.cpp
engines/sci/engine/savegame.h
engines/sci/engine/script_patches.cpp
engines/sci/graphics/screen.cpp
engines/sci/sound/midiparser_sci.cpp
engines/sci/sound/midiparser_sci.h
engines/sci/sound/music.cpp
engines/sci/sound/music.h
engines/sci/sound/soundcmd.cpp
engines/scumm/scumm-md5.h
engines/sword25/gfx/animation.cpp
engines/sword25/gfx/animation.h
engines/sword25/gfx/animationdescription.cpp
engines/sword25/gfx/animationdescription.h
engines/sword25/gfx/animationresource.cpp
engines/sword25/gfx/animationtemplate.cpp
engines/sword25/gfx/animationtemplateregistry.cpp
engines/sword25/gfx/bitmap.h
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/gfx/panel.cpp
engines/sword25/gfx/panel.h
engines/sword25/gfx/renderobject.cpp
engines/sword25/gfx/renderobject.h
engines/sword25/gfx/renderobjectmanager.cpp
engines/sword25/gfx/text.cpp
engines/sword25/gfx/text.h
engines/sword25/input/inputengine.cpp
engines/sword25/kernel/inputpersistenceblock.cpp
engines/sword25/kernel/inputpersistenceblock.h
engines/sword25/kernel/objectregistry.h
engines/sword25/kernel/outputpersistenceblock.cpp
engines/sword25/kernel/outputpersistenceblock.h
engines/sword25/math/polygon.cpp
engines/sword25/math/polygon.h
engines/sword25/math/region.cpp
engines/sword25/math/regionregistry.cpp
engines/sword25/math/walkregion.cpp
engines/sword25/sfx/soundengine.cpp
engines/sword25/sfx/soundengine.h
engines/sword25/util/lua/lcode.cpp
engines/sword25/util/lua/ldebug.cpp
engines/sword25/util/lua/lfunc.cpp
engines/sword25/util/lua/lgc.cpp
engines/sword25/util/lua/llimits.h
engines/sword25/util/lua/lmem.cpp
engines/sword25/util/lua/lopcodes.cpp
engines/sword25/util/lua/lparser.cpp
engines/sword25/util/lua/lstate.cpp
engines/sword25/util/lua/lstring.cpp
engines/sword25/util/lua/lstrlib.cpp
engines/sword25/util/lua/ltablib.cpp
engines/tinsel/scene.cpp
engines/tony/mpal/mpal.cpp
engines/tsage/core.cpp
engines/tsage/core.h
engines/tsage/events.cpp
engines/tsage/events.h
engines/tsage/globals.cpp
engines/tsage/globals.h
engines/tsage/ringworld2/ringworld2_dialogs.cpp
engines/tsage/ringworld2/ringworld2_logic.cpp
engines/tsage/ringworld2/ringworld2_logic.h
engines/tsage/ringworld2/ringworld2_scenes0.cpp
engines/tsage/ringworld2/ringworld2_scenes0.h
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/tsage/ringworld2/ringworld2_scenes1.h
engines/tsage/ringworld2/ringworld2_scenes2.cpp
engines/tsage/ringworld2/ringworld2_scenes2.h
engines/tsage/ringworld2/ringworld2_scenes3.cpp
engines/tsage/ringworld2/ringworld2_scenes3.h
engines/tsage/ringworld2/ringworld2_speakers.cpp
engines/tsage/ringworld2/ringworld2_speakers.h
engines/tsage/scenes.cpp
engines/tsage/staticres.cpp
engines/tsage/staticres.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/font/base_font_truetype.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transform_struct.cpp
engines/wintermute/graphics/transform_struct.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
graphics/decoders/jpeg.cpp
graphics/decoders/jpeg.h
ports.mk
diff --cc engines/configure.engines
index 8ef4e66,20e5a56..db8e341
--- a/engines/configure.engines
+++ b/engines/configure.engines
@@@ -52,5 -52,4 +52,5 @@@ add_engine touche "Touche: The Adventur
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 wintermute "Wintermute" no "" "" "jpeg png zlib vorbis 16bit"
+add_engine zvision "ZVision" no
Commit: 11576c5aa940bbdf90f6fb79f39fbc23118cfd6c
https://github.com/scummvm/scummvm/commit/11576c5aa940bbdf90f6fb79f39fbc23118cfd6c
Author: RichieSams (adastley at gmail.com)
Date: 2013-09-29T19:41:43-07:00
Commit Message:
ZVISION: Rename ZVisionGameIds to use standard format
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/detection.cpp
engines/zvision/detection.h
engines/zvision/string_manager.cpp
engines/zvision/zork_raw.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 50fa503..69a4280 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -47,10 +47,10 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel
_pixelFormat(pixelFormat),
_cursorIsPushed(false) {
// WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
- if (_engine->getGameId() == ZorkNemesis) {
+ if (_engine->getGameId() == GID_NEMESIS) {
Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
_idleCursor = ZorkCursor(name);
- } else if (_engine->getGameId() == ZorkGrandInquisitor) {
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
_idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]);
}
}
@@ -77,7 +77,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
}
for (int i = 0; i < NUM_CURSORS; i++) {
- if (_engine->getGameId() == ZorkNemesis) {
+ if (_engine->getGameId() == GID_NEMESIS) {
if (cursorName.equals(_cursorNames[i])) {
_currentCursor = cursorName;
@@ -88,7 +88,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
changeCursor(ZorkCursor(name));
return;
}
- } else if (_engine->getGameId() == ZorkGrandInquisitor) {
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
if (cursorName.equals(_cursorNames[i])) {
_currentCursor = cursorName;
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index d9bb692..28b7134 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -68,7 +68,7 @@ static const ZVisionGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
- ZorkNemesis
+ GID_NEMESIS
},
{
@@ -82,12 +82,12 @@ static const ZVisionGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
- ZorkGrandInquisitor
+ GID_GRANDINQUISITOR
},
{
AD_TABLE_END_MARKER,
- None
+ GID_NONE
}
};
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index f08cfd2..f9acb4d 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -28,9 +28,9 @@
namespace ZVision {
enum ZVisionGameId {
- None = 0,
- ZorkNemesis = 1,
- ZorkGrandInquisitor = 2
+ GID_NONE = 0,
+ GID_NEMESIS = 1,
+ GID_GRANDINQUISITOR = 2
};
struct ZVisionGameDescription {
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index d069e28..b2d19d9 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -47,10 +47,10 @@ StringManager::~StringManager() {
}
void StringManager::initialize(ZVisionGameId gameId) {
- if (gameId == ZorkNemesis) {
+ if (gameId == GID_NEMESIS) {
// TODO: Check this hardcoded filename against all versions of Nemesis
parseStrFile("nemesis.str");
- } else if (gameId == ZorkGrandInquisitor) {
+ } else if (gameId == GID_GRANDINQUISITOR) {
// TODO: Check this hardcoded filename against all versions of Grand Inquisitor
parseStrFile("inquis.str");
}
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 92f6592..ebb7508 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -164,13 +164,13 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
SoundParams soundParams;
- if (engine->getGameId() == ZorkNemesis) {
+ if (engine->getGameId() == GID_NEMESIS) {
for (int i = 0; i < 6; i++) {
if (zNemSoundParamLookupTable[i].identifier == (fileName[6]))
soundParams = zNemSoundParamLookupTable[i];
}
}
- else if (engine->getGameId() == ZorkGrandInquisitor) {
+ else if (engine->getGameId() == GID_GRANDINQUISITOR) {
for (int i = 0; i < 6; i++) {
if (zgiSoundParamLookupTable[i].identifier == (fileName[7]))
soundParams = zgiSoundParamLookupTable[i];
Commit: 7854f05b794eece823390f348875bd17512202e0
https://github.com/scummvm/scummvm/commit/7854f05b794eece823390f348875bd17512202e0
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:32-07:00
Commit Message:
ZVISION: Remove empty file
Changed paths:
R engines/zvision/scripts.cpp
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 6a6eedc..c2c9950 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -20,7 +20,6 @@ MODULE_OBJS := \
save_manager.o \
scr_file_handling.o \
script_manager.o \
- scripts.o \
single_value_container.o \
string_manager.o \
timer_node.o \
diff --git a/engines/zvision/scripts.cpp b/engines/zvision/scripts.cpp
deleted file mode 100644
index b6deb1b..0000000
--- a/engines/zvision/scripts.cpp
+++ /dev/null
@@ -1,31 +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: a6ae661ef89a5c86b33dd84bf7b4dbd3dfbaec45
https://github.com/scummvm/scummvm/commit/a6ae661ef89a5c86b33dd84bf7b4dbd3dfbaec45
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:46-07:00
Commit Message:
ZVISION: Add newline at end of file
Changed paths:
engines/zvision/subtitles.h
diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h
index e8810832..13426e0 100644
--- a/engines/zvision/subtitles.h
+++ b/engines/zvision/subtitles.h
@@ -26,4 +26,4 @@
// TODO: Implement Subtitles
-#endif
\ No newline at end of file
+#endif
Commit: ea5a6a7bde5b3da4b3f568151c60a0789f26093f
https://github.com/scummvm/scummvm/commit/ea5a6a7bde5b3da4b3f568151c60a0789f26093f
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:47-07:00
Commit Message:
ZVISION: Fix debug typo copy-paste error
Changed paths:
engines/zvision/zfs_archive.cpp
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index 3577ce3..5f4b2a2 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -41,13 +41,13 @@ ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
readHeaders(&zfsFile);
- debug(0, "ArjArchive::ArjArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+ debug(0, "ZfsArchive::ZfsArchive(%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());
+ debug(0, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
}
ZfsArchive::~ZfsArchive() {
Commit: 229e4fe3be9770a3c91fa78ddb892043a6277cf0
https://github.com/scummvm/scummvm/commit/229e4fe3be9770a3c91fa78ddb892043a6277cf0
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:48-07:00
Commit Message:
ZVISION: Move creation of the managers to ZVision::initialize()
In order to make the ZVision constructor as lightweight as possible
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b071908..1e34587 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -54,7 +54,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT),
_pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
_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
@@ -65,15 +64,13 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// 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");
+ _clock(_system),
+ _scriptManager(nullptr),
+ _renderManager(nullptr),
+ _saveManager(nullptr),
+ _stringManager(nullptr),
+ _cursorManager(nullptr) {
- // Register random source
- _rnd = new Common::RandomSource("zvision");
-
- // Create managers
- _scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
- _saveManager = new SaveManager(this);
- _stringManager = new StringManager(this);
debug("ZVision::ZVision");
}
@@ -122,8 +119,17 @@ void ZVision::initialize() {
initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
- // CursorManager must be created after all the directories have been added
+ // Register random source
+ _rnd = new Common::RandomSource("zvision");
+
+ // Create managers
+ _scriptManager = new ScriptManager(this);
+ _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
+ _saveManager = new SaveManager(this);
+ _stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
+
+ // Initialize the managers
_cursorManager->initialize();
_scriptManager->initialize();
_stringManager->initialize(_gameDescription->gameId);
Commit: 031be61b07ba52d1ac561332981790e877f9768e
https://github.com/scummvm/scummvm/commit/031be61b07ba52d1ac561332981790e877f9768e
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:48-07:00
Commit Message:
ZVISION: Clean up the ZVision constructor
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 1e34587..86e0aed 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -54,16 +54,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT),
_pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
_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().
-
- // Do not initialize graphics here
-
- // 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");
_clock(_system),
_scriptManager(nullptr),
_renderManager(nullptr),
Commit: 02aaffd8943bd6713bf6b9e473124956c1f9d592
https://github.com/scummvm/scummvm/commit/02aaffd8943bd6713bf6b9e473124956c1f9d592
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:49-07:00
Commit Message:
ZVISION: Break comment into multiple lines for readability
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 86e0aed..9fa3cd3 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -82,7 +82,9 @@ ZVision::~ZVision() {
void ZVision::initialize() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
- // 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.
+ // 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);
Commit: 72ae75e64a1aa15839f489895220c76250e2943a
https://github.com/scummvm/scummvm/commit/72ae75e64a1aa15839f489895220c76250e2943a
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:49-07:00
Commit Message:
ZVISION: Clean up zvision.h
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index efd94f1..bc7f9e3 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -52,14 +52,6 @@ class StringManager;
class SaveManager;
class RlfAnimation;
-// 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);
Commit: 98e7627591ca8ac2acde347d9f41f6d810f94f67
https://github.com/scummvm/scummvm/commit/98e7627591ca8ac2acde347d9f41f6d810f94f67
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:50-07:00
Commit Message:
ZVISION: Add debug levels
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/script_manager.cpp
engines/zvision/zfs_archive.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 7963851..72da427 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -242,8 +242,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
- // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -263,8 +262,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
- // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -290,8 +288,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
- // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -320,8 +317,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
numberOfSamples += 2;
while (numberOfSamples > 0) {
if (destOffset + 1 >= destSize) {
- // TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 75f88dd..e23a08f 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -173,7 +173,7 @@ void ScriptManager::checkPuzzleCriteria() {
// 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);
+ debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
// Set the puzzle as completed
setStateValue(puzzle->key, 1);
@@ -306,7 +306,7 @@ void ScriptManager::onKeyUp(Common::KeyState keyState) {
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
assert(world != 0);
- debug("Changing location to: %c %c %c %c %u", world, room, node, view, offset);
+ debug(1, "Changing location to: %c %c %c %c %u", world, room, node, view, offset);
// Auto save
_engine->getSaveManager()->autoSave();
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index 5f4b2a2..0836336 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -41,17 +41,17 @@ ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
readHeaders(&zfsFile);
- debug(0, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+ debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
}
ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) {
readHeaders(stream);
- debug(0, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+ debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
}
ZfsArchive::~ZfsArchive() {
- debug(0, "ZfsArchive Destructor Called");
+ debug(1, "ZfsArchive Destructor Called");
ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
for ( ; it != _entryHeaders.end(); ++it) {
delete it->_value;
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 9fa3cd3..6cdc144 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -61,11 +61,11 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_stringManager(nullptr),
_cursorManager(nullptr) {
- debug("ZVision::ZVision");
+ debug(1, "ZVision::ZVision");
}
ZVision::~ZVision() {
- debug("ZVision::~ZVision");
+ debug(1, "ZVision::~ZVision");
// Dispose of resources
delete _console;
Commit: 3c8c4c836f2ac544570f032516aa2e90bc2dd4bf
https://github.com/scummvm/scummvm/commit/3c8c4c836f2ac544570f032516aa2e90bc2dd4bf
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:50-07:00
Commit Message:
ZVISION: Move bit flag to an enum for clarity
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 3d25fa9..461c449 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -367,8 +367,7 @@ bool ActionStreamVideo::execute(ZVision *engine) {
}
Common::Rect destRect;
- // 0x1 flags that the destRect dimensions are different from the original video dimensions
- if ((_flags & 0x1) == 0x1) {
+ if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
destRect = Common::Rect(_x1, _y1, _x2, _y2);
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 5d7cdad..206b5e1 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -321,6 +321,10 @@ public:
bool execute(ZVision *engine);
private:
+ enum {
+ DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions
+ };
+
Common::String _fileName;
uint _x1;
uint _y1;
Commit: db28babf066b83576a5d9b67d5c7e29c931fbb66
https://github.com/scummvm/scummvm/commit/db28babf066b83576a5d9b67d5c7e29c931fbb66
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:51-07:00
Commit Message:
ZVISION: Create file on the heap to prevent memory scope problems
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 461c449..75b771c 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -180,9 +180,9 @@ 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);
+ Common::File *file = new Common::File();
+ if (file->open(_fileName)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
}
} else {
audioStream = makeRawZorkStream(_fileName, engine);
Commit: 01238925da50c8467ce24cfe6c2cca07494a8b8e
https://github.com/scummvm/scummvm/commit/01238925da50c8467ce24cfe6c2cca07494a8b8e
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:51-07:00
Commit Message:
ZVISION: Fix curly braces formatting
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 03ab12d..4a5a4f3 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -45,39 +45,38 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
uint mask = 1;
for (int i = 0; i < 8; i++) {
- if ((flagbyte & mask) == mask)
- {
+ if ((flagbyte & mask) == mask) {
byte data = _source->readByte();
- if (_source->eos())
+ if (_source->eos()) {
return destinationCursor;
+ }
_window[_windowCursor] = data;
destination[destinationCursor++] = data;
// Increment and wrap the window cursor
_windowCursor = (_windowCursor + 1) & 0xFFF;
- }
- else
- {
+ } else {
byte low = _source->readByte();
- if (_source->eos())
+ if (_source->eos()) {
return destinationCursor;
+ }
byte high = _source->readByte();
- if (_source->eos())
+ if (_source->eos()) {
return destinationCursor;
+ }
uint16 length = (high & 0xF) + 2;
uint16 offset = low | ((high & 0xF0)<<4);
- for(int j = 0; j <= length; j++)
- {
+ for(int j = 0; j <= length; j++) {
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
destination[destinationCursor++] = temp;
_windowCursor = (_windowCursor + 1) & 0xFFF;
}
- };
+ }
mask = mask << 1;
}
Commit: e08023c4b62f5cbd74de93af924f7e4d689a4754
https://github.com/scummvm/scummvm/commit/e08023c4b62f5cbd74de93af924f7e4d689a4754
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:52-07:00
Commit Message:
ZVISION: Add newline to end of module.mk
Changed paths:
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index c2c9950..261168f 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -40,4 +40,4 @@ PLUGIN := 1
endif
# Include common rules
-include $(srcdir)/rules.mk
\ No newline at end of file
+include $(srcdir)/rules.mk
Commit: 239493305d1662c38c015e5cc1d321b6fe5baef7
https://github.com/scummvm/scummvm/commit/239493305d1662c38c015e5cc1d321b6fe5baef7
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:53-07:00
Commit Message:
ZVISION: Replace all occurances of (*iter). with iter->
Changed paths:
engines/zvision/lever_control.cpp
engines/zvision/puzzle.h
engines/zvision/render_manager.cpp
engines/zvision/script_manager.cpp
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index f3d369f..62d147c 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -230,8 +230,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
_lastMousePos = backgroundImageSpacePos;
for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
- if (angle >= (int)(*iter).angle - ANGLE_DELTA && angle <= (int)(*iter).angle + ANGLE_DELTA) {
- _currentFrame = (*iter).toFrame;
+ if (angle >= (int)iter->angle - ANGLE_DELTA && angle <= (int)iter->angle + ANGLE_DELTA) {
+ _currentFrame = iter->toFrame;
renderFrame(_currentFrame);
break;
}
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 512a963..679a017 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -36,7 +36,7 @@ struct Puzzle {
~Puzzle() {
for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
- delete (*iter);
+ delete *iter;
}
}
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 55a24c9..7c4fe43 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -59,8 +59,8 @@ RenderManager::~RenderManager() {
_backBuffer.free();
for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
- (*iter)._value.data->free();
- delete (*iter)._value.data;
+ iter->_value.data->free();
+ delete iter->_value.data;
}
}
@@ -121,25 +121,25 @@ void RenderManager::processAlphaEntries() {
for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
- uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top);
- uint16 *entryPtr = (uint16 *)(*iter)._value.data->getPixels();
+ uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top);
+ uint16 *entryPtr = (uint16 *)iter->_value.data->getPixels();
- for (int32 y = 0; y < (*iter)._value.height; y++) {
- for (int32 x = 0; x < (*iter)._value.width; x++) {
+ for (int32 y = 0; y < iter->_value.height; y++) {
+ for (int32 x = 0; x < iter->_value.width; x++) {
uint16 color = entryPtr[sourceOffset + x];
- if (color != (*iter)._value.alphaColor) {
+ if (color != iter->_value.alphaColor) {
backbufferPtr[destOffset + x] = color;
}
}
destOffset += _backBuffer.w;
- sourceOffset += (*iter)._value.width;
+ sourceOffset += iter->_value.width;
}
if (_backBufferDirtyRect.isEmpty()) {
- _backBufferDirtyRect = Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height);
+ _backBufferDirtyRect = Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height);
} else {
- _backBufferDirtyRect.extend(Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height));
+ _backBufferDirtyRect.extend(Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height));
}
}
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index e23a08f..5cc7846 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -71,7 +71,7 @@ void ScriptManager::createReferenceTable() {
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); criteriaIter++) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
@@ -88,7 +88,7 @@ void ScriptManager::createReferenceTable() {
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); criteriaIter++) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
@@ -135,16 +135,16 @@ void ScriptManager::checkPuzzleCriteria() {
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); criteriaIter++) {
criteriaMet = false;
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = (*criteriaIter).begin(); entryIter != (*criteriaIter).end(); entryIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
// Get the value to compare against
uint argumentValue;
- if ((*entryIter).argumentIsAKey)
+ if (entryIter->argumentIsAKey)
argumentValue = getStateValue(entryIter->argument);
else
argumentValue = entryIter->argument;
// Do the comparison
- switch ((*entryIter).criteriaOperator) {
+ switch (entryIter->criteriaOperator) {
case Puzzle::EQUAL_TO:
criteriaMet = getStateValue(entryIter->key) == argumentValue;
break;
@@ -197,7 +197,7 @@ void ScriptManager::cleanStateTable() {
for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
// If the value is equal to zero, we can purge it since getStateValue()
// will return zero if _globalState doesn't contain a key
- if ((*iter)._value == 0) {
+ if (iter->_value == 0) {
// Remove the node
_globalState.erase(iter);
}
@@ -384,8 +384,8 @@ void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
// Write out the key/value pair
- stream->writeUint32LE((*iter)._key);
- stream->writeUint32LE((*iter)._value);
+ stream->writeUint32LE(iter->_key);
+ stream->writeUint32LE(iter->_value);
}
}
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index b2d19d9..9ae479b 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -42,7 +42,7 @@ StringManager::StringManager(ZVision *engine)
StringManager::~StringManager() {
for (Common::HashMap<Common::String, TruetypeFont *>::iterator iter = _fonts.begin(); iter != _fonts.end(); iter++) {
- delete (*iter)._value;
+ delete iter->_value;
}
}
Commit: ffaffa2bc4163fcc72c40416ba713076ba9e8a01
https://github.com/scummvm/scummvm/commit/ffaffa2bc4163fcc72c40416ba713076ba9e8a01
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:53-07:00
Commit Message:
ZVISION: Convert all for-loops to use pre-increment instead of post-increment
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/lever_control.cpp
engines/zvision/lzss_read_stream.cpp
engines/zvision/puzzle.h
engines/zvision/render_manager.cpp
engines/zvision/render_table.cpp
engines/zvision/rlf_animation.cpp
engines/zvision/script_manager.cpp
engines/zvision/string_manager.cpp
engines/zvision/utility.h
engines/zvision/video.cpp
engines/zvision/zfs_archive.cpp
engines/zvision/zork_raw.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 69a4280..0f524bf 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -76,7 +76,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
return;
}
- for (int i = 0; i < NUM_CURSORS; i++) {
+ for (int i = 0; i < NUM_CURSORS; ++i) {
if (_engine->getGameId() == GID_NEMESIS) {
if (cursorName.equals(_cursorNames[i])) {
_currentCursor = cursorName;
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 62d147c..4e04ed4 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -229,7 +229,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
_lastMousePos = backgroundImageSpacePos;
- for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); iter++) {
+ for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); ++iter) {
if (angle >= (int)iter->angle - ANGLE_DELTA && angle <= (int)iter->angle + ANGLE_DELTA) {
_currentFrame = iter->toFrame;
renderFrame(_currentFrame);
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index 4a5a4f3..a90f40b 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -44,7 +44,7 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
break;
uint mask = 1;
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; ++i) {
if ((flagbyte & mask) == mask) {
byte data = _source->readByte();
if (_source->eos()) {
@@ -70,7 +70,7 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
uint16 length = (high & 0xF) + 2;
uint16 offset = low | ((high & 0xF0)<<4);
- for(int j = 0; j <= length; j++) {
+ for(int j = 0; j <= length; ++j) {
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
destination[destinationCursor++] = temp;
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 679a017..75ea954 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -35,7 +35,7 @@ struct Puzzle {
Puzzle() : key(0), flags(0) {}
~Puzzle() {
- for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
+ for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) {
delete *iter;
}
}
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 7c4fe43..b828626 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -58,7 +58,7 @@ RenderManager::~RenderManager() {
_currentBackground.free();
_backBuffer.free();
- for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
iter->_value.data->free();
delete iter->_value.data;
}
@@ -118,14 +118,14 @@ void RenderManager::renderBackbufferToScreen() {
void RenderManager::processAlphaEntries() {
// TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
- for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top);
uint16 *entryPtr = (uint16 *)iter->_value.data->getPixels();
- for (int32 y = 0; y < iter->_value.height; y++) {
- for (int32 x = 0; x < iter->_value.width; x++) {
+ for (int32 y = 0; y < iter->_value.height; ++y) {
+ for (int32 x = 0; x < iter->_value.width; ++x) {
uint16 color = entryPtr[sourceOffset + x];
if (color != iter->_value.alphaColor) {
backbufferPtr[destOffset + x] = color;
@@ -151,7 +151,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
uint16 colorIn565 = _pixelFormat.RGBToColor(r, g, b);
uint16 *bufferPtr = (uint16 *)_workingWindowBuffer.getPixels();
- for (uint32 i = 0; i < workingWindowSize; i++) {
+ for (uint32 i = 0; i < workingWindowSize; ++i) {
bufferPtr[i] = colorIn565;
}
}
@@ -293,10 +293,10 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
if (isTransposed) {
uint16 *dest = (uint16 *)destination.getPixels();
- for (uint32 y = 0; y < imageHeight; y++) {
+ for (uint32 y = 0; y < imageHeight; ++y) {
uint32 columnIndex = y * imageWidth;
- for (uint32 x = 0; x < imageWidth; x++) {
+ for (uint32 x = 0; x < imageWidth; ++x) {
dest[columnIndex + x] = buffer[x * imageHeight + y];
}
}
@@ -320,8 +320,8 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
uint32 sourceOffset = 0;
uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
- for (int32 y = 0; y < height; y++) {
- for (int32 x = 0; x < width; x++) {
+ for (int32 y = 0; y < height; ++y) {
+ for (int32 x = 0; x < width; ++x) {
workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x];
}
@@ -353,8 +353,8 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
uint32 destOffset = 0;
uint16 *surfacePtr = (uint16 *)entry.data->getPixels();
- for (int32 y = 0; y < height; y++) {
- for (int32 x = 0; x < width; x++) {
+ for (int32 y = 0; y < height; ++y) {
+ for (int32 x = 0; x < width; ++x) {
surfacePtr[destOffset + x] = buffer[sourceOffset + x];
}
@@ -509,10 +509,10 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa
const uint16 *source = (const uint16 *)surface->getPixels();
uint16 *dest = (uint16 *)tranposedSurface->getPixels();
- for (uint32 y = 0; y < tranposedSurface->h; y++) {
+ for (uint32 y = 0; y < tranposedSurface->h; ++y) {
uint32 columnIndex = y * tranposedSurface->w;
- for (uint32 x = 0; x < tranposedSurface->w; x++) {
+ for (uint32 x = 0; x < tranposedSurface->w; ++x) {
dest[columnIndex + x] = source[x * surface->w + y];
}
}
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 19f95a5..ce247e2 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -103,10 +103,10 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
uint32 destOffset = 0;
- for (int16 y = subRect.top; y < subRect.bottom; y++) {
+ for (int16 y = subRect.top; y < subRect.bottom; ++y) {
uint32 sourceOffset = y * _numColumns;
- for (int16 x = subRect.left; x < subRect.right; x++) {
+ for (int16 x = subRect.left; x < subRect.right; ++x) {
uint32 normalizedX = x - subRect.left;
uint32 index = sourceOffset + x;
@@ -144,7 +144,7 @@ void RenderTable::generatePanoramaLookupTable() {
float fovInRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
float cylinderRadius = halfHeight / tan(fovInRadians);
- for (uint 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)
// Alpha represents the horizontal angle between the viewer at the center of a cylinder and x
float alpha = atan(((float)x - halfWidth + 0.01f) / cylinderRadius);
@@ -155,7 +155,7 @@ void RenderTable::generatePanoramaLookupTable() {
float cosAlpha = cos(alpha);
- for (uint y = 0; y < _numRows; y++) {
+ for (uint y = 0; y < _numRows; ++y) {
// To calculate y in cylinder coordinates, we can do similar triangles comparison,
// comparing the triangle from the center to the screen and from the center to the edge of the cylinder
int32 yInCylinderCoords = int32(floor(halfHeight + ((float)y - halfHeight) * cosAlpha));
@@ -176,7 +176,7 @@ void RenderTable::generateTiltLookupTable() {
float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f);
float cylinderRadius = halfWidth / tan(fovInRadians);
- for (uint y = 0; y < _numRows; y++) {
+ for (uint y = 0; y < _numRows; ++y) {
// Add an offset of 0.01 to overcome zero tan/atan issue (horizontal line on half of screen)
// Alpha represents the vertical angle between the viewer at the center of a cylinder and y
@@ -189,7 +189,7 @@ void RenderTable::generateTiltLookupTable() {
float cosAlpha = cos(alpha);
uint32 columnIndex = y * _numColumns;
- for (uint x = 0; x < _numColumns; x++) {
+ for (uint x = 0; x < _numColumns; ++x) {
// To calculate x in cylinder coordinates, we can do similar triangles comparison,
// comparing the triangle from the center to the screen and from the center to the edge of the cylinder
int32 xInCylinderCoords = int32(floor(halfWidth + ((float)x - halfWidth) * cosAlpha));
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 72da427..d932fa7 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -63,14 +63,14 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_frames = new Frame[_frameCount];
// Read in each frame
- for (uint i = 0; i < _frameCount; i++) {
+ for (uint i = 0; i < _frameCount; ++i) {
_frames[i] = readNextFrame();
}
}
}
RlfAnimation::~RlfAnimation() {
- for (uint i = 0; i < _frameCount; i++) {
+ for (uint i = 0; i < _frameCount; ++i) {
delete[] _frames[i].encodedData;
}
delete[] _frames;
@@ -165,7 +165,7 @@ void RlfAnimation::seekToFrame(int frameNumber) {
int closestFrame = _currentFrame;
int distance = (int)frameNumber - _currentFrame;
- for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) {
+ for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); ++iter) {
int newDistance = (int)frameNumber - (int)(*iter);
if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
closestFrame = (*iter);
@@ -173,7 +173,7 @@ void RlfAnimation::seekToFrame(int frameNumber) {
}
}
- for (int i = closestFrame; i <= frameNumber; i++) {
+ for (int i = closestFrame; i <= frameNumber; ++i) {
applyFrameToCurrent(i);
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 5cc7846..31983a6 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -43,13 +43,13 @@ ScriptManager::ScriptManager(ZVision *engine)
}
ScriptManager::~ScriptManager() {
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
delete (*iter);
}
- for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
delete (*iter);
}
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
delete (*iter);
}
}
@@ -66,12 +66,12 @@ void ScriptManager::update(uint deltaTimeMillis) {
void ScriptManager::createReferenceTable() {
// Iterate through each local Puzzle
- for (Common::List<Puzzle *>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
+ for (Common::List<Puzzle *>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {
Puzzle *puzzlePtr = (*activePuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); criteriaIter++) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); ++criteriaIter) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
@@ -83,12 +83,12 @@ void ScriptManager::createReferenceTable() {
}
// Iterate through each global Puzzle
- for (Common::List<Puzzle *>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
+ for (Common::List<Puzzle *>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
Puzzle *puzzlePtr = (*globalPuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); criteriaIter++) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); ++criteriaIter) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
_referenceTable[entryIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
@@ -100,7 +100,7 @@ void ScriptManager::createReferenceTable() {
}
// Remove duplicate entries
- for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); referenceTableIter++) {
+ for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
removeDuplicateEntries(referenceTableIter->_value);
}
}
@@ -113,7 +113,7 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) {
// Remove the node
iter = _activeControls.erase(iter);
} else {
- iter++;
+ ++iter;
}
}
}
@@ -132,10 +132,10 @@ void ScriptManager::checkPuzzleCriteria() {
// Check each Criteria
bool criteriaMet = false;
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); criteriaIter++) {
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) {
criteriaMet = false;
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); entryIter++) {
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
// Get the value to compare against
uint argumentValue;
if (entryIter->argumentIsAKey)
@@ -179,7 +179,7 @@ void ScriptManager::checkPuzzleCriteria() {
setStateValue(puzzle->key, 1);
bool shouldContinue = true;
- for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+ for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
if (!shouldContinue) {
break;
@@ -194,7 +194,7 @@ void ScriptManager::checkPuzzleCriteria() {
}
void ScriptManager::cleanStateTable() {
- for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
+ for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) {
// If the value is equal to zero, we can purge it since getStateValue()
// will return zero if _globalState doesn't contain a key
if (iter->_value == 0) {
@@ -215,7 +215,7 @@ 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++) {
+ for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) {
_puzzlesToCheck.push((*iter));
}
}
@@ -230,7 +230,7 @@ void ScriptManager::addControl(Control *control) {
}
Control *ScriptManager::getControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
return (*iter);
}
@@ -240,7 +240,7 @@ Control *ScriptManager::getControl(uint32 key) {
}
void ScriptManager::enableControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->enable();
break;
@@ -249,7 +249,7 @@ void ScriptManager::enableControl(uint32 key) {
}
void ScriptManager::disableControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->disable();
break;
@@ -258,7 +258,7 @@ void ScriptManager::disableControl(uint32 key) {
}
void ScriptManager::focusControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
if (controlKey == key) {
@@ -272,20 +272,20 @@ void ScriptManager::focusControl(uint32 key) {
}
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
}
}
void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
}
}
bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
bool cursorWasChanged = false;
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
}
@@ -293,13 +293,13 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo
}
void ScriptManager::onKeyDown(Common::KeyState keyState) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onKeyDown(keyState);
}
}
void ScriptManager::onKeyUp(Common::KeyState keyState) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onKeyUp(keyState);
}
}
@@ -314,11 +314,11 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
delete (*iter);
}
_activePuzzles.clear();
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
delete (*iter);
}
_activeControls.clear();
@@ -343,12 +343,12 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
_engine->getRenderManager()->setBackgroundPosition(offset);
// Enable all the controls
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->enable();
}
// Add all the local puzzles to the queue to be checked
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter)->key, 0);
@@ -358,7 +358,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
}
// Add all the global puzzles to the queue to be checked
- for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter)->key, 0);
@@ -382,7 +382,7 @@ void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
// Write the number of state value entries
stream->writeUint32LE(_globalState.size());
- for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) {
+ for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) {
// Write out the key/value pair
stream->writeUint32LE(iter->_key);
stream->writeUint32LE(iter->_value);
@@ -396,7 +396,7 @@ void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
// Read the number of key/value pairs
uint32 numberOfPairs = stream->readUint32LE();
- for (uint32 i = 0; i < numberOfPairs; i++) {
+ for (uint32 i = 0; i < numberOfPairs; ++i) {
uint32 key = stream->readUint32LE();
uint32 value = stream->readUint32LE();
// Directly access the state table so we don't trigger Puzzle checks
@@ -408,14 +408,14 @@ void ScriptManager::serializeControls(Common::WriteStream *stream) {
// Count how many controls need to save their data
// Because WriteStream isn't seekable
uint32 numberOfControlsNeedingSerialization = 0;
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->needsSerialization()) {
numberOfControlsNeedingSerialization++;
}
}
stream->writeUint32LE(numberOfControlsNeedingSerialization);
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->serialize(stream);
}
}
@@ -423,9 +423,9 @@ void ScriptManager::serializeControls(Common::WriteStream *stream) {
void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {
uint32 numberOfControls = stream->readUint32LE();
- for (uint32 i = 0; i < numberOfControls; i++) {
+ for (uint32 i = 0; i < numberOfControls; ++i) {
uint32 key = stream->readUint32LE();
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) {
+ for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->deserialize(stream);
break;
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 9ae479b..9ff1dd2 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -41,7 +41,7 @@ StringManager::StringManager(ZVision *engine)
}
StringManager::~StringManager() {
- for (Common::HashMap<Common::String, TruetypeFont *>::iterator iter = _fonts.begin(); iter != _fonts.end(); iter++) {
+ for (Common::HashMap<Common::String, TruetypeFont *>::iterator iter = _fonts.begin(); iter != _fonts.end(); ++iter) {
delete iter->_value;
}
}
@@ -80,7 +80,7 @@ void StringManager::parseStrFile(const Common::String &fileName) {
uint textStringCursor = 0;
bool inTag = false;
- for (uint i = 0; i < asciiLine.size(); i++) {
+ for (uint i = 0; i < asciiLine.size(); ++i) {
switch (asciiLine[i]) {
case '<':
inTag = true;
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 3348a43..af47de7 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.begin(), container.end());
- for (uint i = 0; i + 1 < container.size(); i++) {
+ for (uint i = 0; i + 1 < container.size(); ++i) {
while (i + 1 < container.size() && container[i] == container[i + 1]) {
container.remove_at(i + 1);
}
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 5230653..2fe4d23 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -43,11 +43,11 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
const byte *srcPtr = src;
if (bytesPerPixel == 1) {
- for (uint32 y = 0; y < srcHeight; y++) {
- for (uint32 x = 0; x < srcWidth; x++) {
+ for (uint32 y = 0; y < srcHeight; ++y) {
+ for (uint32 x = 0; x < srcWidth; ++x) {
const byte color = *srcPtr++;
- for (uint i = 0; i < scaleAmount; i++) {
+ for (uint i = 0; i < scaleAmount; ++i) {
dst[i] = color;
dst[pitch + i] = color;
}
@@ -56,12 +56,12 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
dst += pitch;
}
} else if (bytesPerPixel == 2) {
- for (uint32 y = 0; y < srcHeight; y++) {
- for (uint32 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++;
- for (uint i = 0; i < scaleAmount; i++) {
+ for (uint i = 0; i < scaleAmount; ++i) {
uint index = i *2;
dst[index] = color;
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index 0836336..b0444fa 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -78,7 +78,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
nextOffset = stream->readUint32LE();
// Read in each entry header
- for (uint32 i = 0; i < _header.filesPerBlock; i++) {
+ for (uint32 i = 0; i < _header.filesPerBlock; ++i) {
ZfsEntryHeader entryHeader;
entryHeader.name = readEntryName(stream);
@@ -149,7 +149,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
}
void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const {
- for (uint32 i = 0; i < length; i++)
+ for (uint32 i = 0; i < length; ++i)
buffer[i] ^= xorKey[i % 4];
}
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index ebb7508..1231e40 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -165,13 +165,13 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
SoundParams soundParams;
if (engine->getGameId() == GID_NEMESIS) {
- for (int i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; ++i) {
if (zNemSoundParamLookupTable[i].identifier == (fileName[6]))
soundParams = zNemSoundParamLookupTable[i];
}
}
else if (engine->getGameId() == GID_GRANDINQUISITOR) {
- for (int i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; ++i) {
if (zgiSoundParamLookupTable[i].identifier == (fileName[7]))
soundParams = zgiSoundParamLookupTable[i];
}
Commit: 4172334b51a33c0b68ad81ceba2aaf1a6e70d8f2
https://github.com/scummvm/scummvm/commit/4172334b51a33c0b68ad81ceba2aaf1a6e70d8f2
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:54-07:00
Commit Message:
ZVISION: Remove global const variables
Instead, use ColorMasks
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index d932fa7..008a246 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -28,14 +28,13 @@
#include "common/debug.h"
#include "common/endian.h"
+#include "graphics/colormasks.h"
+
#include "zvision/rlf_animation.h"
namespace ZVision {
-const Graphics::PixelFormat RlfAnimation::_pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
-const Graphics::PixelFormat RlfAnimation::_pixelFormat565 = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
-
RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
: _stream(stream),
_lastFrameRead(0),
@@ -56,7 +55,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
return;
}
- _currentFrameBuffer.create(_width, _height, _pixelFormat565);
+ _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>());
_frameBufferByteSize = _width * _height * sizeof(uint16);
if (!stream) {
@@ -247,8 +246,8 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
@@ -293,8 +292,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
@@ -310,8 +309,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 sampleColor = _pixelFormat565.RGBToColor(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
sourceOffset += 2;
numberOfSamples += 2;
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 3f205d9..ca9004f 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -52,9 +52,6 @@ private:
uint32 encodedSize;
};
- const static Graphics::PixelFormat _pixelFormat555;
- const static Graphics::PixelFormat _pixelFormat565;
-
private:
Common::File _file;
bool _stream;
Commit: 4c06affe84640ffa1fc8487a4344b41c225d7d8e
https://github.com/scummvm/scummvm/commit/4c06affe84640ffa1fc8487a4344b41c225d7d8e
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:54-07:00
Commit Message:
ZVISION: Convert _completeFrames to an Array
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 008a246..f0d5ac5 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -164,10 +164,10 @@ void RlfAnimation::seekToFrame(int frameNumber) {
int closestFrame = _currentFrame;
int distance = (int)frameNumber - _currentFrame;
- for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); ++iter) {
- int newDistance = (int)frameNumber - (int)(*iter);
+ for (int i = 0; i < _completeFrames.size(); ++i) {
+ int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
- closestFrame = (*iter);
+ closestFrame = _completeFrames[i];
distance = newDistance;
}
}
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index ca9004f..53247eb 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -62,7 +62,7 @@ private:
uint _height;
uint32 _frameTime; // In milliseconds
Frame *_frames;
- Common::List<uint> _completeFrames;
+ Common::Array<uint> _completeFrames;
int _currentFrame;
Graphics::Surface _currentFrameBuffer;
Commit: afe8cba1a1d161062a54400258467167cab76776
https://github.com/scummvm/scummvm/commit/afe8cba1a1d161062a54400258467167cab76776
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:55-07:00
Commit Message:
ZVISION: Fix spacing
Changed paths:
engines/zvision/save_manager.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 08a7264..9cc664c 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -41,7 +41,7 @@ const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
void SaveManager::saveGame(uint slot, const Common::String &saveName) {
// The games only support 20 slots
- assert(slot <=1 && slot <= 20);
+ assert(slot <= 1 && slot <= 20);
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
Commit: 0deb84522988488b8b93d57bb525fd4a6f8e4588
https://github.com/scummvm/scummvm/commit/0deb84522988488b8b93d57bb525fd4a6f8e4588
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:55-07:00
Commit Message:
ZVISION: Remove global const variable
Replace with ColorMasks
Changed paths:
engines/zvision/string_manager.cpp
engines/zvision/string_manager.h
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 9ff1dd2..cac6858 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -27,6 +27,7 @@
#include "common/debug.h"
#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
#include "zvision/string_manager.h"
#include "zvision/truetype_font.h"
@@ -34,8 +35,6 @@
namespace ZVision {
-const Graphics::PixelFormat StringManager::_pixelFormat565 = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
-
StringManager::StringManager(ZVision *engine)
: _engine(engine) {
}
@@ -206,7 +205,7 @@ void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
}
fragment.style.align = align;
- fragment.style.color = _pixelFormat565.ARGBToColor(0, red, green, blue);
+ fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565>>(0, red, green, blue);
_inGameText[lineNumber].fragments.push_back(fragment);
_lastStyle = fragment.style;
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index b67573b..74d13cd 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -69,8 +69,6 @@ private:
InGameText _inGameText[NUM_TEXT_LINES];
Common::HashMap<Common::String, TruetypeFont *> _fonts;
- static const Graphics::PixelFormat _pixelFormat565;
-
TextStyle _lastStyle;
public:
Commit: 28ac59307b43da50964ad732a65dc676d613ad73
https://github.com/scummvm/scummvm/commit/28ac59307b43da50964ad732a65dc676d613ad73
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:56-07:00
Commit Message:
ZVISION: Update warning message to correspond to the behavior
Changed paths:
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index cac6858..3c9a3c6 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -241,7 +241,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
}
if (charOverflowWarning) {
- warning("UTF-16 is not supported. Characters greater than 255 are clamped to 255");
+ warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'");
}
return asciiString;
Commit: 1f9ba897b8aa8afe776928ecd5ca480b8b2fc3a8
https://github.com/scummvm/scummvm/commit/1f9ba897b8aa8afe776928ecd5ca480b8b2fc3a8
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:56-07:00
Commit Message:
ZVISION: Convert _timeLeft to a signed int
This allows time decrementing to go negative instead of
wrapping to UINT_MAX. Which makes comparisons easier.
Changed paths:
engines/zvision/timer_node.h
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 21c344b..4bc8397 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -48,7 +48,7 @@ public:
inline bool needsSerialization() { return true; }
private:
- uint32 _timeLeft;
+ int32 _timeLeft;
};
} // End of namespace ZVision
Commit: b913e9f8a330328a6600539ecd03754e19560f97
https://github.com/scummvm/scummvm/commit/b913e9f8a330328a6600539ecd03754e19560f97
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:57-07:00
Commit Message:
ZVISION: Update removeDuplicateEntries to preserve order
The new algorithm is potentially slower, but it doesn't need
to use sort. Speed shouldn't be a problem because the function
isn't used that often and in each case the size of the container
is small.
Changed paths:
engines/zvision/utility.h
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index af47de7..1407708 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -61,20 +61,34 @@ void trimCommentsAndWhiteSpace(Common::String *string);
void dumpEveryResultAction(const Common::String &destFile);
/**
- * Removes all duplicate entries from container.
+ * Removes all duplicate entries from container. Relative order will be preserved.
*
- * @param container
- * @return
+ * @param container The Array to remove duplicate entries from
*/
template<class T>
void removeDuplicateEntries(Common::Array<T> &container) {
- Common::sort(container.begin(), container.end());
+ // Length of modified array
+ int newLength = 1;
+ int j;
+
+ for(int i = 1; i < container.size(); i++) {
+ for(j = 0; j < newLength; j++) {
+ if (container[i] == container[j]) {
+ break;
+ }
+ }
- for (uint i = 0; i + 1 < container.size(); ++i) {
- while (i + 1 < container.size() && container[i] == container[i + 1]) {
- container.remove_at(i + 1);
+ // If none of the values in index[0..j] of container are the same as array[i],
+ // then copy the current value to corresponding new position in array
+ if (j == newLength) {
+ container[newLength++] = container[i];
}
}
+
+ // Actually remove the unneeded space
+ while (container.size() < newLength) {
+ container.pop_back();
+ }
}
/**
Commit: 1c8a5582a2dd23c01bda6002e746a4e5749b21b6
https://github.com/scummvm/scummvm/commit/1c8a5582a2dd23c01bda6002e746a4e5749b21b6
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:58-07:00
Commit Message:
ZVISION: Remove unnesessary operator overload
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 75ea954..97b839f 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -74,13 +74,6 @@ struct Puzzle {
// This has to be list of pointers because ResultAction is abstract
Common::List<ResultAction *> resultActions;
uint 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<
- inline bool operator<(const Puzzle &other) const {
- return key < other.key;
- }
};
} // End of namespace ZVision
Commit: 18b1c3130fa1c6dbce79b83491c524e4a1f37867
https://github.com/scummvm/scummvm/commit/18b1c3130fa1c6dbce79b83491c524e4a1f37867
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:58-07:00
Commit Message:
ZVISION: Move two lookup tables inside the RawZorkStream class
Instead of being global variables.
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 1231e40..55ad207 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -52,6 +52,21 @@ const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009,
0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
+const SoundParams RawZorkStream::_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 RawZorkStream::_zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false},
+ {'k',0x2B11, true, true},
+ {'p',0x5622, false, true},
+ {'q',0x5622, true, true},
+ {'u',0xAC44, true, true}
+};
+
RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
: _rate(rate),
_stereo(0),
@@ -166,14 +181,14 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
if (engine->getGameId() == GID_NEMESIS) {
for (int i = 0; i < 6; ++i) {
- if (zNemSoundParamLookupTable[i].identifier == (fileName[6]))
- soundParams = zNemSoundParamLookupTable[i];
+ if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
+ soundParams = RawZorkStream::_zNemSoundParamLookupTable[i];
}
}
else if (engine->getGameId() == GID_GRANDINQUISITOR) {
for (int i = 0; i < 6; ++i) {
- if (zgiSoundParamLookupTable[i].identifier == (fileName[7]))
- soundParams = zgiSoundParamLookupTable[i];
+ if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
+ soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
}
}
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index f19ffc1..62433b1 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -41,21 +41,6 @@ struct SoundParams {
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.
*/
@@ -67,6 +52,8 @@ public:
}
public:
+ static const SoundParams _zNemSoundParamLookupTable[6];
+ static const SoundParams _zgiSoundParamLookupTable[5];
private:
const int _rate; // Sample rate of stream
Commit: 1140c8b48d6d814aa512af348bcb0463006250d3
https://github.com/scummvm/scummvm/commit/1140c8b48d6d814aa512af348bcb0463006250d3
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:59-07:00
Commit Message:
ZVISION: Fix space formatting
Changed paths:
engines/zvision/zork_raw.h
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 62433b1..51248e3 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -89,28 +89,28 @@ public:
/**
* 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).
+ * @param buffer Buffer to play from.
+ * @param size Size of the buffer in bytes.
+ * @param rate Rate of the sound data.
+ * @param dispose AfterUse Whether to free the buffer after use (with free!).
+ * @return The new SeekableAudioStream (or 0 on failure).
*/
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
int rate,
- bool stereo,
+ bool stereo,
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).
+ * @param stream Stream object to play from.
+ * @param rate Rate of the sound data.
+ * @param dispose AfterUse Whether to delete the stream after use.
+ * @return The new SeekableAudioStream (or 0 on failure).
*/
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
int rate,
- bool stereo,
+ bool stereo,
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
Commit: 1bdcae7f18c652b5ab0ab1b8993503745bf5102e
https://github.com/scummvm/scummvm/commit/1bdcae7f18c652b5ab0ab1b8993503745bf5102e
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:09:59-07:00
Commit Message:
ZVISION: Rename zvision.h inclusion guard to be consistent with the other files
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index bc7f9e3..13bdb3c 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -21,8 +21,8 @@
*
*/
-#ifndef ZVISION_H
-#define ZVISION_H
+#ifndef ZVISION_ZVISION_H
+#define ZVISION_ZVISION_H
#include "common/random.h"
#include "common/events.h"
Commit: bad28dc15872e208bf21f1e6fa2ab906bca598c4
https://github.com/scummvm/scummvm/commit/bad28dc15872e208bf21f1e6fa2ab906bca598c4
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:10:00-07:00
Commit Message:
ZVISION: Standardize includes order and format
Format is:
common/scummsys.h (Only if a .cpp file)
header file for this file (Only if a .cpp file)
zengine includes
other includes, grouped by module
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/animation_control.cpp
engines/zvision/animation_control.h
engines/zvision/clock.cpp
engines/zvision/console.cpp
engines/zvision/control.cpp
engines/zvision/control.h
engines/zvision/cursor.cpp
engines/zvision/cursor.h
engines/zvision/cursor_manager.cpp
engines/zvision/cursor_manager.h
engines/zvision/detection.cpp
engines/zvision/detection.h
engines/zvision/events.cpp
engines/zvision/input_control.cpp
engines/zvision/input_control.h
engines/zvision/lever_control.cpp
engines/zvision/lever_control.h
engines/zvision/lzss_read_stream.cpp
engines/zvision/lzss_read_stream.h
engines/zvision/push_toggle_control.cpp
engines/zvision/push_toggle_control.h
engines/zvision/puzzle.h
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/render_table.cpp
engines/zvision/render_table.h
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
engines/zvision/save_manager.cpp
engines/zvision/save_manager.h
engines/zvision/scr_file_handling.cpp
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
engines/zvision/single_value_container.cpp
engines/zvision/string_manager.cpp
engines/zvision/string_manager.h
engines/zvision/timer_node.cpp
engines/zvision/timer_node.h
engines/zvision/truetype_font.cpp
engines/zvision/truetype_font.h
engines/zvision/utility.cpp
engines/zvision/utility.h
engines/zvision/vector2.h
engines/zvision/video.cpp
engines/zvision/zfs_archive.cpp
engines/zvision/zfs_archive.h
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/actions.cpp b/engines/zvision/actions.cpp
index 75b771c..eae4ec2 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -22,11 +22,8 @@
#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"
@@ -35,6 +32,11 @@
#include "zvision/timer_node.h"
#include "zvision/animation_control.h"
+#include "common/file.h"
+
+#include "audio/decoders/wave.h"
+
+
namespace ZVision {
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 206b5e1..afa3e3a 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -23,13 +23,10 @@
#ifndef ZVISION_ACTIONS_H
#define ZVISION_ACTIONS_H
-#include "common/scummsys.h"
+#include "common/str.h"
#include "audio/mixer.h"
-namespace Common {
-class String;
-}
namespace ZVision {
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index bb810a8..1143380 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -22,15 +22,18 @@
#include "common/scummsys.h"
-#include "video/video_decoder.h"
-
#include "zvision/animation_control.h"
+
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
#include "zvision/script_manager.h"
#include "zvision/rlf_animation.h"
#include "zvision/zork_avi_decoder.h"
+#include "video/video_decoder.h"
+
+#include "graphics/surface.h"
+
namespace ZVision {
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
index 935f4ab..2ac3691 100644
--- a/engines/zvision/animation_control.h
+++ b/engines/zvision/animation_control.h
@@ -23,15 +23,21 @@
#ifndef ZVISION_ANIMATION_CONTROL_H
#define ZVISION_ANIMATION_CONTROL_H
-#include "common/types.h"
-
#include "zvision/control.h"
+namespace Common {
+class String;
+}
+
namespace Video {
class VideoDecoder;
}
+namespace Graphics {
+struct Surface;
+}
+
namespace ZVision {
class ZVision;
diff --git a/engines/zvision/clock.cpp b/engines/zvision/clock.cpp
index fe32252..c8ee717 100644
--- a/engines/zvision/clock.cpp
+++ b/engines/zvision/clock.cpp
@@ -23,9 +23,10 @@
#include "common/scummsys.h"
+#include "zvision/clock.h"
+
#include "common/system.h"
-#include "zvision/clock.h"
namespace ZVision {
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 0d290a6..a095d3f 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -22,13 +22,8 @@
#include "common/scummsys.h"
-#include "common/system.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/script_manager.h"
#include "zvision/render_manager.h"
@@ -38,6 +33,14 @@
#include "zvision/utility.h"
#include "zvision/cursor.h"
+#include "common/system.h"
+#include "common/file.h"
+#include "common/bufferedstream.h"
+
+#include "gui/debugger.h"
+
+#include "audio/mixer.h"
+
namespace ZVision {
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index ad0a4c5..bcbdabc 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -22,13 +22,14 @@
#include "common/scummsys.h"
-#include "common/stream.h"
-
#include "zvision/control.h"
+
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
#include "zvision/utility.h"
+#include "common/stream.h"
+
namespace ZVision {
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index a279381..770c540 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -23,8 +23,6 @@
#ifndef ZVISION_CONTROL_H
#define ZVISION_CONTROL_H
-#include "common/types.h"
-
#include "common/keyboard.h"
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index bb0700c..9023d97 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -22,11 +22,11 @@
#include "common/scummsys.h"
+#include "zvision/cursor.h"
+
#include "common/str.h"
#include "common/file.h"
-#include "zvision/cursor.h"
-
namespace ZVision {
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 805a8e7..18ac28c 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -23,10 +23,9 @@
#ifndef ZVISION_CURSOR_H
#define ZVISION_CURSOR_H
-#include "common/types.h"
-
#include "graphics/surface.h"
+
namespace Common {
class String;
}
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 0f524bf..595e794 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -22,13 +22,15 @@
#include "common/scummsys.h"
+#include "zvision/cursor_manager.h"
+
+#include "zvision/zvision.h"
+
#include "common/system.h"
+
#include "graphics/pixelformat.h"
#include "graphics/cursorman.h"
-#include "zvision/zvision.h"
-#include "zvision/cursor_manager.h"
-
namespace ZVision {
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 1c09620..0a369aa 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -23,10 +23,10 @@
#ifndef ZVISION_CURSOR_MANAGER_H
#define ZVISION_CURSOR_MANAGER_H
-#include "common/types.h"
-
#include "zvision/cursor.h"
+#include "common/str.h"
+
namespace Graphics {
struct PixelFormat;
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 28b7134..06e921d 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -21,16 +21,18 @@
*
*/
+#include "common/scummsys.h"
+
#include "base/plugins.h"
+#include "zvision/zvision.h"
+#include "zvision/detection.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 {
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index f9acb4d..3441760 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -25,6 +25,7 @@
#include "engines/advancedDetector.h"
+
namespace ZVision {
enum ZVisionGameId {
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index c1b894c..1103dc3 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -23,17 +23,20 @@
#include "common/scummsys.h"
#include "zvision/zvision.h"
-#include "zvision/console.h"
-#include "common/events.h"
-#include "engines/util.h"
-#include "common/system.h"
-#include "common/rational.h"
+#include "zvision/console.h"
#include "zvision/cursor_manager.h"
#include "zvision/render_manager.h"
#include "zvision/script_manager.h"
#include "zvision/rlf_animation.h"
+#include "common/events.h"
+#include "common/system.h"
+#include "common/rational.h"
+
+#include "engines/util.h"
+
+
namespace ZVision {
void ZVision::processEvents() {
diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp
index ab4cc6b..a445e1a 100644
--- a/engines/zvision/input_control.cpp
+++ b/engines/zvision/input_control.cpp
@@ -22,17 +22,18 @@
#include "common/scummsys.h"
-#include "common/str.h"
-#include "common/stream.h"
-#include "common/rect.h"
-
#include "zvision/input_control.h"
+
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/string_manager.h"
#include "zvision/render_manager.h"
#include "zvision/utility.h"
+#include "common/str.h"
+#include "common/stream.h"
+#include "common/rect.h"
+
namespace ZVision {
diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h
index 33a1b34..aab2c99 100644
--- a/engines/zvision/input_control.h
+++ b/engines/zvision/input_control.h
@@ -23,11 +23,11 @@
#ifndef ZVISION_INPUT_CONTROL_H
#define ZVISION_INPUT_CONTROL_H
-#include "common/types.h"
-
#include "zvision/control.h"
#include "zvision/string_manager.h"
+#include "common/rect.h"
+
namespace ZVision {
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 4e04ed4..79049b8 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -22,14 +22,8 @@
#include "common/scummsys.h"
-#include "common/stream.h"
-#include "common/file.h"
-#include "common/tokenizer.h"
-#include "common/system.h"
-
-#include "graphics/surface.h"
-
#include "zvision/lever_control.h"
+
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
@@ -38,6 +32,14 @@
#include "zvision/zork_avi_decoder.h"
#include "zvision/utility.h"
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
+
namespace ZVision {
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 80fda4f..8ef8f06 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -23,13 +23,11 @@
#ifndef ZVISION_LEVER_CONTROL_H
#define ZVISION_LEVER_CONTROL_H
-#include "common/types.h"
+#include "zvision/control.h"
#include "common/list.h"
#include "common/rect.h"
-#include "zvision/control.h"
-
namespace ZVision {
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index a90f40b..bbbda6f 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -24,6 +24,7 @@
#include "zvision/lzss_read_stream.h"
+
namespace ZVision {
LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 25a8b67..f6b1eb1 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -23,10 +23,10 @@
#ifndef ZVISION_LZSS_STREAM_H
#define ZVISION_LZSS_STREAM_H
-#include "common/types.h"
#include "common/stream.h"
#include "common/array.h"
+
namespace Common {
class SeekableReadStream;
}
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index f4c0bc9..689311b 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -22,14 +22,16 @@
#include "common/scummsys.h"
-#include "common/stream.h"
-
#include "zvision/push_toggle_control.h"
+
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/cursor_manager.h"
#include "zvision/utility.h"
+#include "common/stream.h"
+
+
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h
index 8ab6f61..2a407ca 100644
--- a/engines/zvision/push_toggle_control.h
+++ b/engines/zvision/push_toggle_control.h
@@ -23,12 +23,10 @@
#ifndef ZVISION_PUSH_TOGGLE_CONTROL_H
#define ZVISION_PUSH_TOGGLE_CONTROL_H
-#include "common/types.h"
+#include "zvision/control.h"
#include "common/rect.h"
-#include "zvision/control.h"
-
namespace ZVision {
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 97b839f..1e73036 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -23,11 +23,11 @@
#ifndef ZVISION_PUZZLE_H
#define ZVISION_PUZZLE_H
+#include "zvision/actions.h"
#include "common/list.h"
#include "common/ptr.h"
-#include "zvision/actions.h"
namespace ZVision {
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index b828626..a8ceabc 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -22,15 +22,18 @@
#include "common/scummsys.h"
+#include "zvision/render_manager.h"
+
+#include "zvision/lzss_read_stream.h"
+
#include "common/file.h"
#include "common/system.h"
#include "common/stream.h"
#include "engines/util.h"
+
#include "graphics/decoders/tga.h"
-#include "zvision/render_manager.h"
-#include "zvision/lzss_read_stream.h"
namespace ZVision {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 71f4807..64d36f5 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -23,14 +23,14 @@
#ifndef ZVISION_RENDER_MANAGER_H
#define ZVISION_RENDER_MANAGER_H
-#include "common/types.h"
+#include "zvision/render_table.h"
+#include "zvision/truetype_font.h"
+
#include "common/rect.h"
#include "common/hashmap.h"
#include "graphics/surface.h"
-#include "zvision/render_table.h"
-#include "zvision/truetype_font.h"
class OSystem;
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index ce247e2..f443710 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -22,11 +22,13 @@
#include "common/scummsys.h"
-#include "graphics/colormasks.h"
-
#include "zvision/render_table.h"
+
#include "zvision/vector2.h"
+#include "graphics/colormasks.h"
+
+
namespace ZVision {
RenderTable::RenderTable(uint numColumns, uint numRows)
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 7c8e7d6..b188b14 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -23,11 +23,10 @@
#ifndef ZVISION_RENDER_TABLE_H
#define ZVISION_RENDER_TABLE_H
-#include "common/types.h"
-#include "common/rect.h"
-
#include "zvision/vector2.h"
+#include "common/rect.h"
+
namespace ZVision {
class RenderTable {
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index f0d5ac5..94e48d3 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -22,6 +22,8 @@
#include "common/scummsys.h"
+#include "zvision/rlf_animation.h"
+
#include "common/str.h"
#include "common/file.h"
#include "common/textconsole.h"
@@ -30,8 +32,6 @@
#include "graphics/colormasks.h"
-#include "zvision/rlf_animation.h"
-
namespace ZVision {
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 53247eb..fe5b0d6 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -23,9 +23,8 @@
#ifndef ZVISION_RLF_ANIMATION_H
#define ZVISION_RLF_ANIMATION_H
-#include "common/types.h"
-
#include "common/file.h"
+
#include "graphics/surface.h"
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 9cc664c..c3deadd 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -22,6 +22,12 @@
#include "common/scummsys.h"
+#include "zvision/save_manager.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
+
#include "common/system.h"
#include "graphics/surface.h"
@@ -29,11 +35,6 @@
#include "gui/message.h"
-#include "zvision/save_manager.h"
-#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
-
namespace ZVision {
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 6445f10..b4770e6 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -23,14 +23,16 @@
#ifndef ZVISION_SAVE_MANAGER_H
#define ZVISION_SAVE_MANAGER_H
-#include "common/types.h"
-
#include "common/savefile.h"
namespace Common {
class String;
}
+namespace Graphics {
+struct Surface;
+}
+
namespace ZVision {
class ZVision;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index fa89f75..e90408c 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "zvision/script_manager.h"
+
#include "zvision/utility.h"
#include "zvision/puzzle.h"
#include "zvision/actions.h"
@@ -33,6 +34,7 @@
#include "common/file.h"
#include "common/tokenizer.h"
+
namespace ZVision {
void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 31983a6..f3e14e6 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -22,19 +22,21 @@
#include "common/scummsys.h"
-#include "common/algorithm.h"
-#include "common/hashmap.h"
-#include "common/debug.h"
-#include "common/stream.h"
+#include "zvision/script_manager.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
#include "zvision/cursor_manager.h"
#include "zvision/save_manager.h"
#include "zvision/actions.h"
#include "zvision/utility.h"
+#include "common/algorithm.h"
+#include "common/hashmap.h"
+#include "common/debug.h"
+#include "common/stream.h"
+
+
namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine)
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 349f259..6276095 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -23,11 +23,12 @@
#ifndef ZVISION_SCRIPT_MANAGER_H
#define ZVISION_SCRIPT_MANAGER_H
+#include "zvision/puzzle.h"
+#include "zvision/control.h"
+
#include "common/hashmap.h"
#include "common/queue.h"
-#include "zvision/puzzle.h"
-#include "zvision/control.h"
namespace Common {
class String;
diff --git a/engines/zvision/single_value_container.cpp b/engines/zvision/single_value_container.cpp
index 0fd758a..837bd8d 100644
--- a/engines/zvision/single_value_container.cpp
+++ b/engines/zvision/single_value_container.cpp
@@ -22,10 +22,11 @@
#include "common/scummsys.h"
+#include "zvision/single_value_container.h"
+
#include "common/textconsole.h"
#include "common/str.h"
-#include "zvision/single_value_container.h"
namespace ZVision {
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index 3c9a3c6..fde99c0 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -22,6 +22,10 @@
#include "common/scummsys.h"
+#include "zvision/string_manager.h"
+
+#include "zvision/truetype_font.h"
+
#include "common/file.h"
#include "common/tokenizer.h"
#include "common/debug.h"
@@ -29,9 +33,6 @@
#include "graphics/fontman.h"
#include "graphics/colormasks.h"
-#include "zvision/string_manager.h"
-#include "zvision/truetype_font.h"
-
namespace ZVision {
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index 74d13cd..9cfed52 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -24,8 +24,6 @@
#ifndef ZVISION_STRING_MANAGER_H
#define ZVISION_STRING_MANAGER_H
-#include "common/types.h"
-
#include "zvision/detection.h"
#include "zvision/truetype_font.h"
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index 81468db..55dfa51 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -22,12 +22,14 @@
#include "common/scummsys.h"
-#include "common/stream.h"
-
#include "zvision/timer_node.h"
+
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
+#include "common/stream.h"
+
+
namespace ZVision {
TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 4bc8397..32dca71 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -23,8 +23,6 @@
#ifndef ZVISION_TIMER_NODE_H
#define ZVISION_TIMER_NODE_H
-#include "common/types.h"
-
#include "zvision/control.h"
namespace ZVision {
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index 80d0d6b..8d6aaca 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -22,6 +22,11 @@
#include "common/scummsys.h"
+#include "zvision/truetype_font.h"
+
+#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
+
#include "common/debug.h"
#include "common/file.h"
#include "common/system.h"
@@ -30,10 +35,6 @@
#include "graphics/fonts/ttf.h"
#include "graphics/surface.h"
-#include "zvision/truetype_font.h"
-#include "zvision/zvision.h"
-#include "zvision/render_manager.h"
-
namespace ZVision {
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index c7475d1..4f2ff86 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -25,11 +25,10 @@
#ifndef ZVISION_TRUETYPE_FONT_H
#define ZVISION_TRUETYPE_FONT_H
-#include "common/types.h"
-
#include "graphics/font.h"
#include "graphics/pixelformat.h"
+
namespace Graphics {
struct Surface;
}
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index fb4fe22..d973cb2 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -22,13 +22,15 @@
#include "common/scummsys.h"
-#include "common/tokenizer.h"
-#include "common/file.h"
-
#include "zvision/utility.h"
+
#include "zvision/zvision.h"
#include "zvision/zork_raw.h"
+#include "common/tokenizer.h"
+#include "common/file.h"
+
+
namespace ZVision {
void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 1407708..4aceec6 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -26,6 +26,7 @@
#include "common/array.h"
+
namespace Common {
class String;
}
diff --git a/engines/zvision/vector2.h b/engines/zvision/vector2.h
index 575915c..9616a43 100644
--- a/engines/zvision/vector2.h
+++ b/engines/zvision/vector2.h
@@ -25,6 +25,9 @@
#include "common/scummsys.h"
+#include "common/util.h"
+
+
namespace ZVision {
/**
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 2fe4d23..cd11618 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -22,14 +22,18 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
+
+#include "zvision/clock.h"
+#include "zvision/render_manager.h"
+
#include "common/system.h"
+
#include "video/video_decoder.h"
+
#include "engines/util.h"
-#include "graphics/surface.h"
-#include "zvision/clock.h"
-#include "zvision/render_manager.h"
-#include "zvision/zvision.h"
+#include "graphics/surface.h"
namespace ZVision {
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index b0444fa..24cff27 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -22,13 +22,12 @@
#include "common/scummsys.h"
-#include "common/hashmap.h"
+#include "zvision/zfs_archive.h"
+
#include "common/memstream.h"
#include "common/debug.h"
#include "common/file.h"
-#include "zvision/zfs_archive.h"
-
namespace ZVision {
ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
index 3bf4925..d7b45e4 100644
--- a/engines/zvision/zfs_archive.h
+++ b/engines/zvision/zfs_archive.h
@@ -25,6 +25,7 @@
#include "common/archive.h"
#include "common/hashmap.h"
+#include "common/hash-str.h"
namespace Common {
diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index d9b9511..a614f77 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -23,11 +23,14 @@
#include "common/scummsys.h"
+#include "zvision/zork_avi_decoder.h"
+
+#include "zvision/zork_raw.h"
+
#include "common/stream.h"
+
#include "audio/audiostream.h"
-#include "zvision/zork_avi_decoder.h"
-#include "zvision/zork_raw.h"
namespace ZVision {
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index 1ce2508..ec2be1b 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -26,6 +26,7 @@
#include "video/avi_decoder.h"
+
namespace ZVision {
class ZorkAVIDecoder : public Video::AVIDecoder {
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 55ad207..55493da 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -22,19 +22,22 @@
#include "common/scummsys.h"
+#include "zvision/zork_raw.h"
+
+#include "zvision/zvision.h"
+#include "zvision/detection.h"
+#include "zvision/utility.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 "audio/decoders/raw.h"
-#include "zvision/zork_raw.h"
-#include "zvision/zvision.h"
-#include "zvision/detection.h"
-#include "zvision/utility.h"
namespace ZVision {
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 51248e3..481ea79 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -23,9 +23,9 @@
#ifndef ZVISION_ZORK_RAW_H
#define ZVISION_ZORK_RAW_H
-#include "common/types.h"
#include "audio/audiostream.h"
+
namespace Common {
class SeekableReadStream;
}
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 6cdc144..6d8ae6d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -22,6 +22,17 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
+
+#include "zvision/console.h"
+#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/cursor_manager.h"
+#include "zvision/save_manager.h"
+#include "zvision/string_manager.h"
+#include "zvision/zfs_archive.h"
+#include "zvision/detection.h"
+
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
@@ -33,18 +44,7 @@
#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/cursor_manager.h"
-#include "zvision/save_manager.h"
-#include "zvision/string_manager.h"
-#include "zvision/zfs_archive.h"
-#include "zvision/detection.h"
-#include "zvision/utility.h"
namespace ZVision {
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 13bdb3c..84784d9 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -24,6 +24,9 @@
#ifndef ZVISION_ZVISION_H
#define ZVISION_ZVISION_H
+#include "zvision/detection.h"
+#include "zvision/clock.h"
+
#include "common/random.h"
#include "common/events.h"
@@ -31,9 +34,6 @@
#include "graphics/pixelformat.h"
-#include "zvision/detection.h"
-#include "zvision/clock.h"
-
#include "gui/debugger.h"
Commit: 23a1a1a70fd0481f17e49631e0884d7027d21528
https://github.com/scummvm/scummvm/commit/23a1a1a70fd0481f17e49631e0884d7027d21528
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-02T07:10:01-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/utility.h
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 4aceec6..fb571f3 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -69,10 +69,10 @@ void dumpEveryResultAction(const Common::String &destFile);
template<class T>
void removeDuplicateEntries(Common::Array<T> &container) {
// Length of modified array
- int newLength = 1;
- int j;
+ uint newLength = 1;
+ uint j;
- for(int i = 1; i < container.size(); i++) {
+ for(uint i = 1; i < container.size(); i++) {
for(j = 0; j < newLength; j++) {
if (container[i] == container[j]) {
break;
Commit: c73159150d75f9bf9996722838f8d114c9a66417
https://github.com/scummvm/scummvm/commit/c73159150d75f9bf9996722838f8d114c9a66417
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-04T07:20:25-07:00
Commit Message:
ZVISION: Re-enable Truemotion plugin guard, but add a case for ZVISION
Changed paths:
video/codecs/truemotion1.h
diff --git a/video/codecs/truemotion1.h b/video/codecs/truemotion1.h
index 39950b3..6ac09af 100644
--- a/video/codecs/truemotion1.h
+++ b/video/codecs/truemotion1.h
@@ -22,8 +22,8 @@
// Based on the TrueMotion 1 decoder by Alex Beregszaszi & Mike Melanson in FFmpeg
-// Only compile if SCI32 is enabled or if we're building dynamic modules
-//#if defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES)
+// Only compile if SCI32 is enabled, ZVISION is enabled, or if we're building dynamic modules
+#if defined(ENABLE_SCI32) || defined(ENABLE_ZVISION) || defined(DYNAMIC_MODULES)
#ifndef VIDEO_CODECS_TRUEMOTION1_H
#define VIDEO_CODECS_TRUEMOTION1_H
@@ -106,4 +106,4 @@ private:
} // End of namespace Video
#endif // VIDEO_CODECS_TRUEMOTION1_H
-//#endif // SCI32/Plugins guard
+#endif // SCI32/Plugins guard
Commit: 8a69bcfe97716ae8f0098fd62231ac13717f1484
https://github.com/scummvm/scummvm/commit/8a69bcfe97716ae8f0098fd62231ac13717f1484
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-04T07:20:31-07:00
Commit Message:
ZVISION: Add typedefs to shorten long type names
Changed paths:
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index a8ceabc..af8ca7f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -61,7 +61,7 @@ RenderManager::~RenderManager() {
_currentBackground.free();
_backBuffer.free();
- for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
+ for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
iter->_value.data->free();
delete iter->_value.data;
}
@@ -121,7 +121,7 @@ void RenderManager::renderBackbufferToScreen() {
void RenderManager::processAlphaEntries() {
// TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
- for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
+ for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top);
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 64d36f5..111bf62 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -60,6 +60,8 @@ private:
uint16 height;
};
+ typedef Common::HashMap<uint32, AlphaDataEntry> AlphaEntryMap;
+
private:
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
@@ -71,7 +73,7 @@ private:
// before actually being blitted to the screen
Graphics::Surface _backBuffer;
// A list of Alpha Entries that need to be blitted to the backbuffer
- Common::HashMap<uint32, AlphaDataEntry> _alphaDataEntries;
+ AlphaEntryMap _alphaDataEntries;
// A rectangle representing the portion of the working window where the pixels have been changed since last frame
Common::Rect _workingWindowDirtyRect;
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index f3e14e6..b33ca4c 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -45,13 +45,13 @@ ScriptManager::ScriptManager(ZVision *engine)
}
ScriptManager::~ScriptManager() {
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
+ for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
delete (*iter);
}
- for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
+ for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
delete (*iter);
}
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
delete (*iter);
}
}
@@ -68,7 +68,7 @@ void ScriptManager::update(uint deltaTimeMillis) {
void ScriptManager::createReferenceTable() {
// Iterate through each local Puzzle
- for (Common::List<Puzzle *>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {
+ for (PuzzleList::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {
Puzzle *puzzlePtr = (*activePuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
@@ -85,7 +85,7 @@ void ScriptManager::createReferenceTable() {
}
// Iterate through each global Puzzle
- for (Common::List<Puzzle *>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
+ for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
Puzzle *puzzlePtr = (*globalPuzzleIter);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
@@ -102,14 +102,14 @@ void ScriptManager::createReferenceTable() {
}
// Remove duplicate entries
- for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
+ for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
removeDuplicateEntries(referenceTableIter->_value);
}
}
void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
if ((*iter)->process(deltaTimeMillis)) {
delete (*iter);
// Remove the node
@@ -232,7 +232,7 @@ void ScriptManager::addControl(Control *control) {
}
Control *ScriptManager::getControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
return (*iter);
}
@@ -242,7 +242,7 @@ Control *ScriptManager::getControl(uint32 key) {
}
void ScriptManager::enableControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->enable();
break;
@@ -251,7 +251,7 @@ void ScriptManager::enableControl(uint32 key) {
}
void ScriptManager::disableControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->disable();
break;
@@ -260,7 +260,7 @@ void ScriptManager::disableControl(uint32 key) {
}
void ScriptManager::focusControl(uint32 key) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
if (controlKey == key) {
@@ -274,20 +274,20 @@ void ScriptManager::focusControl(uint32 key) {
}
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
}
}
void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
}
}
bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
bool cursorWasChanged = false;
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
}
@@ -295,13 +295,13 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo
}
void ScriptManager::onKeyDown(Common::KeyState keyState) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onKeyDown(keyState);
}
}
void ScriptManager::onKeyUp(Common::KeyState keyState) {
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->onKeyUp(keyState);
}
}
@@ -316,11 +316,11 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
+ for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
delete (*iter);
}
_activePuzzles.clear();
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
delete (*iter);
}
_activeControls.clear();
@@ -345,12 +345,12 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
_engine->getRenderManager()->setBackgroundPosition(offset);
// Enable all the controls
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->enable();
}
// Add all the local puzzles to the queue to be checked
- for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
+ for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter)->key, 0);
@@ -360,7 +360,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
}
// Add all the global puzzles to the queue to be checked
- for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
+ for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
// Reset any Puzzles that have the flag ONCE_PER_INST
if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {
setStateValue((*iter)->key, 0);
@@ -410,14 +410,14 @@ void ScriptManager::serializeControls(Common::WriteStream *stream) {
// Count how many controls need to save their data
// Because WriteStream isn't seekable
uint32 numberOfControlsNeedingSerialization = 0;
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->needsSerialization()) {
numberOfControlsNeedingSerialization++;
}
}
stream->writeUint32LE(numberOfControlsNeedingSerialization);
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
(*iter)->serialize(stream);
}
}
@@ -427,7 +427,7 @@ void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {
for (uint32 i = 0; i < numberOfControls; ++i) {
uint32 key = stream->readUint32LE();
- for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
if ((*iter)->getKey() == key) {
(*iter)->deserialize(stream);
break;
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 6276095..c44c836 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -49,6 +49,11 @@ struct Location {
uint32 offset;
};
+typedef Common::HashMap<uint32, Common::Array<Puzzle *> > PuzzleMap;
+typedef Common::List<Puzzle *> PuzzleList;
+typedef Common::Queue<Puzzle *> PuzzleQueue;
+typedef Common::List<Control *> ControlList;
+
class ScriptManager {
public:
ScriptManager(ZVision *engine);
@@ -63,15 +68,15 @@ private:
*/
Common::HashMap<uint32, uint> _globalState;
/** References _globalState keys to Puzzles */
- Common::HashMap<uint32, Common::Array<Puzzle *> > _referenceTable;
+ PuzzleMap _referenceTable;
/** Holds the Puzzles that should be checked this frame */
- Common::Queue<Puzzle *> _puzzlesToCheck;
+ PuzzleQueue _puzzlesToCheck;
/** Holds the currently active puzzles */
- Common::List<Puzzle *> _activePuzzles;
+ PuzzleList _activePuzzles;
/** Holds the global puzzles */
- Common::List<Puzzle *>_globalPuzzles;
+ PuzzleList _globalPuzzles;
/** Holds the currently active controls */
- Common::List<Control *> _activeControls;
+ ControlList _activeControls;
Location _currentLocation;
Commit: 39a8243c696f3883f5d1609b1dc333dfae2264ed
https://github.com/scummvm/scummvm/commit/39a8243c696f3883f5d1609b1dc333dfae2264ed
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-04T07:20:32-07:00
Commit Message:
ZVISION: Remove Vector2 class
Originally, the render table needed int32 (x, y) coords, so I created a copy of
Common::Point that used int32. After some code changes, the render table
reverted to int16 coords. Therefore, this class is unnessessary since
Common::Point uses int16 coords.
Changed paths:
R engines/zvision/vector2.h
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 f443710..b6a6a3d 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -24,7 +24,7 @@
#include "zvision/render_table.h"
-#include "zvision/vector2.h"
+#include "common/rect.h"
#include "graphics/colormasks.h"
@@ -37,7 +37,7 @@ RenderTable::RenderTable(uint numColumns, uint numRows)
_renderState(FLAT) {
assert(numRows != 0 && numColumns != 0);
- _internalBuffer = new Vector2[numRows * numColumns];
+ _internalBuffer = new Common::Point[numRows * numColumns];
}
RenderTable::~RenderTable() {
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index b188b14..8980911 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -23,10 +23,9 @@
#ifndef ZVISION_RENDER_TABLE_H
#define ZVISION_RENDER_TABLE_H
-#include "zvision/vector2.h"
-
#include "common/rect.h"
+
namespace ZVision {
class RenderTable {
@@ -43,7 +42,7 @@ public:
private:
uint _numColumns, _numRows;
- Vector2 *_internalBuffer;
+ Common::Point *_internalBuffer;
RenderState _renderState;
struct {
diff --git a/engines/zvision/vector2.h b/engines/zvision/vector2.h
deleted file mode 100644
index 9616a43..0000000
--- a/engines/zvision/vector2.h
+++ /dev/null
@@ -1,82 +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_VECTOR2_H
-#define ZVISION_VECTOR2_H
-
-#include "common/scummsys.h"
-
-#include "common/util.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: 2887e8295d707df99dc21c5e04eecc76953b4d41
https://github.com/scummvm/scummvm/commit/2887e8295d707df99dc21c5e04eecc76953b4d41
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-04T07:20:32-07:00
Commit Message:
ZVISION: Fix nested template formatting
Changed paths:
engines/zvision/rlf_animation.cpp
engines/zvision/string_manager.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 94e48d3..8981a69 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -246,8 +246,8 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
@@ -292,8 +292,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
@@ -309,8 +309,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
}
byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555>>(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565>>(r, g, b);
+ Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
sourceOffset += 2;
numberOfSamples += 2;
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index fde99c0..ab42f3d 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -206,7 +206,7 @@ void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
}
fragment.style.align = align;
- fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565>>(0, red, green, blue);
+ fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565> >(0, red, green, blue);
_inGameText[lineNumber].fragments.push_back(fragment);
_lastStyle = fragment.style;
Commit: 260ba64bdaf76cc201c57284b99890fe3a9422ad
https://github.com/scummvm/scummvm/commit/260ba64bdaf76cc201c57284b99890fe3a9422ad
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-04T12:13:21-07:00
Commit Message:
ZVISION: Fix signed/unsigned mismatch
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 8981a69..5f1d41d 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -164,7 +164,7 @@ void RlfAnimation::seekToFrame(int frameNumber) {
int closestFrame = _currentFrame;
int distance = (int)frameNumber - _currentFrame;
- for (int i = 0; i < _completeFrames.size(); ++i) {
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
closestFrame = _completeFrames[i];
Commit: bbf8e647e90238b1c932898a0814ecbf4f257761
https://github.com/scummvm/scummvm/commit/bbf8e647e90238b1c932898a0814ecbf4f257761
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-06T18:56:47-07:00
Commit Message:
ZVISION: Add an entry in AUTHORS for ZVision
Changed paths:
AUTHORS
diff --git a/AUTHORS b/AUTHORS
index fd5407b..4a249a2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -239,6 +239,9 @@ ScummVM Team
Wintermute:
Einar Johan T. Somaaen
+
+ ZVision:
+ Adrian Astley
Backend Teams
-------------
Commit: 8e8e5af0ec3ee4760e83beff095a0bf76a80e5f6
https://github.com/scummvm/scummvm/commit/8e8e5af0ec3ee4760e83beff095a0bf76a80e5f6
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-08T07:49:28-07:00
Commit Message:
ZVISION: Add an entry in credits.pl for ZVision
Changed paths:
devtools/credits.pl
diff --git a/devtools/credits.pl b/devtools/credits.pl
index 45018a5..133eba5 100755
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@ -754,6 +754,10 @@ begin_credits("Credits");
begin_section("Wintermute");
add_person("Einar Johan T. Sømåen", "somaen", "");
end_section();
+
+ begin_section("ZVision");
+ add_person("Adrian Astley", "RichieSams", "");
+ end_section();
end_section();
Commit: ef87ba54b446346eb528bd1115578b5a99df0b9c
https://github.com/scummvm/scummvm/commit/ef87ba54b446346eb528bd1115578b5a99df0b9c
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-08T07:50:20-07:00
Commit Message:
ZVISION: Add an entry in credits.pl for Marisa Chan / Zidane
Changed paths:
devtools/credits.pl
diff --git a/devtools/credits.pl b/devtools/credits.pl
index 133eba5..57336e2 100755
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@ -1158,6 +1158,7 @@ begin_credits("Credits");
add_person("Jimmi Thøgersen", "", "For ScummRev, and much obscure code/documentation");
add_person("", "Tristan", "For additional work on the original MT-32 emulator");
add_person("James Woodcock", "", "Soundtrack enhancements");
+ add_person("Anton Yartsev", "Zidane", "For the original re-implementation of the ZVison engine");
end_persons();
add_paragraph(
Commit: 7a97c992de67152514886f80f3cf4f2f3686d3d4
https://github.com/scummvm/scummvm/commit/7a97c992de67152514886f80f3cf4f2f3686d3d4
Author: RichieSams (adastley at gmail.com)
Date: 2013-10-14T17:02:18-07:00
Commit Message:
ZVISION: Use credits.pl to update AUTHORS and credits.h
Changed paths:
AUTHORS
devtools/credits.pl
gui/credits.h
diff --git a/AUTHORS b/AUTHORS
index 4a249a2..2451614 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -239,7 +239,7 @@ ScummVM Team
Wintermute:
Einar Johan T. Somaaen
-
+
ZVision:
Adrian Astley
@@ -612,6 +612,8 @@ Special thanks to
Jimmi Thogersen - For ScummRev, and much obscure code/documentation
Tristan - For additional work on the original MT-32 emulator
James Woodcock - Soundtrack enhancements
+ Anton Yartsev - For the original re-implementation of the ZVision
+ engine
Tony Warriner and everyone at Revolution Software Ltd. for sharing with us
the source of some of their brilliant games, allowing us to release
diff --git a/devtools/credits.pl b/devtools/credits.pl
index 57336e2..e7828d8 100755
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@ -1158,7 +1158,7 @@ begin_credits("Credits");
add_person("Jimmi Thøgersen", "", "For ScummRev, and much obscure code/documentation");
add_person("", "Tristan", "For additional work on the original MT-32 emulator");
add_person("James Woodcock", "", "Soundtrack enhancements");
- add_person("Anton Yartsev", "Zidane", "For the original re-implementation of the ZVison engine");
+ add_person("Anton Yartsev", "Zidane", "For the original re-implementation of the ZVision engine");
end_persons();
add_paragraph(
diff --git a/gui/credits.h b/gui/credits.h
index 3a4d776..b4d1680 100644
--- a/gui/credits.h
+++ b/gui/credits.h
@@ -297,6 +297,9 @@ static const char *credits[] = {
"A0""Einar Johan T. Somaaen",
"C0""Einar Johan T. S\370m\345en",
"",
+"C1""ZVision",
+"C0""Adrian Astley",
+"",
"",
"C1""Backend Teams",
"C1""Android",
@@ -769,6 +772,8 @@ static const char *credits[] = {
"C2""For additional work on the original MT-32 emulator",
"C0""James Woodcock",
"C2""Soundtrack enhancements",
+"C0""Anton Yartsev",
+"C2""For the original re-implementation of the ZVision engine",
"C0""Tony Warriner and everyone at Revolution Software Ltd. for sharing with us the source of some of their brilliant games, allowing us to release Beneath a Steel Sky as freeware... and generally being supportive above and beyond the call of duty.",
"C0""",
"C0""John Passfield and Steve Stamatiadis for sharing the source of their classic title, Flight of the Amazon Queen and also being incredibly supportive.",
Commit: a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8
https://github.com/scummvm/scummvm/commit/a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2013-10-17T14:00:00-07:00
Commit Message:
Merge branch 'zvision'
This merges pull request 395 for the ZVision engine developed during
GSoC2013.
Changed paths:
A engines/zvision/actions.cpp
A engines/zvision/actions.h
A engines/zvision/animation_control.cpp
A engines/zvision/animation_control.h
A engines/zvision/clock.cpp
A engines/zvision/clock.h
A engines/zvision/console.cpp
A engines/zvision/console.h
A engines/zvision/control.cpp
A engines/zvision/control.h
A engines/zvision/cursor.cpp
A engines/zvision/cursor.h
A engines/zvision/cursor_manager.cpp
A engines/zvision/cursor_manager.h
A engines/zvision/detection.cpp
A engines/zvision/detection.h
A engines/zvision/events.cpp
A engines/zvision/input_control.cpp
A engines/zvision/input_control.h
A engines/zvision/inventory_manager.h
A engines/zvision/lever_control.cpp
A engines/zvision/lever_control.h
A engines/zvision/lzss_read_stream.cpp
A engines/zvision/lzss_read_stream.h
A engines/zvision/menu.h
A engines/zvision/module.mk
A engines/zvision/push_toggle_control.cpp
A engines/zvision/push_toggle_control.h
A engines/zvision/puzzle.h
A engines/zvision/render_manager.cpp
A engines/zvision/render_manager.h
A engines/zvision/render_table.cpp
A engines/zvision/render_table.h
A engines/zvision/rlf_animation.cpp
A engines/zvision/rlf_animation.h
A engines/zvision/save_manager.cpp
A engines/zvision/save_manager.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/string_manager.cpp
A engines/zvision/string_manager.h
A engines/zvision/subtitles.h
A engines/zvision/timer_node.cpp
A engines/zvision/timer_node.h
A engines/zvision/truetype_font.cpp
A engines/zvision/truetype_font.h
A engines/zvision/utility.cpp
A engines/zvision/utility.h
A engines/zvision/video.cpp
A engines/zvision/zfs_archive.cpp
A engines/zvision/zfs_archive.h
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
AUTHORS
devtools/credits.pl
engines/configure.engines
engines/engines.mk
engines/plugins_table.h
graphics/surface.cpp
graphics/surface.h
gui/credits.h
video/avi_decoder.cpp
video/avi_decoder.h
video/codecs/truemotion1.h
More information about the Scummvm-git-logs
mailing list