[Scummvm-cvs-logs] scummvm master -> 637102d33b9ab69724c1badd9515e0e26a4b4b88
bluegr
bluegr at gmail.com
Tue Dec 2 23:12:56 CET 2014
This automated email contains information about 196 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b9ad7e80a5 ZVISION: screenSpaceToImageSpace return 0,0 when pointer outside working window.
4baa1801fe ZVISION: Don't need to set push flag in cursorDown because it's block change cursor image.
cf99a88322 ZVISION: Change platform detection of ZGI, dos->win.
f1c6b58a94 ZVISION: Select needed workingWindow for ZGI and Nemesis.
7a3518d7c3 ZVISION: Streamvideo alwayas skippable. Skippable flag renamed to skipline.
2050987fa1 ZVISION: Detach raw stream reader from RawZorkStream for creating correct avi raw reader.
82348a74df ZVISION: New base class similar to control for handling timers, music, etc...
a6f025c74f ZVISION: Basic integration of SideFX into scriptManager.
96ac92aae3 ZVISION: Added type field for SideFX
4ac2c3e93b ZVISION: Move TimerNode to SideFX-based class.
aefa58f5a4 ZVISION: Correcting TimerNode behavior.
25834faf07 ZVISION: Style modifing by astyle.
bbe29500cc ZVISION: Forgotten change cursos to pressed in ZGI code.
dbdefe23e9 ZVISION: New render functions for rendering surface-to-surface.
db3d154c63 ZVISION: SetPartialScreen must update part of currentBackground image.
2e0e9dc1f6 ZVISION: Fix changelocation sscanf format string to original format.
9888e66603 ZVISION: Added system StateKey names enum.
3e51ed6a78 ZVISION: Set right reaction for mouse up/down events.
803ff02136 ZVISION: New data types for script files and puzzle reference.
d8ad0e5235 ZVISION: Added clean function for script scope and body for queue
c87ca1bc9c ZVISION: Add flag to puzzle structure for use with new referenceTable.
91cbb1ec79 ZVISION: Move setState to use queuePuzzle.
8e4070c68b ZVISION: Added global StateFlags and set/get/unset functions.
c0a709dc23 ZVISION: Refactoring script manager, massive changes.
6d5e8cb105 ZVISION: Replace disable/enable control functions by call to
4d02fe42fd ZVISION: Remove not needed (de)serialize functions from controls class.
6ace820da6 ZVISION: Remove field "flags" from puzzle structure.
66c9d1d0fd ZVISION: Add engine pointer to actionResult for manipulations with
41088f5516 ZVISION: Make setPartialScreen use mask color correctly.
fa74bcc4d5 ZVISION: Add to sidefx and scriptManager classes stop and kill methods
b0f74feb41 ZVISION: Define all sidefx types.
a8feff10b8 ZVISION: Add universe scope of puzzles to reference table.
e38ca6e7a9 ZVISION: New class for handle values and values from [slots].
fa943f1044 ZVISION: Move actionTimer to use ValueSlot class.
b2aa30afeb ZVISION: Correct timer code to match original.
0b61b653ae ZVISION: Handle go to 0000 - previous location.
44464ce686 ZVISION: Fix actionRandom parameter reader.
1477192e8c ZVISION: Fix ZorkRaw stream decoder return true instead of real flag.
a5430c7703 ZVISION: Don't use unneeded function.
d3ef75dac9 ZVISION: Replace ZorkRaw audio parameters table by fully implemented with 16bit flag.
f46d63d35c ZVISION: Implement engine-wide method for selecting new audio ID.
7f16672037 ZVISION: StateValue must be signed.
a35900142f ZVISION: ActionAdd must handle negative vallues.
e1df572ab8 ZVISION: Implement ActionKill.
be93d7d67d ZVISION: Implement ActionStop.
9dc0533f4f ZVISION: Implement MusicNode and move ActionMusic to work with it.
6a135c6779 ZVISION: Add zgi_mx directory for files search
5da10e99b2 ZVISION: Make source surface const type for read-only access.
b635fab6e6 ZVISION: ActionAssign value can be another slot, ValueSlot must be used.
7bd57a9ad6 ZVISION: Make rlf animation logic equivalent to video decoder methods.
a0d73c34cf ZVISION: Code for ActionDisableControl and ActionEnableControl.
29fc5be12e ZVISION: Don't add puzzle to referencetable[key] twice.
9363a0d071 ZVISION: Reverse queue puzzles adding to end->begin
468c44581f ZVISION: MouseUp and MouseDown now will return break process loop flag.
677c74d59f ZVISION: Now onMouse functions handle return results and processing control list from end to beginning
5fd15be0a2 ZVISION: Don't output setStateValue debug information.
e3b9f84d81 ZVISION: Change _currentLocation to new location before execute first scripts.
30ee8ed0fd ZVISION: Refactore AnimationControl to AnimationNode + changes for correct use it from actions.
5ab767cb37 ZVISION: Rename animation_control files to animation_node.
ff541a0d02 ZVISION: Impliment inventory functions and ActionInventory.
f877410fee ZVISION: Add new ChangeCursor method for load items icons.
4cb006f260 ZVISION: Animation nodes now scaleable.
1dbb6e807a ZVISION: Refactor parsing actions, it must handle presence/miss of slot key in same actions.
9f39b1e819 ZVISION: PreloadAnimation must indicate that the animation is loaded.
feabdc6017 ZVISION: Change clear queued list firstly, not exec list.
f3e2857cde ZVISION: Some scripts action arguments can be uppercased, make all lowercase.
066cc74d96 ZVISION: Refactoring cursor manager into simple and full-functionally.
570630ee3d ZVISION: Make update screen delayed for updates.
621818836e ZVISION: New easy-to-use render functions for next rendermanager generation.
fd325d49f9 ZVISION: Add splitter function into controls class.
0c7d1d2d36 ZVISION: Slot control code.
48156debaf ZVISION: Fix animation_node upper frame.
1428cb8950 ZVISION: Refactoring of renderManager.
e2dc6d31d2 ZVISION: Correct RenderManager methods for support menu.
52bcd62248 ZVISION: Fix onMouseMove rectangle for scriptManager.
aef9c68f3c ZVISION: Implement menus.
4ced9c07e0 ZVISION: Fix killSideFxType iterator.
9803f7e6c0 ZVISION: Fix code style with astyle.
61224e7225 ZVISION: Move MusicNode to use Audio::SoundHandle.
41415002b2 ZVISION: Implement PanTrack.
d973b1fb1b ZVISION: Implement attenuate code.
7b7ae43f7f ZVISION: Implement crossfade.
3a1fda6d57 ZVISION: New class for handle rlf and avi animations.
ff2a20889c ZVISION: Move code of animation_node to use meta_animation.
9c9f59d570 ZVISION: Move lever code to use MetaAnimation.
4a454ed763 ZVISION: New search manager for handle right handle for ZIX-files.
0033740001 ZVISION: Fix lever code;
cb2503aa9d ZVISION: Refactor of pushtoggle code, now full functional implementation.
6210ead126 ZVISION: Fix wrong style.
226ccb0de7 ZVISION: Don't add new timer if sidefx with same key exist
dcfe35c8ac ZVISION: Implement sTTFont class for handle ttf with styles.
cf08849147 ZVISION: Implement textRender with tags parser.
ac9b74dd16 ZVISION: Implement subtitle handle class
8e02e06db1 ZVISION: Change rendermanager code for correct subtitles handle.
1af6f404f4 ZVISION: Add subtitles support for MusicNode.
3608a0f6c6 ZVISION: Change changelocation code for identical work to original.
665014033d ZVISION: Add functions for framedelay controlling in animation_node
d90b325a3b ZVISION: Implement syncsound sidefx class and action class.
eb9061e580 ZVISION: Refactor video-play and correct streamvideo for use subtitles and correct scale.
2a4e9a6358 ZVISION: Refactor of save functions
5eb6462d60 ZVISION: Remove forgotten debug prints
5f92871a9c ZVISION: Fix timer values for savegame
26d923e354 ZVISION: Fix incompatibility of puzzle flugs with original saves.
7d1c4ec27c ZVISION: Fix rlf incorrect ABS -128 issue
84681a2439 ZVISION: SearchManager dir index in ZIX-file started from 1 not 0, include up border
74fe47748e ZVISION: Fix slot rendering for item-to-item click
ea6e151047 ZVISION: Add support for sharp(monochrome) font loading
6ca301c320 ZVISION: Add utf8 char length and utf8->uint16 functions
48360645dc ZVISION: Implement ttyText action
45589950c0 Merge remote-tracking branch 'upstream/master' into zvision
ace0e5e88f ZVISION: Fix compilation errors with latest scummvm
23c1b50861 ZVISION: Reorgonize source files into directories.
628d6cb4ee ZVISION: Fix puzzle disable condition check
bbaebdf680 ZVISION: Process events for controls similar to original engine, fix some errors.
b9103b8d19 ZVISION: Implement functions for system messaging.
57857a1d76 ZVISION: Controls now can return type of control.
9dd9bfce80 ZVISION: String manager only load text lines without parsing text styles.
bc4b0b5bf6 ZVISION: Implement code for getControl
ce248644b8 ZVISION: Fix drawTxt y-position.
7f2d4d9a6c ZVISION: Implement fuctionality for change focus without of calling focus/unfocus
5a870100bd ZVISION: Bool results for keyUp and keyDown events for controls.
fb62b9477b ZVISION: Make controls processing breakeable.
d7d058cd60 ZVISION: New scriptManager location methods
73d26bc233 ZVISION: Don't focus on already focused control
550c4dbc35 ZVISION: Implement full code for input control
5a5a32c84a ZVISION: New SaveManager methods for pre-buffering save data
49fc9eb5e6 ZVISION: Define ID's for system strings
e9676f5d7a ZVISION: Implementation of save control
1696e0dd96 ZVISION: Prepare save data while changing location
7378443e38 ZVISION: Implement safe control
2cfef440d7 ZVISION: venus_id now in base control class
21d6fddab4 ZVISION: Added scaled blitter to bkg
2b6d65f83b ZVISION: Implemented hotmovie control
78552afdae ZVISION: Check .avi and .rlf suffix only in MetaAnimation.
bcb1aea0ff ZVISION: FistControl implementation.
6ae414fbde ZVISION: PaintControl implemented
39c3a26bfa ZVISION: Fix setStateFlag->setStateValue in HotMov control
2a6c2fdf45 ZVISION: Titler control and DisplayMessage action implemented
cf63da941c ZVISION: Action:region and visual effects implemented.
002b8e692a ZVISION: Fix default Tilt linScale
7c9d8f22de ZVISION: Implement dynamic tilt up/down border
ac74070af1 ZVISION: Lever blitter must scale image to rect
a65ec38f8d ZVISION: Fix code style
0b3a20f645 ZVISION: Some push toggles may contain few hotspot zones
4bc3194410 ZVISION: Implement simple midi support
8e9d201cc3 ZVISION: Music actions and sidefx now handle midi sounds.
678f47f043 ZVISION: Implement action:distort and distort sidefx node
19b2e9123d ZVISION: Add distort_node to module.mk for success build
8b18ba64ae ZVISION: Add support for doubleFPS feature
3f21de4694 ZVISION: Make ZorkAVIAudioTrack resetable
d40caba5b7 ZVISION: If ZorkAVIAudioTrack got another format call AVIAudioTrack::queueSound
be8cf97674 ZVISION: Implement settings functions
3131e3aa5a ZVISION: Add missing methods definition
7151240345 ZVISION: Now setBackgroundPosition must care about statekey value
0efa1bc560 ZVISION: Implement action:rotate_to
53002dd2d0 ZVISION: Implement action:animunload
d0f6b61d7d ZVISION: Implement action:delay_render
7ddfcfd17e ZVISION: Implement action:disable_venus and action:set_venus
b8ef942f69 ZVISION: Implement action:dissolve
66d2cb4698 ZVISION: Implement action:flush_mouse_events
44eeb40272 ZVISION: Implement action:menu_bar_enable
19e2251a75 ZVISION: Implement action:preferences
ea8cc34a66 ZVISION: Implement action:restore_game
be5860b93a ZVISION: Change comments of not implemented actions
d0f2e20b62 ZVISION: Fix rlf backward seek and rename class field
51a9ec80df ZVISION: Implement ZeroPoint for panorama renderer
54917582eb ZVISION: Implement missing action - cursor
6f6d5fc24e ZVISION: Hide mouse cursor while streamvideo is working
7d92b44e09 ZVISION: Nemesis and GI has difference in set_partial_screen color mask
42bc6c5daf ZVISION: Fix incorrect usage of Common::String::format
f55f4af293 ZVISION: Fix code style in save_manager.h
9b88ab15df ZVISION: Make strings const in functions declaration
9e9b89071f ZVISION: Implement function for convertion of scummvm KeyCode to win vkKey
c79ac80b0c ZVISION: Implement quit function with reminder
fcbb3d0307 ZVISION: Use ifQuit for menu bars
f658a5c8e6 ZVISION: Implement methods for get state of menu items
db5e2adc58 ZVISION: Implement method for visual output of some info
8e112edb1a ZVISION: Implement Easter eggs and debug cheats
c4911135c1 ZVISION: Implement keyboard hotkeys
e57c358cea ZVISION: Implement method for getting panorama reverse flag
1f0bf5ecf2 ZVISION: Implement code for pan from keyboard and mouse
418b5f6dd2 ZVISION: Passive borders check for tilt and panorama for changelocation
2d7af4bab7 ZVISION: Add call of inventory cycling for Nemesis
bb06ecf798 ZVISION: Make menu bar fully enabled after changelocation called
960bbe53b2 ZVISION: Fix delays with halveDelay option
e970d121ff ZVISION: Lead code of all controls to the same style
f43326a533 ZVISION: Clean of useless code
e6f6687762 ZVISION: Merge upstream
f7b2cd0a7d ZVISION: Added detection for Zork Grand Inquisitor English Demo.
b12b1e1d25 ZVISION: Added detection for Zork Nemesis English Demo.
deeeb0646f ZVISION: Added detection for Zork Grand Inquisitor English DVD version.
03d33e82bc Merge pull request #2 from khbecker/zvision
d5f7a1dc03 ZVISION: Implement forgotten setVenus for controls
5b352da304 ZVISION: More CamelCase and a bit of comments cleanup
596a904a0c ZVISION: Remove wrong TODO from scripting/sidefx.h
637102d33b Merge pull request #532 from Marisa-Chan/zvision
Commit: b9ad7e80a5ec37f59f39858dd5eef7e519afffa2
https://github.com/scummvm/scummvm/commit/b9ad7e80a5ec37f59f39858dd5eef7e519afffa2
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: screenSpaceToImageSpace return 0,0 when pointer outside working window.
Changed paths:
engines/zvision/render_manager.cpp
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index af8ca7f..cb13606 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -385,30 +385,34 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com
}
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 (_workingWindow.contains(point)) {
+ // Convert from screen space to working window space
+ Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
- }
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
+ }
- if (state == RenderTable::PANORAMA) {
- newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset);
- } else if (state == RenderTable::TILT) {
- newPoint -= (Common::Point(0, _screenCenterY) - _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;
+ 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;
+ return newPoint;
+ } else {
+ return Common::Point(0, 0);
+ }
}
const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) {
Commit: 4baa1801fe13e2dafe5317d57dfc9e4fe10bc809
https://github.com/scummvm/scummvm/commit/4baa1801fe13e2dafe5317d57dfc9e4fe10bc809
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: Don't need to set push flag in cursorDown because it's block change cursor image.
Changed paths:
engines/zvision/cursor_manager.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 595e794..4c5ae5e 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -120,7 +120,6 @@ void CursorManager::cursorDown(bool pushed) {
if (_cursorIsPushed == pushed)
return;
- _cursorIsPushed = pushed;
changeCursor(_currentCursor, pushed);
}
Commit: cf99a88322474f2412edc737b9a0c6a38f373610
https://github.com/scummvm/scummvm/commit/cf99a88322474f2412edc737b9a0c6a38f373610
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: Change platform detection of ZGI, dos->win.
Changed paths:
engines/zvision/detection.cpp
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 06e921d..4966493 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -80,7 +80,7 @@ static const ZVisionGameDescription gameDescriptions[] = {
0,
AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944),
Common::EN_ANY,
- Common::kPlatformDOS,
+ Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
Commit: f1c6b58a943689c35bb448094577cfede19b92fc
https://github.com/scummvm/scummvm/commit/f1c6b58a943689c35bb448094577cfede19b92fc
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: Select needed workingWindow for ZGI and Nemesis.
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 6d8ae6d..940e01a 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -51,7 +51,9 @@ namespace ZVision {
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),
+ _workingWindow_ZGI((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),
+ _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT),
+ _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI),
_pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
_desiredFrameTime(33), /* ~30 fps */
_clock(_system),
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 84784d9..89aa60f 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -63,15 +63,21 @@ public:
* are given in this coordinate space. Also, all images are clipped to the
* edges of this Rectangle
*/
- const Common::Rect _workingWindow;
+ const Common::Rect &_workingWindow;
const Graphics::PixelFormat _pixelFormat;
private:
enum {
WINDOW_WIDTH = 640,
WINDOW_HEIGHT = 480,
- WORKING_WINDOW_WIDTH = 512,
- WORKING_WINDOW_HEIGHT = 320,
+
+ //Zork nemesis working window sizes
+ ZNM_WORKING_WINDOW_WIDTH = 512,
+ ZNM_WORKING_WINDOW_HEIGHT = 320,
+
+ //ZGI(and default) working window sizes
+ WORKING_WINDOW_WIDTH = 640,
+ WORKING_WINDOW_HEIGHT = 344,
ROTATION_SCREEN_EDGE_OFFSET = 60,
MAX_ROTATION_SPEED = 400 // Pixels per second
@@ -98,6 +104,8 @@ private:
// To prevent allocation every time we process events
Common::Event _event;
+ const Common::Rect _workingWindow_ZGI;
+ const Common::Rect _workingWindow_ZNM;
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
Commit: 7a3518d7c3c81b2e34dcbba0682dd8dc6e43b80d
https://github.com/scummvm/scummvm/commit/7a3518d7c3c81b2e34dcbba0682dd8dc6e43b80d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: Streamvideo alwayas skippable. Skippable flag renamed to skipline.
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index eae4ec2..fbf2a58 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -354,12 +354,12 @@ bool ActionSetScreen::execute(ZVision *engine) {
ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
char fileName[25];
- uint skippable;
+ uint skipline; //skipline - render video with skip every second line, not skippable.
- sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable);
+ sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline);
_fileName = Common::String(fileName);
- _skippable = (skippable == 0) ? false : true;
+ _skippable = true;
}
bool ActionStreamVideo::execute(ZVision *engine) {
Commit: 2050987fa1ecc347bdc707b58d185804a875106d
https://github.com/scummvm/scummvm/commit/2050987fa1ecc347bdc707b58d185804a875106d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: Detach raw stream reader from RawZorkStream for creating correct avi raw reader.
Changed paths:
engines/zvision/zork_avi_decoder.cpp
engines/zvision/zork_avi_decoder.h
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 a614f77..0711cdf 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -30,6 +30,7 @@
#include "common/stream.h"
#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
namespace ZVision {
@@ -43,9 +44,14 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s
if (_audStream) {
if (_wvInfo.tag == kWaveFormatZorkPCM) {
assert(_wvInfo.size == 8);
- _audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, _audStream->isStereo(), DisposeAfterUse::YES), DisposeAfterUse::YES);
+ RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream);
+ delete stream;
+
+ if (chunk.data)
+ _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO);
}
} else {
+ warning("Got %d wave format in AVI\n", _wvInfo.tag);
delete stream;
}
}
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index ec2be1b..dc3e332 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -25,25 +25,35 @@
#define ZORK_AVI_DECODER_H
#include "video/avi_decoder.h"
-
+#include "zork_raw.h"
namespace ZVision {
class ZorkAVIDecoder : public Video::AVIDecoder {
public:
ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :
- Video::AVIDecoder(soundType) {}
+ Video::AVIDecoder(soundType) {}
- virtual ~ZorkAVIDecoder() {}
+ 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() {}
+ Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType),
+ decoder(NULL) {
+ if (_audStream) {
+ decoder = new RawChunkStream(_audStream->isStereo());
+ }
+ }
+ virtual ~ZorkAVIAudioTrack() {
+ if (decoder)
+ delete decoder;
+ }
void queueSound(Common::SeekableReadStream *stream);
+ private:
+ RawChunkStream *decoder;
};
Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);
@@ -51,7 +61,7 @@ private:
private:
// Audio Codecs
enum {
- kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
+ kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
};
};
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 21613d9..029600b 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -41,65 +41,62 @@
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};
-
-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),
- _stream(stream, disposeStream),
- _endOfData(false) {
+const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12};
+
+const int32 RawChunkStream::_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
+ };
+
+RawChunkStream::RawChunkStream(bool stereo) {
if (stereo)
_stereo = 1;
+ else
+ _stereo = 0;
+
+ init();
+}
+void RawChunkStream::init() {
_lastSample[0].index = 0;
_lastSample[0].sample = 0;
_lastSample[1].index = 0;
_lastSample[1].sample = 0;
+}
- // Calculate the total playtime of the stream
- if (stereo)
- _playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
- else
- _playtime = Audio::Timestamp(0, _stream->size(), rate);
+RawChunkStream::RawChunk RawChunkStream::readNextChunk(Common::SeekableReadStream *stream) {
+ RawChunk tmp;
+ tmp.size = 0;
+ tmp.data = NULL;
+
+ if (stream && (stream->size() == 0 || stream->eos()))
+ return tmp;
+
+ tmp.size = (stream->size() - stream->pos()) * 2;
+ tmp.data = (int16 *)calloc(tmp.size, 1);
+
+ readBuffer(tmp.data, stream, stream->size() - stream->pos());
+
+ return tmp;
}
-int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
- int bytesRead = 0;
+int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples) {
+ int32 bytesRead = 0;
// 0: Left, 1: Right
uint channel = 0;
while (bytesRead < numSamples) {
- byte encodedSample = _stream->readByte();
- if (_stream->eos()) {
- _endOfData = true;
+ byte encodedSample = stream->readByte();
+ if (stream->eos()) {
return bytesRead;
}
bytesRead++;
@@ -140,6 +137,46 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
// Increment and wrap the channel
channel = (channel + 1) & _stereo;
}
+ return bytesRead;
+}
+
+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),
+ _stream(stream, disposeStream),
+ _endOfData(false),
+ _streamReader(stereo) {
+ if (stereo)
+ _stereo = 1;
+
+ // Calculate the total playtime of the stream
+ 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) {
+
+ int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples);
+
+ if (_stream->eos())
+ _endOfData = true;
return bytesRead;
}
@@ -148,10 +185,7 @@ bool RawZorkStream::rewind() {
_stream->seek(0, 0);
_stream->clearErr();
_endOfData = false;
- _lastSample[0].index = 0;
- _lastSample[0].sample = 0;
- _lastSample[1].index = 0;
- _lastSample[1].sample = 0;
+ _streamReader.init();
return true;
}
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 481ea79..1f261ae 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -41,6 +41,45 @@ struct SoundParams {
bool packed;
};
+
+/**
+ * This is a ADPCM stream-reader, this class holds context for multi-chunk reading and no buffers.
+ */
+class RawChunkStream {
+public:
+ RawChunkStream(bool stereo);
+
+ ~RawChunkStream() {
+ }
+private:
+ uint _stereo;
+
+ /**
+ * 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:
+
+ struct RawChunk {
+ int16 *data;
+ uint32 size;
+ };
+
+ void init();
+ //Read next audio portion in new stream (needed for avi), return structure with buffer
+ RawChunk readNextChunk(Common::SeekableReadStream *stream);
+ //Read numSamples from stream to buffer
+ int readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples);
+};
+
/**
* This is a stream, which allows for playing raw ADPCM data from a stream.
*/
@@ -62,17 +101,7 @@ private:
bool _endOfData; // Whether the stream end has been reached
uint _stereo;
- /**
- * 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];
+ RawChunkStream _streamReader;
public:
int readBuffer(int16 *buffer, const int numSamples);
Commit: 82348a74df8edd2f9e628ec939ba515c1703bc70
https://github.com/scummvm/scummvm/commit/82348a74df8edd2f9e628ec939ba515c1703bc70
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T19:48:57Z
Commit Message:
ZVISION: New base class similar to control for handling timers, music, etc...
Changed paths:
A engines/zvision/sidefx.cpp
A engines/zvision/sidefx.h
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 261168f..edd08c8 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -29,7 +29,8 @@ MODULE_OBJS := \
zvision.o \
zfs_archive.o \
zork_avi_decoder.o \
- zork_raw.o
+ zork_raw.o \
+ sidefx.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp
new file mode 100644
index 0000000..3874c86
--- /dev/null
+++ b/engines/zvision/sidefx.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/sidefx.h"
+
+#include "zvision/zvision.h"
+#include "zvision/render_manager.h"
+#include "zvision/utility.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
new file mode 100644
index 0000000..7047982
--- /dev/null
+++ b/engines/zvision/sidefx.h
@@ -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.
+ *
+ */
+
+#ifndef SIDEFX_H_INCLUDED
+#define SIDEFX_H_INCLUDED
+
+namespace Common {
+class SeekableReadStream;
+struct Point;
+class WriteStream;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class SideFX {
+public:
+ SideFX() : _engine(0), _key(0) {}
+ SideFX(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
+ virtual ~SideFX() {}
+
+ uint32 getKey() { return _key; }
+
+ 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;
+ uint32 _key;
+
+// Static member functions
+public:
+};
+
+// TODO: Implement InputControl
+// TODO: Implement SaveControl
+// TODO: Implement SlotControl
+// TODO: Implement SafeControl
+// TODO: Implement FistControl
+// TODO: Implement HotMovieControl
+// TODO: Implement PaintControl
+// TODO: Implement TilterControl
+
+} // End of namespace ZVision
+
+#endif // SIDEFX_H_INCLUDED
Commit: a6f025c74f7aac95154d56dc23a7b62eca965dd4
https://github.com/scummvm/scummvm/commit/a6f025c74f7aac95154d56dc23a7b62eca965dd4
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T20:11:33Z
Commit Message:
ZVISION: Basic integration of SideFX into 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 66a5408..4b4f130 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -108,6 +108,16 @@ void ScriptManager::createReferenceTable() {
}
void ScriptManager::updateNodes(uint deltaTimeMillis) {
+ // If process() returns true, it means the node can be deleted
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
+ if ((*iter)->process(deltaTimeMillis)) {
+ delete (*iter);
+ // Remove the node
+ iter = _activeSideFx.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
// If process() returns true, it means the node can be deleted
for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
if ((*iter)->process(deltaTimeMillis)) {
@@ -262,7 +272,7 @@ void ScriptManager::disableControl(uint32 key) {
void ScriptManager::focusControl(uint32 key) {
for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
-
+
if (controlKey == key) {
(*iter)->focus();
} else if (controlKey == _currentlyFocusedControl) {
@@ -273,6 +283,20 @@ void ScriptManager::focusControl(uint32 key) {
_currentlyFocusedControl = key;
}
+void ScriptManager::addSideFX(SideFX *fx) {
+ _activeSideFx.push_back(fx);
+}
+
+SideFX *ScriptManager::getSideFX(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ return (*iter);
+ }
+ }
+
+ return nullptr;
+}
+
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
for (ControlList::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 388d080..c29bc57 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -25,6 +25,7 @@
#include "zvision/puzzle.h"
#include "zvision/control.h"
+#include "zvision/sidefx.h"
#include "common/hashmap.h"
#include "common/queue.h"
@@ -54,6 +55,7 @@ typedef Common::List<Puzzle *> PuzzleList;
typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;
typedef Common::HashMap<uint32, uint32> StateMap;
+typedef Common::List<SideFX *> SideFXList;
class ScriptManager {
public:
@@ -78,6 +80,8 @@ private:
PuzzleList _globalPuzzles;
/** Holds the currently active controls */
ControlList _activeControls;
+ /** Holds the currently active timers, musics, other */
+ SideFXList _activeSideFx;
Location _currentLocation;
@@ -99,6 +103,9 @@ public:
void focusControl(uint32 key);
+ void addSideFX(SideFX *fx);
+ SideFX *getSideFX(uint32 key);
+
/**
* Called when LeftMouse is pushed.
*
@@ -140,7 +147,7 @@ public:
void deserializeStateTable(Common::SeekableReadStream *stream);
void serializeControls(Common::WriteStream *stream);
void deserializeControls(Common::SeekableReadStream *stream);
-
+
Location getCurrentLocation() const;
private:
Commit: 96ac92aae3bd3cb195abcc73f4df16864c0e3738
https://github.com/scummvm/scummvm/commit/96ac92aae3bd3cb195abcc73f4df16864c0e3738
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T20:43:04Z
Commit Message:
ZVISION: Added type field for SideFX
Changed paths:
engines/zvision/sidefx.h
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index 7047982..35d25d4 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -35,15 +35,21 @@ class ZVision;
class SideFX {
public:
- SideFX() : _engine(0), _key(0) {}
- SideFX(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
+
+ enum SideFXType{
+ SIDEFX_UNK = 0
+ };
+
+ SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
+ SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {}
virtual ~SideFX() {}
uint32 getKey() { return _key; }
+ SideFXType getType() { return _type; }
virtual bool process(uint32 deltaTimeInMillis) { return false; }
/**
- * Serialize a Control for save game use. This should only be used if a Control needs
+ * Serialize a SideFX for save game use. This should only be used if a SideFX 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.
@@ -56,7 +62,7 @@ public:
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
+ * SideFX 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.
*
@@ -67,18 +73,20 @@ public:
*/
virtual void deserialize(Common::SeekableReadStream *stream) {}
/**
- * If a Control overrides serialize() and deserialize(), this should return true
+ * If a SideFX overrides serialize() and deserialize(), this should return true
*
- * @return Does the Control need save game serialization?
+ * @return Does the SideFX need save game serialization?
*/
virtual inline bool needsSerialization() { return false; }
protected:
ZVision * _engine;
uint32 _key;
+ SideFXType _type;
// Static member functions
public:
+
};
// TODO: Implement InputControl
Commit: 4ac2c3e93bd78d4e151035fcde0dae9f17eeb11a
https://github.com/scummvm/scummvm/commit/4ac2c3e93bd78d4e151035fcde0dae9f17eeb11a
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T22:44:33Z
Commit Message:
ZVISION: Move TimerNode to SideFX-based class.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/sidefx.h
engines/zvision/timer_node.cpp
engines/zvision/timer_node.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index fbf2a58..fb4034f 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -387,7 +387,7 @@ ActionTimer::ActionTimer(const Common::String &line) {
}
bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addControl(new TimerNode(engine, _key, _time));
+ engine->getScriptManager()->addSideFX(new TimerNode(engine, _key, _time));
return true;
}
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index 35d25d4..d495655 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -37,7 +37,8 @@ class SideFX {
public:
enum SideFXType{
- SIDEFX_UNK = 0
+ SIDEFX_UNK = 0,
+ SIDEFX_TIMER = 1
};
SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index 55dfa51..7fc3199 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -32,8 +32,9 @@
namespace ZVision {
-TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : Control(engine, key), _timeLeft(timeInSeconds * 1000) {
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : SideFX(engine, key, SIDEFX_TIMER) {
+ _timeLeft = timeInSeconds * 1000;
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 32dca71..afdbd39 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -23,13 +23,13 @@
#ifndef ZVISION_TIMER_NODE_H
#define ZVISION_TIMER_NODE_H
-#include "zvision/control.h"
+#include "zvision/sidefx.h"
namespace ZVision {
class ZVision;
-class TimerNode : public Control {
+class TimerNode : public SideFX {
public:
TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
Commit: aefa58f5a4470b1ba2e275c62aa1a7a0cec76539
https://github.com/scummvm/scummvm/commit/aefa58f5a4470b1ba2e275c62aa1a7a0cec76539
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-18T22:58:02Z
Commit Message:
ZVISION: Correcting TimerNode behavior.
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 7fc3199..dc7dd5b 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -34,16 +34,25 @@ namespace ZVision {
TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
: SideFX(engine, key, SIDEFX_TIMER) {
+ if (_engine->getGameId() == GID_NEMESIS)
_timeLeft = timeInSeconds * 1000;
+ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ _timeLeft = timeInSeconds * 100;
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+TimerNode::~TimerNode() {
+ if (_timeLeft <= 0)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ else
+ _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
_timeLeft -= deltaTimeInMillis;
- if (_timeLeft <= 0) {
- _engine->getScriptManager()->setStateValue(_key, 0);
+ if (_timeLeft <= 0)
return true;
- }
return false;
}
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index afdbd39..2caf43a 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -32,6 +32,7 @@ class ZVision;
class TimerNode : public SideFX {
public:
TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
+ ~TimerNode();
/**
* Decrement the timer by the delta time. If the timer is finished, set the status
Commit: 25834faf0738ae6c33819b196fdfb8ab5e8f1888
https://github.com/scummvm/scummvm/commit/25834faf0738ae6c33819b196fdfb8ab5e8f1888
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-20T18:39:06Z
Commit Message:
ZVISION: Style modifing by astyle.
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/clock.h
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/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/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/sidefx.h
engines/zvision/single_value_container.h
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/video.cpp
engines/zvision/zfs_archive.cpp
engines/zvision/zfs_archive.h
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 fb4034f..1d4ce9c 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -103,8 +103,8 @@ bool ActionChangeLocation::execute(ZVision *engine) {
ActionCrossfade::ActionCrossfade(const Common::String &line) {
sscanf(line.c_str(),
- "%*[^(](%u %u %u %u %u %u %u)",
- &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+ "%*[^(](%u %u %u %u %u %u %u)",
+ &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
}
bool ActionCrossfade::execute(ZVision *engine) {
@@ -123,7 +123,7 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) {
bool ActionDisableControl::execute(ZVision *engine) {
debug("Disabling control %u", _key);
-
+
engine->getScriptManager()->disableControl(_key);
return true;
@@ -189,7 +189,7 @@ bool ActionMusic::execute(ZVision *engine) {
} 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);
@@ -235,8 +235,8 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
// 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, &_loopCount, &_mask, &_framerate);
+ "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
+ &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate);
_fileName = Common::String(fileName);
}
@@ -253,8 +253,8 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
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);
+ "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)",
+ &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
}
bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
@@ -320,7 +320,7 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
bool ActionSetPartialScreen::execute(ZVision *engine) {
RenderManager *renderManager = engine->getRenderManager();
-
+
if (_backgroundColor > 0) {
renderManager->clearWorkingWindowTo555Color(_backgroundColor);
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index afa3e3a..e7a4ea3 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -319,7 +319,7 @@ public:
private:
enum {
- DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions
+ DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions
};
Common::String _fileName;
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 1143380..66eefd7 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -38,13 +38,13 @@
namespace ZVision {
AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName)
- : Control(engine, controlKey),
- _fileType(RLF),
- _loopCount(1),
- _currentLoop(0),
- _accumulatedTime(0),
- _cachedFrame(0),
- _cachedFrameNeedsDeletion(false) {
+ : Control(engine, controlKey),
+ _fileType(RLF),
+ _loopCount(1),
+ _currentLoop(0),
+ _accumulatedTime(0),
+ _cachedFrame(0),
+ _cachedFrameNeedsDeletion(false) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
_animation.rlf = new RlfAnimation(fileName, false);
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
index 2ac3691..247fbf7 100644
--- a/engines/zvision/animation_control.h
+++ b/engines/zvision/animation_control.h
@@ -50,13 +50,13 @@ public:
private:
enum FileType {
- RLF = 1,
- AVI = 2
+ RLF = 1,
+ AVI = 2
};
private:
uint32 _animationKey;
-
+
union {
RlfAnimation *rlf;
Video::VideoDecoder *avi;
@@ -76,10 +76,18 @@ private:
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; }
+ 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
diff --git a/engines/zvision/clock.cpp b/engines/zvision/clock.cpp
index c8ee717..d78cf6e 100644
--- a/engines/zvision/clock.cpp
+++ b/engines/zvision/clock.cpp
@@ -30,7 +30,7 @@
namespace ZVision {
-Clock::Clock(OSystem *system)
+Clock::Clock(OSystem *system)
: _system(system),
_lastTime(0),
_deltaTime(0),
diff --git a/engines/zvision/clock.h b/engines/zvision/clock.h
index 3939ba1..3740e07 100644
--- a/engines/zvision/clock.h
+++ b/engines/zvision/clock.h
@@ -53,22 +53,26 @@ public:
*
* @return Delta time since the last frame (in milliseconds)
*/
- uint32 getDeltaTime() const { return _deltaTime; }
+ 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; }
+ 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.
+ * 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.
+ * Has no effect if the clock is already un-paused.
*/
void stop();
};
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 770c540..ab55763 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -42,7 +42,9 @@ public:
Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
virtual ~Control() {}
- uint32 getKey() { return _key; }
+ uint32 getKey() {
+ return _key;
+ }
virtual void enable();
virtual void disable();
@@ -69,7 +71,9 @@ public:
* @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; }
+ virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* Called when a key is pressed. Default is NOP.
*
@@ -88,14 +92,16 @@ public:
* @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; }
+ 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()
+ * NOTE: If this method is overridden, you MUST also override deserialize()
* and needsSerialization()
*
* @param stream Stream to write any needed data to
@@ -118,10 +124,12 @@ public:
*
* @return Does the Control need save game serialization?
*/
- virtual inline bool needsSerialization() { return false; }
+ virtual inline bool needsSerialization() {
+ return false;
+ }
protected:
- ZVision * _engine;
+ ZVision *_engine;
uint32 _key;
bool _enabled;
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index 9023d97..5386c8e 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -30,18 +30,18 @@
namespace ZVision {
-ZorkCursor::ZorkCursor()
+ZorkCursor::ZorkCursor()
: _width(0),
_height(0),
_hotspotX(0),
_hotspotY(0) {
}
-ZorkCursor::ZorkCursor(const Common::String &fileName)
- : _width(0),
- _height(0),
- _hotspotX(0),
- _hotspotY(0) {
+ZorkCursor::ZorkCursor(const Common::String &fileName)
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0) {
Common::File file;
if (!file.open(fileName))
return;
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 18ac28c..8f119c8 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -32,7 +32,7 @@ class String;
namespace ZVision {
-/**
+/**
* Utility class to parse and hold cursor data
* Modeled off Graphics::Cursor
*/
@@ -53,12 +53,24 @@ private:
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 (const byte *)_surface.getPixels(); }
+ 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 (const byte *)_surface.getPixels();
+ }
};
} // End of namespace ZVision
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 4c5ae5e..015e2b0 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -35,19 +35,22 @@
namespace ZVision {
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" };
+ "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow"
+ };
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" };
+ "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr"
+ };
const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
+ "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up"
+ };
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
- : _engine(engine),
- _pixelFormat(pixelFormat),
- _cursorIsPushed(false) {
+ : _engine(engine),
+ _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() == GID_NEMESIS) {
Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 0a369aa..0173bf8 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -48,9 +48,9 @@ public:
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
+ 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;
@@ -77,7 +77,7 @@ public:
/**
* 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 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);
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 4966493..4ab0d6c 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -134,22 +134,22 @@ public:
bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
return false;
- /*
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
- (f == kSavesSupportPlayTime);
- */
+ /*
+ (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);
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
}*/
bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -174,23 +174,23 @@ SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
Common::StringArray filenames;
filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/
+ 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;
- }
- }
- }*/
+ /* 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;
}
@@ -210,17 +210,17 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ 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);
- }
+ // 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);
+ }
}
*/
}
@@ -231,34 +231,34 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
if (in) {
- ZVision::ZVision::SaveHeader header;
- ZVision::ZVision::kReadSaveHeaderError error;
+ ZVision::ZVision::SaveHeader header;
+ ZVision::ZVision::kReadSaveHeaderError error;
- error = ZVision::ZVision::readSaveHeader(in, true, header);
- delete in;
+ error = ZVision::ZVision::readSaveHeader(in, true, header);
+ delete in;
- if (error == ZVision::ZVision::kRSHENoError) {
- SaveStateDescriptor desc(slot, header.description);
+ if (error == ZVision::ZVision::kRSHENoError) {
+ SaveStateDescriptor desc(slot, header.description);
- desc.setThumbnail(header.thumbnail);
+ 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;
+ 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);
+ desc.setSaveDate(year, month, day);
- int hour = (header.saveTime >> 16) & 0xFF;
- int minutes = (header.saveTime >> 8) & 0xFF;
+ int hour = (header.saveTime >> 16) & 0xFF;
+ int minutes = (header.saveTime >> 8) & 0xFF;
- desc.setSaveTime(hour, minutes);
+ desc.setSaveTime(hour, minutes);
- desc.setPlayTime(header.playTime * 1000);
- }
+ desc.setPlayTime(header.playTime * 1000);
+ }
- return desc;
- }
+ return desc;
+ }
}
*/
@@ -266,7 +266,7 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in
}
#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
- REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
#else
- REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
#endif
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index 3441760..1f430da 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -29,9 +29,9 @@
namespace ZVision {
enum ZVisionGameId {
- GID_NONE = 0,
- GID_NEMESIS = 1,
- GID_GRANDINQUISITOR = 2
+ GID_NONE = 0,
+ GID_NEMESIS = 1,
+ GID_GRANDINQUISITOR = 2
};
struct ZVisionGameDescription {
diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp
index a445e1a..5723a4e 100644
--- a/engines/zvision/input_control.cpp
+++ b/engines/zvision/input_control.cpp
@@ -37,12 +37,12 @@
namespace ZVision {
-InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
- _nextTabstop(0),
- _focused(false),
- _textChanged(false),
- _cursorOffset(0) {
+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);
diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h
index aab2c99..3d7db74 100644
--- a/engines/zvision/input_control.h
+++ b/engines/zvision/input_control.h
@@ -48,8 +48,12 @@ private:
uint _cursorOffset;
public:
- void focus() { _focused = true; }
- void unfocus() { _focused = false; }
+ 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);
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 79049b8..b0f9417 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -43,16 +43,16 @@
namespace ZVision {
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
- _frameInfo(0),
- _frameCount(0),
- _startFrame(0),
- _currentFrame(0),
- _lastRenderedFrame(0),
- _mouseIsCaptured(false),
- _isReturning(false),
- _accumulatedTime(0),
- _returnRoutesCurrentFrame(0) {
+ : Control(engine, key),
+ _frameInfo(0),
+ _frameCount(0),
+ _startFrame(0),
+ _currentFrame(0),
+ _lastRenderedFrame(0),
+ _mouseIsCaptured(false),
+ _isReturning(false),
+ _accumulatedTime(0),
+ _returnRoutesCurrentFrame(0) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
@@ -84,7 +84,7 @@ LeverControl::~LeverControl() {
} else if (_fileType == RLF) {
delete _animation.rlf;
}
-
+
delete[] _frameInfo;
}
@@ -194,7 +194,7 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common
if (!_enabled) {
return;
}
-
+
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
@@ -205,7 +205,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
if (!_enabled) {
return;
}
-
+
if (_mouseIsCaptured) {
_mouseIsCaptured = false;
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
@@ -220,7 +220,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
if (!_enabled) {
return false;
}
-
+
bool cursorWasChanged = false;
if (_mouseIsCaptured) {
@@ -276,7 +276,7 @@ bool LeverControl::process(uint32 deltaTimeInMillis) {
renderFrame(_returnRoutesCurrentFrame);
}
}
-
+
return false;
}
@@ -387,7 +387,7 @@ void LeverControl::renderFrame(uint frameNumber) {
// getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
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()
+ 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();
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 8ef8f06..94d23c1 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -41,8 +41,8 @@ public:
private:
enum FileType {
- RLF = 1,
- AVI = 2
+ RLF = 1,
+ AVI = 2
};
struct Direction {
@@ -59,8 +59,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)
- ANIMATION_FRAME_TIME = 30 // In millis
+ 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:
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp
index bbbda6f..b36bf5f 100644
--- a/engines/zvision/lzss_read_stream.cpp
+++ b/engines/zvision/lzss_read_stream.cpp
@@ -28,10 +28,10 @@
namespace ZVision {
LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
- : _source(source),
- // It's convention to set the starting cursor position to blockSize - 16
- _windowCursor(0x0FEE),
- _eosFlag(false) {
+ : _source(source),
+ // It's convention to set the starting cursor position to blockSize - 16
+ _windowCursor(0x0FEE),
+ _eosFlag(false) {
// Clear the window to null
memset(_window, 0, BLOCK_SIZE);
}
@@ -69,9 +69,9 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
}
uint16 length = (high & 0xF) + 2;
- uint16 offset = low | ((high & 0xF0)<<4);
+ 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/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index f6b1eb1..1f7df9d 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -36,7 +36,7 @@ namespace ZVision {
class LzssReadStream : public Common::ReadStream {
public:
/**
- * A class that decompresses LZSS data and implements ReadStream for easy access
+ * A class that decompresses LZSS data and implements ReadStream for easy access
* to the decompiled data.
*
* @param source The source data
@@ -45,7 +45,7 @@ public:
private:
enum {
- BLOCK_SIZE = 0x1000
+ BLOCK_SIZE = 0x1000
};
private:
@@ -64,7 +64,7 @@ private:
*
* @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes
*/
- uint32 decompressBytes(byte* destination, uint32 numberOfBytes);
+ uint32 decompressBytes(byte *destination, uint32 numberOfBytes);
};
}
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 689311b..21a1c41 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -35,7 +35,7 @@
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
+ : Control(engine, key) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -76,7 +76,7 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com
if (!_enabled) {
return;
}
-
+
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
}
@@ -86,7 +86,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
if (!_enabled) {
return false;
}
-
+
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_hoverCursor);
return true;
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 1e73036..2eea52f 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -42,17 +42,17 @@ struct Puzzle {
/** How criteria should be decided */
enum CriteriaOperator {
- EQUAL_TO,
- NOT_EQUAL_TO,
- GREATER_THAN,
- LESS_THAN
+ EQUAL_TO,
+ NOT_EQUAL_TO,
+ GREATER_THAN,
+ LESS_THAN
};
/** Criteria for a Puzzle result to be fired */
struct CriteriaEntry {
/** 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
*/
@@ -64,9 +64,9 @@ struct Puzzle {
};
enum StateFlags {
- ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
- DISABLED = 0x04
+ ONCE_PER_INST = 0x01,
+ DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
+ DISABLED = 0x04
};
uint32 key;
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index cb13606..1406fbc 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -38,19 +38,19 @@
namespace ZVision {
RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
- : _system(system),
- _workingWidth(workingWindow.width()),
- _workingHeight(workingWindow.height()),
- _screenCenterX(_workingWidth / 2),
- _screenCenterY(_workingHeight / 2),
- _workingWindow(workingWindow),
- _pixelFormat(pixelFormat),
- _backgroundWidth(0),
- _backgroundHeight(0),
- _backgroundInverseVelocity(0),
- _backgroundOffset(0, 0),
- _accumulatedVelocityMilliseconds(0),
- _renderTable(_workingWidth, _workingHeight) {
+ : _system(system),
+ _workingWidth(workingWindow.width()),
+ _workingHeight(workingWindow.height()),
+ _screenCenterX(_workingWidth / 2),
+ _screenCenterY(_workingHeight / 2),
+ _workingWindow(workingWindow),
+ _pixelFormat(pixelFormat),
+ _backgroundWidth(0),
+ _backgroundHeight(0),
+ _backgroundInverseVelocity(0),
+ _backgroundOffset(0, 0),
+ _accumulatedVelocityMilliseconds(0),
+ _renderTable(_workingWidth, _workingHeight) {
_workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat);
_backBuffer.create(windowWidth, windowHeight, pixelFormat);
@@ -159,7 +159,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
}
}
-void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
+void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
int16 subRectX = 0;
int16 subRectY = 0;
@@ -184,8 +184,8 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest
if (wrap) {
_backgroundWidth = surface.w;
_backgroundHeight = surface.h;
-
- if (destinationX > 0) {
+
+ if (destinationX > 0) {
// Move destinationX to 0
subRectX = surface.w - destinationX;
destinationX = 0;
@@ -373,7 +373,7 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com
entry.alphaColor = 0;
entry.destX = destX;
entry.destY = destY;
-
+
// Draw the text to the working window
entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap);
entry.width = entry.data->w;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 111bf62..9fedd1d 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -89,7 +89,7 @@ private:
/** 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
* edges of this Rectangle
@@ -106,7 +106,7 @@ private:
/** 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
*/
@@ -135,13 +135,17 @@ public:
/**
* Clears the AlphaEntry list
*/
- void clearAlphaEntries() { _alphaDataEntries.clear(); }
+ 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); }
+ void removeAlphaEntry(uint32 idNumber) {
+ _alphaDataEntries.erase(idNumber);
+ }
/**
* Copies a sub-rectangle of a buffer to the working window
@@ -224,17 +228,17 @@ public:
/**
* 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.
+ * vertical direction.
*
- * This method will not render anything on the screen. So if nothing else is called that renders the
+ * 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
+ * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and
* positive velocities correspond to right / down scrolling
*
* @param velocity Velocity
@@ -249,7 +253,7 @@ public:
*/
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
/**
- * Converts a point in image coordinate space to ***PRE-WARP***
+ * Converts a point in image coordinate space to ***PRE-WARP***
* working window coordinate space
*
* @param point Point in image coordinate space
@@ -268,7 +272,9 @@ public:
RenderTable *getRenderTable();
uint32 getCurrentBackgroundOffset();
- const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
+ const Graphics::Surface *getBackBuffer() {
+ return &_backBuffer;
+ }
/**
* Creates a copy of surface and transposes the data.
@@ -313,7 +319,7 @@ private:
* 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.
+ * 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.
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index b6a6a3d..5a0bae7 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -32,9 +32,9 @@
namespace ZVision {
RenderTable::RenderTable(uint numColumns, uint numRows)
- : _numRows(numRows),
- _numColumns(numColumns),
- _renderState(FLAT) {
+ : _numRows(numRows),
+ _numColumns(numColumns),
+ _renderState(FLAT) {
assert(numRows != 0 && numColumns != 0);
_internalBuffer = new Common::Point[numRows * numColumns];
@@ -97,12 +97,12 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float 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);
+ (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift);
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
+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) {
@@ -115,7 +115,7 @@ 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;
-
+
destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
@@ -154,11 +154,11 @@ void RenderTable::generatePanoramaLookupTable() {
// 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) {
- // To calculate y in cylinder coordinates, we can do similar triangles comparison,
+ // 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));
@@ -179,7 +179,7 @@ void RenderTable::generateTiltLookupTable() {
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 vertical angle between the viewer at the center of a cylinder and y
float alpha = atan(((float)y - halfHeight + 0.01f) / cylinderRadius);
@@ -192,7 +192,7 @@ void RenderTable::generateTiltLookupTable() {
uint32 columnIndex = y * _numColumns;
for (uint x = 0; x < _numColumns; ++x) {
- // To calculate x in cylinder coordinates, we can do similar triangles comparison,
+ // 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/render_table.h b/engines/zvision/render_table.h
index 8980911..401e627 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -35,9 +35,9 @@ public:
public:
enum RenderState {
- PANORAMA,
- TILT,
- FLAT
+ PANORAMA,
+ TILT,
+ FLAT
};
private:
@@ -59,12 +59,14 @@ private:
} _tiltOptions;
public:
- RenderState getRenderState() { return _renderState; }
+ RenderState getRenderState() {
+ return _renderState;
+ }
void setRenderState(RenderState newState);
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect);
+ void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect);
void generateRenderTable();
void setPanoramaFoV(float fov);
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 5f1d41d..795167e 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -35,16 +35,16 @@
namespace ZVision {
-RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
- : _stream(stream),
- _lastFrameRead(0),
- _frameCount(0),
- _width(0),
- _height(0),
- _frameTime(0),
- _frames(0),
- _currentFrame(-1),
- _frameBufferByteSize(0) {
+RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
+ : _stream(stream),
+ _lastFrameRead(0),
+ _frameCount(0),
+ _width(0),
+ _height(0),
+ _frameTime(0),
+ _frames(0),
+ _currentFrame(-1),
+ _frameBufferByteSize(0) {
if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
return;
@@ -255,8 +255,8 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
numberOfSamples--;
}
- // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
- // This function assumes the dest buffer has been memset with 0's.
+ // 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;
@@ -301,8 +301,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
numberOfSamples--;
}
- // If numberOfSamples is >= 0, copy one sample from source to the
- // next (numberOfSamples + 2) dest spots
+ // If numberOfSamples is >= 0, copy one sample from source to the
+ // next (numberOfSamples + 2) dest spots
} else {
if (sourceOffset + 1 >= sourceSize) {
return;
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index fe5b0d6..b0f7ee2 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -41,8 +41,8 @@ public:
private:
enum EncodingType {
- Masked,
- Simple
+ Masked,
+ Simple
};
struct Frame {
@@ -68,10 +68,18 @@ private:
uint32 _frameBufferByteSize;
public:
- uint frameCount() { return _frameCount; }
- uint width() { return _width; }
- uint height() { return _height; }
- uint32 frameTime() { return _frameTime; }
+ uint frameCount() {
+ return _frameCount;
+ }
+ uint width() {
+ return _width;
+ }
+ uint height() {
+ return _height;
+ }
+ uint32 frameTime() {
+ return _frameTime;
+ }
/**
* Seeks to the frameNumber and updates the internal Surface with
@@ -104,7 +112,9 @@ public:
/**
* @return Is the currentFrame is the last frame in the animation?
*/
- bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
+ bool endOfAnimation() {
+ return _currentFrame == (int)_frameCount - 1;
+ }
private:
/**
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index c3deadd..528dd0f 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -106,7 +106,7 @@ void SaveManager::autoSave() {
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);
@@ -171,7 +171,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea
warning("File is not a ZVision save file. Aborting load");
return false;
}
-
+
// Read in the version
header.version = in->readByte();
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index b4770e6..9de1c51 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -54,13 +54,13 @@ private:
static const uint32 SAVEGAME_ID;
enum {
- SAVE_VERSION = 1
+ SAVE_VERSION = 1
};
public:
/**
* Called every room change. Saves the state of the room just before
- * we switched rooms. Uses ZVision::generateAutoSaveFileName() to
+ * we switched rooms. Uses ZVision::generateAutoSaveFileName() to
* create the save file name.
*/
void autoSave();
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index e90408c..5fed820 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -44,7 +44,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
return;
}
- while(!file.eos()) {
+ while (!file.eos()) {
Common::String line = file.readLine();
if (file.err()) {
warning("Error parsing scr file: %s", fileName.c_str());
@@ -57,7 +57,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
if (line.matchString("puzzle:*", true)) {
Puzzle *puzzle = new Puzzle();
- sscanf(line.c_str(),"puzzle:%u",&(puzzle->key));
+ sscanf(line.c_str(), "puzzle:%u", &(puzzle->key));
parsePuzzle(puzzle, file);
if (isGlobal) {
@@ -236,7 +236,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:ttytext*", true)) {
// TODO: Implement ActionTTYText
} else if (line.matchString("*:universe_music*", true)) {
- // TODO: Implement ActionUniverseMusic
+ // TODO: Implement ActionUniverseMusic
} else if (line.matchString("*:copy_file*", true)) {
// Not used. Purposely left empty
} else {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 4b4f130..72e67bf 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -46,13 +46,13 @@ ScriptManager::ScriptManager(ZVision *engine)
ScriptManager::~ScriptManager() {
for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
+ delete(*iter);
}
for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- delete (*iter);
+ delete(*iter);
}
for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
+ delete(*iter);
}
}
@@ -108,10 +108,10 @@ void ScriptManager::createReferenceTable() {
}
void ScriptManager::updateNodes(uint deltaTimeMillis) {
- // If process() returns true, it means the node can be deleted
+ // If process() returns true, it means the node can be deleted
for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
if ((*iter)->process(deltaTimeMillis)) {
- delete (*iter);
+ delete(*iter);
// Remove the node
iter = _activeSideFx.erase(iter);
} else {
@@ -121,7 +121,7 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
if ((*iter)->process(deltaTimeMillis)) {
- delete (*iter);
+ delete(*iter);
// Remove the node
iter = _activeControls.erase(iter);
} else {
@@ -137,7 +137,7 @@ void ScriptManager::checkPuzzleCriteria() {
// Check if the puzzle is already finished
// Also check that the puzzle isn't disabled
if (getStateValue(puzzle->key) == 1 &&
- (puzzle->flags & Puzzle::DISABLED) == 0) {
+ (puzzle->flags & Puzzle::DISABLED) == 0) {
continue;
}
@@ -341,11 +341,11 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
_referenceTable.clear();
_puzzlesToCheck.clear();
for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
+ delete(*iter);
}
_activePuzzles.clear();
for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
+ delete(*iter);
}
_activeControls.clear();
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index c29bc57..d47ee94 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -64,9 +64,9 @@ public:
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
+ /**
+ * 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.
*/
StateMap _globalState;
@@ -169,7 +169,7 @@ public:
private:
/**
* Parses the stream into a Puzzle object
- * Helper method for parseScrFile.
+ * Helper method for parseScrFile.
*
* @param puzzle The object to store what is parsed
* @param stream Scr file stream
@@ -178,7 +178,7 @@ private:
/**
* Parses the stream into a Criteria object
- * Helper method for parsePuzzle.
+ * Helper method for parsePuzzle.
*
* @param criteria Pointer to the Criteria object to fill
* @param stream Scr file stream
@@ -188,7 +188,7 @@ private:
/**
* Parses the stream into a ResultAction objects
- * Helper method for parsePuzzle.
+ * Helper method for parsePuzzle.
*
* @param stream Scr file stream
* @param actionList The list where the results will be added
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index d495655..6f75ad6 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -36,19 +36,25 @@ class ZVision;
class SideFX {
public:
- enum SideFXType{
- SIDEFX_UNK = 0,
- SIDEFX_TIMER = 1
+ enum SideFXType {
+ SIDEFX_UNK = 0,
+ SIDEFX_TIMER = 1
};
SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {}
virtual ~SideFX() {}
- uint32 getKey() { return _key; }
- SideFXType getType() { return _type; }
+ uint32 getKey() {
+ return _key;
+ }
+ SideFXType getType() {
+ return _type;
+ }
- virtual bool process(uint32 deltaTimeInMillis) { return false; }
+ virtual bool process(uint32 deltaTimeInMillis) {
+ return false;
+ }
/**
* Serialize a SideFX for save game use. This should only be used if a SideFX needs
* to save values that would be different from initialization. AKA a TimerNode needs to
@@ -78,10 +84,12 @@ public:
*
* @return Does the SideFX need save game serialization?
*/
- virtual inline bool needsSerialization() { return false; }
+ virtual inline bool needsSerialization() {
+ return false;
+ }
protected:
- ZVision * _engine;
+ ZVision *_engine;
uint32 _key;
SideFXType _type;
diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
index 45b5a89..33fe69d 100644
--- a/engines/zvision/single_value_container.h
+++ b/engines/zvision/single_value_container.h
@@ -30,21 +30,21 @@ class String;
namespace ZVision {
/**
- * A generic single value storage class. It is useful for storing different
+ * 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
+ BOOL,
+ BYTE,
+ INT16,
+ UINT16,
+ INT32,
+ UINT32,
+ FLOAT,
+ DOUBLE,
+ STRING
};
// Constructors
@@ -60,7 +60,7 @@ public:
explicit SingleValueContainer(Common::String value);
// Copy constructor
- explicit SingleValueContainer(const SingleValueContainer& other);
+ explicit SingleValueContainer(const SingleValueContainer &other);
// Destructor
~SingleValueContainer();
@@ -91,10 +91,10 @@ public:
SingleValueContainer &operator=(const double &rhs);
SingleValueContainer &operator=(const Common::String &rhs);
- SingleValueContainer& operator=(const SingleValueContainer &rhs);
+ SingleValueContainer &operator=(const SingleValueContainer &rhs);
/**
- * Retrieve a bool from the container. If the container is not storing a
+ * 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
@@ -102,7 +102,7 @@ public:
*/
bool getBoolValue(bool *returnValue) const;
/**
- * Retrieve a byte from the container. If the container is not storing a
+ * 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
@@ -110,7 +110,7 @@ public:
*/
bool getByteValue(byte *returnValue) const;
/**
- * Retrieve an int16 from the container. If the container is not storing an
+ * 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
@@ -118,7 +118,7 @@ public:
*/
bool getInt16Value(int16 *returnValue) const;
/**
- * Retrieve a uint16 from the container. If the container is not storing a
+ * 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
@@ -126,7 +126,7 @@ public:
*/
bool getUInt16Value(uint16 *returnValue) const;
/**
- * Retrieve an int32 from the container. If the container is not storing an
+ * 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
@@ -134,7 +134,7 @@ public:
*/
bool getInt32Value(int32 *returnValue) const;
/**
- * Retrieve a uint32 from the container. If the container is not storing a
+ * 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
@@ -142,7 +142,7 @@ public:
*/
bool getUInt32Value(uint32 *returnValue) const;
/**
- * Retrieve a float from the container. If the container is not storing a
+ * 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
@@ -150,7 +150,7 @@ public:
*/
bool getFloatValue(float *returnValue) const;
/**
- * Retrieve a double from the container. If the container is not storing a
+ * 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
@@ -158,9 +158,9 @@ public:
*/
bool getDoubleValue(double *returnValue) const;
/**
- * Retrieve a String from the container. If the container is not storing a
+ * 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().
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp
index ab42f3d..f8a4868 100644
--- a/engines/zvision/string_manager.cpp
+++ b/engines/zvision/string_manager.cpp
@@ -36,7 +36,7 @@
namespace ZVision {
-StringManager::StringManager(ZVision *engine)
+StringManager::StringManager(ZVision *engine)
: _engine(engine) {
}
@@ -218,7 +218,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
// Don't spam the user with warnings about UTF-16 support.
// Just do one warning per String
bool charOverflowWarning = false;
-
+
uint16 value = stream.readUint16LE();
while (!stream.eos()) {
// Check for CRLF
@@ -235,7 +235,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
value = '?';
}
char charValue = (char)value;
-
+
asciiString += charValue;
value = stream.readUint16LE();
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index 9cfed52..a6ae6d2 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -59,7 +59,7 @@ private:
};
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
+ 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:
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index dc7dd5b..c7cefd6 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -34,18 +34,18 @@ namespace ZVision {
TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
: SideFX(engine, key, SIDEFX_TIMER) {
- if (_engine->getGameId() == GID_NEMESIS)
- _timeLeft = timeInSeconds * 1000;
- else if (_engine->getGameId() == GID_GRANDINQUISITOR)
- _timeLeft = timeInSeconds * 100;
- _engine->getScriptManager()->setStateValue(_key, 1);
+ if (_engine->getGameId() == GID_NEMESIS)
+ _timeLeft = timeInSeconds * 1000;
+ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ _timeLeft = timeInSeconds * 100;
+ _engine->getScriptManager()->setStateValue(_key, 1);
}
TimerNode::~TimerNode() {
- if (_timeLeft <= 0)
+ if (_timeLeft <= 0)
_engine->getScriptManager()->setStateValue(_key, 2);
else
- _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
+ _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 2caf43a..4a9c95d 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -44,7 +44,9 @@ public:
bool process(uint32 deltaTimeInMillis);
void serialize(Common::WriteStream *stream);
void deserialize(Common::SeekableReadStream *stream);
- inline bool needsSerialization() { return true; }
+ inline bool needsSerialization() {
+ return true;
+ }
private:
int32 _timeLeft;
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index 289b5fb..dde3b2d 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -39,12 +39,12 @@
namespace ZVision {
TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight)
- : _engine(engine),
- _fontHeight(fontHeight),
- _font(0),
- _lineHeight(0),
- _maxCharWidth(0),
- _maxCharHeight(0) {
+ : _engine(engine),
+ _fontHeight(fontHeight),
+ _font(0),
+ _lineHeight(0),
+ _maxCharWidth(0),
+ _maxCharHeight(0) {
}
TruetypeFont::~TruetypeFont(void) {
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index 33f016c..762657a 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -60,10 +60,10 @@ public:
*
* @param filename The file name of the .ttf file to load
*/
- bool loadFile(const Common::String &filename);
+ bool loadFile(const Common::String &filename);
/**
- * Renders the supplied text to a Surface using 0x0 as the
- * background color.
+ * 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
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index d973cb2..1d96b33 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -39,7 +39,7 @@ void writeFileContentsToFile(const Common::String &sourceFile, const Common::Str
return;
}
- byte* buffer = new byte[f.size()];
+ byte *buffer = new byte[f.size()];
f.read(buffer, f.size());
Common::DumpFile dumpFile;
@@ -63,10 +63,10 @@ void trimCommentsAndWhiteSpace(Common::String *string) {
}
void tryToDumpLine(const Common::String &key,
- Common::String &line,
- Common::HashMap<Common::String, byte> *count,
- Common::HashMap<Common::String, bool> *fileAlreadyUsed,
- Common::DumpFile &output) {
+ 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]) {
@@ -203,7 +203,7 @@ void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Com
return;
Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine);
-
+
Common::DumpFile output;
output.open(outputFile);
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index fb571f3..8da88cf 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -72,8 +72,8 @@ void removeDuplicateEntries(Common::Array<T> &container) {
uint newLength = 1;
uint j;
- for(uint i = 1; i < container.size(); i++) {
- for(j = 0; j < newLength; j++) {
+ for (uint i = 1; i < container.size(); i++) {
+ for (j = 0; j < newLength; j++) {
if (container[i] == container[j]) {
break;
}
@@ -93,7 +93,7 @@ void removeDuplicateEntries(Common::Array<T> &container) {
}
/**
- * Gets the name of the file (including extension). Forward or back slashes
+ * 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
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index cd11618..6b7299e 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -66,7 +66,7 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight,
const byte color2 = *srcPtr++;
for (uint i = 0; i < scaleAmount; ++i) {
- uint index = i *2;
+ uint index = i * 2;
dst[index] = color;
dst[index + 1] = color2;
diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp
index 24cff27..3f5ff5a 100644
--- a/engines/zvision/zfs_archive.cpp
+++ b/engines/zvision/zfs_archive.cpp
@@ -52,7 +52,7 @@ ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStrea
ZfsArchive::~ZfsArchive() {
debug(1, "ZfsArchive Destructor Called");
ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
- for ( ; it != _entryHeaders.end(); ++it) {
+ for (; it != _entryHeaders.end(); ++it) {
delete it->_value;
}
}
@@ -79,7 +79,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
// Read in each entry header
for (uint32 i = 0; i < _header.filesPerBlock; ++i) {
ZfsEntryHeader entryHeader;
-
+
entryHeader.name = readEntryName(stream);
entryHeader.offset = stream->readUint32LE();
entryHeader.id = stream->readUint32LE();
@@ -138,7 +138,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
zfsArchive.seek(entryHeader->offset);
// This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory
- byte* buffer = (byte *)malloc(entryHeader->size);
+ byte *buffer = (byte *)malloc(entryHeader->size);
zfsArchive.read(buffer, entryHeader->size);
// Decrypt the data in place
if (_header.xorKey != 0)
diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h
index d7b45e4..fc4be5a 100644
--- a/engines/zvision/zfs_archive.h
+++ b/engines/zvision/zfs_archive.h
@@ -53,7 +53,7 @@ struct ZfsEntryHeader {
uint32 unknown;
};
-typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
+typedef Common::HashMap<Common::String, ZfsEntryHeader *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
class ZfsArchive : public Common::Archive {
public:
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index dc3e332..7ddecce 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -66,5 +66,5 @@ private:
};
} // End of namespace ZVision
-
+
#endif
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index 029600b..ce83add 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -191,9 +191,9 @@ bool RawZorkStream::rewind() {
}
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse) {
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse) {
if (stereo)
assert(stream->size() % 2 == 0);
@@ -201,9 +201,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
}
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse) {
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse) {
return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
}
@@ -221,14 +221,13 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
soundParams = RawZorkStream::_zNemSoundParamLookupTable[i];
}
- }
- else if (engine->getGameId() == GID_GRANDINQUISITOR) {
+ } else if (engine->getGameId() == GID_GRANDINQUISITOR) {
for (int i = 0; i < 6; ++i) {
if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
}
}
-
+
if (soundParams.packed) {
return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
} else {
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 1f261ae..29b5559 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -106,11 +106,19 @@ private:
public:
int readBuffer(int16 *buffer, const int numSamples);
- bool isStereo() const { return true; }
- bool endOfData() const { return _endOfData; }
+ bool isStereo() const {
+ return true;
+ }
+ bool endOfData() const {
+ return _endOfData;
+ }
- int getRate() const { return _rate; }
- Audio::Timestamp getLength() const { return _playtime; }
+ int getRate() const {
+ return _rate;
+ }
+ Audio::Timestamp getLength() const {
+ return _playtime;
+ }
bool rewind();
};
@@ -125,9 +133,9 @@ public:
* @return The new SeekableAudioStream (or 0 on failure).
*/
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
/**
* Creates an audio stream, which plays from the given stream.
@@ -138,9 +146,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,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 940e01a..8be85d3 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -47,28 +47,28 @@
namespace ZVision {
-
+
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
- : Engine(syst),
- _gameDescription(gameDesc),
- _workingWindow_ZGI((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),
- _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT),
- _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI),
- _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
- _desiredFrameTime(33), /* ~30 fps */
- _clock(_system),
- _scriptManager(nullptr),
- _renderManager(nullptr),
- _saveManager(nullptr),
- _stringManager(nullptr),
- _cursorManager(nullptr) {
-
+ : Engine(syst),
+ _gameDescription(gameDesc),
+ _workingWindow_ZGI((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),
+ _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT),
+ _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI),
+ _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
+ _desiredFrameTime(33), /* ~30 fps */
+ _clock(_system),
+ _scriptManager(nullptr),
+ _renderManager(nullptr),
+ _saveManager(nullptr),
+ _stringManager(nullptr),
+ _cursorManager(nullptr) {
+
debug(1, "ZVision::ZVision");
}
ZVision::~ZVision() {
debug(1, "ZVision::~ZVision");
-
+
// Dispose of resources
delete _console;
delete _cursorManager;
@@ -77,15 +77,15 @@ ZVision::~ZVision() {
delete _renderManager;
delete _scriptManager;
delete _rnd;
-
+
// Remove all of our debug levels
DebugMan.clearAllDebugChannels();
}
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.
+ // 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);
@@ -143,7 +143,7 @@ Common::Error ZVision::run() {
processEvents();
- // Call _renderManager->update() first so the background renders
+ // Call _renderManager->update() first so the background renders
// before anything that puzzles/controls will render
_renderManager->update(deltaTime);
_scriptManager->update(deltaTime);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 89aa60f..10711b1 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -51,7 +51,7 @@ class CursorManager;
class StringManager;
class SaveManager;
class RlfAnimation;
-
+
class ZVision : public Engine {
public:
ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
@@ -68,19 +68,19 @@ public:
private:
enum {
- WINDOW_WIDTH = 640,
- WINDOW_HEIGHT = 480,
+ WINDOW_WIDTH = 640,
+ WINDOW_HEIGHT = 480,
- //Zork nemesis working window sizes
- ZNM_WORKING_WINDOW_WIDTH = 512,
- ZNM_WORKING_WINDOW_HEIGHT = 320,
+ //Zork nemesis working window sizes
+ ZNM_WORKING_WINDOW_WIDTH = 512,
+ ZNM_WORKING_WINDOW_HEIGHT = 320,
- //ZGI(and default) working window sizes
- WORKING_WINDOW_WIDTH = 640,
- WORKING_WINDOW_HEIGHT = 344,
+ //ZGI(and default) working window sizes
+ WORKING_WINDOW_WIDTH = 640,
+ WORKING_WINDOW_HEIGHT = 344,
- ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 400 // Pixels per second
+ ROTATION_SCREEN_EDGE_OFFSET = 60,
+ MAX_ROTATION_SPEED = 400 // Pixels per second
};
Console *_console;
@@ -112,13 +112,27 @@ public:
Common::Error run();
void pauseEngineIntern(bool pause);
- ScriptManager *getScriptManager() const { return _scriptManager; }
- 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; }
+ ScriptManager *getScriptManager() const {
+ return _scriptManager;
+ }
+ 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;
+ }
/**
* Play a video until it is finished. This is a blocking call. It will call
@@ -149,5 +163,5 @@ private:
};
} // End of namespace ZVision
-
+
#endif
Commit: bbe29500ccf0dd6d31ebb5bfcbbf707c74a4500a
https://github.com/scummvm/scummvm/commit/bbe29500ccf0dd6d31ebb5bfcbbf707c74a4500a
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-20T18:39:19Z
Commit Message:
ZVISION: Forgotten change cursos to pressed in ZGI code.
Changed paths:
engines/zvision/cursor_manager.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index 015e2b0..385e4dc 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -105,6 +105,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
char buffer[25];
strcpy(buffer, _zgiCursorFileNames[i]);
buffer[3] += 2;
+ changeCursor(ZorkCursor(buffer));
}
return;
}
Commit: dbdefe23e9861781af63608cd450cfaed86de89a
https://github.com/scummvm/scummvm/commit/dbdefe23e9861781af63608cd450cfaed86de89a
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-20T20:06:12Z
Commit Message:
ZVISION: New render functions for rendering surface-to-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 1406fbc..a240e76 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -159,6 +159,173 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
}
}
+void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) {
+ if (src.format != dst.format)
+ return;
+
+ Common::Rect dstRect = _dstRect;
+ if (dstRect.isEmpty())
+ dstRect = Common::Rect(dst.w, dst.h);
+ dstRect.clip(dst.w, dst.h);
+
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+
+ if (!srcRect.isValidRect() || !dstRect.isValidRect())
+ return;
+
+ Common::Rect rendRect = srcRect;
+ rendRect.clip(dstRect.width(), dstRect.height());
+
+ if (rendRect.isEmpty() || !rendRect.isValidRect())
+ return;
+
+ // Copy rendRect from src surface to dst surface
+ byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top);
+ byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
+
+ int32 w = rendRect.width();
+ int32 h = rendRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel);
+ src_buf += src.pitch;
+ dst_buf += dst.pitch;
+ }
+}
+
+void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) {
+ if (src.format != dst.format)
+ return;
+
+ Common::Rect dstRect = _dstRect;
+ if (dstRect.isEmpty())
+ dstRect = Common::Rect(dst.w, dst.h);
+ dstRect.clip(dst.w, dst.h);
+
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+
+ if (!srcRect.isValidRect() || !dstRect.isValidRect())
+ return;
+
+ Common::Rect rendRect = srcRect;
+ rendRect.clip(dstRect.width(), dstRect.height());
+
+ if (rendRect.isEmpty() || !rendRect.isValidRect())
+ return;
+
+ uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1);
+
+ // Copy rendRect from src surface to dst surface
+ byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top);
+ byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
+
+ int32 w = rendRect.width();
+ int32 h = rendRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ switch (src.format.bytesPerPixel) {
+ case 1: {
+ uint *src_tmp = (uint *)src_buf;
+ uint *dst_tmp = (uint *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ case 2: {
+ uint16 *src_tmp = (uint16 *)src_buf;
+ uint16 *dst_tmp = (uint16 *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ case 4: {
+ uint32 *src_tmp = (uint32 *)src_buf;
+ uint32 *dst_tmp = (uint32 *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ src_buf += src.pitch;
+ dst_buf += dst.pitch;
+ }
+}
+
+void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) {
+ if (!Common::Rect(dst.w, dst.h).contains(dstPt))
+ return;
+ Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
+ copyRectToSurface(src, dst, srcRect, dstRect);
+}
+
+void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) {
+ if (!Common::Rect(dst.w, dst.h).contains(dstPt))
+ return;
+ Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
+ copyRectToSurface(src, dst, srcRect, dstRect, keycolor);
+}
+
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
+
+ Common::Rect srcRect(surface.w, surface.h);
+ Common::Point dstPt(destX, destY);
+
+ copyRectToSurface(surface, _currentBackground, srcRect, dstPt);
+ moveBackground(0);
+}
+
+void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY) {
+ Common::Rect srcRect(surface.w, surface.h);
+ Common::Point dstPt(destX, destY);
+
+ copyRectToSurface(surface, _currentBackground, srcRect, dstPt);
+ moveBackground(0);
+}
+
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
+
+ Common::Rect srcRect(surface.w, surface.h);
+ Common::Point dstPt(destX, destY);
+
+ copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor);
+ moveBackground(0);
+}
+
+void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) {
+ Common::Rect srcRect(surface.w, surface.h);
+ Common::Point dstPt(destX, destY);
+
+ copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor);
+ moveBackground(0);
+}
+
void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
int16 subRectX = 0;
int16 subRectY = 0;
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 9fedd1d..37bfcfa 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -218,6 +218,86 @@ public:
void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false);
/**
+ * Copies a rectangla of source surface and copy to destination rect.
+ *
+ * @param src Source surface
+ * @param dst Destenation surface
+ * @param srcRect Rect of source surface
+ * @param dstRect Rect for destenation surface
+ */
+ void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect);
+
+ /**
+ * Copies a rectangla of source surface and copy to destination rect.
+ *
+ * @param src Source surface
+ * @param dst Destenation surface
+ * @param srcRect Rect of source surface
+ * @param dstRect Rect for destenation surface
+ * @param colorkey Transparent color
+ */
+ void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey);
+
+ /**
+ * Copies a rectangla of source surface and copy to destination rect.
+ *
+ * @param src Source surface
+ * @param dst Destenation surface
+ * @param srcRect Rect of source surface
+ * @param dstPt Point for destenation surface
+ */
+ void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt);
+
+ /**
+ * Copies a rectangla of source surface and copy to destination rect.
+ *
+ * @param src Source surface
+ * @param dst Destenation surface
+ * @param srcRect Rect of source surface
+ * @param dstPt Point for destenation surface
+ * @param colorkey Transparent color
+ */
+ void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey);
+
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @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!
+ */
+ void renderImageToBackground(const Common::String &fileName, int16 destinationX, int16 destinationY);
+
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @param surface 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 renderImageToBackground(Graphics::Surface &surface, int16 destinationX, int16 destinationY);
+
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @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 colorkey Transparent color
+ */
+ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
+
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @param surface 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!
+ * @param colorkey Transparent color
+ */
+ void renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey);
+
+ /**
* 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)
*
Commit: db3d154c63669752d0b1d75dd8f75707b671d862
https://github.com/scummvm/scummvm/commit/db3d154c63669752d0b1d75dd8f75707b671d862
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-20T20:07:31Z
Commit Message:
ZVISION: SetPartialScreen must update part of currentBackground image.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 1d4ce9c..21c0154 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -321,10 +321,10 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
bool ActionSetPartialScreen::execute(ZVision *engine) {
RenderManager *renderManager = engine->getRenderManager();
- if (_backgroundColor > 0) {
- renderManager->clearWorkingWindowTo555Color(_backgroundColor);
- }
- renderManager->renderImageToScreen(_fileName, _x, _y);
+ if (_backgroundColor >= 0)
+ renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
+ else
+ renderManager->renderImageToBackground(_fileName, _x, _y);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index e7a4ea3..15923d6 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -300,7 +300,7 @@ private:
uint _x;
uint _y;
Common::String _fileName;
- uint16 _backgroundColor;
+ int32 _backgroundColor;
};
class ActionSetScreen : public ResultAction {
Commit: 2e0e9dc1f64451485532bbd5b3532b6155288f6c
https://github.com/scummvm/scummvm/commit/2e0e9dc1f64451485532bbd5b3532b6155288f6c
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-21T16:39:40+07:00
Commit Message:
ZVISION: Fix changelocation sscanf format string to original format.
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 21c0154..4976bd4 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -86,7 +86,7 @@ bool ActionAttenuate::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_offset);
+ sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset);
}
bool ActionChangeLocation::execute(ZVision *engine) {
Commit: 9888e66603e1377ff370cbf667efba9d49d5e45d
https://github.com/scummvm/scummvm/commit/9888e66603e1377ff370cbf667efba9d49d5e45d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-22T08:24:30Z
Commit Message:
ZVISION: Added system StateKey names enum.
Changed paths:
engines/zvision/script_manager.h
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index d47ee94..767919e 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -40,6 +40,61 @@ namespace ZVision {
class ZVision;
+enum StateKey {
+ StateKey_World = 3,
+ StateKey_Room = 4,
+ StateKey_Node = 5,
+ StateKey_View = 6,
+ StateKey_ViewPos = 7,
+ StateKey_KeyPress = 8,
+ StateKey_InventoryItem = 9,
+ StateKey_LMouse = 10,
+ StateKey_Rounds = 12,
+ StateKey_Venus = 13,
+ StateKey_RMouse = 18,
+ StateKey_MenuState = 19,
+ StateKey_RestoreFlag = 20,
+ StateKey_Quitting = 39,
+ StateKey_LastWorld = 40,
+ StateKey_LastRoom = 41,
+ StateKey_LastNode = 42,
+ StateKey_LastView = 43,
+ StateKey_LastViewPos = 44,
+ StateKey_Menu_LastWorld = 45,
+ StateKey_Menu_LastRoom = 46,
+ StateKey_Menu_LastNode = 47,
+ StateKey_Menu_LastView = 48,
+ StateKey_Menu_LastViewPos = 49,
+ StateKey_KbdRotateSpeed = 50,
+ StateKey_Subtitles = 51,
+ StateKey_StreamSkipKey = 52,
+ StateKey_RotateSpeed = 53,
+ StateKey_Volume = 56,
+ StateKey_Qsound = 57,
+ StateKey_VenusEnable = 58,
+ StateKey_HighQuality = 59,
+ StateKey_VideoLineSkip = 65,
+ StateKey_Platform = 66,
+ StateKey_InstallLevel = 67,
+ StateKey_CountryCode = 68,
+ StateKey_CPU = 69,
+ StateKey_MovieCursor = 70,
+ StateKey_NoTurnAnim = 71,
+ StateKey_WIN958 = 72,
+ StateKey_ShowErrorDlg = 73,
+ StateKey_DebugCheats = 74,
+ StateKey_JapanFonts = 75,
+ StateKey_Brightness = 77,
+ StateKey_EF9_B = 91,
+ StateKey_EF9_G = 92,
+ StateKey_EF9_R = 93,
+ StateKey_EF9_Speed = 94,
+ StateKey_Inv_0_Slot = 100,
+ StateKey_Inv_1_Slot = 101,
+ StateKey_Inv_49_Slot = 149,
+ StateKey_Inv_TotalSlots = 150
+};
+
struct Location {
Location() : world('g'), room('a'), node('r'), view('y'), offset(0) {}
Commit: 3e51ed6a785ffb1871ffdbfff6aaad309959a1ee
https://github.com/scummvm/scummvm/commit/3e51ed6a785ffb1871ffdbfff6aaad309959a1ee
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-22T12:02:03+07:00
Commit Message:
ZVISION: Set right reaction for mouse up/down events.
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 1103dc3..ede9127 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -43,17 +43,28 @@ void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_LBUTTONDOWN:
+ _cursorManager->cursorDown(true);
+ _scriptManager->setStateValue(StateKey_LMouse, 1);
onMouseDown(_event.mouse);
break;
case Common::EVENT_LBUTTONUP:
+ _cursorManager->cursorDown(false);
+ _scriptManager->setStateValue(StateKey_LMouse, 0);
onMouseUp(_event.mouse);
break;
case Common::EVENT_RBUTTONDOWN:
+ _cursorManager->cursorDown(true);
+ _scriptManager->setStateValue(StateKey_RMouse, 1);
// TODO: Inventory logic
break;
+ case Common::EVENT_RBUTTONUP:
+ _cursorManager->cursorDown(false);
+ _scriptManager->setStateValue(StateKey_RMouse, 0);
+ break;
+
case Common::EVENT_MOUSEMOVE:
onMouseMove(_event.mouse);
break;
@@ -87,15 +98,11 @@ void ZVision::processEvents() {
}
void ZVision::onMouseDown(const Common::Point &pos) {
- _cursorManager->cursorDown(true);
-
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
_scriptManager->onMouseDown(pos, imageCoord);
}
void ZVision::onMouseUp(const Common::Point &pos) {
- _cursorManager->cursorDown(false);
-
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
_scriptManager->onMouseUp(pos, imageCoord);
}
Commit: 803ff02136ddc102084094430aabc366192afe99
https://github.com/scummvm/scummvm/commit/803ff02136ddc102084094430aabc366192afe99
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-24T22:25:34Z
Commit Message:
ZVISION: New data types for script files and puzzle reference.
Changed paths:
engines/zvision/script_manager.h
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 767919e..6dd2190 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -119,6 +119,24 @@ public:
private:
ZVision *_engine;
+
+ struct script_scope {
+ uint32 proc_count;
+
+ PuzzleList *scope_queue; // For adding puzzles to queue
+ PuzzleList *exec_queue; // Switch to it when execute
+ PuzzleList _priv_queue_one;
+ PuzzleList _priv_queue_two;
+
+ PuzzleList _puzzles;
+ ControlList _controls;
+ };
+
+ struct puzzle_ref {
+ Puzzle *puz;
+ script_scope *scope;
+ };
+
/**
* 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
Commit: d8ad0e5235b036a69bdcae68ec99020de95c47bc
https://github.com/scummvm/scummvm/commit/d8ad0e5235b036a69bdcae68ec99020de95c47bc
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-24T22:45:55Z
Commit Message:
ZVISION: Added clean function for script scope and body for queue
routine.
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 72e67bf..515fd7a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -216,6 +216,24 @@ void ScriptManager::cleanStateTable() {
}
}
+void ScriptManager::cleanScriptScope(script_scope &scope) {
+ scope._priv_queue_one.clear();
+ scope._priv_queue_two.clear();
+ scope.scope_queue = &scope._priv_queue_one;
+ scope.exec_queue = &scope._priv_queue_two;
+ for (PuzzleList::iterator iter = scope._puzzles.begin(); iter != scope._puzzles.end(); ++iter)
+ delete(*iter);
+
+ scope._puzzles.clear();
+
+ for (ControlList::iterator iter = scope._controls.begin(); iter != scope._controls.end(); ++iter)
+ delete(*iter);
+
+ scope._controls.clear();
+
+ scope.proc_count = 0;
+}
+
uint ScriptManager::getStateValue(uint32 key) {
if (_globalState.contains(key))
return _globalState[key];
@@ -223,6 +241,9 @@ uint ScriptManager::getStateValue(uint32 key) {
return 0;
}
+void ScriptManager::queuePuzzles(uint32 key) {
+}
+
void ScriptManager::setStateValue(uint32 key, uint value) {
_globalState[key] = value;
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 6dd2190..a532453 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -163,6 +163,7 @@ private:
public:
void initialize();
void update(uint deltaTimeMillis);
+ void queuePuzzles(uint32 key);
uint getStateValue(uint32 key);
void setStateValue(uint32 key, uint value);
@@ -228,6 +229,7 @@ private:
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();
void cleanStateTable();
+ void cleanScriptScope(script_scope &scope);
// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
public:
Commit: c87ca1bc9c9023b2f85b5151e790f6ebe60ea2c2
https://github.com/scummvm/scummvm/commit/c87ca1bc9c9023b2f85b5151e790f6ebe60ea2c2
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-25T08:13:59Z
Commit Message:
ZVISION: Add flag to puzzle structure for use with new referenceTable.
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 2eea52f..1b30829 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -74,6 +74,7 @@ struct Puzzle {
// This has to be list of pointers because ResultAction is abstract
Common::List<ResultAction *> resultActions;
uint flags;
+ bool addedBySetState;
};
} // End of namespace ZVision
Commit: 91cbb1ec790a604309c766ef38f6a2704922365b
https://github.com/scummvm/scummvm/commit/91cbb1ec790a604309c766ef38f6a2704922365b
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-25T14:52:40+07:00
Commit Message:
ZVISION: Move setState to use queuePuzzle.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 515fd7a..7531182 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -245,13 +245,12 @@ void ScriptManager::queuePuzzles(uint32 key) {
}
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));
- }
- }
+ if (value == 0)
+ _globalState.erase(key);
+ else
+ _globalState[key] = value;
+ debug("setStateValue %d %d\n", key , value);
+ queuePuzzles(key);
}
void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
Commit: 8e4070c68b9a6a5e81d80f6805a199c2872089fe
https://github.com/scummvm/scummvm/commit/8e4070c68b9a6a5e81d80f6805a199c2872089fe
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-25T15:39:38+07:00
Commit Message:
ZVISION: Added global StateFlags and set/get/unset functions.
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 7531182..01a6e6d 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -253,6 +253,30 @@ void ScriptManager::setStateValue(uint32 key, uint value) {
queuePuzzles(key);
}
+uint ScriptManager::getStateFlag(uint32 key) {
+ if (_globalStateFlags.contains(key))
+ return _globalStateFlags[key];
+ else
+ return 0;
+}
+
+void ScriptManager::setStateFlag(uint32 key, uint value) {
+ queuePuzzles(key);
+
+ _globalStateFlags[key] |= value;
+}
+
+void ScriptManager::unsetStateFlag(uint32 key, uint value) {
+ queuePuzzles(key);
+
+ if (_globalStateFlags.contains(key)) {
+ _globalStateFlags[key] &= ~value;
+
+ if (_globalStateFlags[key] == 0)
+ _globalStateFlags.erase(key);
+ }
+}
+
void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
_globalState[key] += valueToAdd;
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index a532453..71fefaf 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -143,6 +143,8 @@ private:
* particular state key are checked after the key is modified.
*/
StateMap _globalState;
+ /** Holds execute flags */
+ StateMap _globalStateFlags;
/** References _globalState keys to Puzzles */
PuzzleMap _referenceTable;
/** Holds the Puzzles that should be checked this frame */
@@ -169,6 +171,10 @@ public:
void setStateValue(uint32 key, uint value);
void addToStateValue(uint32 key, uint valueToAdd);
+ uint getStateFlag(uint32 key);
+ void setStateFlag(uint32 key, uint value);
+ void unsetStateFlag(uint32 key, uint value);
+
void addControl(Control *control);
Control *getControl(uint32 key);
Commit: c0a709dc23c689b094c2dab1038447267d6fb8bd
https://github.com/scummvm/scummvm/commit/c0a709dc23c689b094c2dab1038447267d6fb8bd
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-25T17:12:08+07:00
Commit Message:
ZVISION: Refactoring script manager, massive changes.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/console.cpp
engines/zvision/save_manager.cpp
engines/zvision/scr_file_handling.cpp
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 4976bd4..3c0adb4 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -124,7 +124,6 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) {
bool ActionDisableControl::execute(ZVision *engine) {
debug("Disabling control %u", _key);
- engine->getScriptManager()->disableControl(_key);
return true;
}
@@ -141,7 +140,6 @@ ActionEnableControl::ActionEnableControl(const Common::String &line) {
bool ActionEnableControl::execute(ZVision *engine) {
debug("Enabling control %u", _key);
- engine->getScriptManager()->enableControl(_key);
return true;
}
@@ -220,8 +218,6 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
// 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;
}
@@ -267,9 +263,6 @@ bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
control->setXPos(_x1);
control->setYPost(_y1);
- // Enable the control. ScriptManager will take care of the rest
- control->enable();
-
return true;
}
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index a095d3f..400dcb3 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -197,7 +197,6 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
SearchMan.listMatchingMembers(list, "*.scr");
for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- _engine->getScriptManager()->parseScrFile((*iter)->getName());
}
return true;
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index 528dd0f..e8947d8 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -128,8 +128,6 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
// 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) {
@@ -160,9 +158,6 @@ Common::Error SaveManager::loadGame(uint slot) {
// Load the room
scriptManager->changeLocation(world, room, node, view, offset);
- // Update the controls
- scriptManager->deserializeControls(saveFile);
-
return Common::kNoError;
}
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 5fed820..4d18306 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -37,7 +37,7 @@
namespace ZVision {
-void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
+void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) {
Common::File file;
if (!file.open(fileName)) {
warning("Script file not found: %s", fileName.c_str());
@@ -58,17 +58,18 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
if (line.matchString("puzzle:*", true)) {
Puzzle *puzzle = new Puzzle();
sscanf(line.c_str(), "puzzle:%u", &(puzzle->key));
-
+ if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST)
+ setStateValue(puzzle->key, 0);
parsePuzzle(puzzle, file);
- if (isGlobal) {
- _globalPuzzles.push_back(puzzle);
- } else {
- _activePuzzles.push_back(puzzle);
- }
+ scope._puzzles.push_back(puzzle);
+
} else if (line.matchString("control:*", true)) {
- parseControl(line, file);
+ Control *ctrl = parseControl(line, file);
+ if (ctrl)
+ scope._controls.push_back(ctrl);
}
}
+ scope.proc_count = 0;
}
void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
@@ -81,12 +82,14 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre
} else if (line.matchString("results {", true)) {
parseResults(stream, puzzle->resultActions);
} else if (line.matchString("flags {", true)) {
- puzzle->flags = parseFlags(stream);
+ setStateFlag(puzzle->key, parseFlags(stream));
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
+
+ puzzle->addedBySetState = 0;
}
bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const {
@@ -273,7 +276,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
return flags;
}
-void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
+Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
uint32 key;
char controlTypeBuffer[20];
@@ -282,21 +285,20 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
- _activeControls.push_back(new PushToggleControl(_engine, key, stream));
- return;
+ return new PushToggleControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
- return;
+ return NULL;
} else if (controlType.equalsIgnoreCase("pana")) {
Control::parsePanoramaControl(_engine, stream);
- return;
+ return NULL;
} else if (controlType.equalsIgnoreCase("tilt")) {
Control::parseTiltControl(_engine, stream);
- return;
+ return NULL;
} else if (controlType.equalsIgnoreCase("lever")) {
- _activeControls.push_back(new LeverControl(_engine, key, stream));
- return;
+ return new LeverControl(_engine, key, stream);
}
+ return NULL;
}
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 01a6e6d..74035fd 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -41,69 +41,86 @@ namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine)
: _engine(engine),
- _currentlyFocusedControl(0) {
+ _currentlyFocusedControl(0),
+ _activeControls(NULL) {
}
ScriptManager::~ScriptManager() {
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete(*iter);
- }
- for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- delete(*iter);
- }
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete(*iter);
- }
+ cleanScriptScope(universe);
+ cleanScriptScope(world);
+ cleanScriptScope(room);
+ cleanScriptScope(nodeview);
}
void ScriptManager::initialize() {
- parseScrFile("universe.scr", true);
+ cleanScriptScope(universe);
+ cleanScriptScope(world);
+ cleanScriptScope(room);
+ cleanScriptScope(nodeview);
+
+ _currentLocation.node = '0';
+ _currentLocation.world = '0';
+ _currentLocation.room = '0';
+ _currentLocation.view = '0';
+
+ parseScrFile("universe.scr", universe);
changeLocation('g', 'a', 'r', 'y', 0);
}
void ScriptManager::update(uint deltaTimeMillis) {
+ if (_currentLocation.node != _nextLocation.node ||
+ _currentLocation.room != _nextLocation.room ||
+ _currentLocation.view != _nextLocation.view ||
+ _currentLocation.world != _nextLocation.world)
+ do_changeLocation();
+
updateNodes(deltaTimeMillis);
- checkPuzzleCriteria();
+ execScope(nodeview);
+ execScope(room);
+ execScope(world);
+ execScope(universe);
+ updateControls(deltaTimeMillis);
+}
+
+void ScriptManager::execScope(script_scope &scope) {
+ // Swap queues
+ PuzzleList *tmp = scope.exec_queue;
+ scope.exec_queue = scope.scope_queue;
+ scope.scope_queue = tmp;
+
+ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
+ (*PuzzleIter)->addedBySetState = 0;
+
+ if (scope.proc_count < 2 || getStateValue(76)) {
+ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
+ checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ } else {
+ for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter)
+ checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ }
+
+ scope.exec_queue->clear();
+
+ if (scope.proc_count < 2) {
+ scope.proc_count++;
+ }
}
-void ScriptManager::createReferenceTable() {
+void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) {
// Iterate through each local Puzzle
- for (PuzzleList::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {
- Puzzle *puzzlePtr = (*activePuzzleIter);
+ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) {
+ Puzzle *puzzlePtr = (*PuzzleIter);
- // 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);
- }
- }
- }
- }
+ puzzle_ref ref;
+ ref.scope = &scope;
+ ref.puz = puzzlePtr;
- // Iterate through each global Puzzle
- for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
- Puzzle *puzzlePtr = (*globalPuzzleIter);
+ _referenceTable[puzzlePtr->key].push_back(ref);
// 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 (entryIter->argumentIsAKey) {
- _referenceTable[entryIter->argument].push_back(puzzlePtr);
- }
- }
- }
- }
-
- // Remove duplicate entries
- for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
- removeDuplicateEntries(referenceTableIter->_value);
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter)
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter)
+ _referenceTable[entryIter->key].push_back(ref);
}
}
@@ -118,90 +135,85 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) {
++iter;
}
}
- // If process() returns true, it means the node can be deleted
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
- if ((*iter)->process(deltaTimeMillis)) {
- delete(*iter);
- // Remove the node
- iter = _activeControls.erase(iter);
- } else {
- ++iter;
- }
- }
}
-void ScriptManager::checkPuzzleCriteria() {
- while (!_puzzlesToCheck.empty()) {
- Puzzle *puzzle = _puzzlesToCheck.pop();
+void ScriptManager::updateControls(uint deltaTimeMillis) {
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
+ (*iter)->process(deltaTimeMillis);
+}
- // Check if the puzzle is already finished
- // Also check that the puzzle isn't disabled
- if (getStateValue(puzzle->key) == 1 &&
- (puzzle->flags & Puzzle::DISABLED) == 0) {
- continue;
- }
+void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
+ // Check if the puzzle is already finished
+ // Also check that the puzzle isn't disabled
+ if (getStateValue(puzzle->key) == 1 &&
+ (getStateFlag(puzzle->key) & Puzzle::DISABLED) == 0) {
+ return;
+ }
- // Check each Criteria
-
- bool criteriaMet = false;
- 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;
- }
+ // Check each Criteria
+ if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0)
+ return;
+
+ bool criteriaMet = false;
+ 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 any of the Criteria are *fully* met, then execute the results
- if (criteriaMet) {
+ // If one check returns false, don't keep checking
+ if (!criteriaMet) {
break;
}
}
- // criteriaList can be empty. Aka, the puzzle should be executed immediately
- if (puzzle->criteriaList.empty() || criteriaMet) {
- debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
+ // If any of the Criteria are *fully* met, then execute the results
+ if (criteriaMet) {
+ break;
+ }
+ }
- // Set the puzzle as completed
- setStateValue(puzzle->key, 1);
+ // criteriaList can be empty. Aka, the puzzle should be executed immediately
+ if (puzzle->criteriaList.empty() || criteriaMet) {
+ debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
- 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
+ setStateValue(puzzle->key, 1);
+ 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;
}
}
+
+ if (!shouldContinue) {
+ return;
+ }
}
}
@@ -242,6 +254,13 @@ uint ScriptManager::getStateValue(uint32 key) {
}
void ScriptManager::queuePuzzles(uint32 key) {
+ if (_referenceTable.contains(key)) {
+ for (Common::Array<puzzle_ref>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter)
+ if (!iter->puz->addedBySetState) {
+ iter->scope->scope_queue->push_back(iter->puz);
+ iter->puz->addedBySetState = true;
+ }
+ }
}
void ScriptManager::setStateValue(uint32 key, uint value) {
@@ -281,40 +300,16 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
_globalState[key] += valueToAdd;
}
-void ScriptManager::addControl(Control *control) {
- _activeControls.push_back(control);
-}
Control *ScriptManager::getControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- return (*iter);
- }
- }
return nullptr;
}
-void ScriptManager::enableControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- (*iter)->enable();
- break;
- }
- }
-}
-
-void ScriptManager::disableControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- (*iter)->disable();
- break;
- }
- }
-}
-
void ScriptManager::focusControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
if (controlKey == key) {
@@ -342,20 +337,26 @@ SideFX *ScriptManager::getSideFX(uint32 key) {
}
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ 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 (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ 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) {
+ if (!_activeControls)
+ return false;
bool cursorWasChanged = false;
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
}
@@ -363,35 +364,56 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo
}
void ScriptManager::onKeyDown(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
(*iter)->onKeyDown(keyState);
}
}
void ScriptManager::onKeyUp(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ for (ControlList::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(1, "Changing location to: %c %c %c %c %u", world, room, node, view, offset);
+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;
+}
+
+void ScriptManager::do_changeLocation() {
+ assert(_nextLocation.world != 0);
+ debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
// Auto save
- _engine->getSaveManager()->autoSave();
+ //_engine->getSaveManager()->autoSave();
// Clear all the containers
_referenceTable.clear();
- _puzzlesToCheck.clear();
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete(*iter);
- }
- _activePuzzles.clear();
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete(*iter);
- }
- _activeControls.clear();
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+ cleanScriptScope(world);
+
+ // 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, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
+
+ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
+ parseScrFile(fileName, room);
+ addPuzzlesToReferenceTable(room);
+
+ fileName = Common::String::format("%c.scr", _nextLocation.world);
+ parseScrFile(fileName, world);
+ addPuzzlesToReferenceTable(world);
+
+ _activeControls = &nodeview._controls;
// Revert to the idle cursor
_engine->getCursorManager()->revertToIdle();
@@ -402,50 +424,14 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
// Remove any alphaEntries
_engine->getRenderManager()->clearAlphaEntries();
- // 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);
-
// Change the background position
- _engine->getRenderManager()->setBackgroundPosition(offset);
+ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- // Enable all the controls
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->enable();
- }
-
- // Add all the local puzzles to the queue to be checked
- 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);
- }
-
- _puzzlesToCheck.push((*iter));
- }
-
- // Add all the global puzzles to the queue to be checked
- 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);
- }
-
- _puzzlesToCheck.push((*iter));
- }
-
- // Create the puzzle reference table
- createReferenceTable();
+ execScope(room);
+ execScope(nodeview);
// Update _currentLocation
- _currentLocation.world = world;
- _currentLocation.room = room;
- _currentLocation.node = node;
- _currentLocation.view = view;
- _currentLocation.offset = offset;
+ _currentLocation = _nextLocation;
}
void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
@@ -474,36 +460,6 @@ 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 (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->needsSerialization()) {
- numberOfControlsNeedingSerialization++;
- }
- }
- stream->writeUint32LE(numberOfControlsNeedingSerialization);
-
- for (ControlList::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 (ControlList::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 71fefaf..90df2cc 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -105,7 +105,6 @@ 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;
@@ -137,6 +136,8 @@ private:
script_scope *scope;
};
+ typedef Common::HashMap<uint32, Common::Array<puzzle_ref> > PuzzleMap;
+
/**
* 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
@@ -147,18 +148,19 @@ private:
StateMap _globalStateFlags;
/** References _globalState keys to Puzzles */
PuzzleMap _referenceTable;
- /** Holds the Puzzles that should be checked this frame */
- PuzzleQueue _puzzlesToCheck;
- /** Holds the currently active puzzles */
- PuzzleList _activePuzzles;
- /** Holds the global puzzles */
- PuzzleList _globalPuzzles;
/** Holds the currently active controls */
- ControlList _activeControls;
+ ControlList *_activeControls;
+
+ script_scope universe;
+ script_scope world;
+ script_scope room;
+ script_scope nodeview;
+
/** Holds the currently active timers, musics, other */
SideFXList _activeSideFx;
Location _currentLocation;
+ Location _nextLocation;
uint32 _currentlyFocusedControl;
@@ -221,21 +223,25 @@ public:
*/
void onKeyUp(Common::KeyState keyState);
+ /** Mark next location */
void changeLocation(char world, char room, char node, char view, uint32 offset);
void serializeStateTable(Common::WriteStream *stream);
void deserializeStateTable(Common::SeekableReadStream *stream);
- void serializeControls(Common::WriteStream *stream);
- void deserializeControls(Common::SeekableReadStream *stream);
Location getCurrentLocation() const;
private:
- void createReferenceTable();
+ void addPuzzlesToReferenceTable(script_scope &scope);
void updateNodes(uint deltaTimeMillis);
- void checkPuzzleCriteria();
+ void updateControls(uint deltaTimeMillis);
+ void checkPuzzleCriteria(Puzzle *puzzle, uint counter);
void cleanStateTable();
void cleanScriptScope(script_scope &scope);
+ void execScope(script_scope &scope);
+
+ /** Perform change location */
+ void do_changeLocation();
// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
public:
@@ -245,7 +251,7 @@ public:
* @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, bool isGlobal = false);
+ void parseScrFile(const Common::String &fileName, script_scope &scope);
private:
/**
@@ -291,7 +297,7 @@ private:
* @param line The line initially read
* @param stream Scr file stream
*/
- void parseControl(Common::String &line, Common::SeekableReadStream &stream);
+ Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
};
Commit: 6d5e8cb10569eec6b42e41197227ed1652e57900
https://github.com/scummvm/scummvm/commit/6d5e8cb10569eec6b42e41197227ed1652e57900
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-25T20:42:14Z
Commit Message:
ZVISION: Replace disable/enable control functions by call to
getStateFlag.
Changed paths:
engines/zvision/animation_control.cpp
engines/zvision/control.cpp
engines/zvision/control.h
engines/zvision/lever_control.cpp
engines/zvision/push_toggle_control.cpp
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 66eefd7..3f9a2e9 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -71,9 +71,6 @@ AnimationControl::~AnimationControl() {
}
bool AnimationControl::process(uint32 deltaTimeInMillis) {
- if (!_enabled) {
- return false;
- }
bool finished = false;
@@ -253,7 +250,6 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// Then disable the control. DON'T delete it. It can be re-used
if (finished) {
_engine->getScriptManager()->setStateValue(_animationKey, 2);
- disable();
_currentLoop = 0;
}
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index bcbdabc..0346228 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -33,24 +33,6 @@
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 ab55763..66fdbfe 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -38,16 +38,14 @@ class ZVision;
class Control {
public:
- Control() : _engine(0), _key(0), _enabled(false) {}
- Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
+ Control() : _engine(0), _key(0) {}
+ Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
virtual ~Control() {}
uint32 getKey() {
return _key;
}
- virtual void enable();
- virtual void disable();
virtual void focus() {}
virtual void unfocus() {}
/**
@@ -131,7 +129,6 @@ public:
protected:
ZVision *_engine;
uint32 _key;
- bool _enabled;
// Static member functions
public:
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index b0f9417..bd2c186 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -191,9 +191,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
- }
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
@@ -202,9 +201,8 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common
}
void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
- }
if (_mouseIsCaptured) {
_mouseIsCaptured = false;
@@ -217,9 +215,8 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
bool cursorWasChanged = false;
@@ -248,9 +245,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
bool LeverControl::process(uint32 deltaTimeInMillis) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
if (_isReturning) {
_accumulatedTime += deltaTimeInMillis;
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 21a1c41..2cea5db 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -73,9 +73,8 @@ PushToggleControl::~PushToggleControl() {
}
void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
- }
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
@@ -83,9 +82,8 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com
}
bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_hoverCursor);
Commit: 4d02fe42fdbddb4fb6f5d97611b31410c170082d
https://github.com/scummvm/scummvm/commit/4d02fe42fdbddb4fb6f5d97611b31410c170082d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-25T20:44:40Z
Commit Message:
ZVISION: Remove not needed (de)serialize functions from controls class.
Changed paths:
engines/zvision/control.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 66fdbfe..32c59d6 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -93,38 +93,6 @@ public:
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: 6ace820da623b8579972ae58c50ec782dfcf2589
https://github.com/scummvm/scummvm/commit/6ace820da623b8579972ae58c50ec782dfcf2589
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-25T20:47:36Z
Commit Message:
ZVISION: Remove field "flags" from puzzle structure.
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index 1b30829..c02f60c 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -32,7 +32,7 @@
namespace ZVision {
struct Puzzle {
- Puzzle() : key(0), flags(0) {}
+ Puzzle() : key(0) {}
~Puzzle() {
for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) {
@@ -73,7 +73,6 @@ struct Puzzle {
Common::List<Common::List <CriteriaEntry> > criteriaList;
// This has to be list of pointers because ResultAction is abstract
Common::List<ResultAction *> resultActions;
- uint flags;
bool addedBySetState;
};
Commit: 66c9d1d0fd8c9df57bcf986dd124c879eae2f35d
https://github.com/scummvm/scummvm/commit/66c9d1d0fd8c9df57bcf986dd124c879eae2f35d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-29T18:33:37Z
Commit Message:
ZVISION: Add engine pointer to actionResult for manipulations with
engine.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/scr_file_handling.cpp
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 3c0adb4..68c2797 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -43,12 +43,13 @@ namespace ZVision {
// ActionAdd
//////////////////////////////////////////////////////////////////////////////
-ActionAdd::ActionAdd(const Common::String &line) {
+ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
}
-bool ActionAdd::execute(ZVision *engine) {
- engine->getScriptManager()->addToStateValue(_key, _value);
+bool ActionAdd::execute() {
+ _engine->getScriptManager()->addToStateValue(_key, _value);
return true;
}
@@ -57,12 +58,13 @@ bool ActionAdd::execute(ZVision *engine) {
// ActionAssign
//////////////////////////////////////////////////////////////////////////////
-ActionAssign::ActionAssign(const Common::String &line) {
+ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
}
-bool ActionAssign::execute(ZVision *engine) {
- engine->getScriptManager()->setStateValue(_key, _value);
+bool ActionAssign::execute() {
+ _engine->getScriptManager()->setStateValue(_key, _value);
return true;
}
@@ -71,11 +73,12 @@ bool ActionAssign::execute(ZVision *engine) {
// ActionAttenuate
//////////////////////////////////////////////////////////////////////////////
-ActionAttenuate::ActionAttenuate(const Common::String &line) {
+ActionAttenuate::ActionAttenuate(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
}
-bool ActionAttenuate::execute(ZVision *engine) {
+bool ActionAttenuate::execute() {
// TODO: Implement
return true;
}
@@ -85,13 +88,14 @@ bool ActionAttenuate::execute(ZVision *engine) {
// ActionChangeLocation
//////////////////////////////////////////////////////////////////////////////
-ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
+ActionChangeLocation::ActionChangeLocation(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset);
}
-bool ActionChangeLocation::execute(ZVision *engine) {
+bool ActionChangeLocation::execute() {
// 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, _offset);
+ _engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset);
// Tell the puzzle system to stop checking any more puzzles
return false;
}
@@ -101,13 +105,14 @@ bool ActionChangeLocation::execute(ZVision *engine) {
// ActionCrossfade
//////////////////////////////////////////////////////////////////////////////
-ActionCrossfade::ActionCrossfade(const Common::String &line) {
+ActionCrossfade::ActionCrossfade(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(),
"%*[^(](%u %u %u %u %u %u %u)",
&_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
}
-bool ActionCrossfade::execute(ZVision *engine) {
+bool ActionCrossfade::execute() {
// TODO: Implement
return true;
}
@@ -117,11 +122,12 @@ bool ActionCrossfade::execute(ZVision *engine) {
// ActionDisableControl
//////////////////////////////////////////////////////////////////////////////
-ActionDisableControl::ActionDisableControl(const Common::String &line) {
+ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%u)", &_key);
}
-bool ActionDisableControl::execute(ZVision *engine) {
+bool ActionDisableControl::execute() {
debug("Disabling control %u", _key);
@@ -133,11 +139,12 @@ bool ActionDisableControl::execute(ZVision *engine) {
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
-ActionEnableControl::ActionEnableControl(const Common::String &line) {
+ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^(](%u)", &_key);
}
-bool ActionEnableControl::execute(ZVision *engine) {
+bool ActionEnableControl::execute() {
debug("Enabling control %u", _key);
@@ -149,7 +156,9 @@ bool ActionEnableControl::execute(ZVision *engine) {
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
-ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
+ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) :
+ ResultAction(engine),
+ _volume(255) {
uint type;
char fileNameBuffer[25];
uint loop;
@@ -176,7 +185,7 @@ ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
}
}
-bool ActionMusic::execute(ZVision *engine) {
+bool ActionMusic::execute() {
Audio::RewindableAudioStream *audioStream;
if (_fileName.contains(".wav")) {
@@ -185,14 +194,14 @@ bool ActionMusic::execute(ZVision *engine) {
audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
}
} else {
- audioStream = makeRawZorkStream(_fileName, engine);
+ audioStream = makeRawZorkStream(_fileName, _engine);
}
if (_loop) {
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
+ _engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
} else {
- engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
+ _engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
}
return true;
@@ -203,7 +212,8 @@ bool ActionMusic::execute(ZVision *engine) {
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
+ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
char fileName[25];
// The two %*u are always 0 and dont seem to have a use
@@ -212,7 +222,7 @@ ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
_fileName = Common::String(fileName);
}
-bool ActionPreloadAnimation::execute(ZVision *engine) {
+bool ActionPreloadAnimation::execute() {
// 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
@@ -226,7 +236,8 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
// ActionPlayAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
+ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
char fileName[25];
// The two %*u are always 0 and dont seem to have a use
@@ -237,7 +248,7 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
_fileName = Common::String(fileName);
}
-bool ActionPlayAnimation::execute(ZVision *engine) {
+bool ActionPlayAnimation::execute() {
// TODO: Implement
return true;
}
@@ -247,15 +258,16 @@ bool ActionPlayAnimation::execute(ZVision *engine) {
// ActionPlayPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) {
+ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
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) {
+bool ActionPlayPreloadAnimation::execute() {
// Find the control
- AnimationControl *control = (AnimationControl *)engine->getScriptManager()->getControl(_controlKey);
+ AnimationControl *control = (AnimationControl *)_engine->getScriptManager()->getControl(_controlKey);
// Set the needed values within the control
control->setAnimationKey(_animationKey);
@@ -271,8 +283,8 @@ bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
// ActionQuit
//////////////////////////////////////////////////////////////////////////////
-bool ActionQuit::execute(ZVision *engine) {
- engine->quitGame();
+bool ActionQuit::execute() {
+ _engine->quitGame();
return true;
}
@@ -282,13 +294,14 @@ bool ActionQuit::execute(ZVision *engine) {
// ActionRandom
//////////////////////////////////////////////////////////////////////////////
-ActionRandom::ActionRandom(const Common::String &line) {
+ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
}
-bool ActionRandom::execute(ZVision *engine) {
- uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
- engine->getScriptManager()->setStateValue(_key, randNumber);
+bool ActionRandom::execute() {
+ uint randNumber = _engine->getRandomSource()->getRandomNumber(_max);
+ _engine->getScriptManager()->setStateValue(_key, randNumber);
return true;
}
@@ -297,7 +310,8 @@ bool ActionRandom::execute(ZVision *engine) {
// ActionSetPartialScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
+ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
char fileName[25];
uint color;
@@ -311,9 +325,8 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
_backgroundColor = color;
}
-bool ActionSetPartialScreen::execute(ZVision *engine) {
- RenderManager *renderManager = engine->getRenderManager();
-
+bool ActionSetPartialScreen::execute() {
+ RenderManager *renderManager = _engine->getRenderManager();
if (_backgroundColor >= 0)
renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
else
@@ -327,15 +340,16 @@ bool ActionSetPartialScreen::execute(ZVision *engine) {
// ActionSetScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetScreen::ActionSetScreen(const Common::String &line) {
+ActionSetScreen::ActionSetScreen(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
char fileName[25];
sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
_fileName = Common::String(fileName);
}
-bool ActionSetScreen::execute(ZVision *engine) {
- engine->getRenderManager()->setBackgroundImage(_fileName);
+bool ActionSetScreen::execute() {
+ _engine->getRenderManager()->setBackgroundImage(_fileName);
return true;
}
@@ -345,7 +359,8 @@ bool ActionSetScreen::execute(ZVision *engine) {
// ActionStreamVideo
//////////////////////////////////////////////////////////////////////////////
-ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
+ActionStreamVideo::ActionStreamVideo(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
char fileName[25];
uint skipline; //skipline - render video with skip every second line, not skippable.
@@ -355,7 +370,7 @@ ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
_skippable = true;
}
-bool ActionStreamVideo::execute(ZVision *engine) {
+bool ActionStreamVideo::execute() {
ZorkAVIDecoder decoder;
if (!decoder.loadFile(_fileName)) {
return true;
@@ -366,7 +381,7 @@ bool ActionStreamVideo::execute(ZVision *engine) {
destRect = Common::Rect(_x1, _y1, _x2, _y2);
}
- engine->playVideo(decoder, destRect, _skippable);
+ _engine->playVideo(decoder, destRect, _skippable);
return true;
}
@@ -375,12 +390,13 @@ bool ActionStreamVideo::execute(ZVision *engine) {
// ActionTimer
//////////////////////////////////////////////////////////////////////////////
-ActionTimer::ActionTimer(const Common::String &line) {
+ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
}
-bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addSideFX(new TimerNode(engine, _key, _time));
+bool ActionTimer::execute() {
+ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time));
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 15923d6..f779c1f 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -39,6 +39,7 @@ class ZVision;
*/
class ResultAction {
public:
+ ResultAction(ZVision *engine) : _engine(engine) {}
virtual ~ResultAction() {}
/**
* This is called by the script system whenever a Puzzle's criteria are found to be true.
@@ -48,7 +49,9 @@ public:
* @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;
+ virtual bool execute() = 0;
+protected:
+ ZVision *_engine;
};
@@ -85,8 +88,8 @@ public:
class ActionAdd : public ResultAction {
public:
- ActionAdd(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAdd(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -95,8 +98,8 @@ private:
class ActionAssign : public ResultAction {
public:
- ActionAssign(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAssign(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -105,8 +108,8 @@ private:
class ActionAttenuate : public ResultAction {
public:
- ActionAttenuate(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAttenuate(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -115,8 +118,8 @@ private:
class ActionChangeLocation : public ResultAction {
public:
- ActionChangeLocation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionChangeLocation(ZVision *engine, const Common::String &line);
+ bool execute();
private:
char _world;
@@ -128,8 +131,8 @@ private:
class ActionCrossfade : public ResultAction {
public:
- ActionCrossfade(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionCrossfade(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _keyOne;
@@ -143,16 +146,16 @@ private:
class ActionDebug : public ResultAction {
public:
- ActionDebug(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDebug(ZVision *engine, const Common::String &line);
+ bool execute();
private:
};
class ActionDelayRender : public ResultAction {
public:
- ActionDelayRender(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDelayRender(ZVision *engine, const Common::String &line);
+ bool execute();
private:
// TODO: Check if this should actually be frames or if it should be milliseconds/seconds
@@ -161,8 +164,8 @@ private:
class ActionDisableControl : public ResultAction {
public:
- ActionDisableControl(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDisableControl(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -170,38 +173,38 @@ private:
class ActionDisableVenus : public ResultAction {
public:
- ActionDisableVenus(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDisableVenus(ZVision *engine, const Common::String &line);
+ bool execute();
private:
};
class ActionDisplayMessage : public ResultAction {
public:
- ActionDisplayMessage(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDisplayMessage(ZVision *engine, const Common::String &line);
+ bool execute();
private:
};
class ActionDissolve : public ResultAction {
public:
- ActionDissolve();
- bool execute(ZVision *engine);
+ ActionDissolve(ZVision *engine);
+ bool execute();
};
class ActionDistort : public ResultAction {
public:
- ActionDistort(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDistort(ZVision *engine, const Common::String &line);
+ bool execute();
private:
};
class ActionEnableControl : public ResultAction {
public:
- ActionEnableControl(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionEnableControl(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -209,8 +212,8 @@ private:
class ActionMusic : public ResultAction {
public:
- ActionMusic(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionMusic(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -222,8 +225,8 @@ private:
class ActionPlayAnimation : public ResultAction {
public:
- ActionPlayAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPlayAnimation(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -241,8 +244,8 @@ private:
class ActionPlayPreloadAnimation : public ResultAction {
public:
- ActionPlayPreloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _animationKey;
@@ -258,8 +261,8 @@ private:
class ActionPreloadAnimation : public ResultAction {
public:
- ActionPreloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPreloadAnimation(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -270,21 +273,21 @@ private:
class ActionQuit : public ResultAction {
public:
- ActionQuit() {}
- bool execute(ZVision *engine);
+ ActionQuit(ZVision *engine) : ResultAction(engine) {}
+ bool execute();
};
// 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);
+ ActionUnloadAnimation(ZVision *engine, const Common::String &line);
+ bool execute();
};
class ActionRandom : public ResultAction {
public:
- ActionRandom(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionRandom(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
@@ -293,8 +296,8 @@ private:
class ActionSetPartialScreen : public ResultAction {
public:
- ActionSetPartialScreen(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionSetPartialScreen(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint _x;
@@ -305,8 +308,8 @@ private:
class ActionSetScreen : public ResultAction {
public:
- ActionSetScreen(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionSetScreen(ZVision *engine, const Common::String &line);
+ bool execute();
private:
Common::String _fileName;
@@ -314,8 +317,8 @@ private:
class ActionStreamVideo : public ResultAction {
public:
- ActionStreamVideo(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionStreamVideo(ZVision *engine, const Common::String &line);
+ bool execute();
private:
enum {
@@ -333,8 +336,8 @@ private:
class ActionTimer : public ResultAction {
public:
- ActionTimer(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionTimer(ZVision *engine, const Common::String &line);
+ bool execute();
private:
uint32 _key;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 4d18306..5a96a56 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -163,19 +163,19 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
// Parse for the action type
if (line.matchString("*:add*", true)) {
- actionList.push_back(new ActionAdd(line));
+ actionList.push_back(new ActionAdd(_engine, line));
} else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(new ActionPlayAnimation(line));
+ actionList.push_back(new ActionPlayAnimation(_engine, line));
} else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(new ActionPreloadAnimation(line));
+ actionList.push_back(new ActionPreloadAnimation(_engine, line));
} else if (line.matchString("*:animunload*", true)) {
- //actionList.push_back(new ActionUnloadAnimation(line));
+ //actionList.push_back(new ActionUnloadAnimation(_engine, line));
} else if (line.matchString("*:attenuate*", true)) {
// TODO: Implement ActionAttenuate
} else if (line.matchString("*:assign*", true)) {
- actionList.push_back(new ActionAssign(line));
+ actionList.push_back(new ActionAssign(_engine, line));
} else if (line.matchString("*:change_location*", true)) {
- actionList.push_back(new ActionChangeLocation(line));
+ actionList.push_back(new ActionChangeLocation(_engine, line));
} else if (line.matchString("*:crossfade*", true)) {
// TODO: Implement ActionCrossfade
} else if (line.matchString("*:debug*", true)) {
@@ -183,7 +183,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:delay_render*", true)) {
// TODO: Implement ActionDelayRender
} else if (line.matchString("*:disable_control*", true)) {
- actionList.push_back(new ActionDisableControl(line));
+ actionList.push_back(new ActionDisableControl(_engine, line));
} else if (line.matchString("*:disable_venus*", true)) {
// TODO: Implement ActionDisableVenus
} else if (line.matchString("*:display_message*", true)) {
@@ -193,7 +193,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:distort*", true)) {
// TODO: Implement ActionDistort
} else if (line.matchString("*:enable_control*", true)) {
- actionList.push_back(new ActionEnableControl(line));
+ actionList.push_back(new ActionEnableControl(_engine, line));
} else if (line.matchString("*:flush_mouse_events*", true)) {
// TODO: Implement ActionFlushMouseEvents
} else if (line.matchString("*:inventory*", true)) {
@@ -203,17 +203,17 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:menu_bar_enable*", true)) {
// TODO: Implement ActionMenuBarEnable
} else if (line.matchString("*:music*", true)) {
- actionList.push_back(new ActionMusic(line));
+ actionList.push_back(new ActionMusic(_engine, line));
} else if (line.matchString("*:pan_track*", true)) {
// TODO: Implement ActionPanTrack
} else if (line.matchString("*:playpreload*", true)) {
- actionList.push_back(new ActionPlayPreloadAnimation(line));
+ actionList.push_back(new ActionPlayPreloadAnimation(_engine, line));
} else if (line.matchString("*:preferences*", true)) {
// TODO: Implement ActionPreferences
} else if (line.matchString("*:quit*", true)) {
- actionList.push_back(new ActionQuit());
+ actionList.push_back(new ActionQuit(_engine));
} else if (line.matchString("*:random*", true)) {
- actionList.push_back(new ActionRandom(line));
+ actionList.push_back(new ActionRandom(_engine, line));
} else if (line.matchString("*:region*", true)) {
// TODO: Implement ActionRegion
} else if (line.matchString("*:restore_game*", true)) {
@@ -223,19 +223,19 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:save_game*", true)) {
// TODO: Implement ActionSaveGame
} else if (line.matchString("*:set_partial_screen*", true)) {
- actionList.push_back(new ActionSetPartialScreen(line));
+ actionList.push_back(new ActionSetPartialScreen(_engine, line));
} else if (line.matchString("*:set_screen*", true)) {
- actionList.push_back(new ActionSetScreen(line));
+ actionList.push_back(new ActionSetScreen(_engine, 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));
+ actionList.push_back(new ActionStreamVideo(_engine, line));
} else if (line.matchString("*:syncsound*", true)) {
// TODO: Implement ActionSyncSound
} else if (line.matchString("*:timer*", true)) {
- actionList.push_back(new ActionTimer(line));
+ actionList.push_back(new ActionTimer(_engine, line));
} else if (line.matchString("*:ttytext*", true)) {
// TODO: Implement ActionTTYText
} else if (line.matchString("*:universe_music*", true)) {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 74035fd..3054466 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -205,7 +205,7 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
bool shouldContinue = true;
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
- shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
+ shouldContinue = shouldContinue && (*resultIter)->execute();
if (!shouldContinue) {
break;
}
Commit: 41088f5516ba9566dcd558a103216c3798bcf9d4
https://github.com/scummvm/scummvm/commit/41088f5516ba9566dcd558a103216c3798bcf9d4
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-29T19:41:38Z
Commit Message:
ZVISION: Make setPartialScreen use mask color correctly.
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 68c2797..8340c02 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -313,16 +313,23 @@ bool ActionRandom::execute() {
ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) :
ResultAction(engine) {
char fileName[25];
- uint color;
+ int color;
- sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color);
+ sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %d)", &_x, &_y, fileName, &color);
_fileName = Common::String(fileName);
- if (color > 0xFFFF) {
+ if (color >= 0) {
+ byte r, g, b;
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b);
+ _backgroundColor = _engine->_pixelFormat.RGBToColor(r, g, b);
+ } else {
+ _backgroundColor = color;
+ }
+
+ if (color > 65535) {
warning("Background color for ActionSetPartialScreen is bigger than a uint16");
}
- _backgroundColor = color;
}
bool ActionSetPartialScreen::execute() {
Commit: fa74bcc4d50c746c3f06b156200a064a11369baa
https://github.com/scummvm/scummvm/commit/fa74bcc4d50c746c3f06b156200a064a11369baa
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-30T07:51:05Z
Commit Message:
ZVISION: Add to sidefx and scriptManager classes stop and kill methods
Changed paths:
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
engines/zvision/sidefx.h
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 3054466..1118653 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -336,6 +336,52 @@ SideFX *ScriptManager::getSideFX(uint32 key) {
return nullptr;
}
+void ScriptManager::deleteSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ break;
+ }
+ }
+}
+
+void ScriptManager::stopSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ bool ret = (*iter)->stop();
+ if (ret) {
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ }
+ break;
+ }
+ }
+}
+
+void ScriptManager::killSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ (*iter)->kill();
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ break;
+ }
+ }
+}
+
+void ScriptManager::killSideFxType(SideFX::SideFXType type) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
+ if ((*iter)->getType() & type) {
+ (*iter)->kill();
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_activeControls)
return;
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 90df2cc..3399484 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -187,6 +187,10 @@ public:
void addSideFX(SideFX *fx);
SideFX *getSideFX(uint32 key);
+ void deleteSideFx(uint32 key);
+ void stopSideFx(uint32 key);
+ void killSideFx(uint32 key);
+ void killSideFxType(SideFX::SideFXType type);
/**
* Called when LeftMouse is pushed.
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index 6f75ad6..9c18371 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -88,6 +88,11 @@ public:
return false;
}
+ virtual bool stop() {
+ return true;
+ }
+ virtual void kill() {}
+
protected:
ZVision *_engine;
uint32 _key;
Commit: b0f74feb41dfd732480a49dd233b59f33a43be88
https://github.com/scummvm/scummvm/commit/b0f74feb41dfd732480a49dd233b59f33a43be88
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-30T07:53:47Z
Commit Message:
ZVISION: Define all sidefx types.
Changed paths:
engines/zvision/sidefx.h
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index 9c18371..210d98e 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -37,8 +37,15 @@ class SideFX {
public:
enum SideFXType {
- SIDEFX_UNK = 0,
- SIDEFX_TIMER = 1
+ SIDEFX_ANIM = 1,
+ SIDEFX_AUDIO = 2,
+ SIDEFX_DISTORT = 4,
+ SIDEFX_PANTRACK = 8,
+ SIDEFX_REGION = 16,
+ SIDEFX_TIMER = 32,
+ SIDEFX_TTYTXT = 64,
+ SIDEFX_UNK = 128,
+ SIDEFX_ALL = 255
};
SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
Commit: a8feff10b883d686b37a709c483129602187c155
https://github.com/scummvm/scummvm/commit/a8feff10b883d686b37a709c483129602187c155
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-30T07:57:39Z
Commit Message:
ZVISION: Add universe scope of puzzles to reference table.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 1118653..fe8ec897b 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -446,6 +446,8 @@ void ScriptManager::do_changeLocation() {
cleanScriptScope(room);
cleanScriptScope(world);
+ addPuzzlesToReferenceTable(universe);
+
// 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, nodeview);
Commit: e38ca6e7a952b79e1432e322905687c9e11ebb47
https://github.com/scummvm/scummvm/commit/e38ca6e7a952b79e1432e322905687c9e11ebb47
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-30T16:17:29+07:00
Commit Message:
ZVISION: New class for handle values and values from [slots].
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 fe8ec897b..e88c1eb 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -515,4 +515,27 @@ Location ScriptManager::getCurrentLocation() const {
return location;
}
+ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val):
+ _sc_man(sc_man) {
+ value = 0;
+ slot = false;
+ const char *is_slot = strstr(slot_val, "[");
+ if (is_slot) {
+ slot = true;
+ value = atoi(is_slot + 1);
+ } else {
+ slot = false;
+ value = atoi(slot_val);
+ }
+}
+int16 ValueSlot::getValue() {
+ if (slot) {
+ if (value >= 0)
+ return _sc_man->getStateValue(value);
+ else
+ return 0;
+ } else
+ return value;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 3399484..dd995f4 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -304,6 +304,16 @@ private:
Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
};
+class ValueSlot {
+public:
+ ValueSlot(ScriptManager *sc_man, const char *slot_val);
+ int16 getValue();
+private:
+ int16 value;
+ bool slot;
+ ScriptManager *_sc_man;
+};
+
} // End of namespace ZVision
Commit: fa943f1044e78ad9b1305f2d91085c25a945aaa9
https://github.com/scummvm/scummvm/commit/fa943f1044e78ad9b1305f2d91085c25a945aaa9
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-30T16:21:38+07:00
Commit Message:
ZVISION: Move actionTimer to use ValueSlot class.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 8340c02..08e99dc 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -399,11 +399,19 @@ bool ActionStreamVideo::execute() {
ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) :
ResultAction(engine) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
+ char time_buf[64];
+ memset(time_buf, 0, 64);
+ sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, time_buf);
+ _time = new ValueSlot(_engine->getScriptManager(), time_buf);
+}
+
+ActionTimer::~ActionTimer() {
+ if (_time)
+ delete _time;
}
bool ActionTimer::execute() {
- _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time));
+ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time->getValue()));
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index f779c1f..e900167 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -32,6 +32,7 @@ namespace ZVision {
// Forward declaration of ZVision. This file is included before ZVision is declared
class ZVision;
+class ValueSlot;
/**
* The base class that represents any action that a Puzzle can take.
@@ -337,11 +338,11 @@ private:
class ActionTimer : public ResultAction {
public:
ActionTimer(ZVision *engine, const Common::String &line);
+ ~ActionTimer();
bool execute();
-
private:
uint32 _key;
- uint _time;
+ ValueSlot *_time;
};
} // End of namespace ZVision
Commit: b2aa30afebe9c799ad2513f6c22cd798c1818eb0
https://github.com/scummvm/scummvm/commit/b2aa30afebe9c799ad2513f6c22cd798c1818eb0
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-31T07:45:43Z
Commit Message:
ZVISION: Correct timer code to match original.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/script_manager.h
engines/zvision/timer_node.cpp
engines/zvision/timer_node.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 08e99dc..d7921d3 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -408,6 +408,7 @@ ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) :
ActionTimer::~ActionTimer() {
if (_time)
delete _time;
+ _engine->getScriptManager()->killSideFx(_key);
}
bool ActionTimer::execute() {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index dd995f4..c75296b 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -49,6 +49,7 @@ enum StateKey {
StateKey_KeyPress = 8,
StateKey_InventoryItem = 9,
StateKey_LMouse = 10,
+ StateKey_NotSet = 11, // This key doesn't set
StateKey_Rounds = 12,
StateKey_Venus = 13,
StateKey_RMouse = 18,
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index c7cefd6..f8da0bc 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -38,25 +38,34 @@ TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
_timeLeft = timeInSeconds * 1000;
else if (_engine->getGameId() == GID_GRANDINQUISITOR)
_timeLeft = timeInSeconds * 100;
- _engine->getScriptManager()->setStateValue(_key, 1);
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
}
TimerNode::~TimerNode() {
- if (_timeLeft <= 0)
+ if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
- else
- _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
+ int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
+ if (timeLeft > 0)
+ _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
_timeLeft -= deltaTimeInMillis;
if (_timeLeft <= 0)
- return true;
+ return stop();
return false;
}
+bool TimerNode::stop() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ return true;
+}
+
void TimerNode::serialize(Common::WriteStream *stream) {
stream->writeUint32LE(_key);
stream->writeUint32LE(_timeLeft);
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 4a9c95d..f6584be 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -48,6 +48,8 @@ public:
return true;
}
+ bool stop();
+
private:
int32 _timeLeft;
};
Commit: 0b61b653aea21bf0329bcd5738617611d7109ee8
https://github.com/scummvm/scummvm/commit/0b61b653aea21bf0329bcd5738617611d7109ee8
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-10-31T08:20:57Z
Commit Message:
ZVISION: Handle go to 0000 - previous location.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index e88c1eb..c4ea8be 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -431,15 +431,53 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi
_nextLocation.node = _node;
_nextLocation.view = _view;
_nextLocation.offset = offset;
+ // If next location 0000 - it's indicate to go to previous location.
+ if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') {
+ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
+ _nextLocation.world = getStateValue(StateKey_LastWorld);
+ _nextLocation.room = getStateValue(StateKey_LastRoom);
+ _nextLocation.node = getStateValue(StateKey_LastNode);
+ _nextLocation.view = getStateValue(StateKey_LastView);
+ _nextLocation.offset = getStateValue(StateKey_LastViewPos);
+ } else {
+ _nextLocation.world = getStateValue(StateKey_Menu_LastWorld);
+ _nextLocation.room = getStateValue(StateKey_Menu_LastRoom);
+ _nextLocation.node = getStateValue(StateKey_Menu_LastNode);
+ _nextLocation.view = getStateValue(StateKey_Menu_LastView);
+ _nextLocation.offset = getStateValue(StateKey_Menu_LastViewPos);
+ }
+ }
}
void ScriptManager::do_changeLocation() {
assert(_nextLocation.world != 0);
debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
+ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
+ if (_nextLocation.world != 'g' || _nextLocation.room != 'j') {
+ setStateValue(StateKey_LastWorld, getStateValue(StateKey_World));
+ setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room));
+ setStateValue(StateKey_LastNode, getStateValue(StateKey_Node));
+ setStateValue(StateKey_LastView, getStateValue(StateKey_View));
+ setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos));
+ } else {
+ setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World));
+ setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room));
+ setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node));
+ setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View));
+ setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos));
+ }
+ }
+
// Auto save
//_engine->getSaveManager()->autoSave();
+ setStateValue(StateKey_World, _nextLocation.world);
+ setStateValue(StateKey_Room, _nextLocation.room);
+ setStateValue(StateKey_Node, _nextLocation.node);
+ setStateValue(StateKey_View, _nextLocation.view);
+ setStateValue(StateKey_ViewPos, _nextLocation.offset);
+
// Clear all the containers
_referenceTable.clear();
cleanScriptScope(nodeview);
Commit: 44464ce686f26128a37ef3b8da17ed01f436b928
https://github.com/scummvm/scummvm/commit/44464ce686f26128a37ef3b8da17ed01f436b928
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-10-31T09:53:17+07:00
Commit Message:
ZVISION: Fix actionRandom parameter reader.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index d7921d3..5fbfbd6 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -296,11 +296,19 @@ bool ActionQuit::execute() {
ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) :
ResultAction(engine) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
+ char max_buf[64];
+ memset(max_buf, 0, 64);
+ sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf);
+ _max = new ValueSlot(_engine->getScriptManager(), max_buf);
+}
+
+ActionRandom::~ActionRandom() {
+ if (_max)
+ delete _max;
}
bool ActionRandom::execute() {
- uint randNumber = _engine->getRandomSource()->getRandomNumber(_max);
+ uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue());
_engine->getScriptManager()->setStateValue(_key, randNumber);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index e900167..cc32cc0 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -288,11 +288,12 @@ public:
class ActionRandom : public ResultAction {
public:
ActionRandom(ZVision *engine, const Common::String &line);
+ ~ActionRandom();
bool execute();
private:
uint32 _key;
- uint _max;
+ ValueSlot *_max;
};
class ActionSetPartialScreen : public ResultAction {
Commit: 1477192e8c46918bd56d2430fc04b14495e3e8dd
https://github.com/scummvm/scummvm/commit/1477192e8c46918bd56d2430fc04b14495e3e8dd
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:05:15+07:00
Commit Message:
ZVISION: Fix ZorkRaw stream decoder return true instead of real flag.
Changed paths:
engines/zvision/zork_raw.h
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 29b5559..5a07afa 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -107,7 +107,7 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const {
- return true;
+ return _stereo;
}
bool endOfData() const {
return _endOfData;
Commit: a5430c7703331e6180c17b89c95372feb73f0092
https://github.com/scummvm/scummvm/commit/a5430c7703331e6180c17b89c95372feb73f0092
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:23:08+07:00
Commit Message:
ZVISION: Don't use unneeded function.
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 5fbfbd6..ea0d06b 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -49,7 +49,7 @@ ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) :
}
bool ActionAdd::execute() {
- _engine->getScriptManager()->addToStateValue(_key, _value);
+ _engine->getScriptManager()->setStateValue(_key, _engine->getScriptManager()->getStateValue(_key) + _value);
return true;
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index c4ea8be..e7ec34f 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -296,11 +296,6 @@ void ScriptManager::unsetStateFlag(uint32 key, uint value) {
}
}
-void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
- _globalState[key] += valueToAdd;
-}
-
-
Control *ScriptManager::getControl(uint32 key) {
return nullptr;
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index c75296b..07c09c5 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -172,7 +172,6 @@ public:
uint getStateValue(uint32 key);
void setStateValue(uint32 key, uint value);
- void addToStateValue(uint32 key, uint valueToAdd);
uint getStateFlag(uint32 key);
void setStateFlag(uint32 key, uint value);
Commit: d3ef75dac9a1ac9f091ccc75bf1bc51647a8ba02
https://github.com/scummvm/scummvm/commit/d3ef75dac9a1ac9f091ccc75bf1bc51647a8ba02
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:43:33+07:00
Commit Message:
ZVISION: Replace ZorkRaw audio parameters table by fully implemented with 16bit flag.
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 ce83add..e7cc71a 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -140,19 +140,64 @@ int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream
return bytesRead;
}
-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::_zNemSoundParamLookupTable[32] = {{'0', 0x1F40, false, false, false},
+ {'1', 0x1F40, true, false, false},
+ {'2', 0x1F40, false, false, true},
+ {'3', 0x1F40, true, false, true},
+ {'4', 0x2B11, false, false, false},
+ {'5', 0x2B11, true, false, false},
+ {'6', 0x2B11, false, false, true},
+ {'7', 0x2B11, true, false, true},
+ {'8', 0x5622, false, false, false},
+ {'9', 0x5622, true, false, false},
+ {'a', 0x5622, false, false, true},
+ {'b', 0x5622, true, false, true},
+ {'c', 0xAC44, false, false, false},
+ {'d', 0xAC44, true, false, false},
+ {'e', 0xAC44, false, false, true},
+ {'f', 0xAC44, true, false, true},
+ {'g', 0x1F40, false, true, false},
+ {'h', 0x1F40, true, true, false},
+ {'j', 0x1F40, false, true, true},
+ {'k', 0x1F40, true, true, true},
+ {'l', 0x2B11, false, true, false},
+ {'m', 0x2B11, true, true, false},
+ {'n', 0x2B11, false, true, true},
+ {'p', 0x2B11, true, true, true},
+ {'q', 0x5622, false, true, false},
+ {'r', 0x5622, true, true, false},
+ {'s', 0x5622, false, true, true},
+ {'t', 0x5622, true, true, true},
+ {'u', 0xAC44, false, true, false},
+ {'v', 0xAC44, true, true, false},
+ {'w', 0xAC44, false, true, true},
+ {'x', 0xAC44, true, 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}
+const SoundParams RawZorkStream::_zgiSoundParamLookupTable[24] = {{'4', 0x2B11, false, false, false},
+ {'5', 0x2B11, true, false, false},
+ {'6', 0x2B11, false, false, true},
+ {'7', 0x2B11, true, false, true},
+ {'8', 0x5622, false, false, false},
+ {'9', 0x5622, true, false, false},
+ {'a', 0x5622, false, false, true},
+ {'b', 0x5622, true, false, true},
+ {'c', 0xAC44, false, false, false},
+ {'d', 0xAC44, true, false, false},
+ {'e', 0xAC44, false, false, true},
+ {'f', 0xAC44, true, false, true},
+ {'g', 0x2B11, false, true, false},
+ {'h', 0x2B11, true, true, false},
+ {'j', 0x2B11, false, true, true},
+ {'k', 0x2B11, true, true, true},
+ {'m', 0x5622, false, true, false},
+ {'n', 0x5622, true, true, false},
+ {'p', 0x5622, false, true, true},
+ {'q', 0x5622, true, true, true},
+ {'r', 0xAC44, false, true, false},
+ {'s', 0xAC44, true, true, false},
+ {'t', 0xAC44, false, true, true},
+ {'u', 0xAC44, true, true, true}
};
RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
@@ -217,12 +262,12 @@ 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 < 32; ++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) {
+ for (int i = 0; i < 24; ++i) {
if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
}
@@ -232,6 +277,8 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
} else {
byte flags = 0;
+ if (soundParams.bits16)
+ flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
if (soundParams.stereo)
flags |= Audio::FLAG_STEREO;
diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h
index 5a07afa..a5e346d 100644
--- a/engines/zvision/zork_raw.h
+++ b/engines/zvision/zork_raw.h
@@ -39,6 +39,7 @@ struct SoundParams {
uint32 rate;
bool stereo;
bool packed;
+ bool bits16;
};
@@ -91,8 +92,8 @@ public:
}
public:
- static const SoundParams _zNemSoundParamLookupTable[6];
- static const SoundParams _zgiSoundParamLookupTable[5];
+ static const SoundParams _zNemSoundParamLookupTable[32];
+ static const SoundParams _zgiSoundParamLookupTable[24];
private:
const int _rate; // Sample rate of stream
Commit: f46d63d35c61c9076a3c4ef9936bd88dbf8b8218
https://github.com/scummvm/scummvm/commit/f46d63d35c61c9076a3c4ef9936bd88dbf8b8218
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:44:44+07:00
Commit Message:
ZVISION: Implement engine-wide method for selecting new audio ID.
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 8be85d3..9a93259 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -61,7 +61,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_renderManager(nullptr),
_saveManager(nullptr),
_stringManager(nullptr),
- _cursorManager(nullptr) {
+ _cursorManager(nullptr),
+ _aud_id(0) {
debug(1, "ZVision::ZVision");
}
@@ -182,4 +183,11 @@ Common::String ZVision::generateAutoSaveFileName() {
return Common::String::format("%s.auto", _targetName.c_str());
}
+int ZVision::getAudioId() {
+ _aud_id++;
+ if (_aud_id < 0)
+ _aud_id = 0;
+ return _aud_id;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 10711b1..e770928 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -101,6 +101,9 @@ private:
// Clock
Clock _clock;
+ // Audio ID
+ int _aud_id;
+
// To prevent allocation every time we process events
Common::Event _event;
@@ -145,6 +148,8 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
+ int getAudioId();
+
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
Commit: 7f166720372ef8e4fd95cc4622801d420a8669d6
https://github.com/scummvm/scummvm/commit/7f166720372ef8e4fd95cc4622801d420a8669d6
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:46:24+07:00
Commit Message:
ZVISION: StateValue must be signed.
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 e7ec34f..b58056a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -162,7 +162,7 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
// Get the value to compare against
- uint argumentValue;
+ int argumentValue;
if (entryIter->argumentIsAKey)
argumentValue = getStateValue(entryIter->argument);
else
@@ -246,7 +246,7 @@ void ScriptManager::cleanScriptScope(script_scope &scope) {
scope.proc_count = 0;
}
-uint ScriptManager::getStateValue(uint32 key) {
+int ScriptManager::getStateValue(uint32 key) {
if (_globalState.contains(key))
return _globalState[key];
else
@@ -263,7 +263,7 @@ void ScriptManager::queuePuzzles(uint32 key) {
}
}
-void ScriptManager::setStateValue(uint32 key, uint value) {
+void ScriptManager::setStateValue(uint32 key, int value) {
if (value == 0)
_globalState.erase(key);
else
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 07c09c5..487a27c 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -109,7 +109,7 @@ struct Location {
typedef Common::List<Puzzle *> PuzzleList;
typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;
-typedef Common::HashMap<uint32, uint32> StateMap;
+typedef Common::HashMap<uint32, int32> StateMap;
typedef Common::List<SideFX *> SideFXList;
class ScriptManager {
@@ -170,8 +170,8 @@ public:
void update(uint deltaTimeMillis);
void queuePuzzles(uint32 key);
- uint getStateValue(uint32 key);
- void setStateValue(uint32 key, uint value);
+ int getStateValue(uint32 key);
+ void setStateValue(uint32 key, int value);
uint getStateFlag(uint32 key);
void setStateFlag(uint32 key, uint value);
Commit: a35900142f6a316fde6463b470dbf97ce8426752
https://github.com/scummvm/scummvm/commit/a35900142f6a316fde6463b470dbf97ce8426752
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:47:47+07:00
Commit Message:
ZVISION: ActionAdd must handle negative vallues.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index ea0d06b..5af637f 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -45,7 +45,7 @@ namespace ZVision {
ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) :
ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
+ sscanf(line.c_str(), "%*[^(](%u,%d)", &_key, &_value);
}
bool ActionAdd::execute() {
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index cc32cc0..e2e57c3 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -94,7 +94,7 @@ public:
private:
uint32 _key;
- uint _value;
+ int _value;
};
class ActionAssign : public ResultAction {
Commit: e1df572ab848f64826fc5cb4a0f22ccddd135871
https://github.com/scummvm/scummvm/commit/e1df572ab848f64826fc5cb4a0f22ccddd135871
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:53:46+07:00
Commit Message:
ZVISION: Implement ActionKill.
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 5af637f..2a79500 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -153,6 +153,46 @@ bool ActionEnableControl::execute() {
//////////////////////////////////////////////////////////////////////////////
+// ActionKill
+//////////////////////////////////////////////////////////////////////////////
+
+ActionKill::ActionKill(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
+ _key = 0;
+ _type = 0;
+ char keytype[25];
+ sscanf(line.c_str(), "%*[^(](%25s)", keytype);
+ if (keytype[0] == '"') {
+ if (!scumm_stricmp(keytype, "\"ANIM\""))
+ _type = SideFX::SIDEFX_ANIM;
+ else if (!scumm_stricmp(keytype, "\"AUDIO\""))
+ _type = SideFX::SIDEFX_AUDIO;
+ else if (!scumm_stricmp(keytype, "\"DISTORT\""))
+ _type = SideFX::SIDEFX_DISTORT;
+ else if (!scumm_stricmp(keytype, "\"PANTRACK\""))
+ _type = SideFX::SIDEFX_PANTRACK;
+ else if (!scumm_stricmp(keytype, "\"REGION\""))
+ _type = SideFX::SIDEFX_REGION;
+ else if (!scumm_stricmp(keytype, "\"TIMER\""))
+ _type = SideFX::SIDEFX_TIMER;
+ else if (!scumm_stricmp(keytype, "\"TTYTEXT\""))
+ _type = SideFX::SIDEFX_TTYTXT;
+ else if (!scumm_stricmp(keytype, "\"ALL\""))
+ _type = SideFX::SIDEFX_ALL;
+ } else
+ _key = atoi(keytype);
+}
+
+bool ActionKill::execute() {
+ if (_type)
+ _engine->getScriptManager()->killSideFxType((SideFX::SideFXType)_type);
+ else
+ _engine->getScriptManager()->killSideFx(_key);
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index e2e57c3..bcd7848 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -211,6 +211,16 @@ private:
uint32 _key;
};
+class ActionKill : public ResultAction {
+public:
+ ActionKill(ZVision *engine, const Common::String &line);
+ bool execute();
+
+private:
+ uint32 _key;
+ uint32 _type;
+};
+
class ActionMusic : public ResultAction {
public:
ActionMusic(ZVision *engine, const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 5a96a56..edb496a 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -199,7 +199,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:inventory*", true)) {
// TODO: Implement ActionInventory
} else if (line.matchString("*:kill*", true)) {
- // TODO: Implement ActionKill
+ actionList.push_back(new ActionKill(_engine, line));
} else if (line.matchString("*:menu_bar_enable*", true)) {
// TODO: Implement ActionMenuBarEnable
} else if (line.matchString("*:music*", true)) {
Commit: be93d7d67dcea18532917a6c1bd6004665973f4f
https://github.com/scummvm/scummvm/commit/be93d7d67dcea18532917a6c1bd6004665973f4f
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T16:55:19+07:00
Commit Message:
ZVISION: Implement ActionStop.
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 2a79500..06ceea2 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -409,6 +409,21 @@ bool ActionSetScreen::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionStop
+//////////////////////////////////////////////////////////////////////////////
+
+ActionStop::ActionStop(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
+ _key = 0;
+ sscanf(line.c_str(), "%*[^(](%u)", &_key);
+}
+
+bool ActionStop::execute() {
+ _engine->getScriptManager()->stopSideFx(_key);
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionStreamVideo
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index bcd7848..8a8412f 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -327,6 +327,15 @@ private:
Common::String _fileName;
};
+class ActionStop : public ResultAction {
+public:
+ ActionStop(ZVision *engine, const Common::String &line);
+ bool execute();
+
+private:
+ uint32 _key;
+};
+
class ActionStreamVideo : public ResultAction {
public:
ActionStreamVideo(ZVision *engine, const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index edb496a..bfa1481 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -229,7 +229,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:set_venus*", true)) {
// TODO: Implement ActionSetVenus
} else if (line.matchString("*:stop*", true)) {
- // TODO: Implement ActionStop
+ actionList.push_back(new ActionStop(_engine, line));
} else if (line.matchString("*:streamvideo*", true)) {
actionList.push_back(new ActionStreamVideo(_engine, line));
} else if (line.matchString("*:syncsound*", true)) {
Commit: 9dc0533f4f077a2a5edce902e8d93860c68c3fda
https://github.com/scummvm/scummvm/commit/9dc0533f4f077a2a5edce902e8d93860c68c3fda
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T17:00:20+07:00
Commit Message:
ZVISION: Implement MusicNode and move ActionMusic to work with it.
Changed paths:
A engines/zvision/music_node.cpp
A engines/zvision/music_node.h
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 06ceea2..3dd6382 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -30,6 +30,7 @@
#include "zvision/zork_raw.h"
#include "zvision/zork_avi_decoder.h"
#include "zvision/timer_node.h"
+#include "zvision/music_node.h"
#include "zvision/animation_control.h"
#include "common/file.h"
@@ -196,9 +197,10 @@ bool ActionKill::execute() {
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
-ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) :
+ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool global) :
ResultAction(engine),
- _volume(255) {
+ _volume(255),
+ _universe(global) {
uint type;
char fileNameBuffer[25];
uint loop;
@@ -225,24 +227,35 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) :
}
}
-bool ActionMusic::execute() {
- Audio::RewindableAudioStream *audioStream;
+ActionMusic::~ActionMusic() {
+ if (!_universe)
+ _engine->getScriptManager()->killSideFx(_key);
+}
- if (_fileName.contains(".wav")) {
- Common::File *file = new Common::File();
- if (file->open(_fileName)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+bool ActionMusic::execute() {
+ if (_engine->getScriptManager()->getSideFX(_key))
+ return true;
+ Common::File *file = new Common::File();
+ if (!file->exists(_fileName) && _fileName.size() >= 12) {
+ _fileName.setChar('r', 9);
+ _fileName.setChar('a', 10);
+ _fileName.setChar('w', 11);
+ if (!file->exists(_fileName)) {
+ _fileName.setChar('i', 9);
+ _fileName.setChar('f', 10);
+ _fileName.setChar('p', 11);
+ if (!file->exists(_fileName)) {
+ _fileName.setChar('s', 9);
+ _fileName.setChar('r', 10);
+ _fileName.setChar('c', 11);
+ if (!file->exists(_fileName))
+ return true;
+ }
}
- } 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);
}
+ if (file->exists(_fileName))
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _key, _fileName, _loop, _volume));
+ delete file;
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 8a8412f..7464d83 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -223,7 +223,8 @@ private:
class ActionMusic : public ResultAction {
public:
- ActionMusic(ZVision *engine, const Common::String &line);
+ ActionMusic(ZVision *engine, const Common::String &line, bool global);
+ ~ActionMusic();
bool execute();
private:
@@ -232,6 +233,7 @@ private:
Common::String _fileName;
bool _loop;
byte _volume;
+ bool _universe;
};
class ActionPlayAnimation : public ResultAction {
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index edd08c8..8d37311 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -30,7 +30,8 @@ MODULE_OBJS := \
zfs_archive.o \
zork_avi_decoder.o \
zork_raw.o \
- sidefx.o
+ sidefx.o \
+ music_node.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
new file mode 100644
index 0000000..6be4683
--- /dev/null
+++ b/engines/zvision/music_node.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/music_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+
+namespace ZVision {
+
+MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
+ : SideFX(engine, key, SIDEFX_AUDIO) {
+ _loop = loop;
+ _volume = volume;
+ _crossfade = false;
+ _crossfade_delta = 0;
+ _crossfade_time = 0;
+ _attenuate = 0;
+ _pantrack = false;
+ _pantrack_X = 0;
+
+ Audio::RewindableAudioStream *audioStream;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (file->open(filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _id = _engine->getAudioId();
+
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, loopingAudioStream, _id, _volume);
+ } else {
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, audioStream, _id, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+MusicNode::~MusicNode() {
+ _engine->_mixer->stopID(_id);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ debug(1, "MusicNode: %d destroyed\n", _key);
+}
+
+bool MusicNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundIDActive(_id))
+ return stop();
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
new file mode 100644
index 0000000..6aed455
--- /dev/null
+++ b/engines/zvision/music_node.h
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_MUSIC_NODE_H
+#define ZVISION_MUSIC_NODE_H
+
+#include "zvision/sidefx.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class MusicNode : public SideFX {
+public:
+ MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
+ ~MusicNode();
+
+ /**
+ * 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:
+ int32 _timeLeft;
+ bool _pantrack;
+ int32 _pantrack_X;
+ int32 _attenuate;
+ int8 _volume;
+ int32 _id;
+ bool _loop;
+ bool _crossfade;
+ int32 _crossfade_delta;
+ int32 _crossfade_time;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index bfa1481..0df3143 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -203,7 +203,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:menu_bar_enable*", true)) {
// TODO: Implement ActionMenuBarEnable
} else if (line.matchString("*:music*", true)) {
- actionList.push_back(new ActionMusic(_engine, line));
+ actionList.push_back(new ActionMusic(_engine, line, false));
} else if (line.matchString("*:pan_track*", true)) {
// TODO: Implement ActionPanTrack
} else if (line.matchString("*:playpreload*", true)) {
@@ -239,7 +239,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:ttytext*", true)) {
// TODO: Implement ActionTTYText
} else if (line.matchString("*:universe_music*", true)) {
- // TODO: Implement ActionUniverseMusic
+ actionList.push_back(new ActionMusic(_engine, line, true));
} else if (line.matchString("*:copy_file*", true)) {
// Not used. Purposely left empty
} else {
Commit: 6a135c677920184db0d055230c596fc4bd0a5960
https://github.com/scummvm/scummvm/commit/6a135c677920184db0d055230c596fc4bd0a5960
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-01T17:01:07+07:00
Commit Message:
ZVISION: Add zgi_mx directory for files search
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 9a93259..62061bf 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -95,6 +95,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, "zgi_mx", 0, 1, true);
SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true);
// Find zfs archive files
Commit: 5da10e99b25bfd866b1ef73cadee71bf9b825c52
https://github.com/scummvm/scummvm/commit/5da10e99b25bfd866b1ef73cadee71bf9b825c52
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-07T16:43:45+07:00
Commit Message:
ZVISION: Make source surface const type for read-only access.
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 a240e76..58df5a8 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -159,7 +159,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
}
}
-void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) {
+void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) {
if (src.format != dst.format)
return;
@@ -183,7 +183,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
return;
// Copy rendRect from src surface to dst surface
- byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top);
+ const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top);
byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
int32 w = rendRect.width();
@@ -196,7 +196,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
}
}
-void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) {
+void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) {
if (src.format != dst.format)
return;
@@ -222,7 +222,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1);
// Copy rendRect from src surface to dst surface
- byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top);
+ const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top);
byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
int32 w = rendRect.width();
@@ -231,7 +231,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
for (int32 y = 0; y < h; y++) {
switch (src.format.bytesPerPixel) {
case 1: {
- uint *src_tmp = (uint *)src_buf;
+ const uint *src_tmp = (const uint *)src_buf;
uint *dst_tmp = (uint *)dst_buf;
for (int32 x = 0; x < w; x++) {
if (*src_tmp != _keycolor)
@@ -243,7 +243,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
break;
case 2: {
- uint16 *src_tmp = (uint16 *)src_buf;
+ const uint16 *src_tmp = (const uint16 *)src_buf;
uint16 *dst_tmp = (uint16 *)dst_buf;
for (int32 x = 0; x < w; x++) {
if (*src_tmp != _keycolor)
@@ -255,7 +255,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
break;
case 4: {
- uint32 *src_tmp = (uint32 *)src_buf;
+ const uint32 *src_tmp = (const uint32 *)src_buf;
uint32 *dst_tmp = (uint32 *)dst_buf;
for (int32 x = 0; x < w; x++) {
if (*src_tmp != _keycolor)
@@ -274,14 +274,14 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface
}
}
-void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) {
+void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) {
if (!Common::Rect(dst.w, dst.h).contains(dstPt))
return;
Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
copyRectToSurface(src, dst, srcRect, dstRect);
}
-void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) {
+void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) {
if (!Common::Rect(dst.w, dst.h).contains(dstPt))
return;
Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
@@ -299,7 +299,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1
moveBackground(0);
}
-void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY) {
+void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY) {
Common::Rect srcRect(surface.w, surface.h);
Common::Point dstPt(destX, destY);
@@ -318,7 +318,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1
moveBackground(0);
}
-void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) {
+void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) {
Common::Rect srcRect(surface.w, surface.h);
Common::Point dstPt(destX, destY);
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 37bfcfa..c302844 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -225,7 +225,7 @@ public:
* @param srcRect Rect of source surface
* @param dstRect Rect for destenation surface
*/
- void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect);
+ void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect);
/**
* Copies a rectangla of source surface and copy to destination rect.
@@ -236,7 +236,7 @@ public:
* @param dstRect Rect for destenation surface
* @param colorkey Transparent color
*/
- void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey);
+ void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey);
/**
* Copies a rectangla of source surface and copy to destination rect.
@@ -246,7 +246,7 @@ public:
* @param srcRect Rect of source surface
* @param dstPt Point for destenation surface
*/
- void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt);
+ void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt);
/**
* Copies a rectangla of source surface and copy to destination rect.
@@ -257,7 +257,7 @@ public:
* @param dstPt Point for destenation surface
* @param colorkey Transparent color
*/
- void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey);
+ void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey);
/**
* Blits the image or a portion of the image to the background.
@@ -275,7 +275,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 renderImageToBackground(Graphics::Surface &surface, int16 destinationX, int16 destinationY);
+ void renderImageToBackground(const Graphics::Surface &surface, int16 destinationX, int16 destinationY);
/**
* Blits the image or a portion of the image to the background.
@@ -295,7 +295,7 @@ public:
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
* @param colorkey Transparent color
*/
- void renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey);
+ void renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey);
/**
* Sets the current background image to be used by the RenderManager and immediately
Commit: b635fab6e663b0fac154d4fa75d221db4aabb1f5
https://github.com/scummvm/scummvm/commit/b635fab6e663b0fac154d4fa75d221db4aabb1f5
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-07T16:46:54+07:00
Commit Message:
ZVISION: ActionAssign value can be another slot, ValueSlot must be used.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 3dd6382..4fe288d 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -61,11 +61,19 @@ bool ActionAdd::execute() {
ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) :
ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
+ char buf[64];
+ memset(buf, 0, 64);
+ sscanf(line.c_str(), "%*[^(](%u, %s)", &_key, buf);
+ _value = new ValueSlot(_engine->getScriptManager(), buf);
+}
+
+ActionAssign::~ActionAssign() {
+ if (_value)
+ delete _value;
}
bool ActionAssign::execute() {
- _engine->getScriptManager()->setStateValue(_key, _value);
+ _engine->getScriptManager()->setStateValue(_key, _value->getValue());
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 7464d83..1d7a815 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -100,11 +100,12 @@ private:
class ActionAssign : public ResultAction {
public:
ActionAssign(ZVision *engine, const Common::String &line);
+ ~ActionAssign();
bool execute();
private:
uint32 _key;
- uint _value;
+ ValueSlot *_value;
};
class ActionAttenuate : public ResultAction {
Commit: 7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88
https://github.com/scummvm/scummvm/commit/7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-11-07T17:06:25+07:00
Commit Message:
ZVISION: Make rlf animation logic equivalent to video decoder methods.
Changed paths:
engines/zvision/animation_control.cpp
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 3f9a2e9..5b35a4a 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -94,7 +94,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
return false;
}
- const Graphics::Surface *frame = _animation.rlf->getNextFrame();
+ const Graphics::Surface *frame = _animation.rlf->decodeNextFrame();
// Animation frames for PANORAMAs are transposed, so un-transpose them
RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 795167e..dab32ae 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -43,7 +43,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_height(0),
_frameTime(0),
_frames(0),
- _currentFrame(-1),
+ _currentFrame(0),
_frameBufferByteSize(0) {
if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
@@ -157,8 +157,11 @@ void RlfAnimation::seekToFrame(int frameNumber) {
assert(!_stream);
assert(frameNumber < (int)_frameCount || frameNumber >= -1);
- if (frameNumber == -1) {
- _currentFrame = -1;
+ if (_currentFrame == frameNumber)
+ return;
+
+ if (frameNumber < 0) {
+ _currentFrame = 0;
return;
}
@@ -166,13 +169,15 @@ void RlfAnimation::seekToFrame(int frameNumber) {
int distance = (int)frameNumber - _currentFrame;
for (uint i = 0; i < _completeFrames.size(); ++i) {
int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
- if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
+ if (newDistance < 0)
+ break;
+ if (newDistance > 0 && newDistance < distance) {
closestFrame = _completeFrames[i];
distance = newDistance;
}
}
- for (int i = closestFrame; i <= frameNumber; ++i) {
+ for (int i = closestFrame; i < frameNumber; ++i) {
applyFrameToCurrent(i);
}
@@ -184,24 +189,24 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
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) {
+ // decodeNextFrame() it's cheap.
+ if ((int)frameNumber == _currentFrame - 1) {
return &_currentFrameBuffer;
- } else if (_currentFrame + 1 == (int)frameNumber) {
- return getNextFrame();
+ } else if (_currentFrame == (int)frameNumber) {
+ return decodeNextFrame();
}
seekToFrame(frameNumber);
- return &_currentFrameBuffer;
+ return decodeNextFrame();
}
-const Graphics::Surface *RlfAnimation::getNextFrame() {
- assert(_currentFrame + 1 < (int)_frameCount);
+const Graphics::Surface *RlfAnimation::decodeNextFrame() {
+ assert(_currentFrame < (int)_frameCount);
if (_stream) {
applyFrameToCurrent(readNextFrame());
} else {
- applyFrameToCurrent(_currentFrame + 1);
+ applyFrameToCurrent(_currentFrame);
}
_currentFrame++;
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index b0f7ee2..35916de 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -92,7 +92,7 @@ public:
/**
* Returns the pixel data of the frame specified. It will try to use
- * getNextFrame() if possible. If not, it uses seekToFrame() to
+ * decodeNextFrame() if possible. If not, it uses seekToFrame() to
* update the internal Surface and then returns a pointer to it.
* This function requires _stream = false
*
@@ -101,19 +101,18 @@ public:
*/
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.
+ * Returns the pixel data of current frame and go to next. It is up to the user to
+ * check if the current frame is valid before calling this.
* IE. Use endOfAnimation()
*
* @return A pointer to the pixel data. Do NOT delete this.
*/
- const Graphics::Surface *getNextFrame();
-
+ const Graphics::Surface *decodeNextFrame();
/**
* @return Is the currentFrame is the last frame in the animation?
*/
bool endOfAnimation() {
- return _currentFrame == (int)_frameCount - 1;
+ return _currentFrame == (int)_frameCount;
}
private:
Commit: a0d73c34cf21403be85af43a5f1020ae910edde7
https://github.com/scummvm/scummvm/commit/a0d73c34cf21403be85af43a5f1020ae910edde7
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-13T22:38:57Z
Commit Message:
ZVISION: Code for ActionDisableControl and ActionEnableControl.
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 4fe288d..ea33736 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -137,9 +137,7 @@ ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String
}
bool ActionDisableControl::execute() {
- debug("Disabling control %u", _key);
-
-
+ _engine->getScriptManager()->setStateFlag(_key, Puzzle::DISABLED);
return true;
}
@@ -154,9 +152,7 @@ ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &
}
bool ActionEnableControl::execute() {
- debug("Enabling control %u", _key);
-
-
+ _engine->getScriptManager()->unsetStateFlag(_key, Puzzle::DISABLED);
return true;
}
Commit: 29fc5be12ee5e28e1b74402065858698f4b8eb16
https://github.com/scummvm/scummvm/commit/29fc5be12ee5e28e1b74402065858698f4b8eb16
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:02:18Z
Commit Message:
ZVISION: Don't add puzzle to referencetable[key] twice.
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 b58056a..13fb58b 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -106,6 +106,17 @@ void ScriptManager::execScope(script_scope &scope) {
}
}
+void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
+ if (_referenceTable.contains(key)) {
+ Common::Array<puzzle_ref> *arr = &_referenceTable[key];
+ for (uint32 i = 0; i < arr->size(); i++)
+ if ((*arr)[i].puz == ref.puz)
+ return;
+ }
+
+ _referenceTable[key].push_back(ref);
+}
+
void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) {
// Iterate through each local Puzzle
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) {
@@ -115,12 +126,12 @@ void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) {
ref.scope = &scope;
ref.puz = puzzlePtr;
- _referenceTable[puzzlePtr->key].push_back(ref);
+ referenceTableAddPuzzle(puzzlePtr->key, ref);
// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter)
for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter)
- _referenceTable[entryIter->key].push_back(ref);
+ referenceTableAddPuzzle(entryIter->key, ref);
}
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 487a27c..38d3982 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -236,6 +236,7 @@ public:
Location getCurrentLocation() const;
private:
+ void referenceTableAddPuzzle(uint32 key, puzzle_ref ref);
void addPuzzlesToReferenceTable(script_scope &scope);
void updateNodes(uint deltaTimeMillis);
void updateControls(uint deltaTimeMillis);
Commit: 9363a0d07115368f8964dfca5f48730552ef9855
https://github.com/scummvm/scummvm/commit/9363a0d07115368f8964dfca5f48730552ef9855
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:05:11Z
Commit Message:
ZVISION: Reverse queue puzzles adding to end->begin
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 13fb58b..2885085 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -266,10 +266,11 @@ int ScriptManager::getStateValue(uint32 key) {
void ScriptManager::queuePuzzles(uint32 key) {
if (_referenceTable.contains(key)) {
- for (Common::Array<puzzle_ref>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter)
- if (!iter->puz->addedBySetState) {
- iter->scope->scope_queue->push_back(iter->puz);
- iter->puz->addedBySetState = true;
+ Common::Array<puzzle_ref> *arr = &_referenceTable[key];
+ for (int32 i = arr->size() - 1; i >= 0; i--)
+ if (!(*arr)[i].puz->addedBySetState) {
+ (*arr)[i].scope->scope_queue->push_back((*arr)[i].puz);
+ (*arr)[i].puz->addedBySetState = true;
}
}
}
Commit: 468c44581f4a051d435f8574fa4f689b97188ae2
https://github.com/scummvm/scummvm/commit/468c44581f4a051d435f8574fa4f689b97188ae2
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:10:27Z
Commit Message:
ZVISION: MouseUp and MouseDown now will return break process loop flag.
Changed paths:
engines/zvision/control.h
engines/zvision/input_control.cpp
engines/zvision/input_control.h
engines/zvision/lever_control.cpp
engines/zvision/lever_control.h
engines/zvision/push_toggle_control.cpp
engines/zvision/push_toggle_control.h
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 32c59d6..65d76da 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -54,14 +54,18 @@ public:
* @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) {}
+ virtual bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* 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) {}
+ virtual bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* Called on every MouseMove. Default is NOP.
*
diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp
index 5723a4e..8d9d79b 100644
--- a/engines/zvision/input_control.cpp
+++ b/engines/zvision/input_control.cpp
@@ -93,8 +93,9 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
}
-void InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
_engine->getScriptManager()->focusControl(_key);
+ return false;
}
void InputControl::onKeyDown(Common::KeyState keyState) {
diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h
index 3d7db74..0179bd9 100644
--- a/engines/zvision/input_control.h
+++ b/engines/zvision/input_control.h
@@ -54,7 +54,7 @@ public:
void unfocus() {
_focused = false;
}
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
void onKeyDown(Common::KeyState keyState);
bool process(uint32 deltaTimeInMillis);
};
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index bd2c186..6d13d60 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -190,19 +190,20 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
}
-void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return;
+ return false;
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
}
+ return false;
}
-void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+bool LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return;
+ return false;
if (_mouseIsCaptured) {
_mouseIsCaptured = false;
@@ -212,6 +213,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
_returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
_returnRoutesCurrentFrame = _currentFrame;
}
+ return false;
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 94d23c1..19ecc7b 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -88,8 +88,8 @@ private:
uint32 _accumulatedTime;
public:
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool process(uint32 deltaTimeInMillis);
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 2cea5db..88619e8 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -72,13 +72,15 @@ PushToggleControl::~PushToggleControl() {
_engine->getScriptManager()->setStateValue(_key, 0);
}
-void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return;
+ return false;
if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
+ return true;
}
+ return false;
}
bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h
index 2a407ca..1de279a 100644
--- a/engines/zvision/push_toggle_control.h
+++ b/engines/zvision/push_toggle_control.h
@@ -41,7 +41,7 @@ public:
* @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);
+ bool 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.
*
Commit: 677c74d59ffe43e618911f84c2dd4302cd11478f
https://github.com/scummvm/scummvm/commit/677c74d59ffe43e618911f84c2dd4302cd11478f
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:12:51Z
Commit Message:
ZVISION: Now onMouse functions handle return results and processing control list from end to beginning
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 2885085..c8ef8655 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -392,28 +392,31 @@ void ScriptManager::killSideFxType(SideFX::SideFXType type) {
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_activeControls)
return;
- for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
- (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos))
+ return;
}
}
void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_activeControls)
return;
- for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
- (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos))
+ return;
}
}
bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_activeControls)
return false;
- bool cursorWasChanged = false;
- for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
- cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
+
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos))
+ return true;
}
- return cursorWasChanged;
+ return false;
}
void ScriptManager::onKeyDown(Common::KeyState keyState) {
Commit: 5fd15be0a2810c7c18dca982685c118ee83349e7
https://github.com/scummvm/scummvm/commit/5fd15be0a2810c7c18dca982685c118ee83349e7
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:14:09Z
Commit Message:
ZVISION: Don't output setStateValue debug information.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index c8ef8655..861f0e4 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -280,7 +280,7 @@ void ScriptManager::setStateValue(uint32 key, int value) {
_globalState.erase(key);
else
_globalState[key] = value;
- debug("setStateValue %d %d\n", key , value);
+
queuePuzzles(key);
}
Commit: e3b9f84d8179a69be011f7351fb50635f854bf73
https://github.com/scummvm/scummvm/commit/e3b9f84d8179a69be011f7351fb50635f854bf73
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:15:12Z
Commit Message:
ZVISION: Change _currentLocation to new location before execute first scripts.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 861f0e4..b121eaa 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -523,11 +523,11 @@ void ScriptManager::do_changeLocation() {
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- execScope(room);
- execScope(nodeview);
-
// Update _currentLocation
_currentLocation = _nextLocation;
+
+ execScope(room);
+ execScope(nodeview);
}
void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
Commit: 30ee8ed0fd1e983f5472bd5f382c39ba7e400cb2
https://github.com/scummvm/scummvm/commit/30ee8ed0fd1e983f5472bd5f382c39ba7e400cb2
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:34:11Z
Commit Message:
ZVISION: Refactore AnimationControl to AnimationNode + changes for correct use it from actions.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/animation_control.cpp
engines/zvision/animation_control.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index ea33736..f83d295 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -274,17 +274,29 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St
char fileName[25];
// The two %*u are always 0 and dont seem to have a use
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
+ sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate);
+
+ if (_mask > 0) {
+ byte r, g, b;
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
+ _mask = _engine->_pixelFormat.RGBToColor(r, g, b);
+ }
_fileName = Common::String(fileName);
}
-bool ActionPreloadAnimation::execute() {
- // 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
+ActionPreloadAnimation::~ActionPreloadAnimation() {
+ _engine->getScriptManager()->deleteSideFx(_key);
+}
- // TODO: Check if the Control already exists
+bool ActionPreloadAnimation::execute() {
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
- // Create the control, but disable it until PlayPreload is called
+ if (!nod) {
+ nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false);
+ _engine->getScriptManager()->addSideFX(nod);
+ } else
+ nod->stop();
return true;
}
@@ -299,14 +311,34 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &
// 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)",
+ "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)",
&_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate);
+ if (_mask > 0) {
+ byte r, g, b;
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
+ _mask = _engine->_pixelFormat.RGBToColor(r, g, b);
+ }
+
_fileName = Common::String(fileName);
}
+ActionPlayAnimation::~ActionPlayAnimation() {
+ _engine->getScriptManager()->deleteSideFx(_key);
+}
+
bool ActionPlayAnimation::execute() {
- // TODO: Implement
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
+
+ if (!nod) {
+ nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate);
+ _engine->getScriptManager()->addSideFX(nod);
+ } else
+ nod->stop();
+
+ if (nod)
+ nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount);
+
return true;
}
@@ -323,14 +355,10 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Co
}
bool ActionPlayPreloadAnimation::execute() {
- // 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);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey);
+
+ if (nod)
+ nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 1d7a815..b75c201 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -240,6 +240,7 @@ private:
class ActionPlayAnimation : public ResultAction {
public:
ActionPlayAnimation(ZVision *engine, const Common::String &line);
+ ~ActionPlayAnimation();
bool execute();
private:
@@ -251,9 +252,9 @@ private:
uint32 _height;
uint32 _start;
uint32 _end;
- uint _mask;
- uint _framerate;
- uint _loopCount;
+ int32 _mask;
+ int32 _framerate;
+ int32 _loopCount;
};
class ActionPlayPreloadAnimation : public ResultAction {
@@ -276,13 +277,14 @@ private:
class ActionPreloadAnimation : public ResultAction {
public:
ActionPreloadAnimation(ZVision *engine, const Common::String &line);
+ ~ActionPreloadAnimation();
bool execute();
private:
uint32 _key;
Common::String _fileName;
- uint _mask;
- uint _framerate;
+ int32 _mask;
+ int32 _framerate;
};
class ActionQuit : public ResultAction {
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
index 5b35a4a..f825bbe 100644
--- a/engines/zvision/animation_control.cpp
+++ b/engines/zvision/animation_control.cpp
@@ -37,222 +37,140 @@
namespace ZVision {
-AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName)
- : Control(engine, controlKey),
+AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
+ : SideFX(engine, controlKey, SIDEFX_ANIM),
_fileType(RLF),
- _loopCount(1),
- _currentLoop(0),
- _accumulatedTime(0),
- _cachedFrame(0),
- _cachedFrameNeedsDeletion(false) {
+ _DisposeAfterUse(DisposeAfterUse),
+ _mask(mask) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
_animation.rlf = new RlfAnimation(fileName, false);
+ _frmDelay = _animation.rlf->frameTime();
} else if (fileName.hasSuffix(".avi")) {
_fileType = AVI;
_animation.avi = new ZorkAVIDecoder();
_animation.avi->loadFile(fileName);
+ _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
}
- _cachedFrame = new Graphics::Surface();
+ if (frate > 0)
+ _frmDelay = 1000.0 / frate;
}
-AnimationControl::~AnimationControl() {
+AnimationNode::~AnimationNode() {
if (_fileType == RLF) {
delete _animation.rlf;
} else if (_fileType == AVI) {
delete _animation.avi;
}
- _cachedFrame->free();
- delete _cachedFrame;
-}
-
-bool AnimationControl::process(uint32 deltaTimeInMillis) {
-
- bool finished = false;
+ _engine->getScriptManager()->setStateValue(_key, 2);
- if (_fileType == RLF) {
- _accumulatedTime += deltaTimeInMillis;
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end())
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
- uint32 frameTime = _animation.rlf->frameTime();
- if (_accumulatedTime >= frameTime) {
- while (_accumulatedTime >= frameTime) {
- _accumulatedTime -= frameTime;
+ _playList.clear();
+}
- // Make sure the frame is inside the working window
- // If it's not, then just return
+bool AnimationNode::process(uint32 deltaTimeInMillis) {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+
+ nod->_delay -= deltaTimeInMillis;
+ if (nod->_delay <= 0) {
+ nod->_delay += _frmDelay;
+
+ const Graphics::Surface *frame = NULL;
+
+ if (nod->_cur_frm == -1) { // Start of new playlist node
+ nod->_cur_frm = nod->start;
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(nod->_cur_frm);
+ frame = _animation.rlf->decodeNextFrame();
+ } else if (_fileType == AVI) {
+ _animation.avi->seekToFrame(nod->_cur_frm);
+ frame = _animation.avi->decodeNextFrame();
+ }
- 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());
+ nod->_delay = _frmDelay;
+ if (nod->slot)
+ _engine->getScriptManager()->setStateValue(nod->slot, 1);
+ } else {
+ nod->_cur_frm++;
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
+ if (nod->_cur_frm > nod->stop) {
+ nod->loop--;
- const Graphics::Surface *frame = _animation.rlf->decodeNextFrame();
-
- // 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());
-
- // 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();
- delete tranposedFrame;
+ if (nod->loop == 0) {
+ if (nod->slot >= 0)
+ _engine->getScriptManager()->setStateValue(nod->slot, 2);
+ _playList.erase(it);
+ return _DisposeAfterUse;
}
- } else {
- 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) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _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;
- }
+ nod->_cur_frm = nod->start;
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(nod->_cur_frm);
+ frame = _animation.rlf->decodeNextFrame();
+ } else if (_fileType == AVI) {
+ _animation.avi->seekToFrame(nod->_cur_frm);
+ frame = _animation.avi->decodeNextFrame();
}
+ } else {
+ if (_fileType == RLF)
+ frame = _animation.rlf->decodeNextFrame();
+ else if (_fileType == AVI)
+ frame = _animation.avi->decodeNextFrame();
}
}
- } 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()) {
- _animation.avi->start();
- }
-
- if (_animation.avi->needsUpdate()) {
- 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);
-
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- 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());
-
- // 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();
- delete tranposedFrame;
- }
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
+ Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
+ if (_mask > 0)
+ _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top);
+ delete transposed;
} else {
- 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) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _cachedFrame->copyFrom(*frame);
- }
+ if (_mask > 0)
+ _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top);
}
- } 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);
+ return false;
+}
- // 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());
- }
- }
- }
- // Check if we should continue looping
- if (_animation.avi->endOfVideo()) {
- _animation.avi->rewind();
- if (_loopCount > 0) {
- _currentLoop++;
- if (_currentLoop >= _loopCount) {
- _animation.avi->stop();
- finished = true;
- }
- }
- }
- }
+void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) {
+ playnode nod;
+ nod.loop = loops;
+ nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1);
+ nod.start = start_frame;
+ nod.stop = end_frame;
+ nod.slot = slot;
+ nod._cur_frm = -1;
+ nod._delay = 0;
+ _playList.push_back(nod);
+}
- // 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);
- _currentLoop = 0;
- }
+bool AnimationNode::stop() {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end())
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ _playList.clear();
+ // We don't need to delete, it's may be reused
return false;
}
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
index 247fbf7..e63824f 100644
--- a/engines/zvision/animation_control.h
+++ b/engines/zvision/animation_control.h
@@ -23,7 +23,9 @@
#ifndef ZVISION_ANIMATION_CONTROL_H
#define ZVISION_ANIMATION_CONTROL_H
-#include "zvision/control.h"
+#include "zvision/sidefx.h"
+#include "common/rect.h"
+#include "common/list.h"
namespace Common {
@@ -43,10 +45,20 @@ namespace ZVision {
class ZVision;
class RlfAnimation;
-class AnimationControl : public Control {
+class AnimationNode : public SideFX {
public:
- AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName);
- ~AnimationControl();
+ AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true);
+ ~AnimationNode();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ };
private:
enum FileType {
@@ -55,7 +67,9 @@ private:
};
private:
- uint32 _animationKey;
+ typedef Common::List<playnode> PlayNodes;
+
+ PlayNodes _playList;
union {
RlfAnimation *rlf;
@@ -63,31 +77,16 @@ private:
} _animation;
FileType _fileType;
- uint _loopCount;
- int32 _x;
- int32 _y;
-
- uint _accumulatedTime;
- uint _currentLoop;
-
- Graphics::Surface *_cachedFrame;
- bool _cachedFrameNeedsDeletion;
+ int32 _frmDelay;
+ int32 _mask;
+ bool _DisposeAfterUse;
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;
- }
+ void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1);
+
+ bool stop();
};
} // End of namespace ZVision
Commit: 5ab767cb37da791aa0ca4a1354d405a7ac85f7e6
https://github.com/scummvm/scummvm/commit/5ab767cb37da791aa0ca4a1354d405a7ac85f7e6
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-15T18:46:57Z
Commit Message:
ZVISION: Rename animation_control files to animation_node.
Changed paths:
A engines/zvision/animation_node.cpp
A engines/zvision/animation_node.h
R engines/zvision/animation_control.cpp
R engines/zvision/animation_control.h
engines/zvision/actions.cpp
engines/zvision/module.mk
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index f83d295..f540e3e 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -31,7 +31,7 @@
#include "zvision/zork_avi_decoder.h"
#include "zvision/timer_node.h"
#include "zvision/music_node.h"
-#include "zvision/animation_control.h"
+#include "zvision/animation_node.h"
#include "common/file.h"
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp
deleted file mode 100644
index f825bbe..0000000
--- a/engines/zvision/animation_control.cpp
+++ /dev/null
@@ -1,177 +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/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 {
-
-AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
- : SideFX(engine, controlKey, SIDEFX_ANIM),
- _fileType(RLF),
- _DisposeAfterUse(DisposeAfterUse),
- _mask(mask) {
- if (fileName.hasSuffix(".rlf")) {
- _fileType = RLF;
- _animation.rlf = new RlfAnimation(fileName, false);
- _frmDelay = _animation.rlf->frameTime();
- } else if (fileName.hasSuffix(".avi")) {
- _fileType = AVI;
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
- _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
- } else {
- warning("Unrecognized animation file type: %s", fileName.c_str());
- }
-
- if (frate > 0)
- _frmDelay = 1000.0 / frate;
-}
-
-AnimationNode::~AnimationNode() {
- if (_fileType == RLF) {
- delete _animation.rlf;
- } else if (_fileType == AVI) {
- delete _animation.avi;
- }
-
- _engine->getScriptManager()->setStateValue(_key, 2);
-
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end())
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
-
- _playList.clear();
-}
-
-bool AnimationNode::process(uint32 deltaTimeInMillis) {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- playnode *nod = &(*it);
-
- nod->_delay -= deltaTimeInMillis;
- if (nod->_delay <= 0) {
- nod->_delay += _frmDelay;
-
- const Graphics::Surface *frame = NULL;
-
- if (nod->_cur_frm == -1) { // Start of new playlist node
- nod->_cur_frm = nod->start;
- if (_fileType == RLF) {
- _animation.rlf->seekToFrame(nod->_cur_frm);
- frame = _animation.rlf->decodeNextFrame();
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(nod->_cur_frm);
- frame = _animation.avi->decodeNextFrame();
- }
-
- nod->_delay = _frmDelay;
- if (nod->slot)
- _engine->getScriptManager()->setStateValue(nod->slot, 1);
- } else {
- nod->_cur_frm++;
-
- if (nod->_cur_frm > nod->stop) {
- nod->loop--;
-
- if (nod->loop == 0) {
- if (nod->slot >= 0)
- _engine->getScriptManager()->setStateValue(nod->slot, 2);
- _playList.erase(it);
- return _DisposeAfterUse;
- }
-
- nod->_cur_frm = nod->start;
- if (_fileType == RLF) {
- _animation.rlf->seekToFrame(nod->_cur_frm);
- frame = _animation.rlf->decodeNextFrame();
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(nod->_cur_frm);
- frame = _animation.avi->decodeNextFrame();
- }
- } else {
- if (_fileType == RLF)
- frame = _animation.rlf->decodeNextFrame();
- else if (_fileType == AVI)
- frame = _animation.avi->decodeNextFrame();
- }
- }
-
- if (frame) {
- if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
- Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
- if (_mask > 0)
- _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask);
- else
- _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top);
- delete transposed;
- } else {
- if (_mask > 0)
- _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask);
- else
- _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top);
- }
- }
- }
- }
-
- return false;
-}
-
-
-
-void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) {
- playnode nod;
- nod.loop = loops;
- nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1);
- nod.start = start_frame;
- nod.stop = end_frame;
- nod.slot = slot;
- nod._cur_frm = -1;
- nod._delay = 0;
- _playList.push_back(nod);
-}
-
-bool AnimationNode::stop() {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end())
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
-
- _playList.clear();
-
- // We don't need to delete, it's may be reused
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h
deleted file mode 100644
index e63824f..0000000
--- a/engines/zvision/animation_control.h
+++ /dev/null
@@ -1,94 +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_ANIMATION_CONTROL_H
-#define ZVISION_ANIMATION_CONTROL_H
-
-#include "zvision/sidefx.h"
-#include "common/rect.h"
-#include "common/list.h"
-
-
-namespace Common {
-class String;
-}
-
-namespace Video {
-class VideoDecoder;
-}
-
-namespace Graphics {
-struct Surface;
-}
-
-namespace ZVision {
-
-class ZVision;
-class RlfAnimation;
-
-class AnimationNode : public SideFX {
-public:
- AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true);
- ~AnimationNode();
-
- struct playnode {
- Common::Rect pos;
- int32 slot;
- int32 start;
- int32 stop;
- int32 loop;
- int32 _cur_frm;
- int32 _delay;
- };
-
-private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
-
-private:
- typedef Common::List<playnode> PlayNodes;
-
- PlayNodes _playList;
-
- union {
- RlfAnimation *rlf;
- Video::VideoDecoder *avi;
- } _animation;
-
- FileType _fileType;
- int32 _frmDelay;
- int32 _mask;
- bool _DisposeAfterUse;
-
-public:
- bool process(uint32 deltaTimeInMillis);
-
- void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1);
-
- bool stop();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
new file mode 100644
index 0000000..72afeab
--- /dev/null
+++ b/engines/zvision/animation_node.cpp
@@ -0,0 +1,177 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/animation_node.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 {
+
+AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
+ : SideFX(engine, controlKey, SIDEFX_ANIM),
+ _fileType(RLF),
+ _DisposeAfterUse(DisposeAfterUse),
+ _mask(mask) {
+ if (fileName.hasSuffix(".rlf")) {
+ _fileType = RLF;
+ _animation.rlf = new RlfAnimation(fileName, false);
+ _frmDelay = _animation.rlf->frameTime();
+ } else if (fileName.hasSuffix(".avi")) {
+ _fileType = AVI;
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadFile(fileName);
+ _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+
+ if (frate > 0)
+ _frmDelay = 1000.0 / frate;
+}
+
+AnimationNode::~AnimationNode() {
+ if (_fileType == RLF) {
+ delete _animation.rlf;
+ } else if (_fileType == AVI) {
+ delete _animation.avi;
+ }
+
+ _engine->getScriptManager()->setStateValue(_key, 2);
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end())
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ _playList.clear();
+}
+
+bool AnimationNode::process(uint32 deltaTimeInMillis) {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+
+ nod->_delay -= deltaTimeInMillis;
+ if (nod->_delay <= 0) {
+ nod->_delay += _frmDelay;
+
+ const Graphics::Surface *frame = NULL;
+
+ if (nod->_cur_frm == -1) { // Start of new playlist node
+ nod->_cur_frm = nod->start;
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(nod->_cur_frm);
+ frame = _animation.rlf->decodeNextFrame();
+ } else if (_fileType == AVI) {
+ _animation.avi->seekToFrame(nod->_cur_frm);
+ frame = _animation.avi->decodeNextFrame();
+ }
+
+ nod->_delay = _frmDelay;
+ if (nod->slot)
+ _engine->getScriptManager()->setStateValue(nod->slot, 1);
+ } else {
+ nod->_cur_frm++;
+
+ if (nod->_cur_frm > nod->stop) {
+ nod->loop--;
+
+ if (nod->loop == 0) {
+ if (nod->slot >= 0)
+ _engine->getScriptManager()->setStateValue(nod->slot, 2);
+ _playList.erase(it);
+ return _DisposeAfterUse;
+ }
+
+ nod->_cur_frm = nod->start;
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(nod->_cur_frm);
+ frame = _animation.rlf->decodeNextFrame();
+ } else if (_fileType == AVI) {
+ _animation.avi->seekToFrame(nod->_cur_frm);
+ frame = _animation.avi->decodeNextFrame();
+ }
+ } else {
+ if (_fileType == RLF)
+ frame = _animation.rlf->decodeNextFrame();
+ else if (_fileType == AVI)
+ frame = _animation.avi->decodeNextFrame();
+ }
+ }
+
+ if (frame) {
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
+ Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
+ if (_mask > 0)
+ _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top);
+ delete transposed;
+ } else {
+ if (_mask > 0)
+ _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
+
+void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) {
+ playnode nod;
+ nod.loop = loops;
+ nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1);
+ nod.start = start_frame;
+ nod.stop = end_frame;
+ nod.slot = slot;
+ nod._cur_frm = -1;
+ nod._delay = 0;
+ _playList.push_back(nod);
+}
+
+bool AnimationNode::stop() {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end())
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ _playList.clear();
+
+ // We don't need to delete, it's may be reused
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h
new file mode 100644
index 0000000..76c961c
--- /dev/null
+++ b/engines/zvision/animation_node.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_NODE_H
+#define ZVISION_ANIMATION_NODE_H
+
+#include "zvision/sidefx.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace Common {
+class String;
+}
+
+namespace Video {
+class VideoDecoder;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+class RlfAnimation;
+
+class AnimationNode : public SideFX {
+public:
+ AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true);
+ ~AnimationNode();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ };
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+private:
+ typedef Common::List<playnode> PlayNodes;
+
+ PlayNodes _playList;
+
+ union {
+ RlfAnimation *rlf;
+ Video::VideoDecoder *avi;
+ } _animation;
+
+ FileType _fileType;
+ int32 _frmDelay;
+ int32 _mask;
+ bool _DisposeAfterUse;
+
+public:
+ bool process(uint32 deltaTimeInMillis);
+
+ void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1);
+
+ bool stop();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 8d37311..b66f02d 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -2,7 +2,7 @@ MODULE := engines/zvision
MODULE_OBJS := \
actions.o \
- animation_control.o \
+ animation_node.o \
clock.o \
console.o \
control.o \
Commit: ff541a0d021796d0c42d627dc4dcfe91c1335487
https://github.com/scummvm/scummvm/commit/ff541a0d021796d0c42d627dc4dcfe91c1335487
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-20T11:44:43Z
Commit Message:
ZVISION: Impliment inventory functions and ActionInventory.
Changed paths:
A engines/zvision/inventory_manager.cpp
R engines/zvision/inventory_manager.h
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
engines/zvision/script_manager.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index f540e3e..5568e39 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -156,6 +156,55 @@ bool ActionEnableControl::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionInventory
+//////////////////////////////////////////////////////////////////////////////
+
+ActionInventory::ActionInventory(ZVision *engine, const Common::String &line) :
+ ResultAction(engine) {
+ char buf[25];
+ sscanf(line.c_str(), "%*[^(](%25s %d)", buf, &_key);
+
+ if (strcmp(buf, "add") == 0) {
+ _type = 0;
+ } else if (strcmp(buf, "addi") == 0) {
+ _type = 1;
+ } else if (strcmp(buf, "drop") == 0) {
+ _type = 2;
+ } else if (strcmp(buf, "dropi") == 0) {
+ _type = 3;
+ } else if (strcmp(buf, "cycle") == 0) {
+ _type = 4;
+ }
+
+}
+
+bool ActionInventory::execute() {
+ switch (_type) {
+ case 0: // add
+ _engine->getScriptManager()->invertory_add(_key);
+ break;
+ case 1: // addi
+ _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(_key));
+ break;
+ case 2: // drop
+ if (_key >= 0)
+ _engine->getScriptManager()->invertory_drop(_key);
+ else
+ _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem));
+ break;
+ case 3: // dropi
+ _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(_key));
+ break;
+ case 4: // cycle
+ _engine->getScriptManager()->invertory_cycle();
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionKill
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index b75c201..50224aa 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -212,6 +212,15 @@ private:
uint32 _key;
};
+class ActionInventory : public ResultAction {
+public:
+ ActionInventory(ZVision *engine, const Common::String &line);
+ bool execute();
+private:
+ uint8 _type;
+ int32 _key;
+};
+
class ActionKill : public ResultAction {
public:
ActionKill(ZVision *engine, const Common::String &line);
diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp
new file mode 100644
index 0000000..3924c6b
--- /dev/null
+++ b/engines/zvision/inventory_manager.cpp
@@ -0,0 +1,123 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* 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/script_manager.h"
+
+
+namespace ZVision {
+
+int8 ScriptManager::invertory_getCount() {
+ return getStateValue(StateKey_Inv_Cnt_Slot);
+}
+
+void ScriptManager::invertory_setCount(int8 cnt) {
+ setStateValue(StateKey_Inv_Cnt_Slot, cnt);
+}
+
+int16 ScriptManager::invertory_getItem(int8 id) {
+ if (id < 49 && id >= 0)
+ return getStateValue(StateKey_Inv_1_Slot + id);
+ return -1;
+}
+
+void ScriptManager::invertory_setItem(int8 id, int16 item) {
+ if (id < 49 && id >= 0)
+ setStateValue(StateKey_Inv_1_Slot + id, item);
+}
+
+void ScriptManager::invertory_add(int16 item) {
+ int8 cnt = invertory_getCount();
+
+ if (cnt < 49) {
+ bool not_exist = true;
+
+ if (cnt == 0) {
+ invertory_setItem(0, 0);
+ invertory_setCount(1); // we needed empty item for cycle code
+ cnt = 1;
+ }
+
+ for (int8 cur = 0; cur < cnt; cur++)
+ if (invertory_getItem(cur) == item) {
+ not_exist = false;
+ break;
+ }
+
+ if (not_exist) {
+ for (int8 i = cnt; i > 0; i--)
+ invertory_setItem(i, invertory_getItem(i - 1));
+
+ invertory_setItem(0, item);
+
+ setStateValue(StateKey_InventoryItem, item);
+
+ invertory_setCount(cnt + 1);
+ }
+ }
+}
+
+void ScriptManager::invertory_drop(int16 item) {
+ int8 items_cnt = invertory_getCount();
+
+ // if items in inventory > 0
+ if (items_cnt != 0) {
+ int8 index = 0;
+
+ // finding needed item
+ while (index < items_cnt) {
+ if (invertory_getItem(index) == item)
+ break;
+
+ index++;
+ }
+
+ // if item in the inventory
+ if (items_cnt != index) {
+ // shift all items left with rewrite founded item
+ for (int8 v = index; v < items_cnt - 1 ; v++)
+ invertory_setItem(v, invertory_getItem(v + 1));
+
+ // del last item
+ invertory_setItem(items_cnt - 1, 0);
+ invertory_setCount(invertory_getCount() - 1);
+
+ setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+ }
+ }
+}
+void ScriptManager::invertory_cycle() {
+ int8 item_cnt = invertory_getCount();
+ int8 cur_item = invertory_getItem(0);
+ if (item_cnt > 1) {
+ for (int8 i = 0; i < item_cnt - 1; i++)
+ invertory_setItem(i, invertory_getItem(i + 1));
+
+ invertory_setItem(item_cnt - 1, cur_item);
+
+ setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/inventory_manager.h b/engines/zvision/inventory_manager.h
deleted file mode 100644
index ae6d116..0000000
--- a/engines/zvision/inventory_manager.h
+++ /dev/null
@@ -1,28 +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_INVENTORY_MANAGER_H
-#define ZVISION_INVENTORY_MANAGER_H
-
-// TODO: Implement InventoryManager
-
-#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index b66f02d..ffdef16 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -31,7 +31,8 @@ MODULE_OBJS := \
zork_avi_decoder.o \
zork_raw.o \
sidefx.o \
- music_node.o
+ music_node.o \
+ inventory_manager.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 0df3143..769c949 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -197,7 +197,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:flush_mouse_events*", true)) {
// TODO: Implement ActionFlushMouseEvents
} else if (line.matchString("*:inventory*", true)) {
- // TODO: Implement ActionInventory
+ actionList.push_back(new ActionInventory(_engine, line));
} else if (line.matchString("*:kill*", true)) {
actionList.push_back(new ActionKill(_engine, line));
} else if (line.matchString("*:menu_bar_enable*", true)) {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 38d3982..2f585b6 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -90,7 +90,7 @@ enum StateKey {
StateKey_EF9_G = 92,
StateKey_EF9_R = 93,
StateKey_EF9_Speed = 94,
- StateKey_Inv_0_Slot = 100,
+ StateKey_Inv_Cnt_Slot = 100,
StateKey_Inv_1_Slot = 101,
StateKey_Inv_49_Slot = 149,
StateKey_Inv_TotalSlots = 150
@@ -248,8 +248,18 @@ private:
/** Perform change location */
void do_changeLocation();
-// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
+ int8 invertory_getCount();
+ void invertory_setCount(int8 cnt);
+ int16 invertory_getItem(int8 id);
+ void invertory_setItem(int8 id, int16 item);
+
+
public:
+ void invertory_add(int16 item);
+ void invertory_drop(int16 item);
+ void invertory_cycle();
+
+ // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
/**
* Parses a script file into triggers and events
*
Commit: f877410feef2e0030dd6c0664d615cc86118ca29
https://github.com/scummvm/scummvm/commit/f877410feef2e0030dd6c0664d615cc86118ca29
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-20T11:45:52Z
Commit Message:
ZVISION: Add new ChangeCursor method for load items icons.
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 385e4dc..de229a3 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -116,6 +116,23 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed)
warning("No cursor found for identifier %s", cursorName.c_str());
}
+void CursorManager::changeCursor(int id, bool active, bool pushed) {
+ Common::String file;
+ if (_engine->getGameId() == GID_NEMESIS) {
+ file = Common::String::format("%2.2d%s%c.zcr", id, active ? "act" : "idle", pushed ? 'b' : 'a');
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ file = Common::String::format("g0b%cc%2.2x1.zcr", active ? (pushed ? 'd' : 'c') : (pushed ? 'b' : 'a') , id);
+ } else
+ return;
+
+ if (_currentCursor.equals(file))
+ return;
+
+ _currentCursor = file;
+
+ changeCursor(ZorkCursor(file));
+}
+
void CursorManager::changeCursor(const ZorkCursor &cursor) {
CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat);
}
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 0173bf8..ac79b25 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -81,6 +81,8 @@ public:
* @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);
+
+ void changeCursor(int id, bool active, bool pushed);
/**
* Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen.
*
Commit: 4cb006f2602199a3f201f918392f3e66a385df0e
https://github.com/scummvm/scummvm/commit/4cb006f2602199a3f201f918392f3e66a385df0e
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-24T14:48:45Z
Commit Message:
ZVISION: Animation nodes now scaleable.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/animation_node.cpp
engines/zvision/animation_node.h
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 5568e39..2fbec29 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -361,7 +361,7 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &
// 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 %d %*u %*u %d %d)",
- &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate);
+ &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
if (_mask > 0) {
byte r, g, b;
@@ -386,7 +386,7 @@ bool ActionPlayAnimation::execute() {
nod->stop();
if (nod)
- nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount);
+ nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount);
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 50224aa..d987132 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -257,8 +257,8 @@ private:
Common::String _fileName;
uint32 _x;
uint32 _y;
- uint32 _width;
- uint32 _height;
+ uint32 _x2;
+ uint32 _y2;
uint32 _start;
uint32 _end;
int32 _mask;
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 72afeab..73e419e 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -69,9 +69,13 @@ AnimationNode::~AnimationNode() {
_engine->getScriptManager()->setStateValue(_key, 2);
PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end())
+ if (it != _playList.end()) {
_engine->getScriptManager()->setStateValue((*it).slot, 2);
+ if ((*it)._scaled)
+ delete(*it)._scaled;
+ }
+
_playList.clear();
}
@@ -108,6 +112,8 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
if (nod->loop == 0) {
if (nod->slot >= 0)
_engine->getScriptManager()->setStateValue(nod->slot, 2);
+ if (nod->_scaled)
+ delete nod->_scaled;
_playList.erase(it);
return _DisposeAfterUse;
}
@@ -129,6 +135,33 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
}
if (frame) {
+
+ uint32 dstw;
+ uint32 dsth;
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
+ dstw = nod->pos.height();
+ dsth = nod->pos.width();
+ } else {
+ dstw = nod->pos.width();
+ dsth = nod->pos.height();
+ }
+
+ if (frame->w != dstw || frame->h != dsth) {
+ if (nod->_scaled)
+ if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
+ delete nod->_scaled;
+ nod->_scaled = NULL;
+ }
+
+ if (!nod->_scaled) {
+ nod->_scaled = new Graphics::Surface;
+ nod->_scaled->create(dstw, dsth, frame->format);
+ }
+
+ _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
+ frame = nod->_scaled;
+ }
+
if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
if (_mask > 0)
@@ -151,22 +184,26 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
-void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) {
+void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) {
playnode nod;
nod.loop = loops;
- nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1);
+ nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
nod.start = start_frame;
nod.stop = end_frame;
nod.slot = slot;
nod._cur_frm = -1;
nod._delay = 0;
+ nod._scaled = NULL;
_playList.push_back(nod);
}
bool AnimationNode::stop() {
PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end())
+ if (it != _playList.end()) {
_engine->getScriptManager()->setStateValue((*it).slot, 2);
+ if ((*it)._scaled)
+ delete(*it)._scaled;
+ }
_playList.clear();
diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h
index 76c961c..843e592 100644
--- a/engines/zvision/animation_node.h
+++ b/engines/zvision/animation_node.h
@@ -58,6 +58,7 @@ public:
int32 loop;
int32 _cur_frm;
int32 _delay;
+ Graphics::Surface *_scaled;
};
private:
@@ -84,7 +85,7 @@ private:
public:
bool process(uint32 deltaTimeInMillis);
- void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1);
+ void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1);
bool stop();
};
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 58df5a8..fc15e18 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -694,4 +694,31 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa
return tranposedSurface;
}
+void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight) {
+ assert(bytesPerPixel == 1 || bytesPerPixel == 2);
+
+ const float xscale = (float)srcWidth / (float)dstWidth;
+ const float yscale = (float)srcHeight / (float)dstHeight;
+
+ if (bytesPerPixel == 1) {
+ const byte *srcPtr = (const byte *)src;
+ byte *dstPtr = (byte *)dst;
+ for (uint32 y = 0; y < dstHeight; ++y) {
+ for (uint32 x = 0; x < dstWidth; ++x) {
+ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
+ dstPtr++;
+ }
+ }
+ } else if (bytesPerPixel == 2) {
+ const uint16 *srcPtr = (const uint16 *)src;
+ uint16 *dstPtr = (uint16 *)dst;
+ for (uint32 y = 0; y < dstHeight; ++y) {
+ for (uint32 x = 0; x < dstWidth; ++x) {
+ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
+ dstPtr++;
+ }
+ }
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index c302844..14ca704 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -367,6 +367,8 @@ public:
*/
static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface);
+ void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
+
private:
/**
* Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect
Commit: 1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05
https://github.com/scummvm/scummvm/commit/1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-25T13:30:29Z
Commit Message:
ZVISION: Refactor parsing actions, it must handle presence/miss of slot key in same actions.
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 2fbec29..9670016 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -44,9 +44,9 @@ namespace ZVision {
// ActionAdd
//////////////////////////////////////////////////////////////////////////////
-ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u,%d)", &_key, &_value);
+ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%u,%d", &_key, &_value);
}
bool ActionAdd::execute() {
@@ -59,11 +59,11 @@ bool ActionAdd::execute() {
// ActionAssign
//////////////////////////////////////////////////////////////////////////////
-ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char buf[64];
memset(buf, 0, 64);
- sscanf(line.c_str(), "%*[^(](%u, %s)", &_key, buf);
+ sscanf(line.c_str(), "%u, %s", &_key, buf);
_value = new ValueSlot(_engine->getScriptManager(), buf);
}
@@ -82,9 +82,9 @@ bool ActionAssign::execute() {
// ActionAttenuate
//////////////////////////////////////////////////////////////////////////////
-ActionAttenuate::ActionAttenuate(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
+ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%u, %d", &_key, &_attenuation);
}
bool ActionAttenuate::execute() {
@@ -97,9 +97,9 @@ bool ActionAttenuate::execute() {
// ActionChangeLocation
//////////////////////////////////////////////////////////////////////////////
-ActionChangeLocation::ActionChangeLocation(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset);
+ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset);
}
bool ActionChangeLocation::execute() {
@@ -114,10 +114,10 @@ bool ActionChangeLocation::execute() {
// ActionCrossfade
//////////////////////////////////////////////////////////////////////////////
-ActionCrossfade::ActionCrossfade(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
sscanf(line.c_str(),
- "%*[^(](%u %u %u %u %u %u %u)",
+ "%u %u %u %u %u %u %u",
&_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
}
@@ -131,9 +131,9 @@ bool ActionCrossfade::execute() {
// ActionDisableControl
//////////////////////////////////////////////////////////////////////////////
-ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
+ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%u", &_key);
}
bool ActionDisableControl::execute() {
@@ -146,9 +146,9 @@ bool ActionDisableControl::execute() {
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
-ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
+ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%u", &_key);
}
bool ActionEnableControl::execute() {
@@ -160,10 +160,10 @@ bool ActionEnableControl::execute() {
// ActionInventory
//////////////////////////////////////////////////////////////////////////////
-ActionInventory::ActionInventory(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char buf[25];
- sscanf(line.c_str(), "%*[^(](%25s %d)", buf, &_key);
+ sscanf(line.c_str(), "%25s %d", buf, &_key);
if (strcmp(buf, "add") == 0) {
_type = 0;
@@ -210,12 +210,12 @@ bool ActionInventory::execute() {
// ActionKill
//////////////////////////////////////////////////////////////////////////////
-ActionKill::ActionKill(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
_key = 0;
_type = 0;
char keytype[25];
- sscanf(line.c_str(), "%*[^(](%25s)", keytype);
+ sscanf(line.c_str(), "%25s", keytype);
if (keytype[0] == '"') {
if (!scumm_stricmp(keytype, "\"ANIM\""))
_type = SideFX::SIDEFX_ANIM;
@@ -250,8 +250,8 @@ bool ActionKill::execute() {
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
-ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool global) :
- ResultAction(engine),
+ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) :
+ ResultAction(engine, slotkey),
_volume(255),
_universe(global) {
uint type;
@@ -259,7 +259,7 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa
uint loop;
uint volume = 255;
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
+ sscanf(line.c_str(), "%u %25s %u %u", &type, fileNameBuffer, &loop, &volume);
// type 4 are midi sound effect files
if (type == 4) {
@@ -282,11 +282,11 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa
ActionMusic::~ActionMusic() {
if (!_universe)
- _engine->getScriptManager()->killSideFx(_key);
+ _engine->getScriptManager()->killSideFx(_slotkey);
}
bool ActionMusic::execute() {
- if (_engine->getScriptManager()->getSideFX(_key))
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
return true;
Common::File *file = new Common::File();
if (!file->exists(_fileName) && _fileName.size() >= 12) {
@@ -307,7 +307,7 @@ bool ActionMusic::execute() {
}
}
if (file->exists(_fileName))
- _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _key, _fileName, _loop, _volume));
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
delete file;
return true;
@@ -318,12 +318,12 @@ bool ActionMusic::execute() {
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char fileName[25];
// The two %*u are always 0 and dont seem to have a use
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate);
+ sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate);
if (_mask > 0) {
byte r, g, b;
@@ -335,14 +335,14 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St
}
ActionPreloadAnimation::~ActionPreloadAnimation() {
- _engine->getScriptManager()->deleteSideFx(_key);
+ _engine->getScriptManager()->deleteSideFx(_slotkey);
}
bool ActionPreloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
if (!nod) {
- nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false);
+ nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
@@ -354,14 +354,14 @@ bool ActionPreloadAnimation::execute() {
// ActionPlayAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char fileName[25];
// 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 %d %*u %*u %d %d)",
- &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
+ "%25s %u %u %u %u %u %u %d %*u %*u %d %d",
+ fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
if (_mask > 0) {
byte r, g, b;
@@ -373,20 +373,20 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &
}
ActionPlayAnimation::~ActionPlayAnimation() {
- _engine->getScriptManager()->deleteSideFx(_key);
+ _engine->getScriptManager()->deleteSideFx(_slotkey);
}
bool ActionPlayAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
if (!nod) {
- nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate);
+ nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
if (nod)
- nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount);
+ nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount);
return true;
}
@@ -396,18 +396,18 @@ bool ActionPlayAnimation::execute() {
// ActionPlayPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
sscanf(line.c_str(),
- "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)",
- &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
+ "%u %u %u %u %u %u %u %u",
+ &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
}
bool ActionPlayPreloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey);
if (nod)
- nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
+ nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
return true;
}
@@ -428,11 +428,11 @@ bool ActionQuit::execute() {
// ActionRandom
//////////////////////////////////////////////////////////////////////////////
-ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char max_buf[64];
memset(max_buf, 0, 64);
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf);
+ sscanf(line.c_str(), "%s", max_buf);
_max = new ValueSlot(_engine->getScriptManager(), max_buf);
}
@@ -443,7 +443,7 @@ ActionRandom::~ActionRandom() {
bool ActionRandom::execute() {
uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue());
- _engine->getScriptManager()->setStateValue(_key, randNumber);
+ _engine->getScriptManager()->setStateValue(_slotkey, randNumber);
return true;
}
@@ -452,12 +452,12 @@ bool ActionRandom::execute() {
// ActionSetPartialScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char fileName[25];
int color;
- sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %d)", &_x, &_y, fileName, &color);
+ sscanf(line.c_str(), "%u %u %25s %*u %d", &_x, &_y, fileName, &color);
_fileName = Common::String(fileName);
@@ -489,10 +489,10 @@ bool ActionSetPartialScreen::execute() {
// ActionSetScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetScreen::ActionSetScreen(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char fileName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
+ sscanf(line.c_str(), "%25s", fileName);
_fileName = Common::String(fileName);
}
@@ -507,10 +507,10 @@ bool ActionSetScreen::execute() {
// ActionStop
//////////////////////////////////////////////////////////////////////////////
-ActionStop::ActionStop(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
_key = 0;
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
+ sscanf(line.c_str(), "%u", &_key);
}
bool ActionStop::execute() {
@@ -523,12 +523,12 @@ bool ActionStop::execute() {
// ActionStreamVideo
//////////////////////////////////////////////////////////////////////////////
-ActionStreamVideo::ActionStreamVideo(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char fileName[25];
uint skipline; //skipline - render video with skip every second line, not skippable.
- sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline);
+ sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline);
_fileName = Common::String(fileName);
_skippable = true;
@@ -554,22 +554,22 @@ bool ActionStreamVideo::execute() {
// ActionTimer
//////////////////////////////////////////////////////////////////////////////
-ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) :
- ResultAction(engine) {
+ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
char time_buf[64];
memset(time_buf, 0, 64);
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, time_buf);
+ sscanf(line.c_str(), "%s", time_buf);
_time = new ValueSlot(_engine->getScriptManager(), time_buf);
}
ActionTimer::~ActionTimer() {
if (_time)
delete _time;
- _engine->getScriptManager()->killSideFx(_key);
+ _engine->getScriptManager()->killSideFx(_slotkey);
}
bool ActionTimer::execute() {
- _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time->getValue()));
+ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue()));
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index d987132..aadb97f 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -40,7 +40,7 @@ class ValueSlot;
*/
class ResultAction {
public:
- ResultAction(ZVision *engine) : _engine(engine) {}
+ ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {}
virtual ~ResultAction() {}
/**
* This is called by the script system whenever a Puzzle's criteria are found to be true.
@@ -53,6 +53,7 @@ public:
virtual bool execute() = 0;
protected:
ZVision *_engine;
+ int32 _slotkey;
};
@@ -89,7 +90,7 @@ protected:
class ActionAdd : public ResultAction {
public:
- ActionAdd(ZVision *engine, const Common::String &line);
+ ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -99,7 +100,7 @@ private:
class ActionAssign : public ResultAction {
public:
- ActionAssign(ZVision *engine, const Common::String &line);
+ ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line);
~ActionAssign();
bool execute();
@@ -110,7 +111,7 @@ private:
class ActionAttenuate : public ResultAction {
public:
- ActionAttenuate(ZVision *engine, const Common::String &line);
+ ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -120,7 +121,7 @@ private:
class ActionChangeLocation : public ResultAction {
public:
- ActionChangeLocation(ZVision *engine, const Common::String &line);
+ ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -133,7 +134,7 @@ private:
class ActionCrossfade : public ResultAction {
public:
- ActionCrossfade(ZVision *engine, const Common::String &line);
+ ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -148,7 +149,7 @@ private:
class ActionDebug : public ResultAction {
public:
- ActionDebug(ZVision *engine, const Common::String &line);
+ ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -156,7 +157,7 @@ private:
class ActionDelayRender : public ResultAction {
public:
- ActionDelayRender(ZVision *engine, const Common::String &line);
+ ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -166,7 +167,7 @@ private:
class ActionDisableControl : public ResultAction {
public:
- ActionDisableControl(ZVision *engine, const Common::String &line);
+ ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -175,7 +176,7 @@ private:
class ActionDisableVenus : public ResultAction {
public:
- ActionDisableVenus(ZVision *engine, const Common::String &line);
+ ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -183,7 +184,7 @@ private:
class ActionDisplayMessage : public ResultAction {
public:
- ActionDisplayMessage(ZVision *engine, const Common::String &line);
+ ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -197,7 +198,7 @@ public:
class ActionDistort : public ResultAction {
public:
- ActionDistort(ZVision *engine, const Common::String &line);
+ ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -205,7 +206,7 @@ private:
class ActionEnableControl : public ResultAction {
public:
- ActionEnableControl(ZVision *engine, const Common::String &line);
+ ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -214,7 +215,7 @@ private:
class ActionInventory : public ResultAction {
public:
- ActionInventory(ZVision *engine, const Common::String &line);
+ ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
uint8 _type;
@@ -223,7 +224,7 @@ private:
class ActionKill : public ResultAction {
public:
- ActionKill(ZVision *engine, const Common::String &line);
+ ActionKill(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -233,7 +234,7 @@ private:
class ActionMusic : public ResultAction {
public:
- ActionMusic(ZVision *engine, const Common::String &line, bool global);
+ ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global);
~ActionMusic();
bool execute();
@@ -248,7 +249,7 @@ private:
class ActionPlayAnimation : public ResultAction {
public:
- ActionPlayAnimation(ZVision *engine, const Common::String &line);
+ ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
~ActionPlayAnimation();
bool execute();
@@ -268,7 +269,7 @@ private:
class ActionPlayPreloadAnimation : public ResultAction {
public:
- ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line);
+ ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -285,7 +286,7 @@ private:
class ActionPreloadAnimation : public ResultAction {
public:
- ActionPreloadAnimation(ZVision *engine, const Common::String &line);
+ ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
~ActionPreloadAnimation();
bool execute();
@@ -298,20 +299,20 @@ private:
class ActionQuit : public ResultAction {
public:
- ActionQuit(ZVision *engine) : ResultAction(engine) {}
+ ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {}
bool execute();
};
// TODO: See if this exists in ZGI. It doesn't in ZNem
class ActionUnloadAnimation : public ResultAction {
public:
- ActionUnloadAnimation(ZVision *engine, const Common::String &line);
+ ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
};
class ActionRandom : public ResultAction {
public:
- ActionRandom(ZVision *engine, const Common::String &line);
+ ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line);
~ActionRandom();
bool execute();
@@ -322,7 +323,7 @@ private:
class ActionSetPartialScreen : public ResultAction {
public:
- ActionSetPartialScreen(ZVision *engine, const Common::String &line);
+ ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -334,7 +335,7 @@ private:
class ActionSetScreen : public ResultAction {
public:
- ActionSetScreen(ZVision *engine, const Common::String &line);
+ ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -343,7 +344,7 @@ private:
class ActionStop : public ResultAction {
public:
- ActionStop(ZVision *engine, const Common::String &line);
+ ActionStop(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -352,7 +353,7 @@ private:
class ActionStreamVideo : public ResultAction {
public:
- ActionStreamVideo(ZVision *engine, const Common::String &line);
+ ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
private:
@@ -371,7 +372,7 @@ private:
class ActionTimer : public ResultAction {
public:
- ActionTimer(ZVision *engine, const Common::String &line);
+ ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line);
~ActionTimer();
bool execute();
private:
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 769c949..0149347 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -161,89 +161,132 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
continue;
}
- // Parse for the action type
- if (line.matchString("*:add*", true)) {
- actionList.push_back(new ActionAdd(_engine, line));
- } else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(new ActionPlayAnimation(_engine, line));
- } else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(new ActionPreloadAnimation(_engine, line));
- } else if (line.matchString("*:animunload*", true)) {
- //actionList.push_back(new ActionUnloadAnimation(_engine, line));
- } else if (line.matchString("*:attenuate*", true)) {
- // TODO: Implement ActionAttenuate
- } else if (line.matchString("*:assign*", true)) {
- actionList.push_back(new ActionAssign(_engine, line));
- } else if (line.matchString("*:change_location*", true)) {
- actionList.push_back(new ActionChangeLocation(_engine, 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(_engine, 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(_engine, line));
- } else if (line.matchString("*:flush_mouse_events*", true)) {
- // TODO: Implement ActionFlushMouseEvents
- } else if (line.matchString("*:inventory*", true)) {
- actionList.push_back(new ActionInventory(_engine, line));
- } else if (line.matchString("*:kill*", true)) {
- actionList.push_back(new ActionKill(_engine, line));
- } else if (line.matchString("*:menu_bar_enable*", true)) {
- // TODO: Implement ActionMenuBarEnable
- } else if (line.matchString("*:music*", true)) {
- actionList.push_back(new ActionMusic(_engine, line, false));
- } else if (line.matchString("*:pan_track*", true)) {
- // TODO: Implement ActionPanTrack
- } else if (line.matchString("*:playpreload*", true)) {
- actionList.push_back(new ActionPlayPreloadAnimation(_engine, line));
- } else if (line.matchString("*:preferences*", true)) {
- // TODO: Implement ActionPreferences
- } else if (line.matchString("*:quit*", true)) {
- actionList.push_back(new ActionQuit(_engine));
- } else if (line.matchString("*:random*", true)) {
- actionList.push_back(new ActionRandom(_engine, line));
- } 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(_engine, line));
- } else if (line.matchString("*:set_screen*", true)) {
- actionList.push_back(new ActionSetScreen(_engine, line));
- } else if (line.matchString("*:set_venus*", true)) {
- // TODO: Implement ActionSetVenus
- } else if (line.matchString("*:stop*", true)) {
- actionList.push_back(new ActionStop(_engine, line));
- } else if (line.matchString("*:streamvideo*", true)) {
- actionList.push_back(new ActionStreamVideo(_engine, line));
- } else if (line.matchString("*:syncsound*", true)) {
- // TODO: Implement ActionSyncSound
- } else if (line.matchString("*:timer*", true)) {
- actionList.push_back(new ActionTimer(_engine, line));
- } else if (line.matchString("*:ttytext*", true)) {
- // TODO: Implement ActionTTYText
- } else if (line.matchString("*:universe_music*", true)) {
- actionList.push_back(new ActionMusic(_engine, line, true));
- } else if (line.matchString("*:copy_file*", true)) {
- // Not used. Purposely left empty
- } else {
- warning("Unhandled result action type: %s", line.c_str());
+ const char *chrs = line.c_str();
+ uint pos;
+ for (pos = 0; pos < line.size(); pos++)
+ if (chrs[pos] == ':')
+ break;
+
+ if (pos < line.size()) {
+
+ uint startpos = pos + 1;
+
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == ':' || chrs[pos] == '(')
+ break;
+
+ if (pos < line.size()) {
+ int32 slot = 11;
+ Common::String args = "";
+ Common::String act(chrs + startpos, chrs + pos);
+
+ startpos = pos + 1;
+
+ if (chrs[pos] == ':') {
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == '(')
+ break;
+ Common::String s_slot(chrs + startpos, chrs + pos);
+ slot = atoi(s_slot.c_str());
+
+ startpos = pos + 1;
+ }
+
+ if (pos < line.size()) {
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == ')')
+ break;
+
+ args = Common::String(chrs + startpos, chrs + pos);
+ }
+
+
+
+ // Parse for the action type
+ if (act.matchString("add", true)) {
+ actionList.push_back(new ActionAdd(_engine, slot, args));
+ } else if (act.matchString("animplay", true)) {
+ actionList.push_back(new ActionPlayAnimation(_engine, slot, args));
+ } else if (act.matchString("animpreload", true)) {
+ actionList.push_back(new ActionPreloadAnimation(_engine, slot, args));
+ } else if (act.matchString("animunload", true)) {
+ //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
+ } else if (act.matchString("attenuate", true)) {
+ // TODO: Implement ActionAttenuate
+ } else if (act.matchString("assign", true)) {
+ actionList.push_back(new ActionAssign(_engine, slot, args));
+ } else if (act.matchString("change_location", true)) {
+ actionList.push_back(new ActionChangeLocation(_engine, slot, args));
+ } else if (act.matchString("crossfade", true)) {
+ // TODO: Implement ActionCrossfade
+ } else if (act.matchString("debug", true)) {
+ // TODO: Implement ActionDebug
+ } else if (act.matchString("delay_render", true)) {
+ // TODO: Implement ActionDelayRender
+ } else if (act.matchString("disable_control", true)) {
+ actionList.push_back(new ActionDisableControl(_engine, slot, args));
+ } else if (act.matchString("disable_venus", true)) {
+ // TODO: Implement ActionDisableVenus
+ } else if (act.matchString("display_message", true)) {
+ // TODO: Implement ActionDisplayMessage
+ } else if (act.matchString("dissolve", true)) {
+ // TODO: Implement ActionDissolve
+ } else if (act.matchString("distort", true)) {
+ // TODO: Implement ActionDistort
+ } else if (act.matchString("enable_control", true)) {
+ actionList.push_back(new ActionEnableControl(_engine, slot, args));
+ } else if (act.matchString("flush_mouse_events", true)) {
+ // TODO: Implement ActionFlushMouseEvents
+ } else if (act.matchString("inventory", true)) {
+ actionList.push_back(new ActionInventory(_engine, slot, args));
+ } else if (act.matchString("kill", true)) {
+ actionList.push_back(new ActionKill(_engine, slot, args));
+ } else if (act.matchString("menu_bar_enable", true)) {
+ // TODO: Implement ActionMenuBarEnable
+ } else if (act.matchString("music", true)) {
+ actionList.push_back(new ActionMusic(_engine, slot, args, false));
+ } else if (act.matchString("pan_track", true)) {
+ // TODO: Implement ActionPanTrack
+ } else if (act.matchString("playpreload", true)) {
+ actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args));
+ } else if (act.matchString("preferences", true)) {
+ // TODO: Implement ActionPreferences
+ } else if (act.matchString("quit", true)) {
+ actionList.push_back(new ActionQuit(_engine, slot));
+ } else if (act.matchString("random", true)) {
+ actionList.push_back(new ActionRandom(_engine, slot, args));
+ } else if (act.matchString("region", true)) {
+ // TODO: Implement ActionRegion
+ } else if (act.matchString("restore_game", true)) {
+ // TODO: Implement ActionRestoreGame
+ } else if (act.matchString("rotate_to", true)) {
+ // TODO: Implement ActionRotateTo
+ } else if (act.matchString("save_game", true)) {
+ // TODO: Implement ActionSaveGame
+ } else if (act.matchString("set_partial_screen", true)) {
+ actionList.push_back(new ActionSetPartialScreen(_engine, slot, args));
+ } else if (act.matchString("set_screen", true)) {
+ actionList.push_back(new ActionSetScreen(_engine, slot, args));
+ } else if (act.matchString("set_venus", true)) {
+ // TODO: Implement ActionSetVenus
+ } else if (act.matchString("stop", true)) {
+ actionList.push_back(new ActionStop(_engine, slot, args));
+ } else if (act.matchString("streamvideo", true)) {
+ actionList.push_back(new ActionStreamVideo(_engine, slot, args));
+ } else if (act.matchString("syncsound", true)) {
+ // TODO: Implement ActionSyncSound
+ } else if (act.matchString("timer", true)) {
+ actionList.push_back(new ActionTimer(_engine, slot, args));
+ } else if (act.matchString("ttytext", true)) {
+ // TODO: Implement ActionTTYText
+ } else if (act.matchString("universe_music", true)) {
+ actionList.push_back(new ActionMusic(_engine, slot, args, true));
+ } else if (act.matchString("copy_file", true)) {
+ // Not used. Purposely left empty
+ } else {
+ warning("Unhandled result action type: %s", line.c_str());
+ }
+ }
}
line = stream.readLine();
Commit: 9f39b1e819a94d56c2dd6ecbca1488f7e0cd553a
https://github.com/scummvm/scummvm/commit/9f39b1e819a94d56c2dd6ecbca1488f7e0cd553a
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-25T13:34:44Z
Commit Message:
ZVISION: PreloadAnimation must indicate that the animation is loaded.
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 9670016..ccae6fd 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -346,6 +346,7 @@ bool ActionPreloadAnimation::execute() {
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
+ _engine->getScriptManager()->setStateValue(_slotkey, 2);
return true;
}
Commit: feabdc60179452973cc329520b3539f5dc22841a
https://github.com/scummvm/scummvm/commit/feabdc60179452973cc329520b3539f5dc22841a
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-25T13:41:37Z
Commit Message:
ZVISION: Change clear queued list firstly, not exec list.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index b121eaa..f62cbd8 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -87,6 +87,7 @@ void ScriptManager::execScope(script_scope &scope) {
PuzzleList *tmp = scope.exec_queue;
scope.exec_queue = scope.scope_queue;
scope.scope_queue = tmp;
+ scope.scope_queue->clear();
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
(*PuzzleIter)->addedBySetState = 0;
@@ -99,8 +100,6 @@ void ScriptManager::execScope(script_scope &scope) {
checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
}
- scope.exec_queue->clear();
-
if (scope.proc_count < 2) {
scope.proc_count++;
}
Commit: f3e2857cde044019dc322eba46bbdcc854fd4839
https://github.com/scummvm/scummvm/commit/f3e2857cde044019dc322eba46bbdcc854fd4839
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-11-26T15:02:38Z
Commit Message:
ZVISION: Some scripts action arguments can be uppercased, make all lowercase.
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 0149347..f80700c 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -151,13 +151,14 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ line.toLowercase();
// TODO: Re-order the if-then statements in order of highest occurrence
while (!stream.eos() && !line.contains('}')) {
if (line.empty()) {
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
-
+ line.toLowercase();
continue;
}
@@ -291,6 +292,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ line.toLowercase();
}
return;
Commit: 066cc74d9690222cb6af8cfc08b840eaffd57764
https://github.com/scummvm/scummvm/commit/066cc74d9690222cb6af8cfc08b840eaffd57764
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2013-12-04T14:00:48Z
Commit Message:
ZVISION: Refactoring cursor manager into simple and full-functionally.
Changed paths:
engines/zvision/cursor_manager.cpp
engines/zvision/cursor_manager.h
engines/zvision/events.cpp
engines/zvision/lever_control.cpp
engines/zvision/push_toggle_control.cpp
engines/zvision/script_manager.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index de229a3..aaf3bb8 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -50,87 +50,59 @@ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
: _engine(engine),
_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() == GID_NEMESIS) {
- Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
- _idleCursor = ZorkCursor(name);
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]);
+ _cursorIsPushed(false),
+ _item(0),
+ _lastitem(0) {
+ for (int i = 0; i < NUM_CURSORS; i++) {
+ if (_engine->getGameId() == GID_NEMESIS) {
+ Common::String name;
+ name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]);
+ _cursors[i][0] = ZorkCursor(name); // Up cursor
+ name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]);
+ _cursors[i][1] = ZorkCursor(name); // Down cursor
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ _cursors[i][0] = ZorkCursor(_zgiCursorFileNames[i]); // Up cursor
+ char buffer[25];
+ strcpy(buffer, _zgiCursorFileNames[i]);
+ buffer[3] += 2;
+ _cursors[i][1] = ZorkCursor(buffer); // Down cursor
+ }
}
}
-void CursorManager::initialize() {
- revertToIdle();
- CursorMan.showMouse(true);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName) {
- changeCursor(cursorName, _cursorIsPushed);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) {
- if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed)
- return;
-
- if (_cursorIsPushed != pushed)
- _cursorIsPushed = pushed;
-
- if (cursorName == "idle" && !pushed) {
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- return;
- }
-
- for (int i = 0; i < NUM_CURSORS; ++i) {
- if (_engine->getGameId() == GID_NEMESIS) {
- 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());
-
- changeCursor(ZorkCursor(name));
- return;
- }
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- if (cursorName.equals(_cursorNames[i])) {
- _currentCursor = 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;
- changeCursor(ZorkCursor(buffer));
- }
+void CursorManager::setItemID(int id) {
+ if (id != _item) {
+ if (id) {
+ Common::String file;
+ if (_engine->getGameId() == GID_NEMESIS) {
+ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a');
+ _cursors[NUM_CURSORS][0] = ZorkCursor(file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b');
+ _cursors[NUM_CURSORS][1] = ZorkCursor(file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a');
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b');
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id);
+ _cursors[NUM_CURSORS][0] = ZorkCursor(file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id);
+ _cursors[NUM_CURSORS][1] = ZorkCursor(file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id);
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id);
+ _cursors[NUM_CURSORS + 1][1] = ZorkCursor(file);
+ } else
return;
- }
}
+ _item = id;
+ changeCursor(CursorIndex_Idle);
}
-
- // If we get here, something went wrong
- warning("No cursor found for identifier %s", cursorName.c_str());
}
-void CursorManager::changeCursor(int id, bool active, bool pushed) {
- Common::String file;
- if (_engine->getGameId() == GID_NEMESIS) {
- file = Common::String::format("%2.2d%s%c.zcr", id, active ? "act" : "idle", pushed ? 'b' : 'a');
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- file = Common::String::format("g0b%cc%2.2x1.zcr", active ? (pushed ? 'd' : 'c') : (pushed ? 'b' : 'a') , id);
- } else
- return;
-
- if (_currentCursor.equals(file))
- return;
-
- _currentCursor = file;
-
- changeCursor(ZorkCursor(file));
+void CursorManager::initialize() {
+ changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]);
+ showMouse(true);
}
void CursorManager::changeCursor(const ZorkCursor &cursor) {
@@ -141,31 +113,42 @@ void CursorManager::cursorDown(bool pushed) {
if (_cursorIsPushed == pushed)
return;
- changeCursor(_currentCursor, pushed);
-}
+ _cursorIsPushed = pushed;
-void CursorManager::setLeftCursor() {
- changeCursor("leftarrow");
+ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
}
-void CursorManager::setRightCursor() {
- changeCursor("rightarrow");
-}
+void CursorManager::changeCursor(int id) {
+ int _id = id;
-void CursorManager::setUpCursor() {
- changeCursor("zuparrow");
+ if (_item &&
+ (_id == CursorIndex_Active ||
+ _id == CursorIndex_Idle ||
+ _id == CursorIndex_HandPu)) {
+
+ if (_id == CursorIndex_Idle)
+ _id = CursorIndex_ItemIdle;
+ else
+ _id = CursorIndex_ItemAct;
+ }
+
+ if (_currentCursor != _id ||
+ ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) {
+ _currentCursor = _id;
+ _lastitem = _item;
+ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
+ }
}
-void CursorManager::setDownCursor() {
- changeCursor("downarrow");
+int CursorManager::getCursorId(Common::String &name) {
+ for (int i = 0; i < NUM_CURSORS; i++)
+ if (name.equals(_cursorNames[i]))
+ return i;
+ return CursorIndex_Idle;
}
-void CursorManager::revertToIdle() {
- _currentCursor = "idle";
- if (!_cursorIsPushed)
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- else
- changeCursor(_currentCursor, _cursorIsPushed);
+void CursorManager::showMouse(bool vis) {
+ CursorMan.showMouse(vis);
}
} // End of namespace ZVision
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index ac79b25..7bd1c42 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -37,6 +37,21 @@ namespace ZVision {
class ZVision;
/**
+ * Mostly usable cursors
+ */
+enum CursorIndex {
+ CursorIndex_Active = 0,
+ CursorIndex_DownArr = 3,
+ CursorIndex_HandPu = 6,
+ CursorIndex_Idle = 11,
+ CursorIndex_Left = 12,
+ CursorIndex_Right = 13,
+ CursorIndex_UpArr = 17,
+ CursorIndex_ItemIdle = 18,
+ CursorIndex_ItemAct = 19
+};
+
+/**
* Class to manage cursor changes. The actual changes have to be done
* through CursorMan. Otherwise the cursor will disappear after GMM
* or debug console.
@@ -47,17 +62,17 @@ 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
- };
+ static const int NUM_CURSORS = 18;
+
+ // 18 default cursors in up/down states, +2 for items idle/act cursors
+ ZorkCursor _cursors[NUM_CURSORS + 2][2];
ZVision *_engine;
const Graphics::PixelFormat *_pixelFormat;
- ZorkCursor _idleCursor;
- Common::String _currentCursor;
bool _cursorIsPushed;
+ int _item;
+ int _lastitem;
+ int _currentCursor;
static const char *_cursorNames[];
static const char *_zgiCursorFileNames[];
@@ -68,21 +83,30 @@ public:
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
+ * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item.
+ *
+ * @param id Wanted cursor id.
+ */
+
+ void changeCursor(int id);
+
+ /**
+ * Return founded id for string contains cursor name
*
- * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
+ * @param name Cursor name
+ * @return Id of cursor or idle cursor id if not found
*/
- void changeCursor(const Common::String &cursorName);
+
+ int getCursorId(Common::String &name);
+
/**
- * Parses a cursor name into a cursor file then creates and shows that cursor.
+ * Load cursor for item by id, and try to change cursor to item cursor if it's not 0
*
- * @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)
+ * @param id Item id or 0 for no item cursor
*/
- void changeCursor(const Common::String &cursorName, bool pushed);
- void changeCursor(int id, bool active, bool pushed);
+ void setItemID(int id);
+
/**
* Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen.
*
@@ -90,17 +114,12 @@ public:
*/
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();
+ /**
+ * Show or hide mouse cursor.
+ *
+ * @param vis Should the cursor be showed (true) or hide (false)
+ */
+ void showMouse(bool vis);
private:
/**
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index ede9127..69f5ffe 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -150,14 +150,14 @@ void ZVision::onMouseMove(const Common::Point &pos) {
// 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();
+ _cursorManager->changeCursor(CursorIndex_Left);
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();
+ _cursorManager->changeCursor(CursorIndex_Right);
cursorWasChanged = true;
} else {
_renderManager->setBackgroundVelocity(0);
@@ -168,14 +168,14 @@ void ZVision::onMouseMove(const Common::Point &pos) {
// 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();
+ _cursorManager->changeCursor(CursorIndex_UpArr);
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();
+ _cursorManager->changeCursor(CursorIndex_DownArr);
cursorWasChanged = true;
} else {
_renderManager->setBackgroundVelocity(0);
@@ -186,7 +186,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
}
if (!cursorWasChanged) {
- _cursorManager->revertToIdle();
+ _cursorManager->changeCursor(CursorIndex_Idle);
}
}
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 6d13d60..fa8475f 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -239,7 +239,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
}
} else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_cursorName);
+ _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_cursorName));
cursorWasChanged = true;
}
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 88619e8..86f4997 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -88,7 +88,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
return false;
if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_hoverCursor);
+ _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor));
return true;
}
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index f62cbd8..e2397ab 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -511,7 +511,7 @@ void ScriptManager::do_changeLocation() {
_activeControls = &nodeview._controls;
// Revert to the idle cursor
- _engine->getCursorManager()->revertToIdle();
+ _engine->getCursorManager()->changeCursor(CursorIndex_Idle);
// Reset the background velocity
_engine->getRenderManager()->setBackgroundVelocity(0);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 62061bf..39d61d9 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -143,6 +143,8 @@ Common::Error ZVision::run() {
uint32 currentTime = _clock.getLastMeasuredTime();
uint32 deltaTime = _clock.getDeltaTime();
+ _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem));
+
processEvents();
// Call _renderManager->update() first so the background renders
Commit: 570630ee3df60e1dd22fbab1595a4d9dfaa38774
https://github.com/scummvm/scummvm/commit/570630ee3df60e1dd22fbab1595a4d9dfaa38774
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-12-24T14:38:11+07:00
Commit Message:
ZVISION: Make update screen delayed for updates.
Changed paths:
engines/zvision/script_manager.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index e2397ab..e30861a 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -462,6 +462,8 @@ void ScriptManager::do_changeLocation() {
assert(_nextLocation.world != 0);
debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
+ _engine->setRenderDelay(2);
+
if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
if (_nextLocation.world != 'g' || _nextLocation.room != 'j') {
setStateValue(StateKey_LastWorld, getStateValue(StateKey_World));
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 39d61d9..65064d8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -62,7 +62,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_saveManager(nullptr),
_stringManager(nullptr),
_cursorManager(nullptr),
- _aud_id(0) {
+ _aud_id(0),
+ _rendDelay(2) {
debug(1, "ZVision::ZVision");
}
@@ -156,7 +157,10 @@ Common::Error ZVision::run() {
_renderManager->renderBackbufferToScreen();
// Update the screen
- _system->updateScreen();
+ if (_rendDelay <= 0)
+ _system->updateScreen();
+ else
+ _rendDelay--;
// Calculate the frame delay based off a desired frame time
int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
@@ -193,4 +197,12 @@ int ZVision::getAudioId() {
return _aud_id;
}
+void ZVision::setRenderDelay(uint delay) {
+ _rendDelay = delay;
+}
+
+bool ZVision::canRender() {
+ return _rendDelay <= 0;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index e770928..05c5fcd 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -109,6 +109,8 @@ private:
const Common::Rect _workingWindow_ZGI;
const Common::Rect _workingWindow_ZNM;
+
+ int _rendDelay;
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
@@ -153,6 +155,9 @@ public:
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
+ void setRenderDelay(uint);
+ bool canRender();
+
private:
void initialize();
void initFonts();
Commit: 621818836e6a1100bbed2dbc1520a1005f1ad9ed
https://github.com/scummvm/scummvm/commit/621818836e6a1100bbed2dbc1520a1005f1ad9ed
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-12-24T14:43:42+07:00
Commit Message:
ZVISION: New easy-to-use render functions for next rendermanager generation.
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 fc15e18..6578c85 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -721,4 +721,60 @@ void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uin
}
}
+void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y) {
+ Common::Rect pos(x, y, x + src.w, y + src.h);
+ pos.clip(dst.w, dst.h);
+ copyRectToSurface(src, dst, Common::Rect(), pos);
+}
+
+void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) {
+ Common::Rect pos(x, y, x + src.w, y + src.h);
+ pos.clip(dst.w, dst.h);
+ copyRectToSurface(src, dst, Common::Rect(), pos, colorkey);
+}
+
+void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y) {
+ blitSurfaceToSurface(src, _currentBackground, x, y);
+ moveBackground(0); // Temporary workaround
+}
+
+void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) {
+ blitSurfaceToSurface(src, _currentBackground, x, y, colorkey);
+ moveBackground(0); // Temporary workaround
+}
+
+void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y) {
+ blitSurfaceToSurface(src, _workingWindowBuffer, x, y);
+}
+
+void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) {
+ blitSurfaceToSurface(src, _workingWindowBuffer, x, y, colorkey);
+}
+
+Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) {
+ Common::Rect dst = rect;
+ dst.clip(_currentBackground.w, _currentBackground.h);
+
+ if (dst.isEmpty() || !dst.isValidRect())
+ return NULL;
+
+ Graphics::Surface *srf = new Graphics::Surface;
+ srf->create(dst.width(), dst.height(), _currentBackground.format);
+
+ srf->copyRectToSurface(_currentBackground, 0, 0, Common::Rect(dst));
+
+ return srf;
+}
+
+Graphics::Surface *RenderManager::loadImage(Common::String &file) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ readImageToSurface(file, *tmp);
+ return tmp;
+}
+
+Graphics::Surface *RenderManager::loadImage(const char *file) {
+ Common::String str = Common::String(file);
+ return loadImage(str);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 14ca704..e16d356 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -369,6 +369,16 @@ public:
void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
+ void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y);
+ void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
+ void blitSurfaceToBkg(Graphics::Surface &src, int x, int y);
+ void blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey);
+ void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y);
+ void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey);
+ Graphics::Surface *getBkgRect(Common::Rect &rect);
+ Graphics::Surface *loadImage(const char *file);
+ Graphics::Surface *loadImage(Common::String &file);
+
private:
/**
* Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect
Commit: fd325d49f9103408f7d2fc10cc99dae7fab9a0a1
https://github.com/scummvm/scummvm/commit/fd325d49f9103408f7d2fc10cc99dae7fab9a0a1
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-12-24T15:05:23+07:00
Commit Message:
ZVISION: Add splitter function into controls class.
Changed paths:
engines/zvision/control.cpp
engines/zvision/control.h
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index 0346228..ef2e90f 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -103,4 +103,28 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
+void Control::getParams(Common::String &input_str, Common::String ¶meter, Common::String &values) {
+ const char *chrs = input_str.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < input_str.size(); lbr++)
+ if (chrs[lbr] == '(')
+ break;
+
+ if (lbr >= input_str.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ if (chrs[rbr] == ')')
+ break;
+
+ if (rbr >= input_str.size())
+ return;
+
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index 65d76da..93ad5f5 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -24,6 +24,7 @@
#define ZVISION_CONTROL_H
#include "common/keyboard.h"
+#include "common/str.h"
namespace Common {
@@ -102,6 +103,7 @@ protected:
ZVision *_engine;
uint32 _key;
+ void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values);
// Static member functions
public:
static void parseFlatControl(ZVision *engine);
Commit: 0c7d1d2d3691f93701e33f40cb665d87004e5499
https://github.com/scummvm/scummvm/commit/0c7d1d2d3691f93701e33f40cb665d87004e5499
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-12-24T15:11:39+07:00
Commit Message:
ZVISION: Slot control code.
Changed paths:
A engines/zvision/slot_control.cpp
A engines/zvision/slot_control.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index ffdef16..b551263 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -32,7 +32,8 @@ MODULE_OBJS := \
zork_raw.o \
sidefx.o \
music_node.o \
- inventory_manager.o
+ inventory_manager.o \
+ slot_control.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index f80700c..4f1c363 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -29,6 +29,7 @@
#include "zvision/actions.h"
#include "zvision/push_toggle_control.h"
#include "zvision/lever_control.h"
+#include "zvision/slot_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -342,6 +343,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return NULL;
} else if (controlType.equalsIgnoreCase("lever")) {
return new LeverControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("slot")) {
+ return new SlotControl(_engine, key, stream);
}
return NULL;
}
diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp
new file mode 100644
index 0000000..418aa8f
--- /dev/null
+++ b/engines/zvision/slot_control.cpp
@@ -0,0 +1,215 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/slot_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/cursor_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/utility.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key) {
+
+ _rendered_item = 0;
+ _bkg = NULL;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("hotspot", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _hotspot = Common::Rect(x, y, width, height);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("distance_id", true)) {
+ sscanf(values.c_str(), "%c", &_distance_id);
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ } else if (param.matchString("eligible_objects", true)) {
+ char buf[256];
+ memset(buf, 0, 256);
+ strcpy(buf, values.c_str());
+
+ char *curpos = buf;
+ char *strend = buf + strlen(buf);
+ while (true) {
+ char *st = curpos;
+
+ if (st >= strend)
+ break;
+
+ while (*curpos != ' ' && curpos < strend)
+ curpos++;
+
+ *curpos = 0;
+ curpos++;
+
+ int obj = atoi(st);
+
+ _eligible_objects.push_back(obj);
+ }
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_hotspot.isEmpty() || _rectangle.isEmpty()) {
+ warning("Slot %u was parsed incorrectly", key);
+ }
+}
+
+SlotControl::~SlotControl() {
+ // Clear the state value back to 0
+ //_engine->getScriptManager()->setStateValue(_key, 0);
+
+ if (_bkg)
+ delete _bkg;
+}
+
+bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ //ctrl_setvenus(ct);
+
+ int item = _engine->getScriptManager()->getStateValue(_key);
+ int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (item != 0) {
+ if (mouse_item != 0) {
+ if (eligeblity(mouse_item)) {
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ _engine->getScriptManager()->invertory_add(item);
+ _engine->getScriptManager()->setStateValue(_key, mouse_item);
+ }
+ } else {
+ _engine->getScriptManager()->invertory_add(item);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (mouse_item == 0) {
+ if (eligeblity(0)) {
+ _engine->getScriptManager()->invertory_drop(0);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (eligeblity(mouse_item)) {
+ _engine->getScriptManager()->setStateValue(_key, mouse_item);
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ }
+ }
+ return false;
+}
+
+bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+ return true;
+ }
+
+ return false;
+}
+
+bool SlotControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_engine->canRender()) {
+ int cur_item = _engine->getScriptManager()->getStateValue(_key);
+ if (cur_item != _rendered_item) {
+ if (_rendered_item == 0) {
+ if (_bkg)
+ delete _bkg;
+
+ _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
+
+ char buf[16];
+ if (_engine->getGameId() == GID_NEMESIS)
+ sprintf(buf, "%d%cobj.tga", cur_item, _distance_id);
+ else
+ sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item);
+
+ Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);
+
+ int16 drawx = _rectangle.left;
+ int16 drawy = _rectangle.top;
+
+ if (_rectangle.width() > srf->w)
+ drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2;
+
+ if (_rectangle.height() > srf->h)
+ drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2;
+
+ _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0);
+
+ delete srf;
+
+ _rendered_item = cur_item;
+ } else {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ _rendered_item = cur_item;
+ }
+ }
+ }
+ return false;
+}
+
+bool SlotControl::eligeblity(int item_id) {
+ for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
+ if (*it == item_id)
+ return true;
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h
new file mode 100644
index 0000000..eec2d04
--- /dev/null
+++ b/engines/zvision/slot_control.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SLOT_CONTROL_H
+#define ZVISION_SLOT_CONTROL_H
+
+#include "zvision/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace ZVision {
+
+class SlotControl : public Control {
+public:
+ SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~SlotControl();
+
+ /**
+ * 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
+ */
+ bool 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);
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _rectangle;
+ Common::Rect _hotspot;
+
+ int _cursor;
+ char _distance_id;
+ int _venus_id;
+
+ int _rendered_item;
+
+ Common::List<int> _eligible_objects;
+
+ bool eligeblity(int item_id);
+
+ Graphics::Surface *_bkg;
+
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 48156debaf148b50acd3eb6e3de7020498016a5f
https://github.com/scummvm/scummvm/commit/48156debaf148b50acd3eb6e3de7020498016a5f
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2013-12-24T15:37:11+07:00
Commit Message:
ZVISION: Fix animation_node upper frame.
Changed paths:
engines/zvision/animation_node.cpp
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 73e419e..967dee2 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -190,6 +190,13 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st
nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
nod.start = start_frame;
nod.stop = end_frame;
+ if (_fileType == RLF) {
+ if (nod.stop >= (int)_animation.rlf->frameCount())
+ nod.stop = _animation.rlf->frameCount() - 1;
+ } else if (_fileType == AVI) {
+ if (nod.stop > (int)_animation.avi->getFrameCount())
+ nod.stop = _animation.avi->getFrameCount();
+ }
nod.slot = slot;
nod._cur_frm = -1;
nod._delay = 0;
Commit: 1428cb8950e5bdcfad9d15d0fb2e32ff1dbc0bae
https://github.com/scummvm/scummvm/commit/1428cb8950e5bdcfad9d15d0fb2e32ff1dbc0bae
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-01-07T18:39:16+07:00
Commit Message:
ZVISION: Refactoring of renderManager.
Changed paths:
engines/zvision/animation_node.cpp
engines/zvision/console.cpp
engines/zvision/events.cpp
engines/zvision/input_control.cpp
engines/zvision/lever_control.cpp
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/render_table.cpp
engines/zvision/render_table.h
engines/zvision/script_manager.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 967dee2..74b532b 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -165,15 +165,15 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
if (_mask > 0)
- _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask);
+ _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
else
- _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top);
+ _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top);
delete transposed;
} else {
if (_mask > 0)
- _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask);
+ _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
else
- _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top);
+ _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top);
}
}
}
diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp
index 400dcb3..252a4b7 100644
--- a/engines/zvision/console.cpp
+++ b/engines/zvision/console.cpp
@@ -60,12 +60,12 @@ 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]));
- else {
- DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
- return true;
- }
+// if (argc == 4)
+// _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
+// else {
+// DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
+// return true;
+// }
return true;
}
@@ -208,8 +208,8 @@ bool Console::cmdRenderText(int argc, const char **argv) {
return true;
}
- StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
- _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);
+ //StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
+ //_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;
}
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 69f5ffe..d882886 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -146,43 +146,53 @@ void ZVision::onMouseMove(const Common::Point &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());
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0)
+ mspeed = 400 >> 4;
+ _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+
_cursorManager->changeCursor(CursorIndex_Left);
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());
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0)
+ mspeed = 400 >> 4;
+ _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+
_cursorManager->changeCursor(CursorIndex_Right);
cursorWasChanged = true;
} else {
- _renderManager->setBackgroundVelocity(0);
+ _velocity = 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());
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0)
+ mspeed = 400 >> 4;
+ _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+
_cursorManager->changeCursor(CursorIndex_UpArr);
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());
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0)
+ mspeed = 400 >> 4;
+ _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+
_cursorManager->changeCursor(CursorIndex_DownArr);
cursorWasChanged = true;
} else {
- _renderManager->setBackgroundVelocity(0);
+ _velocity = 0;
}
+ } else {
+ _velocity = 0;
}
} else {
- _renderManager->setBackgroundVelocity(0);
+ _velocity = 0;
}
if (!cursorWasChanged) {
diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp
index 8d9d79b..a366e06 100644
--- a/engines/zvision/input_control.cpp
+++ b/engines/zvision/input_control.cpp
@@ -129,9 +129,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) {
// 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());
+ //Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width());
- _cursorOffset = destRect.left - _textRectangle.left;
+ //_cursorOffset = destRect.left - _textRectangle.left;
}
// Render the next frame of the animation
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index fa8475f..9cd36cf 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -375,26 +375,20 @@ void LeverControl::renderFrame(uint frameNumber) {
_lastRenderedFrame = frameNumber;
}
- const uint16 *frameData;
+ const Graphics::Surface *frameData;
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 = (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()
+ frameData = _animation.rlf->getFrameData(frameNumber);
} else if (_fileType == AVI) {
_animation.avi->seekToFrame(frameNumber);
const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
- frameData = (const uint16 *)surface->getPixels();
- width = surface->w;
- height = surface->h;
+ frameData = surface;
}
- _engine->getRenderManager()->copyRectToWorkingWindow(frameData, x, y, width, width, height);
+ _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 6578c85..bc4d169 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -39,356 +39,75 @@ namespace ZVision {
RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
: _system(system),
- _workingWidth(workingWindow.width()),
- _workingHeight(workingWindow.height()),
- _screenCenterX(_workingWidth / 2),
- _screenCenterY(_workingHeight / 2),
+ _wrkWidth(workingWindow.width()),
+ _wrkHeight(workingWindow.height()),
+ _screenCenterX(_wrkWidth / 2),
+ _screenCenterY(_wrkHeight / 2),
_workingWindow(workingWindow),
_pixelFormat(pixelFormat),
- _backgroundWidth(0),
- _backgroundHeight(0),
- _backgroundInverseVelocity(0),
- _backgroundOffset(0, 0),
- _accumulatedVelocityMilliseconds(0),
- _renderTable(_workingWidth, _workingHeight) {
+ _bkgWidth(0),
+ _bkgHeight(0),
+ _bkgOff(0),
+ _renderTable(_wrkWidth, _wrkHeight) {
- _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat);
- _backBuffer.create(windowWidth, windowHeight, pixelFormat);
-}
+ _wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
+ _outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
+ _menuWnd.create(windowWidth, workingWindow.top, _pixelFormat);
+ _subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat);
-RenderManager::~RenderManager() {
- _workingWindowBuffer.free();
- _currentBackground.free();
- _backBuffer.free();
+ _menuWndRect = Common::Rect(0, 0, windowWidth, workingWindow.top);
+ _subWndRect = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight);
- for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
- iter->_value.data->free();
- delete iter->_value.data;
- }
+ _subid = 0;
}
-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) {
- _accumulatedVelocityMilliseconds += deltaTimeInMillis;
-
- uint absVelocity = uint(abs(_backgroundInverseVelocity));
-
- 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);
- }
+RenderManager::~RenderManager() {
+ _curBkg.free();
+ _wrkWnd.free();
+ _outWnd.free();
}
void RenderManager::renderBackbufferToScreen() {
- 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
- if (_backBufferDirtyRect.isEmpty()) {
- _backBufferDirtyRect = _workingWindowDirtyRect;
- } else {
- _backBufferDirtyRect.extend(_workingWindowDirtyRect);
- }
-
- // Clear the dirty rect
- _workingWindowDirtyRect = Common::Rect();
- }
-
- // 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());
- _backBufferDirtyRect = Common::Rect();
- }
-}
-
-void RenderManager::processAlphaEntries() {
- // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
+ Graphics::Surface *out = &_outWnd;
- 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);
- 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) {
- uint16 color = entryPtr[sourceOffset + x];
- if (color != iter->_value.alphaColor) {
- backbufferPtr[destOffset + x] = color;
- }
- }
-
- destOffset += _backBuffer.w;
- 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);
- } 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));
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (!_wrkWndDirtyRect.isEmpty()) {
+ _renderTable.mutateImage(&_outWnd, &_wrkWnd);
+ out = &_outWnd;
+ _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight);
}
+ } else {
+ out = &_wrkWnd;
+ _outWndDirtyRect = _wrkWndDirtyRect;
}
-}
-
-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) {
- bufferPtr[i] = colorIn565;
- }
-}
-
-void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) {
- if (src.format != dst.format)
- return;
-
- Common::Rect dstRect = _dstRect;
- if (dstRect.isEmpty())
- dstRect = Common::Rect(dst.w, dst.h);
- dstRect.clip(dst.w, dst.h);
-
- Common::Rect srcRect = _srcRect;
- if (srcRect.isEmpty())
- srcRect = Common::Rect(src.w, src.h);
- srcRect.clip(src.w, src.h);
-
- if (!srcRect.isValidRect() || !dstRect.isValidRect())
- return;
-
- Common::Rect rendRect = srcRect;
- rendRect.clip(dstRect.width(), dstRect.height());
-
- if (rendRect.isEmpty() || !rendRect.isValidRect())
- return;
- // Copy rendRect from src surface to dst surface
- const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top);
- byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
- int32 w = rendRect.width();
- int32 h = rendRect.height();
+ if (!_outWndDirtyRect.isEmpty()) {
+ _system->copyRectToScreen(out->getBasePtr(_outWndDirtyRect.left, _outWndDirtyRect.top), out->pitch,
+ _outWndDirtyRect.left + _workingWindow.left,
+ _outWndDirtyRect.top + _workingWindow.top,
+ _outWndDirtyRect.width(),
+ _outWndDirtyRect.height());
- for (int32 y = 0; y < h; y++) {
- memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel);
- src_buf += src.pitch;
- dst_buf += dst.pitch;
+ _outWndDirtyRect = Common::Rect();
}
}
-void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) {
- if (src.format != dst.format)
- return;
-
- Common::Rect dstRect = _dstRect;
- if (dstRect.isEmpty())
- dstRect = Common::Rect(dst.w, dst.h);
- dstRect.clip(dst.w, dst.h);
-
- Common::Rect srcRect = _srcRect;
- if (srcRect.isEmpty())
- srcRect = Common::Rect(src.w, src.h);
- srcRect.clip(src.w, src.h);
-
- if (!srcRect.isValidRect() || !dstRect.isValidRect())
- return;
-
- Common::Rect rendRect = srcRect;
- rendRect.clip(dstRect.width(), dstRect.height());
-
- if (rendRect.isEmpty() || !rendRect.isValidRect())
- return;
-
- uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1);
-
- // Copy rendRect from src surface to dst surface
- const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top);
- byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top);
-
- int32 w = rendRect.width();
- int32 h = rendRect.height();
-
- for (int32 y = 0; y < h; y++) {
- switch (src.format.bytesPerPixel) {
- case 1: {
- const uint *src_tmp = (const uint *)src_buf;
- uint *dst_tmp = (uint *)dst_buf;
- for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
- }
- }
- break;
-
- case 2: {
- const uint16 *src_tmp = (const uint16 *)src_buf;
- uint16 *dst_tmp = (uint16 *)dst_buf;
- for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
- }
- }
- break;
-
- case 4: {
- const uint32 *src_tmp = (const uint32 *)src_buf;
- uint32 *dst_tmp = (uint32 *)dst_buf;
- for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
- }
- }
- break;
-
- default:
- break;
- }
- src_buf += src.pitch;
- dst_buf += dst.pitch;
- }
-}
-
-void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) {
- if (!Common::Rect(dst.w, dst.h).contains(dstPt))
- return;
- Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
- copyRectToSurface(src, dst, srcRect, dstRect);
-}
-
-void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) {
- if (!Common::Rect(dst.w, dst.h).contains(dstPt))
- return;
- Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h);
- copyRectToSurface(src, dst, srcRect, dstRect, keycolor);
-}
-
void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) {
Graphics::Surface surface;
readImageToSurface(fileName, surface);
- Common::Rect srcRect(surface.w, surface.h);
- Common::Point dstPt(destX, destY);
-
- copyRectToSurface(surface, _currentBackground, srcRect, dstPt);
- moveBackground(0);
-}
-
-void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY) {
- Common::Rect srcRect(surface.w, surface.h);
- Common::Point dstPt(destX, destY);
-
- copyRectToSurface(surface, _currentBackground, srcRect, dstPt);
- moveBackground(0);
+ blitSurfaceToBkg(surface, destX, destY);
+ surface.free();
}
void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) {
Graphics::Surface surface;
readImageToSurface(fileName, surface);
- Common::Rect srcRect(surface.w, surface.h);
- Common::Point dstPt(destX, destY);
-
- copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor);
- moveBackground(0);
-}
-
-void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) {
- Common::Rect srcRect(surface.w, surface.h);
- Common::Point dstPt(destX, destY);
-
- copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor);
- moveBackground(0);
-}
-
-void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
- int16 subRectX = 0;
- int16 subRectY = 0;
-
- // Take care of negative destinations
- if (destinationX < 0) {
- subRectX = -destinationX;
- destinationX = 0;
- } else if (destinationX >= surface.w) {
- // Take care of extreme positive destinations
- destinationX -= surface.w;
- }
-
- // Take care of negative destinations
- if (destinationY < 0) {
- subRectY = -destinationY;
- destinationY = 0;
- } else if (destinationY >= surface.h) {
- // Take care of extreme positive destinations
- destinationY -= surface.h;
- }
-
- if (wrap) {
- _backgroundWidth = surface.w;
- _backgroundHeight = surface.h;
-
- if (destinationX > 0) {
- // Move destinationX to 0
- subRectX = surface.w - destinationX;
- destinationX = 0;
- }
-
- if (destinationY > 0) {
- // Move destinationY to 0
- subRectY = surface.h - destinationY;
- destinationY = 0;
- }
- }
-
- // Clip subRect to working window bounds
- Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight);
-
- if (!wrap) {
- // Clip to image bounds
- subRect.clip(surface.w, surface.h);
- }
-
- // Check destRect for validity
- if (!subRect.isValidRect() || subRect.isEmpty())
- return;
-
- 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) {
- 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);
+ blitSurfaceToBkg(surface, destX, destY, keycolor);
+ surface.free();
}
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
@@ -485,72 +204,6 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
destination.convertToInPlace(_pixelFormat);
}
-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);
-
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x];
- }
-
- destOffset += _workingWidth;
- sourceOffset += imageWidth;
- }
-
- 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);
-}
-
-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();
- entry.data->create(width, height, _pixelFormat);
- entry.destX = destX;
- entry.destY = destY;
- entry.width = width;
- entry.height = height;
-
- uint32 sourceOffset = 0;
- uint32 destOffset = 0;
- uint16 *surfacePtr = (uint16 *)entry.data->getPixels();
-
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- surfacePtr[destOffset + x] = buffer[sourceOffset + x];
- }
-
- destOffset += width;
- sourceOffset += imageWidth;
- }
-
- _alphaDataEntries[idNumber] = entry;
-}
-
-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;
- entry.destY = destY;
-
- // Draw the text to the working window
- entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap);
- entry.width = entry.data->w;
- entry.height = entry.data->h;
-
- _alphaDataEntries[idNumber] = entry;
-
- return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
-}
-
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
if (_workingWindow.contains(point)) {
// Convert from screen space to working window space
@@ -562,19 +215,20 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &
}
if (state == RenderTable::PANORAMA) {
- newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset);
+ newPoint += (Common::Point(_bkgOff - _screenCenterX, 0));
} else if (state == RenderTable::TILT) {
- newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset);
+ newPoint += (Common::Point(0, _bkgOff - _screenCenterY));
}
+ if (_bkgWidth)
+ newPoint.x %= _bkgWidth;
+ if (_bkgHeight)
+ newPoint.y %= _bkgHeight;
+
if (newPoint.x < 0)
- newPoint.x += _backgroundWidth;
- else if (newPoint.x >= _backgroundWidth)
- newPoint.x -= _backgroundWidth;
+ newPoint.x += _bkgWidth;
if (newPoint.y < 0)
- newPoint.y += _backgroundHeight;
- else if (newPoint.y >= _backgroundHeight)
- newPoint.y -= _backgroundHeight;
+ newPoint.y += _bkgHeight;
return newPoint;
} else {
@@ -582,95 +236,32 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &
}
}
-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;
-}
-
-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;
}
void RenderManager::setBackgroundImage(const Common::String &fileName) {
- readImageToSurface(fileName, _currentBackground);
-
- moveBackground(0);
+ readImageToSurface(fileName, _curBkg);
+ _bkgWidth = _curBkg.w;
+ _bkgHeight = _curBkg.h;
+ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
}
void RenderManager::setBackgroundPosition(int offset) {
RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = offset;
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset.x = offset;
- _backgroundOffset.y = 0;
- } else {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = 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) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset += Common::Point(0, offset);
-
- _backgroundOffset.y = CLIP<int16>(_backgroundOffset.y, _screenCenterY, (int16)_backgroundHeight - _screenCenterY);
-
- renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset += Common::Point(offset, 0);
-
- if (_backgroundOffset.x <= -_backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
- else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x -= _backgroundWidth;
-
- renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
- } else {
- renderImageToScreen(_currentBackground, 0, 0);
- }
+ if (state == RenderTable::TILT || state == RenderTable::PANORAMA)
+ if (_bkgOff != offset)
+ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
+ _bkgOff = offset;
}
uint32 RenderManager::getCurrentBackgroundOffset() {
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::PANORAMA) {
- return _backgroundOffset.x;
+ return _bkgOff;
} else if (state == RenderTable::TILT) {
- return _backgroundOffset.y;
+ return _bkgOff;
} else {
return 0;
}
@@ -721,47 +312,196 @@ void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uin
}
}
-void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y) {
- Common::Rect pos(x, y, x + src.w, y + src.h);
- pos.clip(dst.w, dst.h);
- copyRectToSurface(src, dst, Common::Rect(), pos);
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) {
+
+ if (src.format != dst.format)
+ return;
+
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
+ srcRect.clip(dstRect);
+
+ if (srcRect.isEmpty() || !srcRect.isValidRect())
+ return;
+
+ // Copy srcRect from src surface to dst surface
+ const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
+
+ int xx = _x;
+ int yy = _y;
+
+ if (xx < 0)
+ xx = 0;
+ if (yy < 0)
+ yy = 0;
+
+ if (_x >= dst.w || _y >= dst.h)
+ return;
+
+ byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
+
+ int32 w = srcRect.width();
+ int32 h = srcRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel);
+ src_buf += src.pitch;
+ dst_buf += dst.pitch;
+ }
}
-void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) {
- Common::Rect pos(x, y, x + src.w, y + src.h);
- pos.clip(dst.w, dst.h);
- copyRectToSurface(src, dst, Common::Rect(), pos, colorkey);
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey) {
+
+ if (src.format != dst.format)
+ return;
+
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
+ srcRect.clip(dstRect);
+
+ if (srcRect.isEmpty() || !srcRect.isValidRect())
+ return;
+
+
+
+ uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1);
+
+ // Copy srcRect from src surface to dst surface
+ const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
+
+ int xx = _x;
+ int yy = _y;
+
+ if (xx < 0)
+ xx = 0;
+ if (yy < 0)
+ yy = 0;
+
+ if (_x >= dst.w || _y >= dst.h)
+ return;
+
+ byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
+
+ int32 w = srcRect.width();
+ int32 h = srcRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ switch (src.format.bytesPerPixel) {
+ case 1: {
+ const uint *src_tmp = (const uint *)src_buf;
+ uint *dst_tmp = (uint *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ case 2: {
+ const uint16 *src_tmp = (const uint16 *)src_buf;
+ uint16 *dst_tmp = (uint16 *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ case 4: {
+ const uint32 *src_tmp = (const uint32 *)src_buf;
+ uint32 *dst_tmp = (uint32 *)dst_buf;
+ for (int32 x = 0; x < w; x++) {
+ if (*src_tmp != _keycolor)
+ *dst_tmp = *src_tmp;
+ src_tmp++;
+ dst_tmp++;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ src_buf += src.pitch;
+ dst_buf += dst.pitch;
+ }
+}
+
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, dst, x, y);
+}
+
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, dst, x, y, colorkey);
}
-void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y) {
- blitSurfaceToSurface(src, _currentBackground, x, y);
- moveBackground(0); // Temporary workaround
+void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, _curBkg, x, y);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_bkgDirtyRect.isEmpty())
+ _bkgDirtyRect = dirty;
+ else
+ _bkgDirtyRect.extend(dirty);
}
-void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) {
- blitSurfaceToSurface(src, _currentBackground, x, y, colorkey);
- moveBackground(0); // Temporary workaround
+void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, _curBkg, x, y, colorkey);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_bkgDirtyRect.isEmpty())
+ _bkgDirtyRect = dirty;
+ else
+ _bkgDirtyRect.extend(dirty);
}
-void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y) {
- blitSurfaceToSurface(src, _workingWindowBuffer, x, y);
+void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, _menuWnd, x, y);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_menuWndDirtyRect.isEmpty())
+ _menuWndDirtyRect = dirty;
+ else
+ _menuWndDirtyRect.extend(dirty);
}
-void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) {
- blitSurfaceToSurface(src, _workingWindowBuffer, x, y, colorkey);
+void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) {
+ Common::Rect empt;
+ blitSurfaceToSurface(src, empt, _menuWnd, x, y, colorkey);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_menuWndDirtyRect.isEmpty())
+ _menuWndDirtyRect = dirty;
+ else
+ _menuWndDirtyRect.extend(dirty);
}
Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) {
Common::Rect dst = rect;
- dst.clip(_currentBackground.w, _currentBackground.h);
+ dst.clip(_bkgWidth, _bkgHeight);
if (dst.isEmpty() || !dst.isValidRect())
return NULL;
Graphics::Surface *srf = new Graphics::Surface;
- srf->create(dst.width(), dst.height(), _currentBackground.format);
+ srf->create(dst.width(), dst.height(), _curBkg.format);
- srf->copyRectToSurface(_currentBackground, 0, 0, Common::Rect(dst));
+ srf->copyRectToSurface(_curBkg, 0, 0, Common::Rect(dst));
return srf;
}
@@ -777,4 +517,149 @@ Graphics::Surface *RenderManager::loadImage(const char *file) {
return loadImage(str);
}
+void RenderManager::prepareBkg() {
+ _bkgDirtyRect.clip(_bkgWidth, _bkgHeight);
+ RenderTable::RenderState state = _renderTable.getRenderState();
+
+ if (state == RenderTable::PANORAMA) {
+ Common::Rect viewPort(_wrkWidth, _wrkHeight);
+ viewPort.translate(-(_screenCenterX - _bkgOff), 0);
+ Common::Rect drawRect = _bkgDirtyRect;
+ drawRect.clip(viewPort);
+
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - _bkgOff + drawRect.left, drawRect.top);
+
+ _wrkWndDirtyRect = _bkgDirtyRect;
+ _wrkWndDirtyRect.translate(_screenCenterX - _bkgOff, 0);
+
+ if (_bkgOff < _screenCenterX) {
+ viewPort.moveTo(-(_screenCenterX - (_bkgOff + _bkgWidth)), 0);
+ drawRect = _bkgDirtyRect;
+ drawRect.clip(viewPort);
+
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - (_bkgOff + _bkgWidth) + drawRect.left, drawRect.top);
+
+ Common::Rect tmp = _bkgDirtyRect;
+ tmp.translate(_screenCenterX - (_bkgOff + _bkgWidth), 0);
+ if (!tmp.isEmpty())
+ _wrkWndDirtyRect.extend(tmp);
+
+ } else if (_bkgWidth - _bkgOff < _screenCenterX) {
+ viewPort.moveTo(-(_screenCenterX + _bkgWidth - _bkgOff), 0);
+ drawRect = _bkgDirtyRect;
+ drawRect.clip(viewPort);
+
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX + _bkgWidth - _bkgOff + drawRect.left, drawRect.top);
+
+ Common::Rect tmp = _bkgDirtyRect;
+ tmp.translate(_screenCenterX + _bkgWidth - _bkgOff, 0);
+ if (!tmp.isEmpty())
+ _wrkWndDirtyRect.extend(tmp);
+
+ }
+ } else if (state == RenderTable::TILT) {
+ Common::Rect viewPort(_wrkWidth, _wrkHeight);
+ viewPort.translate(0, -(_screenCenterY - _bkgOff));
+ Common::Rect drawRect = _bkgDirtyRect;
+ drawRect.clip(viewPort);
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, drawRect.left, _screenCenterY - _bkgOff + drawRect.top);
+
+ _wrkWndDirtyRect = _bkgDirtyRect;
+ _wrkWndDirtyRect.translate(0, _screenCenterY - _bkgOff);
+
+ } else {
+ if (!_bkgDirtyRect.isEmpty())
+ blitSurfaceToSurface(_curBkg, _bkgDirtyRect, _wrkWnd, _bkgDirtyRect.left, _bkgDirtyRect.top);
+ _wrkWndDirtyRect = _bkgDirtyRect;
+ }
+
+ _bkgDirtyRect = Common::Rect();
+
+ _wrkWndDirtyRect.clip(_wrkWidth, _wrkHeight);
+}
+
+void RenderManager::clearMenuSurface() {
+ _menuWndDirtyRect = Common::Rect(0, 0, _menuWnd.w, _menuWnd.h);
+ _menuWnd.fillRect(_menuWndDirtyRect, 0);
+}
+
+void RenderManager::renderMenuToScreen() {
+ if (!_menuWndDirtyRect.isEmpty()) {
+ _menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h));
+
+ _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch,
+ _menuWndDirtyRect.left + _menuWndRect.left,
+ _menuWndDirtyRect.top + _menuWndRect.top,
+ _menuWndDirtyRect.width(),
+ _menuWndDirtyRect.height());
+ _menuWndDirtyRect = Common::Rect();
+ }
+}
+
+uint16 RenderManager::createSubArea(const Common::Rect &area) {
+ _subid++;
+
+ oneSub sub;
+ sub.redraw = false;
+ sub.timer = -1;
+ sub.todelete = false;
+ sub._r = area;
+
+ _subsList[_subid] = sub;
+
+ return _subid;
+}
+
+void RenderManager::deleteSubArea(uint16 id) {
+ if (_subsList.contains(id))
+ _subsList[id].todelete = true;
+}
+
+void RenderManager::deleteSubArea(uint16 id, int16 delay) {
+ if (_subsList.contains(id))
+ _subsList[id].timer = delay;
+}
+
+void RenderManager::updateSubArea(uint16 id, const Common::String &txt) {
+ if (_subsList.contains(id)) {
+ oneSub *sub = &_subsList[id];
+ sub->_txt = txt;
+ sub->redraw = true;
+ }
+}
+
+void RenderManager::renderSubsToScreen() {
+ bool redraw = false;
+ for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
+ if (it->_value.todelete) {
+ _subsList.erase(it);
+ redraw = true;
+ } else if (it->_value.redraw) {
+ redraw = true;
+ }
+ }
+
+ if (redraw) {
+ _subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0);
+
+ for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
+ //draw subs
+ }
+
+ _system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch,
+ _subWndRect.left,
+ _subWndRect.top,
+ _subWnd.w,
+ _subWnd.h);
+ }
+}
+
+Common::Point RenderManager::getBkgSize() {
+ return Common::Point(_bkgWidth, _bkgHeight);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index e16d356..de53481 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -51,39 +51,66 @@ public:
~RenderManager();
private:
- struct AlphaDataEntry {
- Graphics::Surface *data;
- uint16 alphaColor;
- uint16 destX;
- uint16 destY;
- uint16 width;
- uint16 height;
+ struct oneSub {
+ Common::Rect _r;
+ Common::String _txt;
+ int16 timer;
+ bool todelete;
+ bool redraw;
};
-
- typedef Common::HashMap<uint32, AlphaDataEntry> AlphaEntryMap;
+// struct AlphaDataEntry {
+// Graphics::Surface *data;
+// uint16 alphaColor;
+// uint16 destX;
+// uint16 destY;
+// uint16 width;
+// uint16 height;
+// };
+//
+ typedef Common::HashMap<uint16, oneSub> subMap;
private:
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
+ // A buffer for blitting background image to working window
+ Graphics::Surface _wrkWnd;
+
+ Common::Rect _wrkWndDirtyRect;
+
+ Graphics::Surface _outWnd;
+
+ Common::Rect _outWndDirtyRect;
+
+ Common::Rect _bkgDirtyRect;
+
+ Graphics::Surface _subWnd;
+
+ Common::Rect _subWndDirtyRect;
+
+ Graphics::Surface _menuWnd;
+
+ Common::Rect _menuWndDirtyRect;
+
+
// A buffer the exact same size as the workingWindow
// This buffer stores everything un-warped, then does a warp at the end of the frame
- Graphics::Surface _workingWindowBuffer;
+ //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;
+ //Graphics::Surface _backBuffer;
// A list of Alpha Entries that need to be blitted to the backbuffer
- AlphaEntryMap _alphaDataEntries;
+ //AlphaEntryMap _alphaDataEntries;
// A rectangle representing the portion of the working window where the pixels have been changed since last frame
- Common::Rect _workingWindowDirtyRect;
+ //Common::Rect _workingWindowDirtyRect;
// A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame
- Common::Rect _backBufferDirtyRect;
+ //Common::Rect _backBufferDirtyRect;
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
- const int _workingWidth;
+ const int _wrkWidth;
/** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
- const int _workingHeight;
+ const int _wrkHeight;
/** Center of the screen in the x direction */
const int _screenCenterX;
/** Center of the screen in the y direction */
@@ -95,33 +122,36 @@ private:
* edges of this Rectangle
*/
const Common::Rect _workingWindow;
+
+ Common::Rect _subWndRect;
+
+ Common::Rect _menuWndRect;
+
/** Used to warp the background image */
RenderTable _renderTable;
- Graphics::Surface _currentBackground;
+ Graphics::Surface _curBkg;
/** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
- Common::Point _backgroundOffset;
+ int16 _bkgOff;
/** The width of the current background image */
- uint16 _backgroundWidth;
+ uint16 _bkgWidth;
/** The height of the current background image */
- uint16 _backgroundHeight;
+ uint16 _bkgHeight;
+
+ uint16 _subid;
+
+ subMap _subsList;
/**
* 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;
+ //int _backgroundInverseVelocity;
/** Holds any 'leftover' milliseconds between frames */
- uint _accumulatedVelocityMilliseconds;
+ //uint _accumulatedVelocityMilliseconds;
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);
/**
* Renders the current state of the backbuffer to the screen
@@ -129,137 +159,6 @@ 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);
-
- /**
- * 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)
- */
- 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.
- * 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. 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, 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.
- * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
- *
- * @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(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false);
-
- /**
- * Copies a rectangla of source surface and copy to destination rect.
- *
- * @param src Source surface
- * @param dst Destenation surface
- * @param srcRect Rect of source surface
- * @param dstRect Rect for destenation surface
- */
- void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect);
-
- /**
- * Copies a rectangla of source surface and copy to destination rect.
- *
- * @param src Source surface
- * @param dst Destenation surface
- * @param srcRect Rect of source surface
- * @param dstRect Rect for destenation surface
- * @param colorkey Transparent color
- */
- void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey);
-
- /**
- * Copies a rectangla of source surface and copy to destination rect.
- *
- * @param src Source surface
- * @param dst Destenation surface
- * @param srcRect Rect of source surface
- * @param dstPt Point for destenation surface
- */
- void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt);
-
- /**
- * Copies a rectangla of source surface and copy to destination rect.
- *
- * @param src Source surface
- * @param dst Destenation surface
- * @param srcRect Rect of source surface
- * @param dstPt Point for destenation surface
- * @param colorkey Transparent color
- */
- void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey);
-
- /**
* Blits the image or a portion of the image to the background.
*
* @param fileName Name of the image file
@@ -271,15 +170,6 @@ public:
/**
* Blits the image or a portion of the image to the background.
*
- * @param surface 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 renderImageToBackground(const Graphics::Surface &surface, int16 destinationX, int16 destinationY);
-
- /**
- * Blits the image or a portion of the image to the background.
- *
* @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!
@@ -288,16 +178,6 @@ public:
void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
/**
- * Blits the image or a portion of the image to the background.
- *
- * @param surface 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!
- * @param colorkey Transparent color
- */
- void renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey);
-
- /**
* 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)
*
@@ -318,43 +198,15 @@ public:
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);
- /**
- * 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);
-
- /**
- * 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();
- const Graphics::Surface *getBackBuffer() {
- return &_backBuffer;
- }
/**
* Creates a copy of surface and transposes the data.
@@ -369,31 +221,32 @@ public:
void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
- void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y);
- void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
- void blitSurfaceToBkg(Graphics::Surface &src, int x, int y);
- void blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey);
- void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y);
- void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey);
+
+ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y);
+ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey);
+ void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y);
+ void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
+ void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y);
+ void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey);
+ void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y);
+ void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey);
+
+ uint16 createSubArea(const Common::Rect &area);
+ void deleteSubArea(uint16 id);
+ void deleteSubArea(uint16 id, int16 delay);
+ void updateSubArea(uint16 id, const Common::String &txt);
+ void renderSubsToScreen();
+
+ Common::Point getBkgSize();
+
Graphics::Surface *getBkgRect(Common::Rect &rect);
Graphics::Surface *loadImage(const char *file);
Graphics::Surface *loadImage(Common::String &file);
-private:
- /**
- * 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
- * @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(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap);
+ void clearMenuSurface();
+ void renderMenuToScreen();
+
+ void prepareBkg();
/**
* Reads an image file pixel data into a Surface buffer. In the process
@@ -406,19 +259,6 @@ private:
* @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);
};
} // End of namespace ZVision
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 5a0bae7..210c4fc 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -123,6 +123,28 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 d
}
}
+void RenderTable::mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf) {
+ uint32 destOffset = 0;
+
+ uint16 *sourceBuffer = (uint16 *)srcBuf->getPixels();
+ uint16 *destBuffer = (uint16 *)dstBuf->getPixels();
+
+ for (int16 y = 0; y < srcBuf->h; ++y) {
+ uint32 sourceOffset = y * _numColumns;
+
+ for (int16 x = 0; x < srcBuf->w; ++x) {
+ uint32 index = sourceOffset + x;
+
+ // RenderTable only stores offsets from the original coordinates
+ uint32 sourceYIndex = y + _internalBuffer[index].y;
+ uint32 sourceXIndex = x + _internalBuffer[index].x;
+
+ destBuffer[destOffset] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
+ destOffset++;
+ }
+ }
+}
+
void RenderTable::generateRenderTable() {
switch (_renderState) {
case ZVision::RenderTable::PANORAMA:
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 401e627..db9ab08 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -24,6 +24,7 @@
#define ZVISION_RENDER_TABLE_H
#include "common/rect.h"
+#include "graphics/surface.h"
namespace ZVision {
@@ -67,6 +68,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect);
+ void mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf);
void generateRenderTable();
void setPanoramaFoV(float fov);
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index e30861a..ddb57c8 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -516,10 +516,10 @@ void ScriptManager::do_changeLocation() {
_engine->getCursorManager()->changeCursor(CursorIndex_Idle);
// Reset the background velocity
- _engine->getRenderManager()->setBackgroundVelocity(0);
+ //_engine->getRenderManager()->setBackgroundVelocity(0);
// Remove any alphaEntries
- _engine->getRenderManager()->clearAlphaEntries();
+ //_engine->getRenderManager()->clearAlphaEntries();
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 65064d8..787b3ee 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -63,7 +63,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_stringManager(nullptr),
_cursorManager(nullptr),
_aud_id(0),
- _rendDelay(2) {
+ _rendDelay(2),
+ _velocity(0) {
debug(1, "ZVision::ZVision");
}
@@ -147,13 +148,16 @@ Common::Error ZVision::run() {
_cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem));
processEvents();
+ updateRotation();
// Call _renderManager->update() first so the background renders
// before anything that puzzles/controls will render
- _renderManager->update(deltaTime);
_scriptManager->update(deltaTime);
// Render the backBuffer to the screen
+ _renderManager->prepareBkg();
+ _renderManager->renderMenuToScreen();
+ _renderManager->renderSubsToScreen();
_renderManager->renderBackbufferToScreen();
// Update the screen
@@ -205,4 +209,46 @@ bool ZVision::canRender() {
return _rendDelay <= 0;
}
+void ZVision::updateRotation() {
+ if (_velocity) {
+ RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
+ if (renderState == RenderTable::PANORAMA) {
+ int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
+
+ int16 zero_point = 0;
+ if (st_pos >= zero_point && new_pos < zero_point)
+ _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1);
+ if (st_pos <= zero_point && new_pos > zero_point)
+ _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1);
+
+ int16 scr_width = _renderManager->getBkgSize().x;
+ if (scr_width)
+ new_pos %= scr_width;
+
+ if (new_pos < 0)
+ new_pos += scr_width;
+
+ _scriptManager->setStateValue(StateKey_ViewPos, new_pos);
+ _renderManager->setBackgroundPosition(new_pos);
+ } else if (renderState == RenderTable::TILT) {
+ int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
+
+ int16 scr_height = _renderManager->getBkgSize().y;
+ int16 tilt_gap = _workingWindow.height() / 2;
+
+ if (new_pos >= (scr_height - tilt_gap))
+ new_pos = scr_height - tilt_gap;
+ if (new_pos <= tilt_gap)
+ new_pos = tilt_gap;
+
+ _scriptManager->setStateValue(StateKey_ViewPos, new_pos);
+ _renderManager->setBackgroundPosition(new_pos);
+ }
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 05c5fcd..974384c 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -111,6 +111,7 @@ private:
const Common::Rect _workingWindow_ZNM;
int _rendDelay;
+ int16 _velocity;
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
@@ -170,6 +171,7 @@ private:
void onMouseDown(const Common::Point &pos);
void onMouseUp(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
+ void updateRotation();
};
} // End of namespace ZVision
Commit: e2dc6d31d27760bae85b1e00eba32011a07da178
https://github.com/scummvm/scummvm/commit/e2dc6d31d27760bae85b1e00eba32011a07da178
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-01-12T19:19:11+07:00
Commit Message:
ZVISION: Correct RenderManager methods for support menu.
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 bc4d169..f5d6847 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -204,6 +204,99 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
destination.convertToInPlace(_pixelFormat);
}
+void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) {
+ Common::File file;
+
+ if (!file.open(fileName)) {
+ warning("Could not open file %s", fileName.c_str());
+ return;
+ }
+
+ // Read the magic number
+ // Some files are true TGA, while others are TGZ
+ uint32 fileType = file.readUint32BE();
+
+ uint32 imageWidth;
+ uint32 imageHeight;
+ Graphics::TGADecoder tga;
+ uint16 *buffer;
+ // 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 = file.readSint32LE();
+ imageWidth = file.readSint32LE();
+ imageHeight = file.readSint32LE();
+
+ LzssReadStream lzssStream(&file);
+ buffer = (uint16 *)(new uint16[decompressedSize]);
+ lzssStream.read(buffer, decompressedSize);
+ } else {
+ isTGZ = false;
+
+ // Reset the cursor
+ file.seek(0);
+
+ // Decode
+ if (!tga.loadStream(file)) {
+ warning("Error while reading TGA image");
+ return;
+ }
+
+ Graphics::Surface tgaSurface = *(tga.getSurface());
+ imageWidth = tgaSurface.w;
+ imageHeight = tgaSurface.h;
+
+ buffer = (uint16 *)tgaSurface.getPixels();
+ }
+
+ // Flip the width and height if transposed
+ if (transposed) {
+ 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 transposed, 'un-transpose' the data while copying it to the destination
+ // Otherwise, just do a simple copy
+ if (transposed) {
+ 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);
+ }
+
+ // Cleanup
+ if (isTGZ) {
+ delete[] buffer;
+ } else {
+ tga.destroy();
+ }
+
+ // Convert in place to RGB 565 from RGB 555
+ destination.convertToInPlace(_pixelFormat);
+}
+
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
if (_workingWindow.contains(point)) {
// Convert from screen space to working window space
@@ -517,6 +610,17 @@ Graphics::Surface *RenderManager::loadImage(const char *file) {
return loadImage(str);
}
+Graphics::Surface *RenderManager::loadImage(Common::String &file, bool transposed) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ readImageToSurface(file, *tmp, transposed);
+ return tmp;
+}
+
+Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) {
+ Common::String str = Common::String(file);
+ return loadImage(str, transposed);
+}
+
void RenderManager::prepareBkg() {
_bkgDirtyRect.clip(_bkgWidth, _bkgHeight);
RenderTable::RenderState state = _renderTable.getRenderState();
@@ -587,15 +691,23 @@ void RenderManager::clearMenuSurface() {
_menuWnd.fillRect(_menuWndDirtyRect, 0);
}
+void RenderManager::clearMenuSurface(const Common::Rect &r) {
+ if (_menuWndDirtyRect.isEmpty())
+ _menuWndDirtyRect = r;
+ else
+ _menuWndDirtyRect.extend(r);
+ _menuWnd.fillRect(r, 0);
+}
+
void RenderManager::renderMenuToScreen() {
if (!_menuWndDirtyRect.isEmpty()) {
_menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h));
-
- _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch,
- _menuWndDirtyRect.left + _menuWndRect.left,
- _menuWndDirtyRect.top + _menuWndRect.top,
- _menuWndDirtyRect.width(),
- _menuWndDirtyRect.height());
+ if (!_menuWndDirtyRect.isEmpty())
+ _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch,
+ _menuWndDirtyRect.left + _menuWndRect.left,
+ _menuWndDirtyRect.top + _menuWndRect.top,
+ _menuWndDirtyRect.width(),
+ _menuWndDirtyRect.height());
_menuWndDirtyRect = Common::Rect();
}
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index de53481..901385b 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -242,8 +242,11 @@ public:
Graphics::Surface *getBkgRect(Common::Rect &rect);
Graphics::Surface *loadImage(const char *file);
Graphics::Surface *loadImage(Common::String &file);
+ Graphics::Surface *loadImage(const char *file, bool transposed);
+ Graphics::Surface *loadImage(Common::String &file, bool transposed);
void clearMenuSurface();
+ void clearMenuSurface(const Common::Rect &r);
void renderMenuToScreen();
void prepareBkg();
@@ -259,6 +262,7 @@ public:
* @param destination A reference to the Surface to store the pixel data in
*/
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
+ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
};
} // End of namespace ZVision
Commit: 52bcd6224813410aab3935a3f02de07b60abefe5
https://github.com/scummvm/scummvm/commit/52bcd6224813410aab3935a3f02de07b60abefe5
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-01-12T19:20:49+07:00
Commit Message:
ZVISION: Fix onMouseMove rectangle for scriptManager.
Changed paths:
engines/zvision/events.cpp
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index d882886..34b72e8 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -110,7 +110,7 @@ void ZVision::onMouseUp(const Common::Point &pos) {
void ZVision::onMouseMove(const Common::Point &pos) {
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
+ bool cursorWasChanged = false;
// Graph of the function governing rotation velocity:
//
@@ -143,6 +143,8 @@ void ZVision::onMouseMove(const Common::Point &pos) {
// ^
if (_workingWindow.contains(pos)) {
+ cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
+
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) {
Commit: aef9c68f3c99908ae6027c059652b46ee758ca7b
https://github.com/scummvm/scummvm/commit/aef9c68f3c99908ae6027c059652b46ee758ca7b
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-01-12T19:27:11+07:00
Commit Message:
ZVISION: Implement menus.
Changed paths:
A engines/zvision/menu.cpp
engines/zvision/events.cpp
engines/zvision/menu.h
engines/zvision/module.mk
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp
index 34b72e8..189bf00 100644
--- a/engines/zvision/events.cpp
+++ b/engines/zvision/events.cpp
@@ -29,6 +29,7 @@
#include "zvision/render_manager.h"
#include "zvision/script_manager.h"
#include "zvision/rlf_animation.h"
+#include "zvision/menu.h"
#include "common/events.h"
#include "common/system.h"
@@ -98,16 +99,21 @@ void ZVision::processEvents() {
}
void ZVision::onMouseDown(const Common::Point &pos) {
+ _menu->onMouseDown(pos);
+
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
_scriptManager->onMouseDown(pos, imageCoord);
}
void ZVision::onMouseUp(const Common::Point &pos) {
+ _menu->onMouseUp(pos);
+
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
_scriptManager->onMouseUp(pos, imageCoord);
}
void ZVision::onMouseMove(const Common::Point &pos) {
+ _menu->onMouseMove(pos);
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
bool cursorWasChanged = false;
diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp
new file mode 100644
index 0000000..4c84271
--- /dev/null
+++ b/engines/zvision/menu.cpp
@@ -0,0 +1,774 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/menu.h"
+
+#include "zvision/render_manager.h"
+
+
+namespace ZVision {
+
+enum {
+ SLOT_START_SLOT = 151,
+ SLOT_SPELL_1 = 191,
+ SLOT_USER_CHOSE_THIS_SPELL = 205,
+ SLOT_REVERSED_SPELLBOOK = 206
+};
+
+enum {
+ menu_MAIN_SAVE = 0,
+ menu_MAIN_REST = 1,
+ menu_MAIN_PREF = 2,
+ menu_MAIN_EXIT = 3
+};
+
+menuHandler::menuHandler(ZVision *engine) {
+ _engine = engine;
+ menu_bar_flag = 0xFFFF;
+}
+
+menuZgi::menuZgi(ZVision *engine) :
+ menuHandler(engine) {
+ menu_mousefocus = -1;
+ inmenu = false;
+ scrolled[0] = false;
+ scrolled[1] = false;
+ scrolled[2] = false;
+ scrollPos[0] = 0.0;
+ scrollPos[1] = 0.0;
+ scrollPos[2] = 0.0;
+ mouse_on_item = -1;
+
+ char buf[24];
+ for (int i = 1; i < 4; i++) {
+ sprintf(buf, "gmzau%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false);
+ sprintf(buf, "gmzau%2.2x1.tga", i + 0x10);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false);
+ }
+ for (int i = 0; i < 4; i++) {
+ sprintf(buf, "gmzmu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false);
+ sprintf(buf, "gmznu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false);
+ }
+
+ for (int i = 0; i < 50; i++) {
+ items[i][0] = NULL;
+ items[i][1] = NULL;
+ item_id[i] = 0;
+ }
+
+ for (int i = 0; i < 12; i++) {
+ magic[i][0] = NULL;
+ magic[i][1] = NULL;
+ magic_id[i] = 0;
+ }
+}
+
+menuZgi::~menuZgi() {
+ for (int i = 0; i < 3; i++) {
+ menuback[i][0].free();
+ menuback[i][1].free();
+ }
+ for (int i = 0; i < 4; i++) {
+ menubar[i][0].free();
+ menubar[i][1].free();
+ }
+ for (int i = 0; i < 50; i++) {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ }
+ }
+ for (int i = 0; i < 12; i++) {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ }
+ }
+}
+
+void menuZgi::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items) {
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
+ scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
+ int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (mouse_item >= 0 && mouse_item < 0xE0) {
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i));
+ _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item);
+
+ redraw = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic) {
+ for (int i = 0; i < 12; i++) {
+
+ uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ if (itemnum != 0) {
+ if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ itemnum = 0xEE + i;
+ else
+ itemnum = 0xE0 + i;
+ }
+ if (itemnum)
+ if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0)
+ if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
+ 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos))
+ _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum);
+ }
+
+ }
+ break;
+
+ case menu_MAIN:
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(320 + 135,
+ scrollPos[menu_MAIN],
+ 320 + 135 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ // ifquit();
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(320 ,
+ scrollPos[menu_MAIN],
+ 320 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(320 - 135,
+ scrollPos[menu_MAIN],
+ 320,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[menu_MAIN],
+ 320 - 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ }
+ break;
+ }
+ }
+}
+
+void menuZgi::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ if (!inmenu)
+ redraw = true;
+ inmenu = true;
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items) {
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+ else if (item_count > 50)
+ item_count = 50;
+
+ int last_item = mouse_on_item;
+
+ mouse_on_item = -1;
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
+ scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
+ mouse_on_item = i;
+ break;
+ }
+ }
+
+ if (last_item != mouse_on_item)
+ if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) ||
+ _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item))
+ redraw = true;
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic) {
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+ for (int i = 0; i < 12; i++) {
+ if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
+ 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) {
+ mouse_on_item = i;
+ break;
+ }
+ }
+
+ if (last_item != mouse_on_item)
+ if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) ||
+ _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item))
+ redraw = true;
+
+ }
+ break;
+
+ case menu_MAIN:
+ {
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(320 + 135,
+ scrollPos[menu_MAIN],
+ 320 + 135 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_EXIT;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(320 ,
+ scrollPos[menu_MAIN],
+ 320 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_PREF;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(320 - 135,
+ scrollPos[menu_MAIN],
+ 320,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_REST;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[menu_MAIN],
+ 320 - 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_SAVE;
+ }
+
+ if (last_item != mouse_on_item)
+ redraw = true;
+ }
+ break;
+
+ default:
+ int cur_menu = menu_mousefocus;
+ if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main
+ menu_mousefocus = menu_MAIN;
+ scrolled[menu_MAIN] = false;
+ scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+ }
+
+ if (menu_bar_flag & menuBar_Magic)
+ if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
+ menu_mousefocus = menu_MAGIC;
+ scrolled[menu_MAGIC] = false;
+ scrollPos[menu_MAGIC] = 28;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
+ }
+
+ if (menu_bar_flag & menuBar_Items)
+ if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
+ menu_mousefocus = menu_ITEM;
+ scrolled[menu_ITEM] = false;
+ scrollPos[menu_ITEM] = 28 - 600;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
+ }
+
+ if (cur_menu != menu_mousefocus)
+ clean = true;
+
+ break;
+ }
+ } else {
+ if (inmenu)
+ clean = true;
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ menu_mousefocus = -1;
+ }
+}
+
+void menuZgi::process(uint32 deltatime) {
+ if (clean) {
+ _engine->getRenderManager()->clearMenuSurface();
+ clean = false;
+ }
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items)
+ if (!scrolled[menu_ITEM]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_ITEM] += scrl;
+
+ if (scrollPos[menu_ITEM] >= 0) {
+ scrolled[menu_ITEM] = true;
+ scrollPos [menu_ITEM] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0);
+
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+ else if (item_count > 50)
+ item_count = 50;
+
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ bool inrect = false;
+
+ if (mouse_on_item == i)
+ inrect = true;
+
+ uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
+
+ if (cur_item_id != 0) {
+ if (item_id[i] != cur_item_id) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ items[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ items[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ item_id[i] = cur_item_id;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+
+ } else {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ items[i][0] = NULL;
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ items[i][1] = NULL;
+ }
+ item_id[i] = 0;
+ }
+ }
+
+ redraw = false;
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic)
+ if (!scrolled[menu_MAGIC]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_MAGIC] += scrl;
+
+ if (scrollPos[menu_MAGIC] >= 600) {
+ scrolled[menu_MAGIC] = true;
+ scrollPos [menu_MAGIC] = 600;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0);
+
+ for (int i = 0; i < 12; i++) {
+ bool inrect = false;
+
+ if (mouse_on_item == i)
+ inrect = true;
+
+ uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ if (cur_item_id) {
+ if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ cur_item_id = 0xEE + i;
+ else
+ cur_item_id = 0xE0 + i;
+ }
+
+ if (cur_item_id != 0) {
+ if (item_id[i] != cur_item_id) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ magic[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ magic[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ magic_id[i] = cur_item_id;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+
+ } else {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ magic[i][0] = NULL;
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ magic[i][1] = NULL;
+ }
+ magic_id[i] = 0;
+ }
+ }
+ redraw = false;
+ }
+ break;
+
+ case menu_MAIN:
+ if (!scrolled[menu_MAIN]) {
+ redraw = true;
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_MAIN] += scrl;
+
+ if (scrollPos[menu_MAIN] >= 0) {
+ scrolled[menu_MAIN] = true;
+ scrollPos [menu_MAIN] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
+
+ if (menu_bar_flag & menuBar_Exit)
+ {
+ if (mouse_on_item == menu_MAIN_EXIT)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Settings)
+ {
+ if (mouse_on_item == menu_MAIN_PREF)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Restore)
+ {
+ if (mouse_on_item == menu_MAIN_REST)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Save)
+ {
+ if (mouse_on_item == menu_MAIN_SAVE)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ }
+ redraw = false;
+ }
+ break;
+ default:
+ if (redraw) {
+ if (inmenu) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0);
+
+ if (menu_bar_flag & menuBar_Items)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0);
+
+ if (menu_bar_flag & menuBar_Magic)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0);
+ }
+ redraw = false;
+ }
+ break;
+ }
+}
+
+
+menuNem::menuNem(ZVision *engine) :
+ menuHandler(engine) {
+ inmenu = false;
+ scrolled = false;
+ scrollPos = 0.0;
+ mouse_on_item = -1;
+
+ char buf[24];
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++) {
+ sprintf(buf, "butfrm%d%d.tga", i + 1, j);
+ _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false);
+ }
+
+ _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false);
+
+ frm = 0;
+}
+
+menuNem::~menuNem() {
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++)
+ but[i][j].free();
+
+ menubar.free();
+}
+
+static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} };
+
+void menuNem::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ // ifquit();
+ frm = 5;
+ redraw = true;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+ }
+}
+
+void menuNem::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ inmenu = true;
+
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_EXIT;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_PREF;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_REST;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_SAVE;
+ }
+
+ if (last_item != mouse_on_item) {
+ redraw = true;
+ frm = 0;
+ delay = 200;
+ }
+ } else {
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ mouse_on_item = -1;
+ }
+}
+
+void menuNem::process(uint32 deltatime) {
+ if (inmenu) {
+ if (!scrolled)
+ {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos += scrl;
+ redraw = true;
+ }
+
+ if (scrollPos >= 0)
+ {
+ scrolled = true;
+ scrollPos = 0;
+ }
+
+ if (mouse_on_item != -1) {
+ delay -= deltatime;
+ if (delay <= 0 && frm < 4) {
+ delay = 200;
+ frm++;
+ redraw = true;
+ }
+ }
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+
+ if (menu_bar_flag & menuBar_Exit)
+ if (mouse_on_item == menu_MAIN_EXIT)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Settings)
+ if (mouse_on_item == menu_MAIN_PREF)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Restore)
+ if (mouse_on_item == menu_MAIN_REST)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Save)
+ if (mouse_on_item == menu_MAIN_SAVE)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
+
+ redraw = false;
+ }
+ } else {
+ scrolled = false;
+ if (scrollPos > -32)
+ {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1);
+ _engine->getRenderManager()->clearMenuSurface(cl);
+
+ scrollPos -= scrl;
+ redraw = true;
+ }
+ else
+ scrollPos = -32;
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+ redraw = false;
+ }
+ }
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h
index affc69a..c5938cd 100644
--- a/engines/zvision/menu.h
+++ b/engines/zvision/menu.h
@@ -23,6 +23,98 @@
#ifndef ZVISION_MENU_H
#define ZVISION_MENU_H
-// TODO: Implement MenuHandler
+#include "graphics/surface.h"
+#include "common/rect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+
+namespace ZVision {
+
+enum menuBar {
+ menuBar_Exit = 0x1,
+ menuBar_Settings = 0x2,
+ menuBar_Restore = 0x4,
+ menuBar_Save = 0x8,
+ menuBar_Items = 0x100,
+ menuBar_Magic = 0x200
+};
+
+class menuHandler {
+public:
+ menuHandler(ZVision *engine);
+ virtual ~menuHandler() {};
+ virtual void onMouseMove(const Common::Point &Pos) {};
+ virtual void onMouseDown(const Common::Point &Pos) {};
+ virtual void onMouseUp(const Common::Point &Pos) {};
+ virtual void process(uint32 deltaTimeInMillis) {};
+protected:
+ uint16 menu_bar_flag;
+ ZVision *_engine;
+};
+
+class menuZgi: public menuHandler {
+public:
+ menuZgi(ZVision *engine);
+ ~menuZgi();
+ void onMouseMove(const Common::Point &Pos);
+ void onMouseUp(const Common::Point &Pos);
+ void process(uint32 deltaTimeInMillis);
+private:
+ Graphics::Surface menuback[3][2];
+ Graphics::Surface menubar[4][2];
+
+
+ Graphics::Surface *items[50][2];
+ uint item_id[50];
+
+ Graphics::Surface *magic[12][2];
+ uint magic_id[12];
+
+ int menu_mousefocus;
+ bool inmenu;
+
+ int mouse_on_item;
+
+ bool scrolled[3];
+ float scrollPos[3];
+
+ enum {
+ menu_ITEM = 0,
+ menu_MAGIC = 1,
+ menu_MAIN = 2
+ };
+
+ bool clean;
+ bool redraw;
+
+};
+
+class menuNem: public menuHandler {
+public:
+ menuNem(ZVision *engine);
+ ~menuNem();
+ void onMouseMove(const Common::Point &Pos);
+ void onMouseUp(const Common::Point &Pos);
+ void process(uint32 deltaTimeInMillis);
+private:
+ Graphics::Surface but[4][6];
+ Graphics::Surface menubar;
+
+ bool inmenu;
+
+ int mouse_on_item;
+
+ bool scrolled;
+ float scrollPos;
+
+ bool redraw;
+
+ int frm;
+ int16 delay;
+
+};
+
+}
#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index b551263..af90923 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -33,7 +33,8 @@ MODULE_OBJS := \
sidefx.o \
music_node.o \
inventory_manager.o \
- slot_control.o
+ slot_control.o \
+ menu.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 787b3ee..05923ce 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -32,6 +32,7 @@
#include "zvision/string_manager.h"
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
+#include "zvision/menu.h"
#include "common/config-manager.h"
#include "common/debug.h"
@@ -127,6 +128,11 @@ void ZVision::initialize() {
_stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
+ if (_gameDescription->gameId == GID_GRANDINQUISITOR)
+ _menu = new menuZgi(this);
+ else
+ _menu = new menuNem(this);
+
// Initialize the managers
_cursorManager->initialize();
_scriptManager->initialize();
@@ -153,6 +159,7 @@ Common::Error ZVision::run() {
// Call _renderManager->update() first so the background renders
// before anything that puzzles/controls will render
_scriptManager->update(deltaTime);
+ _menu->process(deltaTime);
// Render the backBuffer to the screen
_renderManager->prepareBkg();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 974384c..23c5f60 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -51,6 +51,7 @@ class CursorManager;
class StringManager;
class SaveManager;
class RlfAnimation;
+class menuHandler;
class ZVision : public Engine {
public:
@@ -97,6 +98,7 @@ private:
CursorManager *_cursorManager;
SaveManager *_saveManager;
StringManager *_stringManager;
+ menuHandler *_menu;
// Clock
Clock _clock;
Commit: 4ced9c07e0ce55fd77c7a31261a3179b5abb7a8c
https://github.com/scummvm/scummvm/commit/4ced9c07e0ce55fd77c7a31261a3179b5abb7a8c
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-01-13T07:53:36+07:00
Commit Message:
ZVISION: Fix killSideFxType iterator.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index ddb57c8..a100319 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -381,7 +381,7 @@ void ScriptManager::killSideFxType(SideFX::SideFXType type) {
if ((*iter)->getType() & type) {
(*iter)->kill();
delete(*iter);
- _activeSideFx.erase(iter);
+ iter = _activeSideFx.erase(iter);
} else {
++iter;
}
Commit: 9803f7e6c045d625ee41e5b2769b1b2de3ab8ee3
https://github.com/scummvm/scummvm/commit/9803f7e6c045d625ee41e5b2769b1b2de3ab8ee3
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-13T09:07:44+07:00
Commit Message:
ZVISION: Fix code style with astyle.
Changed paths:
engines/zvision/animation_node.cpp
engines/zvision/menu.cpp
engines/zvision/menu.h
engines/zvision/script_manager.h
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 74b532b..27ee873 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -191,11 +191,11 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st
nod.start = start_frame;
nod.stop = end_frame;
if (_fileType == RLF) {
- if (nod.stop >= (int)_animation.rlf->frameCount())
- nod.stop = _animation.rlf->frameCount() - 1;
+ if (nod.stop >= (int)_animation.rlf->frameCount())
+ nod.stop = _animation.rlf->frameCount() - 1;
} else if (_fileType == AVI) {
- if (nod.stop > (int)_animation.avi->getFrameCount())
- nod.stop = _animation.avi->getFrameCount();
+ if (nod.stop > (int)_animation.avi->getFrameCount())
+ nod.stop = _animation.avi->getFrameCount();
}
nod.slot = slot;
nod._cur_frm = -1;
diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp
index 4c84271..8e1dea1 100644
--- a/engines/zvision/menu.cpp
+++ b/engines/zvision/menu.cpp
@@ -30,17 +30,17 @@
namespace ZVision {
enum {
- SLOT_START_SLOT = 151,
- SLOT_SPELL_1 = 191,
- SLOT_USER_CHOSE_THIS_SPELL = 205,
- SLOT_REVERSED_SPELLBOOK = 206
+ SLOT_START_SLOT = 151,
+ SLOT_SPELL_1 = 191,
+ SLOT_USER_CHOSE_THIS_SPELL = 205,
+ SLOT_REVERSED_SPELLBOOK = 206
};
enum {
- menu_MAIN_SAVE = 0,
- menu_MAIN_REST = 1,
- menu_MAIN_PREF = 2,
- menu_MAIN_EXIT = 3
+ menu_MAIN_SAVE = 0,
+ menu_MAIN_REST = 1,
+ menu_MAIN_PREF = 2,
+ menu_MAIN_EXIT = 3
};
menuHandler::menuHandler(ZVision *engine) {
diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h
index c5938cd..35e7347 100644
--- a/engines/zvision/menu.h
+++ b/engines/zvision/menu.h
@@ -32,12 +32,12 @@
namespace ZVision {
enum menuBar {
- menuBar_Exit = 0x1,
- menuBar_Settings = 0x2,
- menuBar_Restore = 0x4,
- menuBar_Save = 0x8,
- menuBar_Items = 0x100,
- menuBar_Magic = 0x200
+ menuBar_Exit = 0x1,
+ menuBar_Settings = 0x2,
+ menuBar_Restore = 0x4,
+ menuBar_Save = 0x8,
+ menuBar_Items = 0x100,
+ menuBar_Magic = 0x200
};
class menuHandler {
@@ -80,9 +80,9 @@ private:
float scrollPos[3];
enum {
- menu_ITEM = 0,
- menu_MAGIC = 1,
- menu_MAIN = 2
+ menu_ITEM = 0,
+ menu_MAGIC = 1,
+ menu_MAIN = 2
};
bool clean;
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 2f585b6..3e671aa 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -41,59 +41,59 @@ namespace ZVision {
class ZVision;
enum StateKey {
- StateKey_World = 3,
- StateKey_Room = 4,
- StateKey_Node = 5,
- StateKey_View = 6,
- StateKey_ViewPos = 7,
- StateKey_KeyPress = 8,
- StateKey_InventoryItem = 9,
- StateKey_LMouse = 10,
- StateKey_NotSet = 11, // This key doesn't set
- StateKey_Rounds = 12,
- StateKey_Venus = 13,
- StateKey_RMouse = 18,
- StateKey_MenuState = 19,
- StateKey_RestoreFlag = 20,
- StateKey_Quitting = 39,
- StateKey_LastWorld = 40,
- StateKey_LastRoom = 41,
- StateKey_LastNode = 42,
- StateKey_LastView = 43,
- StateKey_LastViewPos = 44,
- StateKey_Menu_LastWorld = 45,
- StateKey_Menu_LastRoom = 46,
- StateKey_Menu_LastNode = 47,
- StateKey_Menu_LastView = 48,
- StateKey_Menu_LastViewPos = 49,
- StateKey_KbdRotateSpeed = 50,
- StateKey_Subtitles = 51,
- StateKey_StreamSkipKey = 52,
- StateKey_RotateSpeed = 53,
- StateKey_Volume = 56,
- StateKey_Qsound = 57,
- StateKey_VenusEnable = 58,
- StateKey_HighQuality = 59,
- StateKey_VideoLineSkip = 65,
- StateKey_Platform = 66,
- StateKey_InstallLevel = 67,
- StateKey_CountryCode = 68,
- StateKey_CPU = 69,
- StateKey_MovieCursor = 70,
- StateKey_NoTurnAnim = 71,
- StateKey_WIN958 = 72,
- StateKey_ShowErrorDlg = 73,
- StateKey_DebugCheats = 74,
- StateKey_JapanFonts = 75,
- StateKey_Brightness = 77,
- StateKey_EF9_B = 91,
- StateKey_EF9_G = 92,
- StateKey_EF9_R = 93,
- StateKey_EF9_Speed = 94,
- StateKey_Inv_Cnt_Slot = 100,
- StateKey_Inv_1_Slot = 101,
- StateKey_Inv_49_Slot = 149,
- StateKey_Inv_TotalSlots = 150
+ StateKey_World = 3,
+ StateKey_Room = 4,
+ StateKey_Node = 5,
+ StateKey_View = 6,
+ StateKey_ViewPos = 7,
+ StateKey_KeyPress = 8,
+ StateKey_InventoryItem = 9,
+ StateKey_LMouse = 10,
+ StateKey_NotSet = 11, // This key doesn't set
+ StateKey_Rounds = 12,
+ StateKey_Venus = 13,
+ StateKey_RMouse = 18,
+ StateKey_MenuState = 19,
+ StateKey_RestoreFlag = 20,
+ StateKey_Quitting = 39,
+ StateKey_LastWorld = 40,
+ StateKey_LastRoom = 41,
+ StateKey_LastNode = 42,
+ StateKey_LastView = 43,
+ StateKey_LastViewPos = 44,
+ StateKey_Menu_LastWorld = 45,
+ StateKey_Menu_LastRoom = 46,
+ StateKey_Menu_LastNode = 47,
+ StateKey_Menu_LastView = 48,
+ StateKey_Menu_LastViewPos = 49,
+ StateKey_KbdRotateSpeed = 50,
+ StateKey_Subtitles = 51,
+ StateKey_StreamSkipKey = 52,
+ StateKey_RotateSpeed = 53,
+ StateKey_Volume = 56,
+ StateKey_Qsound = 57,
+ StateKey_VenusEnable = 58,
+ StateKey_HighQuality = 59,
+ StateKey_VideoLineSkip = 65,
+ StateKey_Platform = 66,
+ StateKey_InstallLevel = 67,
+ StateKey_CountryCode = 68,
+ StateKey_CPU = 69,
+ StateKey_MovieCursor = 70,
+ StateKey_NoTurnAnim = 71,
+ StateKey_WIN958 = 72,
+ StateKey_ShowErrorDlg = 73,
+ StateKey_DebugCheats = 74,
+ StateKey_JapanFonts = 75,
+ StateKey_Brightness = 77,
+ StateKey_EF9_B = 91,
+ StateKey_EF9_G = 92,
+ StateKey_EF9_R = 93,
+ StateKey_EF9_Speed = 94,
+ StateKey_Inv_Cnt_Slot = 100,
+ StateKey_Inv_1_Slot = 101,
+ StateKey_Inv_49_Slot = 149,
+ StateKey_Inv_TotalSlots = 150
};
struct Location {
Commit: 61224e7225061551765c07b691e8d8c5da3434df
https://github.com/scummvm/scummvm/commit/61224e7225061551765c07b691e8d8c5da3434df
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T09:32:06+07:00
Commit Message:
ZVISION: Move MusicNode to use Audio::SoundHandle.
Changed paths:
engines/zvision/music_node.cpp
engines/zvision/music_node.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index 6be4683..709b554 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -57,13 +57,12 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
audioStream = makeRawZorkStream(filename, _engine);
}
- _id = _engine->getAudioId();
if (_loop) {
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, loopingAudioStream, _id, _volume);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
} else {
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, audioStream, _id, _volume);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
}
if (_key != StateKey_NotSet)
@@ -71,14 +70,14 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
}
MusicNode::~MusicNode() {
- _engine->_mixer->stopID(_id);
+ _engine->_mixer->stopHandle(_handle);
if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
debug(1, "MusicNode: %d destroyed\n", _key);
}
bool MusicNode::process(uint32 deltaTimeInMillis) {
- if (! _engine->_mixer->isSoundIDActive(_id))
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
return stop();
return false;
}
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
index 6aed455..973feaf 100644
--- a/engines/zvision/music_node.h
+++ b/engines/zvision/music_node.h
@@ -23,6 +23,7 @@
#ifndef ZVISION_MUSIC_NODE_H
#define ZVISION_MUSIC_NODE_H
+#include "audio/mixer.h"
#include "zvision/sidefx.h"
namespace Common {
@@ -55,6 +56,7 @@ private:
bool _crossfade;
int32 _crossfade_delta;
int32 _crossfade_time;
+ Audio::SoundHandle _handle;
};
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 05923ce..f21498c 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -201,13 +201,6 @@ Common::String ZVision::generateAutoSaveFileName() {
return Common::String::format("%s.auto", _targetName.c_str());
}
-int ZVision::getAudioId() {
- _aud_id++;
- if (_aud_id < 0)
- _aud_id = 0;
- return _aud_id;
-}
-
void ZVision::setRenderDelay(uint delay) {
_rendDelay = delay;
}
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 23c5f60..26d7644 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -153,8 +153,6 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
- int getAudioId();
-
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
Commit: 41415002b223e5ae0e53fb351ee41d8a99fbc920
https://github.com/scummvm/scummvm/commit/41415002b223e5ae0e53fb351ee41d8a99fbc920
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T10:57:29+07:00
Commit Message:
ZVISION: Implement PanTrack.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/music_node.cpp
engines/zvision/music_node.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index ccae6fd..3eec70d 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -313,6 +313,30 @@ bool ActionMusic::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionPanTrack
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey),
+ _pos(0),
+ _mus_slot(0) {
+
+ sscanf(line.c_str(), "%u %d", &_mus_slot, &_pos);
+}
+
+ActionPanTrack::~ActionPanTrack() {
+ _engine->getScriptManager()->killSideFx(_slotkey);
+}
+
+bool ActionPanTrack::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotkey, _mus_slot, _pos));
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionPreloadAnimation
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index aadb97f..417c1ad 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -247,6 +247,17 @@ private:
bool _universe;
};
+class ActionPanTrack : public ResultAction {
+public:
+ ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionPanTrack();
+ bool execute();
+
+private:
+ int32 _pos;
+ uint32 _mus_slot;
+};
+
class ActionPlayAnimation : public ResultAction {
public:
ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index 709b554..081c9db 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -26,6 +26,7 @@
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
#include "zvision/zork_raw.h"
#include "common/stream.h"
@@ -40,7 +41,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
_loop = loop;
_volume = volume;
_crossfade = false;
- _crossfade_delta = 0;
+ _crossfade_target = 0;
_crossfade_time = 0;
_attenuate = 0;
_pantrack = false;
@@ -57,6 +58,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
audioStream = makeRawZorkStream(filename, _engine);
}
+ _stereo = audioStream->isStereo();
if (_loop) {
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
@@ -76,10 +78,81 @@ MusicNode::~MusicNode() {
debug(1, "MusicNode: %d destroyed\n", _key);
}
+void MusicNode::setPanTrack(int16 pos) {
+ if (!_stereo) {
+ _pantrack = true;
+ _pantrack_X = pos;
+ setVolume(_volume);
+ }
+}
+
+void MusicNode::unsetPanTrack() {
+ _pantrack = false;
+ setVolume(_volume);
+}
+
bool MusicNode::process(uint32 deltaTimeInMillis) {
if (! _engine->_mixer->isSoundHandleActive(_handle))
return stop();
+ else {
+ uint8 _newvol = _volume;
+
+ if (_pantrack || _volume != _newvol)
+ setVolume(_newvol);
+ }
return false;
}
+void MusicNode::setVolume(uint8 new_volume) {
+ if (_pantrack) {
+ int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+ cur_x -= _pantrack_X;
+ int32 _width = _engine->getRenderManager()->getBkgSize().x;
+ if (cur_x < (-_width) / 2)
+ cur_x += _width;
+ else if (cur_x >= _width / 2)
+ cur_x -= _width;
+
+ float norm = (float)cur_x / ((float)_width / 2.0);
+ float lvl = fabs(norm);
+ if (lvl > 0.5)
+ lvl = (lvl - 0.5) * 1.7;
+ else
+ lvl = 1.0;
+
+ float bal = sin(-norm * 3.1415926) * 127.0;
+
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, bal);
+ _engine->_mixer->setChannelVolume(_handle, new_volume * lvl);
+ }
+ } else {
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, 0);
+ _engine->_mixer->setChannelVolume(_handle, new_volume);
+ }
+ }
+
+ _volume = new_volume;
+}
+
+PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
+ : SideFX(engine, key, SIDEFX_PANTRACK) {
+ _slot = slot;
+
+ SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
+ if (fx && fx->getType() == SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->setPanTrack(pos);
+ }
+}
+
+PanTrackNode::~PanTrackNode() {
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
+ if (fx && fx->getType() == SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->unsetPanTrack();
+ }
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
index 973feaf..9ccf9ab 100644
--- a/engines/zvision/music_node.h
+++ b/engines/zvision/music_node.h
@@ -45,20 +45,33 @@ public:
*/
bool process(uint32 deltaTimeInMillis);
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
private:
int32 _timeLeft;
bool _pantrack;
int32 _pantrack_X;
int32 _attenuate;
- int8 _volume;
- int32 _id;
+ uint8 _volume;
bool _loop;
bool _crossfade;
- int32 _crossfade_delta;
+ uint8 _crossfade_target;
int32 _crossfade_time;
+ bool _stereo;
Audio::SoundHandle _handle;
};
+class PanTrackNode : public SideFX {
+public:
+ PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
+ ~PanTrackNode();
+
+private:
+ uint32 _slot;
+};
+
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 4f1c363..83f25a8 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -248,7 +248,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("music", true)) {
actionList.push_back(new ActionMusic(_engine, slot, args, false));
} else if (act.matchString("pan_track", true)) {
- // TODO: Implement ActionPanTrack
+ actionList.push_back(new ActionPanTrack(_engine, slot, args));
} else if (act.matchString("playpreload", true)) {
actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args));
} else if (act.matchString("preferences", true)) {
Commit: d973b1fb1bde603b3b2436a58afcf043b178c407
https://github.com/scummvm/scummvm/commit/d973b1fb1bde603b3b2436a58afcf043b178c407
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T11:07:58+07:00
Commit Message:
ZVISION: Implement attenuate code.
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 3eec70d..92d6f6c 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -88,7 +88,11 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S
}
bool ActionAttenuate::execute() {
- // TODO: Implement
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_key);
+ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->setVolume(255 - (abs(_attenuation) >> 7));
+ }
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 417c1ad..b204fbe 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -116,7 +116,7 @@ public:
private:
uint32 _key;
- int _attenuation;
+ int32 _attenuation;
};
class ActionChangeLocation : public ResultAction {
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 83f25a8..002871a 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -214,7 +214,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("animunload", true)) {
//actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
} else if (act.matchString("attenuate", true)) {
- // TODO: Implement ActionAttenuate
+ actionList.push_back(new ActionAttenuate(_engine, slot, args));
} else if (act.matchString("assign", true)) {
actionList.push_back(new ActionAssign(_engine, slot, args));
} else if (act.matchString("change_location", true)) {
Commit: 7b7ae43f7fe30782201fba691beee1bad18db60a
https://github.com/scummvm/scummvm/commit/7b7ae43f7fe30782201fba691beee1bad18db60a
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T11:10:17+07:00
Commit Message:
ZVISION: Implement crossfade.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/music_node.cpp
engines/zvision/music_node.h
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 92d6f6c..5d1dc9a 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -121,12 +121,32 @@ bool ActionChangeLocation::execute() {
ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey) {
sscanf(line.c_str(),
- "%u %u %u %u %u %u %u",
+ "%u %u %d %d %d %d %d",
&_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
}
bool ActionCrossfade::execute() {
- // TODO: Implement
+ if (_keyOne) {
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_keyOne);
+ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ if (_oneStartVolume >= 0)
+ mus->setVolume((_oneStartVolume * 255) / 100);
+
+ mus->setFade(_timeInMillis, (_oneEndVolume * 255) / 100);
+ }
+ }
+
+ if (_keyTwo) {
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
+ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ if (_twoStartVolume >= 0)
+ mus->setVolume((_twoStartVolume * 255) / 100);
+
+ mus->setFade(_timeInMillis, (_twoEndVolume * 255) / 100);
+ }
+ }
return true;
}
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index b204fbe..5c6cf6c 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -140,11 +140,11 @@ public:
private:
uint32 _keyOne;
uint32 _keyTwo;
- uint _oneStartVolume;
- uint _twoStartVolume;
- uint _oneEndVolume;
- uint _twoEndVolume;
- uint _timeInMillis;
+ int32 _oneStartVolume;
+ int32 _twoStartVolume;
+ int32 _oneEndVolume;
+ int32 _twoEndVolume;
+ int32 _timeInMillis;
};
class ActionDebug : public ResultAction {
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index 081c9db..3027148 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -91,12 +91,31 @@ void MusicNode::unsetPanTrack() {
setVolume(_volume);
}
+void MusicNode::setFade(int32 time, uint8 target) {
+ _crossfade_target = target;
+ _crossfade_time = time;
+ _crossfade = true;
+}
+
bool MusicNode::process(uint32 deltaTimeInMillis) {
if (! _engine->_mixer->isSoundHandleActive(_handle))
return stop();
else {
uint8 _newvol = _volume;
+ if (_crossfade) {
+ if (_crossfade_time > 0) {
+ if ((int32)deltaTimeInMillis > _crossfade_time)
+ deltaTimeInMillis = _crossfade_time;
+ _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis;
+ _crossfade_time -= deltaTimeInMillis;
+ }
+ else {
+ _crossfade = false;
+ _newvol = _crossfade_target;
+ }
+ }
+
if (_pantrack || _volume != _newvol)
setVolume(_newvol);
}
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
index 9ccf9ab..6e3033f 100644
--- a/engines/zvision/music_node.h
+++ b/engines/zvision/music_node.h
@@ -49,6 +49,9 @@ public:
void setPanTrack(int16 pos);
void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
private:
int32 _timeLeft;
bool _pantrack;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 002871a..833db11 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("change_location", true)) {
actionList.push_back(new ActionChangeLocation(_engine, slot, args));
} else if (act.matchString("crossfade", true)) {
- // TODO: Implement ActionCrossfade
+ actionList.push_back(new ActionCrossfade(_engine, slot, args));
} else if (act.matchString("debug", true)) {
// TODO: Implement ActionDebug
} else if (act.matchString("delay_render", true)) {
Commit: 3a1fda6d5760b25acb3bb561b567f6402685bcc6
https://github.com/scummvm/scummvm/commit/3a1fda6d5760b25acb3bb561b567f6402685bcc6
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T16:52:26+07:00
Commit Message:
ZVISION: New class for handle rlf and avi animations.
Changed paths:
A engines/zvision/meta_animation.cpp
A engines/zvision/meta_animation.h
engines/zvision/module.mk
diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp
new file mode 100644
index 0000000..430b143
--- /dev/null
+++ b/engines/zvision/meta_animation.cpp
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/meta_animation.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 {
+
+MetaAnimation::MetaAnimation(const Common::String &fileName)
+ : _fileType(RLF),
+ _cur_frame(NULL) {
+ if (fileName.hasSuffix(".rlf")) {
+ _fileType = RLF;
+ _animation.rlf = new RlfAnimation(fileName, false);
+ _frmDelay = _animation.rlf->frameTime();
+ } else if (fileName.hasSuffix(".avi")) {
+ _fileType = AVI;
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadFile(fileName);
+ _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+}
+
+MetaAnimation::~MetaAnimation() {
+ if (_fileType == RLF) {
+ delete _animation.rlf;
+ } else if (_fileType == AVI) {
+ delete _animation.avi;
+ }
+}
+
+uint MetaAnimation::frameCount() {
+ if (_fileType == RLF) {
+ return _animation.rlf->frameCount();
+ } else
+ return _animation.avi->getFrameCount();
+
+}
+
+uint MetaAnimation::width() {
+ if (_fileType == RLF) {
+ return _animation.rlf->width();
+ } else
+ return _animation.avi->getWidth();
+}
+uint MetaAnimation::height() {
+ if (_fileType == RLF) {
+ return _animation.rlf->height();
+ } else
+ return _animation.avi->getHeight();
+}
+uint32 MetaAnimation::frameTime() {
+ return _frmDelay;
+}
+
+void MetaAnimation::seekToFrame(int frameNumber) {
+ if (frameNumber >= (int)frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(frameNumber);
+ } else
+ _animation.avi->seekToFrame(frameNumber);
+}
+
+const Graphics::Surface *MetaAnimation::decodeNextFrame() {
+ if (_fileType == RLF)
+ _cur_frame = _animation.rlf->decodeNextFrame();
+ else
+ _cur_frame = _animation.avi->decodeNextFrame();
+
+ return _cur_frame;
+}
+
+const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
+ if (frameNumber >= frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _cur_frame = _animation.rlf->getFrameData(frameNumber);
+ return _cur_frame;
+ } else {
+ _animation.avi->seekToFrame(frameNumber);
+ _cur_frame = _animation.avi->decodeNextFrame();
+ return _cur_frame;
+ }
+}
+
+bool MetaAnimation::endOfAnimation() {
+ if (_fileType == RLF) {
+ return _animation.rlf->endOfAnimation();
+ } else
+ return _animation.avi->endOfVideo();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h
new file mode 100644
index 0000000..fea7a6a
--- /dev/null
+++ b/engines/zvision/meta_animation.h
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_METAANIM_NODE_H
+#define ZVISION_METAANIM_NODE_H
+
+#include "zvision/sidefx.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace Common {
+class String;
+}
+
+namespace Video {
+class VideoDecoder;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+class RlfAnimation;
+
+class MetaAnimation {
+public:
+ MetaAnimation(const Common::String &fileName);
+ ~MetaAnimation();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ Graphics::Surface *_scaled;
+ };
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+private:
+ union {
+ RlfAnimation *rlf;
+ Video::VideoDecoder *avi;
+ } _animation;
+
+ FileType _fileType;
+ int32 _frmDelay;
+
+ const Graphics::Surface *_cur_frame;
+
+public:
+
+ uint frameCount();
+ uint width();
+ uint height();
+ uint32 frameTime();
+
+ void seekToFrame(int frameNumber);
+
+ const Graphics::Surface *decodeNextFrame();
+ const Graphics::Surface *getFrameData(uint frameNumber);
+
+ bool endOfAnimation();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index af90923..62a1293 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -34,7 +34,8 @@ MODULE_OBJS := \
music_node.o \
inventory_manager.o \
slot_control.o \
- menu.o
+ menu.o \
+ meta_animation.o
MODULE_DIRS += \
engines/zvision
Commit: ff2a20889cfead5075c252dd5cdcdba658a40844
https://github.com/scummvm/scummvm/commit/ff2a20889cfead5075c252dd5cdcdba658a40844
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T16:54:59+07:00
Commit Message:
ZVISION: Move code of animation_node to use meta_animation.
Changed paths:
engines/zvision/animation_node.cpp
engines/zvision/animation_node.h
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 27ee873..11275b5 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -27,10 +27,7 @@
#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 "zvision/meta_animation.h"
#include "graphics/surface.h"
@@ -39,18 +36,13 @@ namespace ZVision {
AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
: SideFX(engine, controlKey, SIDEFX_ANIM),
- _fileType(RLF),
_DisposeAfterUse(DisposeAfterUse),
- _mask(mask) {
- if (fileName.hasSuffix(".rlf")) {
- _fileType = RLF;
- _animation.rlf = new RlfAnimation(fileName, false);
- _frmDelay = _animation.rlf->frameTime();
- } else if (fileName.hasSuffix(".avi")) {
- _fileType = AVI;
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
- _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
+ _mask(mask),
+ _animation(NULL) {
+
+ if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
+ _animation = new MetaAnimation(fileName);
+ _frmDelay = _animation->frameTime();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
}
@@ -60,11 +52,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
}
AnimationNode::~AnimationNode() {
- if (_fileType == RLF) {
- delete _animation.rlf;
- } else if (_fileType == AVI) {
- delete _animation.avi;
- }
+ if (_animation)
+ delete _animation;
_engine->getScriptManager()->setStateValue(_key, 2);
@@ -92,13 +81,9 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
if (nod->_cur_frm == -1) { // Start of new playlist node
nod->_cur_frm = nod->start;
- if (_fileType == RLF) {
- _animation.rlf->seekToFrame(nod->_cur_frm);
- frame = _animation.rlf->decodeNextFrame();
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(nod->_cur_frm);
- frame = _animation.avi->decodeNextFrame();
- }
+
+ _animation->seekToFrame(nod->_cur_frm);
+ frame = _animation->decodeNextFrame();
nod->_delay = _frmDelay;
if (nod->slot)
@@ -119,19 +104,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
}
nod->_cur_frm = nod->start;
- if (_fileType == RLF) {
- _animation.rlf->seekToFrame(nod->_cur_frm);
- frame = _animation.rlf->decodeNextFrame();
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(nod->_cur_frm);
- frame = _animation.avi->decodeNextFrame();
- }
- } else {
- if (_fileType == RLF)
- frame = _animation.rlf->decodeNextFrame();
- else if (_fileType == AVI)
- frame = _animation.avi->decodeNextFrame();
+ _animation->seekToFrame(nod->_cur_frm);
}
+
+ frame = _animation->decodeNextFrame();
}
if (frame) {
@@ -190,13 +166,10 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st
nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
nod.start = start_frame;
nod.stop = end_frame;
- if (_fileType == RLF) {
- if (nod.stop >= (int)_animation.rlf->frameCount())
- nod.stop = _animation.rlf->frameCount() - 1;
- } else if (_fileType == AVI) {
- if (nod.stop > (int)_animation.avi->getFrameCount())
- nod.stop = _animation.avi->getFrameCount();
- }
+
+ if (nod.stop >= (int)_animation->frameCount())
+ nod.stop = _animation->frameCount() - 1;
+
nod.slot = slot;
nod._cur_frm = -1;
nod._delay = 0;
diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h
index 843e592..556ab8a 100644
--- a/engines/zvision/animation_node.h
+++ b/engines/zvision/animation_node.h
@@ -32,10 +32,6 @@ namespace Common {
class String;
}
-namespace Video {
-class VideoDecoder;
-}
-
namespace Graphics {
struct Surface;
}
@@ -43,7 +39,7 @@ struct Surface;
namespace ZVision {
class ZVision;
-class RlfAnimation;
+class MetaAnimation;
class AnimationNode : public SideFX {
public:
@@ -62,26 +58,16 @@ public:
};
private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
-
-private:
typedef Common::List<playnode> PlayNodes;
PlayNodes _playList;
- union {
- RlfAnimation *rlf;
- Video::VideoDecoder *avi;
- } _animation;
-
- FileType _fileType;
- int32 _frmDelay;
int32 _mask;
bool _DisposeAfterUse;
+ MetaAnimation *_animation;
+ int32 _frmDelay;
+
public:
bool process(uint32 deltaTimeInMillis);
Commit: 9c9f59d57060617d1acec71bd0d4066504f17c7a
https://github.com/scummvm/scummvm/commit/9c9f59d57060617d1acec71bd0d4066504f17c7a
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-01-17T16:56:49+07:00
Commit Message:
ZVISION: Move lever code to use MetaAnimation.
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 9cd36cf..e96c873 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -28,8 +28,7 @@
#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"
+#include "zvision/meta_animation.h"
#include "zvision/utility.h"
#include "common/stream.h"
@@ -79,11 +78,8 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
LeverControl::~LeverControl() {
- if (_fileType == AVI) {
- delete _animation.avi;
- } else if (_fileType == RLF) {
- delete _animation.rlf;
- }
+ if (_animation)
+ delete _animation;
delete[] _frameInfo;
}
@@ -106,14 +102,9 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
Common::String animationFileName(fileNameBuffer);
- 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;
- }
+ if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf"))
+ _animation = new MetaAnimation(animationFileName);
+
} else if (line.matchString("*skipcolor*", true)) {
// Not used
} else if (line.matchString("*anim_coords*", true)) {
@@ -379,16 +370,9 @@ void LeverControl::renderFrame(uint frameNumber) {
int x = _animationCoords.left;
int y = _animationCoords.top;
- if (_fileType == RLF) {
- // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- frameData = _animation.rlf->getFrameData(frameNumber);
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(frameNumber);
- const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
- frameData = surface;
- }
-
- _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
+ frameData = _animation->getFrameData(frameNumber);
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
}
} // End of namespace ZVision
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 19ecc7b..591d64e 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -32,7 +32,7 @@
namespace ZVision {
class ZorkAVIDecoder;
-class RlfAnimation;
+class MetaAnimation;
class LeverControl : public Control {
public:
@@ -40,10 +40,6 @@ public:
~LeverControl();
private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
struct Direction {
Direction(uint a, uint t) : angle(a), toFrame(t) {}
@@ -64,11 +60,7 @@ private:
};
private:
- union {
- RlfAnimation *rlf;
- ZorkAVIDecoder *avi;
- } _animation;
- FileType _fileType;
+ MetaAnimation *_animation;
Common::String _cursorName;
Common::Rect _animationCoords;
Commit: 4a454ed763c24f94062be5dd57f43e0a84c1b0a2
https://github.com/scummvm/scummvm/commit/4a454ed763c24f94062be5dd57f43e0a84c1b0a2
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-04T08:32:02+07:00
Commit Message:
ZVISION: New search manager for handle right handle for ZIX-files.
Changed paths:
A engines/zvision/search_manager.cpp
A engines/zvision/search_manager.h
engines/zvision/actions.cpp
engines/zvision/animation_node.cpp
engines/zvision/cursor.cpp
engines/zvision/cursor.h
engines/zvision/cursor_manager.cpp
engines/zvision/lever_control.cpp
engines/zvision/meta_animation.cpp
engines/zvision/meta_animation.h
engines/zvision/module.mk
engines/zvision/music_node.cpp
engines/zvision/render_manager.cpp
engines/zvision/render_manager.h
engines/zvision/rlf_animation.cpp
engines/zvision/rlf_animation.h
engines/zvision/scr_file_handling.cpp
engines/zvision/zork_raw.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 5d1dc9a..7b9050f 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -312,27 +312,11 @@ ActionMusic::~ActionMusic() {
bool ActionMusic::execute() {
if (_engine->getScriptManager()->getSideFX(_slotkey))
return true;
- Common::File *file = new Common::File();
- if (!file->exists(_fileName) && _fileName.size() >= 12) {
- _fileName.setChar('r', 9);
- _fileName.setChar('a', 10);
- _fileName.setChar('w', 11);
- if (!file->exists(_fileName)) {
- _fileName.setChar('i', 9);
- _fileName.setChar('f', 10);
- _fileName.setChar('p', 11);
- if (!file->exists(_fileName)) {
- _fileName.setChar('s', 9);
- _fileName.setChar('r', 10);
- _fileName.setChar('c', 11);
- if (!file->exists(_fileName))
- return true;
- }
- }
- }
- if (file->exists(_fileName))
- _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
- delete file;
+
+ if (!_engine->getSearchManager()->hasFile(_fileName))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
return true;
}
@@ -585,16 +569,21 @@ ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Commo
bool ActionStreamVideo::execute() {
ZorkAVIDecoder decoder;
- if (!decoder.loadFile(_fileName)) {
- return true;
- }
+ Common::File *_file = _engine->getSearchManager()->openFile(_fileName);
+
+ if (_file) {
+ if (!decoder.loadStream(_file)) {
+ return true;
+ }
+
+ Common::Rect destRect;
+ if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
+ destRect = Common::Rect(_x1, _y1, _x2, _y2);
+ }
- Common::Rect destRect;
- if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
- destRect = Common::Rect(_x1, _y1, _x2, _y2);
+ _engine->playVideo(decoder, destRect, _skippable);
}
- _engine->playVideo(decoder, destRect, _skippable);
return true;
}
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 11275b5..89d0f5e 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -41,7 +41,7 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
_animation(NULL) {
if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
- _animation = new MetaAnimation(fileName);
+ _animation = new MetaAnimation(fileName, engine);
_frmDelay = _animation->frameTime();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp
index 5386c8e..e2e3d7e 100644
--- a/engines/zvision/cursor.cpp
+++ b/engines/zvision/cursor.cpp
@@ -66,6 +66,35 @@ ZorkCursor::ZorkCursor(const Common::String &fileName)
_surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
}
+ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName)
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0) {
+ Common::File file;
+ if (!engine->getSearchManager()->openFile(file, 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 * 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, 5, 0, 11, 5, 0, 0));
+}
+
ZorkCursor::ZorkCursor(const ZorkCursor &other) {
_width = other._width;
_height = other._height;
diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h
index 8f119c8..2304bf4 100644
--- a/engines/zvision/cursor.h
+++ b/engines/zvision/cursor.h
@@ -24,6 +24,7 @@
#define ZVISION_CURSOR_H
#include "graphics/surface.h"
+#include "zvision/zvision.h"
namespace Common {
@@ -40,6 +41,7 @@ class ZorkCursor {
public:
ZorkCursor();
ZorkCursor(const Common::String &fileName);
+ ZorkCursor(ZVision *engine, const Common::String &fileName);
ZorkCursor(const ZorkCursor &other);
~ZorkCursor();
diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp
index aaf3bb8..c66fa65 100644
--- a/engines/zvision/cursor_manager.cpp
+++ b/engines/zvision/cursor_manager.cpp
@@ -57,15 +57,15 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel
if (_engine->getGameId() == GID_NEMESIS) {
Common::String name;
name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]);
- _cursors[i][0] = ZorkCursor(name); // Up cursor
+ _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor
name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]);
- _cursors[i][1] = ZorkCursor(name); // Down cursor
+ _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor
} else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- _cursors[i][0] = ZorkCursor(_zgiCursorFileNames[i]); // Up cursor
+ _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor
char buffer[25];
strcpy(buffer, _zgiCursorFileNames[i]);
buffer[3] += 2;
- _cursors[i][1] = ZorkCursor(buffer); // Down cursor
+ _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor
}
}
}
@@ -76,22 +76,22 @@ void CursorManager::setItemID(int id) {
Common::String file;
if (_engine->getGameId() == GID_NEMESIS) {
file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a');
- _cursors[NUM_CURSORS][0] = ZorkCursor(file);
+ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b');
- _cursors[NUM_CURSORS][1] = ZorkCursor(file);
+ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a');
- _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b');
- _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
} else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id);
- _cursors[NUM_CURSORS][0] = ZorkCursor(file);
+ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id);
- _cursors[NUM_CURSORS][1] = ZorkCursor(file);
+ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id);
- _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id);
- _cursors[NUM_CURSORS + 1][1] = ZorkCursor(file);
+ _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file);
} else
return;
}
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index e96c873..33aa2be 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -86,7 +86,7 @@ LeverControl::~LeverControl() {
void LeverControl::parseLevFile(const Common::String &fileName) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("LEV file %s could could be opened", fileName.c_str());
return;
}
@@ -103,7 +103,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
Common::String animationFileName(fileNameBuffer);
if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf"))
- _animation = new MetaAnimation(animationFileName);
+ _animation = new MetaAnimation(animationFileName, _engine);
} else if (line.matchString("*skipcolor*", true)) {
// Not used
diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp
index 430b143..33ae92a 100644
--- a/engines/zvision/meta_animation.cpp
+++ b/engines/zvision/meta_animation.cpp
@@ -37,17 +37,19 @@
namespace ZVision {
-MetaAnimation::MetaAnimation(const Common::String &fileName)
+MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
: _fileType(RLF),
_cur_frame(NULL) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
- _animation.rlf = new RlfAnimation(fileName, false);
+ Common::File *_file = engine->getSearchManager()->openFile(fileName);
+ _animation.rlf = new RlfAnimation(_file, false);
_frmDelay = _animation.rlf->frameTime();
} else if (fileName.hasSuffix(".avi")) {
_fileType = AVI;
+ Common::File *_file = engine->getSearchManager()->openFile(fileName);
_animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
+ _animation.avi->loadStream(_file);
_frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h
index fea7a6a..e259955 100644
--- a/engines/zvision/meta_animation.h
+++ b/engines/zvision/meta_animation.h
@@ -24,6 +24,7 @@
#define ZVISION_METAANIM_NODE_H
#include "zvision/sidefx.h"
+#include "zvision/zvision.h"
#include "common/rect.h"
#include "common/list.h"
@@ -47,7 +48,7 @@ class RlfAnimation;
class MetaAnimation {
public:
- MetaAnimation(const Common::String &fileName);
+ MetaAnimation(const Common::String &fileName, ZVision *engine);
~MetaAnimation();
struct playnode {
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 62a1293..b8dca9e 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -35,7 +35,8 @@ MODULE_OBJS := \
inventory_manager.o \
slot_control.o \
menu.o \
- meta_animation.o
+ meta_animation.o \
+ search_manager.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index 3027148..d47a796 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -51,7 +51,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
if (filename.contains(".wav")) {
Common::File *file = new Common::File();
- if (file->open(filename)) {
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
}
} else {
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index f5d6847..6cfc050 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
#include "zvision/render_manager.h"
#include "zvision/lzss_read_stream.h"
@@ -37,8 +38,9 @@
namespace ZVision {
-RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
- : _system(system),
+RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
+ : _engine(engine),
+ _system(engine->_system),
_wrkWidth(workingWindow.width()),
_wrkHeight(workingWindow.height()),
_screenCenterX(_wrkWidth / 2),
@@ -113,7 +115,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Could not open file %s", fileName.c_str());
return;
}
@@ -207,7 +209,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Could not open file %s", fileName.c_str());
return;
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 901385b..3c03331 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -47,7 +47,7 @@ namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
+ RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
~RenderManager();
private:
@@ -70,6 +70,7 @@ private:
typedef Common::HashMap<uint16, oneSub> subMap;
private:
+ ZVision *_engine;
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index dab32ae..f23f569 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -37,6 +37,7 @@ namespace ZVision {
RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
: _stream(stream),
+ _readStream(NULL),
_lastFrameRead(0),
_frameCount(0),
_width(0),
@@ -45,11 +46,15 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_frames(0),
_currentFrame(0),
_frameBufferByteSize(0) {
- if (!_file.open(fileName)) {
+
+ Common::File *_file = new Common::File;
+ if (!_file->open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
return;
}
+ _readStream = _file;
+
if (!readHeader()) {
warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str());
return;
@@ -68,59 +73,90 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
}
}
+RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream)
+ : _stream(stream),
+ _readStream(rstream),
+ _lastFrameRead(0),
+ _frameCount(0),
+ _width(0),
+ _height(0),
+ _frameTime(0),
+ _frames(0),
+ _currentFrame(0),
+ _frameBufferByteSize(0) {
+
+ if (!readHeader()) {
+ warning("Stream is not a RLF animation. Wrong magic number");
+ return;
+ }
+
+ _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>());
+ _frameBufferByteSize = _width * _height * sizeof(uint16);
+
+ if (!stream) {
+ _frames = new Frame[_frameCount];
+
+ // Read in each frame
+ for (uint i = 0; i < _frameCount; ++i) {
+ _frames[i] = readNextFrame();
+ }
+ }
+}
+
RlfAnimation::~RlfAnimation() {
for (uint i = 0; i < _frameCount; ++i) {
delete[] _frames[i].encodedData;
}
delete[] _frames;
+ delete _readStream;
_currentFrameBuffer.free();
}
bool RlfAnimation::readHeader() {
- if (_file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
+ if (_readStream->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
+ _readStream->readUint32LE(); // Size1
+ _readStream->readUint32LE(); // Unknown1
+ _readStream->readUint32LE(); // Unknown2
+ _frameCount = _readStream->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);
+ _readStream->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
+ //_readStream->readUint32BE(); // Magic number FNIC
+ //_readStream->readUint32LE(); // Size2
+ //_readStream->readUint32LE(); // Unknown3
+ //_readStream->readUint32LE(); // Unknown4
+ //_readStream->readUint32LE(); // Unknown5
+ //_readStream->seek(0x18, SEEK_CUR); // VRLE
+ //_readStream->readUint32LE(); // LRVD
+ //_readStream->readUint32LE(); // Unknown6
+ //_readStream->seek(0x18, SEEK_CUR); // HRLE
+ //_readStream->readUint32LE(); // ELHD
+ //_readStream->readUint32LE(); // Unknown7
+ //_readStream->seek(0x18, SEEK_CUR); // HKEY
+ //_readStream->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
+ //_readStream->readUint32BE(); // Magic number FNIM
+ //_readStream->readUint32LE(); // Size3
+ //_readStream->readUint32LE(); // OEDV
+ //_readStream->readUint32LE(); // Unknown8
+ //_readStream->readUint32LE(); // Unknown9
+ //_readStream->readUint32LE(); // Unknown10
+ _width = _readStream->readUint32LE(); // Width
+ _height = _readStream->readUint32LE(); // Height
// Read time header
- _file.readUint32BE(); // Magic number EMIT
- _file.readUint32LE(); // Size4
- _file.readUint32LE(); // Unknown11
- _frameTime = _file.readUint32LE() / 10; // Frame time in microseconds
+ _readStream->readUint32BE(); // Magic number EMIT
+ _readStream->readUint32LE(); // Size4
+ _readStream->readUint32LE(); // Unknown11
+ _frameTime = _readStream->readUint32LE() / 10; // Frame time in microseconds
return true;
}
@@ -128,17 +164,17 @@ bool RlfAnimation::readHeader() {
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
+ _readStream->readUint32BE(); // Magic number MARF
+ uint32 size = _readStream->readUint32LE(); // Size
+ _readStream->readUint32LE(); // Unknown1
+ _readStream->readUint32LE(); // Unknown2
+ uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH
+ uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
+ _readStream->readUint32LE(); // Unknown3
frame.encodedSize = size - headerSize;
frame.encodedData = new int8[frame.encodedSize];
- _file.read(frame.encodedData, frame.encodedSize);
+ _readStream->read(frame.encodedData, frame.encodedSize);
if (type == MKTAG('E', 'L', 'H', 'D')) {
frame.type = Masked;
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 35916de..3764465 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -37,6 +37,7 @@ namespace ZVision {
class RlfAnimation {
public:
RlfAnimation(const Common::String &fileName, bool stream = true);
+ RlfAnimation(Common::SeekableReadStream *rstream, bool stream);
~RlfAnimation();
private:
@@ -52,7 +53,7 @@ private:
};
private:
- Common::File _file;
+ Common::SeekableReadStream *_readStream;
bool _stream;
uint _lastFrameRead;
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 833db11..db4e8fa 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/utility.h"
@@ -40,7 +41,7 @@ namespace ZVision {
void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Script file not found: %s", fileName.c_str());
return;
}
diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp
new file mode 100644
index 0000000..5c94ff0
--- /dev/null
+++ b/engines/zvision/search_manager.cpp
@@ -0,0 +1,274 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+#include "common/debug.h"
+
+#include "zvision/search_manager.h"
+#include "zvision/zfs_archive.h"
+#include "common/fs.h"
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+sManager::sManager(const Common::String &root_path, int depth) {
+ _root = root_path;
+ if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/')
+ _root.deleteLastChar();
+
+ Common::FSNode fs_node(_root);
+
+ list_dir_recursive(dir_list, fs_node, depth);
+
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end();)
+ if (it->size() == _root.size())
+ it = dir_list.erase(it);
+ else if (it->size() > _root.size()) {
+ *it = Common::String(it->c_str() + _root.size() + 1);
+ it++;
+ } else
+ it++;
+}
+
+sManager::~sManager() {
+ Common::List<Common::Archive *>::iterator it = archList.begin();
+ while (it != archList.end()) {
+ delete *it;
+ it++;
+ }
+
+ archList.clear();
+}
+
+void sManager::addPatch(const Common::String &src, const Common::String &dst) {
+ Common::String lw_name = dst;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator it = files.find(lw_name);
+
+ if (it != files.end()) {
+ lw_name = src;
+ lw_name.toLowercase();
+ files[lw_name] = it->_value;
+ }
+}
+
+void sManager::addFile(const Common::String &name, Common::Archive *arch) {
+ bool addArch = true;
+ Common::List<Common::Archive *>::iterator it = archList.begin();
+ while (it != archList.end()) {
+ if (*it == arch) {
+ addArch = false;
+ break;
+ }
+ it++;
+ }
+ if (addArch)
+ archList.push_back(arch);
+
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::Node nod;
+ nod.name = lw_name;
+ nod.arch = arch;
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit == files.end()) {
+ files[lw_name] = nod;
+ } else {
+ Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
+ if (stream) {
+ if (stream->size() < 10)
+ fit->_value.arch = arch;
+ delete stream;
+ } else {
+ files[lw_name] = nod;
+ }
+ }
+}
+
+Common::File *sManager::openFile(const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end()) {
+ Common::File *tmp = new Common::File();
+ tmp->open(fit->_value.name, *fit->_value.arch);
+ return tmp;
+ }
+ return NULL;
+}
+
+bool sManager::openFile(Common::File &file, const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end())
+ return file.open(fit->_value.name, *fit->_value.arch);
+ return false;
+}
+
+bool sManager::hasFile(const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end())
+ return true;
+ return false;
+}
+
+void sManager::loadZix(const Common::String &name) {
+ Common::File file;
+ file.open(name);
+
+ Common::String line;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ if (line.matchString("----------*", true))
+ break;
+ }
+
+ if (file.eos())
+ return;
+
+ Common::Array<Common::Archive *> archives;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ if (line.matchString("----------*", true))
+ break;
+ else if (line.matchString("DIR:*", true)) {
+ Common::String path(line.c_str() + 5);
+ Common::Archive *arc;
+ char n_path[128];
+ strcpy(n_path, path.c_str());
+ for (uint i = 0; i < path.size(); i++)
+ if (n_path[i] == '\\')
+ n_path[i] = '/';
+
+ path = Common::String(n_path);
+ if (path.size() && path[0] == '.')
+ path.deleteChar(0);
+ if (path.size() && path[0] == '/')
+ path.deleteChar(0);
+
+ if (path.matchString("*.zfs", true))
+ arc = new ZfsArchive(path);
+ else {
+ if (path.size()) {
+ if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/')
+ path.deleteLastChar();
+ if (path.size())
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ if (path.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+ }
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ arc = new Common::FSDirectory(path);
+ }
+ archives.push_back(arc);
+ }
+ }
+
+ if (file.eos())
+ return;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ uint dr = 0;
+ char buf[32];
+ if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
+ if (dr < archives.size() && dr > 0) {
+ addFile(Common::String(buf), archives[dr - 1]);
+ }
+ }
+ }
+}
+
+void sManager::addDir(const Common::String &name) {
+ Common::String path;
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ if (name.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+
+ if (path.size() == 0)
+ return;
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ Common::FSDirectory *dir = new Common::FSDirectory(path);
+
+ Common::ArchiveMemberList list;
+ dir->listMatchingMembers(list, "*.zfs");
+
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+
+ ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str()));
+
+ Common::ArchiveMemberList zfslist;
+ zfs->listMembers(zfslist);
+
+ for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
+ Common::String z_name = (*ziter)->getName();
+ addFile(z_name, zfs);
+ }
+ }
+
+ list.clear();
+ dir->listMembers(list);
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+ addFile(flname, dir);
+ }
+}
+
+void sManager::list_dir_recursive(Common::List<Common::String> &_list, const Common::FSNode &fs_node, int depth) {
+ Common::FSList fs_list;
+ fs_node.getChildren(fs_list);
+
+ _list.push_back(fs_node.getPath());
+
+ if (depth > 1)
+ for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it)
+ list_dir_recursive(_list, *it, depth - 1);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/search_manager.h b/engines/zvision/search_manager.h
new file mode 100644
index 0000000..c768cb8
--- /dev/null
+++ b/engines/zvision/search_manager.h
@@ -0,0 +1,51 @@
+#ifndef SEARCH_MANAGER_H_INCLUDED
+#define SEARCH_MANAGER_H_INCLUDED
+
+#include "common/str.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/list.h"
+
+namespace ZVision {
+
+class sManager {
+public:
+ sManager(const Common::String &root_path, int depth);
+ ~sManager();
+
+ void addFile(const Common::String &name, Common::Archive *arch);
+ void addDir(const Common::String &name);
+ void addPatch(const Common::String &src, const Common::String &dst);
+
+ Common::File *openFile(const Common::String &name);
+ bool openFile(Common::File &file, const Common::String &name);
+ bool hasFile(const Common::String &name);
+
+ void loadZix(const Common::String &name);
+
+private:
+
+ void list_dir_recursive(Common::List<Common::String> &dir_list, const Common::FSNode &fs_node, int depth);
+
+ struct Node {
+ Common::String name;
+ Common::Archive *arch;
+ };
+
+ Common::List<Common::String> dir_list;
+
+ typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList;
+
+ Common::List<Common::Archive *> archList;
+ MatchList files;
+
+ Common::String _root;
+
+private:
+};
+
+}
+
+#endif // SEARCH_MANAGER_H_INCLUDED
diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp
index e7cc71a..a4d091f 100644
--- a/engines/zvision/zork_raw.cpp
+++ b/engines/zvision/zork_raw.cpp
@@ -254,7 +254,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
Common::File *file = new Common::File();
- assert(file->open(filePath));
+ assert(engine->getSearchManager()->openFile(*file, filePath));
Common::String fileName = getFileName(filePath);
fileName.toLowercase();
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f21498c..bf945f8 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -33,8 +33,10 @@
#include "zvision/zfs_archive.h"
#include "zvision/detection.h"
#include "zvision/menu.h"
+#include "zvision/search_manager.h"
#include "common/config-manager.h"
+#include "common/str.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/textconsole.h"
@@ -88,6 +90,29 @@ ZVision::~ZVision() {
void ZVision::initialize() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
+
+ _searchManager = new sManager(ConfMan.get("path"), 6);
+
+ _searchManager->addDir("addon");
+
+ if (_gameDescription->gameId == GID_GRANDINQUISITOR) {
+ _searchManager->loadZix("INQUIS.ZIX");
+ _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC");
+ _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC");
+ _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC");
+ _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC");
+ _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC");
+ _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC");
+ _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC");
+ _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC");
+ _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC");
+ _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC");
+ _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC");
+ _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC");
+ _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC");
+ _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC");
+ } else if (_gameDescription->gameId == GID_NEMESIS)
+ _searchManager->loadZix("NEMESIS.ZIX");
// 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.
@@ -123,7 +148,7 @@ void ZVision::initialize() {
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
+ _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
_saveManager = new SaveManager(this);
_stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 26d7644..c9e14e8 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -26,6 +26,7 @@
#include "zvision/detection.h"
#include "zvision/clock.h"
+#include "zvision/search_manager.h"
#include "common/random.h"
#include "common/events.h"
@@ -99,6 +100,7 @@ private:
SaveManager *_saveManager;
StringManager *_stringManager;
menuHandler *_menu;
+ sManager *_searchManager;
// Clock
Clock _clock;
@@ -135,6 +137,9 @@ public:
StringManager *getStringManager() const {
return _stringManager;
}
+ sManager *getSearchManager() const {
+ return _searchManager;
+ }
Common::RandomSource *getRandomSource() const {
return _rnd;
}
Commit: 00337400010efc1012e95ec0c14a77423bb3a0ee
https://github.com/scummvm/scummvm/commit/00337400010efc1012e95ec0c14a77423bb3a0ee
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-02-07T16:07:52+07:00
Commit Message:
ZVISION: Fix lever code;
Changed paths:
engines/zvision/lever_control.cpp
diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp
index 33aa2be..f68f256 100644
--- a/engines/zvision/lever_control.cpp
+++ b/engines/zvision/lever_control.cpp
@@ -91,9 +91,11 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
return;
}
- Common::String line = file.readLine();
+ Common::String line;
while (!file.eos()) {
+ line = file.readLine();
+
if (line.matchString("*animation_id*", true)) {
// Not used
} else if (line.matchString("*filename*", true)) {
@@ -142,6 +144,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
uint frameNumber;
uint x, y;
+ line.toLowercase();
+
if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
_frameInfo[frameNumber].hotspot.left = x;
_frameInfo[frameNumber].hotspot.top = y;
@@ -149,13 +153,13 @@ 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();
Common::String token = tokenizer.nextToken();
while (!tokenizer.empty()) {
- if (token == "D") {
+ if (token == "d") {
token = tokenizer.nextToken();
uint angle;
@@ -163,7 +167,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
_frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
- } else if (token.hasPrefix("P")) {
+ } else if (token.hasPrefix("p")) {
// Format: P(<from> to <to>)
tokenizer.nextToken();
tokenizer.nextToken();
@@ -177,7 +181,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
}
- line = file.readLine();
+ // Don't read lines in this place because last will not be parsed.
}
}
@@ -290,7 +294,7 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Calculate the angle using arctan
// Then convert to degrees. (180 / 3.14159 = 57.2958)
- int angle = int(atan((float)yDist / (float)xDist) * 57);
+ int angle = int(atan((float)yDist / (float)abs(xDist)) * 57);
// Calculate what quadrant pointTwo is in
uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
@@ -339,16 +343,16 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Convert the local angles to unit circle angles
switch (quadrant) {
case 0:
- angle = 180 + angle;
+ angle = -angle;
break;
case 1:
- // Do nothing
+ angle = angle + 180;
break;
case 2:
- angle = 180 + angle;
+ angle = 360 - angle;
break;
case 3:
- angle = 360 + angle;
+ angle = 180 + angle;
break;
}
Commit: cb2503aa9dd5d76a12aaf0522ddea810907a97a5
https://github.com/scummvm/scummvm/commit/cb2503aa9dd5d76a12aaf0522ddea810907a97a5
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-07T23:03:02+07:00
Commit Message:
ZVISION: Refactor of pushtoggle code, now full functional implementation.
Changed paths:
engines/zvision/push_toggle_control.cpp
engines/zvision/push_toggle_control.h
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp
index 86f4997..0ba6dd7 100644
--- a/engines/zvision/push_toggle_control.cpp
+++ b/engines/zvision/push_toggle_control.cpp
@@ -35,10 +35,13 @@
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
+ : Control(engine, key),
+ _countTo(2),
+ _event(Common::EVENT_LBUTTONUP) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ line.toLowercase();
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("*_hotspot*", true)) {
@@ -56,6 +59,27 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
_hoverCursor = Common::String(nameBuffer);
+ } else if (line.matchString("animation*", true)) {
+ // Not used
+ } else if (line.matchString("sound*", true)) {
+ // Not used
+ } else if (line.matchString("count_to*", true)) {
+ sscanf(line.c_str(), "%*[^(](%u)", &_countTo);
+ } else if (line.matchString("mouse_event*", true)) {
+ char nameBuffer[25];
+
+ sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
+
+ Common::String evntStr(nameBuffer);
+ if (evntStr.equalsIgnoreCase("up")) {
+ _event = Common::EVENT_LBUTTONUP;
+ } else if (evntStr.equalsIgnoreCase("down")) {
+ _event = Common::EVENT_LBUTTONDOWN;
+ } else if (evntStr.equalsIgnoreCase("double")) {
+ // Not used
+ }
+ } else if (line.matchString("venus_id*", true)) {
+ // Not used
}
line = stream.readLine();
@@ -68,16 +92,35 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
}
PushToggleControl::~PushToggleControl() {
- // Clear the state value back to 0
- _engine->getScriptManager()->setStateValue(_key, 0);
}
bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
+ if (_event != Common::EVENT_LBUTTONUP)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ int32 val = _engine->getScriptManager()->getStateValue(_key);
+ val = (val + 1) % _countTo;
+ _engine->getScriptManager()->setStateValue(_key, val);
+ return true;
+ }
+ return false;
+}
+
+bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_event != Common::EVENT_LBUTTONDOWN)
+ return false;
+
if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getScriptManager()->setStateValue(_key, 1);
+ int32 val = _engine->getScriptManager()->getStateValue(_key);
+ val = (val + 1) % _countTo;
+ _engine->getScriptManager()->setStateValue(_key, val);
return true;
}
return false;
diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h
index 1de279a..17ff850 100644
--- a/engines/zvision/push_toggle_control.h
+++ b/engines/zvision/push_toggle_control.h
@@ -26,6 +26,7 @@
#include "zvision/control.h"
#include "common/rect.h"
+#include "common/events.h"
namespace ZVision {
@@ -36,6 +37,13 @@ public:
~PushToggleControl();
/**
+ * 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
+ */
+ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
* Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1);
*
* @param screenSpacePos The position of the mouse in screen space
@@ -60,6 +68,10 @@ private:
Common::Rect _hotspot;
/** The cursor to use when hovering over _hotspot */
Common::String _hoverCursor;
+ /** Button maximal values count */
+ uint _countTo;
+
+ Common::EventType _event;
};
} // End of namespace ZVision
Commit: 6210ead126ea81727e6a68398366c4cbe8da9e79
https://github.com/scummvm/scummvm/commit/6210ead126ea81727e6a68398366c4cbe8da9e79
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T20:37:58+07:00
Commit Message:
ZVISION: Fix wrong style.
Changed paths:
engines/zvision/actions.h
engines/zvision/cursor_manager.h
engines/zvision/detection.h
engines/zvision/lever_control.h
engines/zvision/lzss_read_stream.h
engines/zvision/menu.cpp
engines/zvision/menu.h
engines/zvision/meta_animation.h
engines/zvision/music_node.cpp
engines/zvision/puzzle.h
engines/zvision/render_table.h
engines/zvision/rlf_animation.h
engines/zvision/save_manager.h
engines/zvision/script_manager.h
engines/zvision/sidefx.h
engines/zvision/single_value_container.h
engines/zvision/string_manager.h
engines/zvision/zork_avi_decoder.h
engines/zvision/zvision.h
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 5c6cf6c..f4a2c0f 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -369,7 +369,7 @@ public:
private:
enum {
- DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions
+ DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions
};
Common::String _fileName;
diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h
index 7bd1c42..0521a17 100644
--- a/engines/zvision/cursor_manager.h
+++ b/engines/zvision/cursor_manager.h
@@ -40,15 +40,15 @@ class ZVision;
* Mostly usable cursors
*/
enum CursorIndex {
- CursorIndex_Active = 0,
- CursorIndex_DownArr = 3,
- CursorIndex_HandPu = 6,
- CursorIndex_Idle = 11,
- CursorIndex_Left = 12,
- CursorIndex_Right = 13,
- CursorIndex_UpArr = 17,
- CursorIndex_ItemIdle = 18,
- CursorIndex_ItemAct = 19
+ CursorIndex_Active = 0,
+ CursorIndex_DownArr = 3,
+ CursorIndex_HandPu = 6,
+ CursorIndex_Idle = 11,
+ CursorIndex_Left = 12,
+ CursorIndex_Right = 13,
+ CursorIndex_UpArr = 17,
+ CursorIndex_ItemIdle = 18,
+ CursorIndex_ItemAct = 19
};
/**
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index 1f430da..3441760 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -29,9 +29,9 @@
namespace ZVision {
enum ZVisionGameId {
- GID_NONE = 0,
- GID_NEMESIS = 1,
- GID_GRANDINQUISITOR = 2
+ GID_NONE = 0,
+ GID_NEMESIS = 1,
+ GID_GRANDINQUISITOR = 2
};
struct ZVisionGameDescription {
diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h
index 591d64e..ac7ee8b 100644
--- a/engines/zvision/lever_control.h
+++ b/engines/zvision/lever_control.h
@@ -55,8 +55,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)
- ANIMATION_FRAME_TIME = 30 // In millis
+ 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:
diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h
index 1f7df9d..73e848b 100644
--- a/engines/zvision/lzss_read_stream.h
+++ b/engines/zvision/lzss_read_stream.h
@@ -45,7 +45,7 @@ public:
private:
enum {
- BLOCK_SIZE = 0x1000
+ BLOCK_SIZE = 0x1000
};
private:
diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp
index 8e1dea1..bf422b3 100644
--- a/engines/zvision/menu.cpp
+++ b/engines/zvision/menu.cpp
@@ -30,17 +30,17 @@
namespace ZVision {
enum {
- SLOT_START_SLOT = 151,
- SLOT_SPELL_1 = 191,
- SLOT_USER_CHOSE_THIS_SPELL = 205,
- SLOT_REVERSED_SPELLBOOK = 206
+ SLOT_START_SLOT = 151,
+ SLOT_SPELL_1 = 191,
+ SLOT_USER_CHOSE_THIS_SPELL = 205,
+ SLOT_REVERSED_SPELLBOOK = 206
};
enum {
- menu_MAIN_SAVE = 0,
- menu_MAIN_REST = 1,
- menu_MAIN_PREF = 2,
- menu_MAIN_EXIT = 3
+ menu_MAIN_SAVE = 0,
+ menu_MAIN_REST = 1,
+ menu_MAIN_PREF = 2,
+ menu_MAIN_EXIT = 3
};
menuHandler::menuHandler(ZVision *engine) {
@@ -264,8 +264,7 @@ void menuZgi::onMouseMove(const Common::Point &Pos) {
}
break;
- case menu_MAIN:
- {
+ case menu_MAIN: {
int last_item = mouse_on_item;
mouse_on_item = -1;
@@ -510,29 +509,25 @@ void menuZgi::process(uint32 deltatime) {
if (redraw) {
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
- if (menu_bar_flag & menuBar_Exit)
- {
+ if (menu_bar_flag & menuBar_Exit) {
if (mouse_on_item == menu_MAIN_EXIT)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Settings)
- {
+ if (menu_bar_flag & menuBar_Settings) {
if (mouse_on_item == menu_MAIN_PREF)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Restore)
- {
+ if (menu_bar_flag & menuBar_Restore) {
if (mouse_on_item == menu_MAIN_REST)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Save)
- {
+ if (menu_bar_flag & menuBar_Save) {
if (mouse_on_item == menu_MAIN_SAVE)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
else
@@ -698,8 +693,7 @@ void menuNem::onMouseMove(const Common::Point &Pos) {
void menuNem::process(uint32 deltatime) {
if (inmenu) {
- if (!scrolled)
- {
+ if (!scrolled) {
float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
if (scrl == 0)
@@ -709,8 +703,7 @@ void menuNem::process(uint32 deltatime) {
redraw = true;
}
- if (scrollPos >= 0)
- {
+ if (scrollPos >= 0) {
scrolled = true;
scrollPos = 0;
}
@@ -747,8 +740,7 @@ void menuNem::process(uint32 deltatime) {
}
} else {
scrolled = false;
- if (scrollPos > -32)
- {
+ if (scrollPos > -32) {
float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
if (scrl == 0)
@@ -759,8 +751,7 @@ void menuNem::process(uint32 deltatime) {
scrollPos -= scrl;
redraw = true;
- }
- else
+ } else
scrollPos = -32;
if (redraw) {
diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h
index 35e7347..c5938cd 100644
--- a/engines/zvision/menu.h
+++ b/engines/zvision/menu.h
@@ -32,12 +32,12 @@
namespace ZVision {
enum menuBar {
- menuBar_Exit = 0x1,
- menuBar_Settings = 0x2,
- menuBar_Restore = 0x4,
- menuBar_Save = 0x8,
- menuBar_Items = 0x100,
- menuBar_Magic = 0x200
+ menuBar_Exit = 0x1,
+ menuBar_Settings = 0x2,
+ menuBar_Restore = 0x4,
+ menuBar_Save = 0x8,
+ menuBar_Items = 0x100,
+ menuBar_Magic = 0x200
};
class menuHandler {
@@ -80,9 +80,9 @@ private:
float scrollPos[3];
enum {
- menu_ITEM = 0,
- menu_MAGIC = 1,
- menu_MAIN = 2
+ menu_ITEM = 0,
+ menu_MAGIC = 1,
+ menu_MAIN = 2
};
bool clean;
diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h
index e259955..3754aae 100644
--- a/engines/zvision/meta_animation.h
+++ b/engines/zvision/meta_animation.h
@@ -64,8 +64,8 @@ public:
private:
enum FileType {
- RLF = 1,
- AVI = 2
+ RLF = 1,
+ AVI = 2
};
private:
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index d47a796..31d222a 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -109,8 +109,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
deltaTimeInMillis = _crossfade_time;
_newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis;
_crossfade_time -= deltaTimeInMillis;
- }
- else {
+ } else {
_crossfade = false;
_newvol = _crossfade_target;
}
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index c02f60c..e06b087 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -42,10 +42,10 @@ struct Puzzle {
/** How criteria should be decided */
enum CriteriaOperator {
- EQUAL_TO,
- NOT_EQUAL_TO,
- GREATER_THAN,
- LESS_THAN
+ EQUAL_TO,
+ NOT_EQUAL_TO,
+ GREATER_THAN,
+ LESS_THAN
};
/** Criteria for a Puzzle result to be fired */
@@ -64,9 +64,9 @@ struct Puzzle {
};
enum StateFlags {
- ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
- DISABLED = 0x04
+ ONCE_PER_INST = 0x01,
+ DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
+ DISABLED = 0x04
};
uint32 key;
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index db9ab08..86afd1f 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -36,9 +36,9 @@ public:
public:
enum RenderState {
- PANORAMA,
- TILT,
- FLAT
+ PANORAMA,
+ TILT,
+ FLAT
};
private:
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 3764465..bc5fdc5 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -42,8 +42,8 @@ public:
private:
enum EncodingType {
- Masked,
- Simple
+ Masked,
+ Simple
};
struct Frame {
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index 9de1c51..ec80b37 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -54,7 +54,7 @@ private:
static const uint32 SAVEGAME_ID;
enum {
- SAVE_VERSION = 1
+ SAVE_VERSION = 1
};
public:
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 3e671aa..2f585b6 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -41,59 +41,59 @@ namespace ZVision {
class ZVision;
enum StateKey {
- StateKey_World = 3,
- StateKey_Room = 4,
- StateKey_Node = 5,
- StateKey_View = 6,
- StateKey_ViewPos = 7,
- StateKey_KeyPress = 8,
- StateKey_InventoryItem = 9,
- StateKey_LMouse = 10,
- StateKey_NotSet = 11, // This key doesn't set
- StateKey_Rounds = 12,
- StateKey_Venus = 13,
- StateKey_RMouse = 18,
- StateKey_MenuState = 19,
- StateKey_RestoreFlag = 20,
- StateKey_Quitting = 39,
- StateKey_LastWorld = 40,
- StateKey_LastRoom = 41,
- StateKey_LastNode = 42,
- StateKey_LastView = 43,
- StateKey_LastViewPos = 44,
- StateKey_Menu_LastWorld = 45,
- StateKey_Menu_LastRoom = 46,
- StateKey_Menu_LastNode = 47,
- StateKey_Menu_LastView = 48,
- StateKey_Menu_LastViewPos = 49,
- StateKey_KbdRotateSpeed = 50,
- StateKey_Subtitles = 51,
- StateKey_StreamSkipKey = 52,
- StateKey_RotateSpeed = 53,
- StateKey_Volume = 56,
- StateKey_Qsound = 57,
- StateKey_VenusEnable = 58,
- StateKey_HighQuality = 59,
- StateKey_VideoLineSkip = 65,
- StateKey_Platform = 66,
- StateKey_InstallLevel = 67,
- StateKey_CountryCode = 68,
- StateKey_CPU = 69,
- StateKey_MovieCursor = 70,
- StateKey_NoTurnAnim = 71,
- StateKey_WIN958 = 72,
- StateKey_ShowErrorDlg = 73,
- StateKey_DebugCheats = 74,
- StateKey_JapanFonts = 75,
- StateKey_Brightness = 77,
- StateKey_EF9_B = 91,
- StateKey_EF9_G = 92,
- StateKey_EF9_R = 93,
- StateKey_EF9_Speed = 94,
- StateKey_Inv_Cnt_Slot = 100,
- StateKey_Inv_1_Slot = 101,
- StateKey_Inv_49_Slot = 149,
- StateKey_Inv_TotalSlots = 150
+ StateKey_World = 3,
+ StateKey_Room = 4,
+ StateKey_Node = 5,
+ StateKey_View = 6,
+ StateKey_ViewPos = 7,
+ StateKey_KeyPress = 8,
+ StateKey_InventoryItem = 9,
+ StateKey_LMouse = 10,
+ StateKey_NotSet = 11, // This key doesn't set
+ StateKey_Rounds = 12,
+ StateKey_Venus = 13,
+ StateKey_RMouse = 18,
+ StateKey_MenuState = 19,
+ StateKey_RestoreFlag = 20,
+ StateKey_Quitting = 39,
+ StateKey_LastWorld = 40,
+ StateKey_LastRoom = 41,
+ StateKey_LastNode = 42,
+ StateKey_LastView = 43,
+ StateKey_LastViewPos = 44,
+ StateKey_Menu_LastWorld = 45,
+ StateKey_Menu_LastRoom = 46,
+ StateKey_Menu_LastNode = 47,
+ StateKey_Menu_LastView = 48,
+ StateKey_Menu_LastViewPos = 49,
+ StateKey_KbdRotateSpeed = 50,
+ StateKey_Subtitles = 51,
+ StateKey_StreamSkipKey = 52,
+ StateKey_RotateSpeed = 53,
+ StateKey_Volume = 56,
+ StateKey_Qsound = 57,
+ StateKey_VenusEnable = 58,
+ StateKey_HighQuality = 59,
+ StateKey_VideoLineSkip = 65,
+ StateKey_Platform = 66,
+ StateKey_InstallLevel = 67,
+ StateKey_CountryCode = 68,
+ StateKey_CPU = 69,
+ StateKey_MovieCursor = 70,
+ StateKey_NoTurnAnim = 71,
+ StateKey_WIN958 = 72,
+ StateKey_ShowErrorDlg = 73,
+ StateKey_DebugCheats = 74,
+ StateKey_JapanFonts = 75,
+ StateKey_Brightness = 77,
+ StateKey_EF9_B = 91,
+ StateKey_EF9_G = 92,
+ StateKey_EF9_R = 93,
+ StateKey_EF9_Speed = 94,
+ StateKey_Inv_Cnt_Slot = 100,
+ StateKey_Inv_1_Slot = 101,
+ StateKey_Inv_49_Slot = 149,
+ StateKey_Inv_TotalSlots = 150
};
struct Location {
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
index 210d98e..2c53467 100644
--- a/engines/zvision/sidefx.h
+++ b/engines/zvision/sidefx.h
@@ -37,15 +37,15 @@ class SideFX {
public:
enum SideFXType {
- SIDEFX_ANIM = 1,
- SIDEFX_AUDIO = 2,
- SIDEFX_DISTORT = 4,
- SIDEFX_PANTRACK = 8,
- SIDEFX_REGION = 16,
- SIDEFX_TIMER = 32,
- SIDEFX_TTYTXT = 64,
- SIDEFX_UNK = 128,
- SIDEFX_ALL = 255
+ SIDEFX_ANIM = 1,
+ SIDEFX_AUDIO = 2,
+ SIDEFX_DISTORT = 4,
+ SIDEFX_PANTRACK = 8,
+ SIDEFX_REGION = 16,
+ SIDEFX_TIMER = 32,
+ SIDEFX_TTYTXT = 64,
+ SIDEFX_UNK = 128,
+ SIDEFX_ALL = 255
};
SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h
index 33fe69d..32b4d6c 100644
--- a/engines/zvision/single_value_container.h
+++ b/engines/zvision/single_value_container.h
@@ -36,15 +36,15 @@ namespace ZVision {
class SingleValueContainer {
public:
enum ValueType {
- BOOL,
- BYTE,
- INT16,
- UINT16,
- INT32,
- UINT32,
- FLOAT,
- DOUBLE,
- STRING
+ BOOL,
+ BYTE,
+ INT16,
+ UINT16,
+ INT32,
+ UINT32,
+ FLOAT,
+ DOUBLE,
+ STRING
};
// Constructors
diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h
index a6ae6d2..9cfed52 100644
--- a/engines/zvision/string_manager.h
+++ b/engines/zvision/string_manager.h
@@ -59,7 +59,7 @@ private:
};
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
+ 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:
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index 7ddecce..d8937ac 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -61,7 +61,7 @@ private:
private:
// Audio Codecs
enum {
- kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
+ kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
};
};
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index c9e14e8..983d5a5 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -70,19 +70,19 @@ public:
private:
enum {
- WINDOW_WIDTH = 640,
- WINDOW_HEIGHT = 480,
+ WINDOW_WIDTH = 640,
+ WINDOW_HEIGHT = 480,
- //Zork nemesis working window sizes
- ZNM_WORKING_WINDOW_WIDTH = 512,
- ZNM_WORKING_WINDOW_HEIGHT = 320,
+ //Zork nemesis working window sizes
+ ZNM_WORKING_WINDOW_WIDTH = 512,
+ ZNM_WORKING_WINDOW_HEIGHT = 320,
- //ZGI(and default) working window sizes
- WORKING_WINDOW_WIDTH = 640,
- WORKING_WINDOW_HEIGHT = 344,
+ //ZGI(and default) working window sizes
+ WORKING_WINDOW_WIDTH = 640,
+ WORKING_WINDOW_HEIGHT = 344,
- ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 400 // Pixels per second
+ ROTATION_SCREEN_EDGE_OFFSET = 60,
+ MAX_ROTATION_SPEED = 400 // Pixels per second
};
Console *_console;
Commit: 226ccb0de7ed702d4b41625c8a2211fac9cc0787
https://github.com/scummvm/scummvm/commit/226ccb0de7ed702d4b41625c8a2211fac9cc0787
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T20:40:20+07:00
Commit Message:
ZVISION: Don't add new timer if sidefx with same key exist
Changed paths:
engines/zvision/actions.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 7b9050f..c3f85fe 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -607,6 +607,8 @@ ActionTimer::~ActionTimer() {
}
bool ActionTimer::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
+ return true;
_engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue()));
return true;
}
Commit: dcfe35c8ac1cd2c9139f5d7a59f0f554e3c5082b
https://github.com/scummvm/scummvm/commit/dcfe35c8ac1cd2c9139f5d7a59f0f554e3c5082b
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T20:44:22+07:00
Commit Message:
ZVISION: Implement sTTFont class for handle ttf with styles.
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 dde3b2d..5e1bc7a 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -27,9 +27,11 @@
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
+#include "common/config-manager.h"
#include "common/debug.h"
#include "common/file.h"
#include "common/system.h"
+#include "common/unzip.h"
#include "graphics/font.h"
#include "graphics/fonts/ttf.h"
@@ -113,4 +115,228 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, u
return surface;
}
+sTTFont::sTTFont(ZVision *engine) {
+ _engine = engine;
+ _style = 0;
+ _font = NULL;
+ _lineHeight = 0;
+}
+
+sTTFont::~sTTFont() {
+ if (_font)
+ delete _font;
+}
+
+bool sTTFont::loadFont(const Common::String &fontName, int32 point, uint style) {
+ _style = style;
+ return loadFont(fontName, point);
+}
+
+bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
+ Common::String newFontName;
+ if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
+ newFontName = "timesbi.ttf";
+ else if (_style & STTF_BOLD)
+ newFontName = "timesbd.ttf";
+ else if (_style & STTF_ITALIC)
+ newFontName = "timesi.ttf";
+ else
+ newFontName = "times.ttf";
+
+ } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
+ newFontName = "courbi.ttf";
+ else if (_style & STTF_BOLD)
+ newFontName = "courbd.ttf";
+ else if (_style & STTF_ITALIC)
+ newFontName = "couri.ttf";
+ else
+ newFontName = "cour.ttf";
+
+ } else if (fontName.matchString("*century schoolbook*", true)) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
+ newFontName = "censcbkbi.ttf";
+ else if (_style & STTF_BOLD)
+ newFontName = "censcbkbd.ttf";
+ else if (_style & STTF_ITALIC)
+ newFontName = "censcbki.ttf";
+ else
+ newFontName = "censcbk.ttf";
+
+ } else if (fontName.matchString("*garamond*", true)) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
+ newFontName = "garabi.ttf";
+ else if (_style & STTF_BOLD)
+ newFontName = "garabd.ttf";
+ else if (_style & STTF_ITALIC)
+ newFontName = "garai.ttf";
+ else
+ newFontName = "gara.ttf";
+
+ } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
+ newFontName = "arialbi.ttf";
+ else if (_style & STTF_BOLD)
+ newFontName = "arialbd.ttf";
+ else if (_style & STTF_ITALIC)
+ newFontName = "ariali.ttf";
+ else
+ newFontName = "arial.ttf";
+
+ } else {
+ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
+ newFontName = "arial.ttf";
+ }
+
+ Common::File *file = _engine->getSearchManager()->openFile(newFontName);
+
+ if (!file) {
+ Common::SeekableReadStream *themeFile = nullptr;
+ if (ConfMan.hasKey("themepath")) {
+ Common::FSNode themePath(ConfMan.get("themepath"));
+ if (themePath.exists()) {
+ Common::FSNode scummModern = themePath.getChild("scummmodern.zip");
+ if (scummModern.exists()) {
+ themeFile = scummModern.createReadStream();
+ }
+ }
+ }
+ if (!themeFile) { // Fallback 2.5: Search for ScummModern.zip in SearchMan.
+ themeFile = SearchMan.createReadStreamForMember("scummmodern.zip");
+ }
+ if (themeFile) {
+ Common::Archive *themeArchive = Common::makeZipArchive(themeFile);
+ if (themeArchive->hasFile("FreeSans.ttf")) {
+ Common::SeekableReadStream *stream = nullptr;
+ stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60); // 66 dpi for 640 x 480 on 14" display
+ if (_newFont) {
+ if (!_font)
+ delete _font;
+ _font = _newFont;
+ }
+ if (stream)
+ delete stream;
+ }
+ delete themeArchive;
+ themeArchive = nullptr;
+ }
+ } else {
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60); // 66 dpi for 640 x 480 on 14" display
+ if (_newFont) {
+ if (!_font)
+ delete _font;
+ _font = _newFont;
+ }
+ delete file;
+ }
+
+ _fntName = fontName;
+ _lineHeight = point;
+
+ if (_font)
+ return true;
+ return false;
+}
+
+void sTTFont::setStyle(uint newStyle) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC)) != (newStyle & (STTF_BOLD | STTF_ITALIC))) {
+ _style = newStyle;
+ loadFont(_fntName, _lineHeight);
+ } else {
+ _style = newStyle;
+ }
+}
+
+int sTTFont::getFontHeight() {
+ if (_font)
+ return _font->getFontHeight();
+ return 0;
+}
+
+int sTTFont::getMaxCharWidth() {
+ if (_font)
+ return _font->getMaxCharWidth();
+ return 0;
+}
+
+int sTTFont::getCharWidth(byte chr) {
+ if (_font)
+ return _font->getCharWidth(chr);
+ return 0;
+}
+
+int sTTFont::getKerningOffset(byte left, byte right) {
+ if (_font)
+ return _font->getKerningOffset(left, right);
+ return 0;
+}
+
+void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) {
+ if (_font) {
+ _font->drawChar(dst, chr, x, y, color);
+ if (_style & STTF_UNDERLINE) {
+ int16 pos = floor(_font->getFontHeight() * 0.87);
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
+ }
+ if (_style & STTF_STRIKEOUT) {
+ int16 pos = floor(_font->getFontHeight() * 0.60);
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
+ }
+ }
+}
+
+void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) {
+ if (_font) {
+ _font->drawString(dst, str, x, y, w, color, align);
+ if (_style & STTF_UNDERLINE) {
+ int16 pos = floor(_font->getFontHeight() * 0.87);
+ int16 wd = MIN(_font->getStringWidth(str), w);
+ int16 stX = x;
+ if (align == Graphics::kTextAlignCenter)
+ stX += (w - wd) / 2;
+ else if (align == Graphics::kTextAlignRight)
+ stX += (w - wd);
+
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+
+ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
+ }
+ if (_style & STTF_STRIKEOUT) {
+ int16 pos = floor(_font->getFontHeight() * 0.60);
+ int16 wd = MIN(_font->getStringWidth(str), w);
+ int16 stX = x;
+ if (align == Graphics::kTextAlignCenter)
+ stX += (w - wd) / 2;
+ else if (align == Graphics::kTextAlignRight)
+ stX += (w - wd);
+
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+
+ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
+ }
+ }
+}
+
+int sTTFont::getStringWidth(const Common::String &str) {
+ if (_font)
+ return _font->getStringWidth(str);
+ return 0;
+}
+
+Graphics::Surface *sTTFont::renderSolidText(const Common::String &str, uint32 color) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ if (_font) {
+ int16 w = _font->getStringWidth(str);
+ if (w && w < 1024) {
+ tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat);
+ drawString(tmp, str, 0, 0, w, color);
+ }
+ }
+ return tmp;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index 762657a..0462f35 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -76,6 +76,48 @@ public:
Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
};
+// Styled TTF
+class sTTFont {
+public:
+ sTTFont(ZVision *engine);
+ ~sTTFont();
+
+ enum {
+ STTF_BOLD = 1,
+ STTF_ITALIC = 2,
+ STTF_UNDERLINE = 4,
+ STTF_STRIKEOUT = 8
+ };
+
+private:
+ ZVision *_engine;
+ Graphics::Font *_font;
+ int _lineHeight;
+ uint _style;
+ Common::String _fntName;
+
+public:
+ bool loadFont(const Common::String &fontName, int32 point);
+ bool loadFont(const Common::String &fontName, int32 point, uint style);
+ void setStyle(uint newStyle);
+
+ int getFontHeight();
+ int getMaxCharWidth();
+ int getCharWidth(byte chr);
+ int getKerningOffset(byte left, byte right);
+
+ void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color);
+
+ void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft);
+ int getStringWidth(const Common::String &str);
+
+ Graphics::Surface *renderSolidText(const Common::String &str, uint32 color);
+
+ bool isLoaded() {
+ return _font != NULL;
+ };
+};
+
} // End of namespace ZVision
#endif
Commit: cf08849147905ffd12cd9571b617033ded5a95fb
https://github.com/scummvm/scummvm/commit/cf08849147905ffd12cd9571b617033ded5a95fb
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T22:31:06+07:00
Commit Message:
ZVISION: Implement textRender with tags parser.
Changed paths:
A engines/zvision/text.cpp
A engines/zvision/text.h
engines/zvision/module.mk
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index b8dca9e..ea70b4b 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -36,7 +36,8 @@ MODULE_OBJS := \
slot_control.o \
menu.o \
meta_animation.o \
- search_manager.o
+ search_manager.o \
+ text.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp
new file mode 100644
index 0000000..575ca03
--- /dev/null
+++ b/engines/zvision/text.cpp
@@ -0,0 +1,512 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/text.h"
+
+#include "zvision/truetype_font.h"
+
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/debug.h"
+#include "common/rect.h"
+
+#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
+
+#include "zvision/render_manager.h"
+#include "zvision/script_manager.h"
+
+
+namespace ZVision {
+
+cTxtStyle::cTxtStyle() {
+ fontname = "Arial";
+ blue = 255;
+ green = 255;
+ red = 255;
+ bold = false;
+ escapement = 0;
+ italic = false;
+ justify = TXT_JUSTIFY_LEFT;
+ newline = false;
+ size = 12;
+ skipcolor = false;
+ strikeout = false;
+ underline = false;
+ statebox = 0;
+}
+
+txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
+ Common::String buf = Common::String(strin.c_str(), ln);
+
+ int8 retval = TXT_RET_NOTHING;
+
+ Common::StringTokenizer tokenizer(buf, " ");
+ Common::String token;
+
+ while (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+
+ if (token.matchString("font", true)) {
+ token = tokenizer.nextToken();
+ if (token[0] == '"') {
+ Common::String _tmp = Common::String(token.c_str() + 1);
+
+ while (token.lastChar() != '"' && !tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ _tmp += " " + token;
+ }
+
+ if (_tmp.lastChar() == '"')
+ _tmp.deleteLastChar();
+
+ fontname = _tmp;
+ } else {
+ if (!tokenizer.empty())
+ fontname = token;
+ }
+ retval |= TXT_RET_FNTCHG;
+
+ } else if (token.matchString("blue", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (blue != tmp) {
+ blue = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("red", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (red != tmp) {
+ red = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("green", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (green != tmp) {
+ green = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("newline", true)) {
+ if ((retval & TXT_RET_NEWLN) == 0)
+ newline = 0;
+
+ newline++;
+ retval |= TXT_RET_NEWLN;
+ } else if (token.matchString("point", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (size != tmp) {
+ size = tmp;
+ retval |= TXT_RET_FNTCHG;
+ }
+ }
+ } else if (token.matchString("escapement", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ escapement = tmp;
+ }
+ } else if (token.matchString("italic", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (italic != true) {
+ italic = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (italic != false) {
+ italic = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("underline", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (underline != true) {
+ underline = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (underline != false) {
+ underline = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("strikeout", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (strikeout != true) {
+ strikeout = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (strikeout != false) {
+ strikeout = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("bold", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (bold != true) {
+ bold = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (bold != false) {
+ bold = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("skipcolor", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ skipcolor = true;
+ } else if (token.matchString("off", true)) {
+ skipcolor = false;
+ }
+ }
+ } else if (token.matchString("image", true)) {
+ // Not used
+ } else if (token.matchString("statebox", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ statebox = atoi(token.c_str());
+ retval |= TXT_RET_HASSTBOX;
+ }
+ } else if (token.matchString("justify", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("center", true))
+ justify = TXT_JUSTIFY_CENTER;
+ else if (token.matchString("left", true))
+ justify = TXT_JUSTIFY_LEFT;
+ else if (token.matchString("right", true))
+ justify = TXT_JUSTIFY_RIGHT;
+ }
+ }
+ }
+ return (txtReturn)retval;
+}
+
+void cTxtStyle::readAllStyle(const Common::String &txt) {
+ int16 strt = -1;
+ int16 endt = -1;
+
+ for (uint16 i = 0; i < txt.size(); i++) {
+ if (txt[i] == '<')
+ strt = i;
+ else if (txt[i] == '>') {
+ endt = i;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1);
+ }
+
+ }
+}
+
+void cTxtStyle::setFontStyle(sTTFont &font) {
+ uint temp_stl = 0;
+
+ if (bold)
+ temp_stl |= sTTFont::STTF_BOLD;
+
+ if (italic)
+ temp_stl |= sTTFont::STTF_ITALIC;
+
+ if (underline)
+ temp_stl |= sTTFont::STTF_UNDERLINE;
+
+ if (strikeout)
+ temp_stl |= sTTFont::STTF_STRIKEOUT;
+
+ font.setStyle(temp_stl);
+}
+
+void cTxtStyle::setFont(sTTFont &font) {
+ uint temp_stl = 0;
+
+ if (bold)
+ temp_stl |= sTTFont::STTF_BOLD;
+
+ if (italic)
+ temp_stl |= sTTFont::STTF_ITALIC;
+
+ if (underline)
+ temp_stl |= sTTFont::STTF_UNDERLINE;
+
+ if (strikeout)
+ temp_stl |= sTTFont::STTF_STRIKEOUT;
+
+ font.loadFont(fontname, size, temp_stl);
+}
+
+Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
+ style.setFontStyle(fnt);
+ uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue);
+ return fnt.renderSolidText(txt, clr);
+}
+
+void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
+ if (justify == TXT_JUSTIFY_LEFT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft);
+ else if (justify == TXT_JUSTIFY_CENTER)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter);
+ else if (justify == TXT_JUSTIFY_RIGHT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight);
+}
+
+int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) {
+ sTTFont font(_engine);
+ fnt_stl.setFont(font);
+
+ dst.fillRect(Common::Rect(dst.w, dst.h), 0);
+
+ uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue);
+
+ int16 w;
+
+ w = font.getStringWidth(txt);
+
+ drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify);
+
+ return w;
+}
+
+void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
+ const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it
+ const int TXT_CFG_TEXTURES_PER_LINE = 6;
+ cTxtStyle style, style2;
+ int16 strt = -1;
+ int16 endt = -1;
+ int16 i = 0;
+ int16 dx = 0, dy = 0;
+ int16 txt_w;
+ int16 txtpos = 0;
+ Common::String buf;
+ Common::String buf2;
+
+ Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE];
+ int16 currentline = 0, currentlineitm = 0;
+
+ int TxtJustify[TXT_CFG_TEXTURES_LINES];
+ int TxtPoint[TXT_CFG_TEXTURES_LINES];
+
+ for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) {
+ TxtPoint[k] = 0;
+ for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ TxtSurfaces[k][j] = NULL;
+ }
+
+ int16 stringlen = text.size();
+
+ sTTFont font(_engine);
+
+ style.setFont(font);
+
+ int16 prevbufspace = 0, prevtxtspace = 0;
+
+ while (i < stringlen) {
+ TxtJustify[currentline] = style.justify;
+ if (text[i] == '<') {
+ int16 ret = 0;
+
+ strt = i;
+ while (i < stringlen && text[i] != '>')
+ i++;
+ endt = i;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0) {
+ style2 = style;
+ ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1);
+ }
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (buf.size() > 0) {
+ txt_w = font.getStringWidth(buf);
+
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+
+ currentlineitm++;
+
+ buf.clear();
+ prevbufspace = 0;
+ txtpos = 0;
+ dx += txt_w;
+
+ }
+ if (ret & TXT_RET_FNTCHG) {
+ style.setFont(font);
+ }
+ if (ret & TXT_RET_FNTSTL)
+ style.setFontStyle(font);
+
+ if (ret & TXT_RET_NEWLN) {
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf3;
+ buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox));
+ buf += buf3;
+ txtpos += buf3.size();
+ }
+
+ } else {
+
+ buf += text[i];
+ txtpos++;
+
+ if (text[i] == ' ') {
+ prevbufspace = txtpos - 1;
+ prevtxtspace = i;
+ }
+
+ if (font.isLoaded()) {
+ txt_w = font.getStringWidth(buf);
+ if (txt_w + dx > dst.w) {
+ if (prevbufspace == 0) {
+ prevtxtspace = i;
+ prevbufspace = txtpos - 1;
+ }
+ buf2 = Common::String(buf.c_str(), prevbufspace + 1);
+
+ if (buf2.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ buf.clear();
+ i = prevtxtspace;
+ prevbufspace = 0;
+ txtpos = 0;
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+ }
+ i++;
+ }
+
+ if (buf.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ dy = 0;
+ for (i = 0; i <= currentline; i++) {
+ int16 j = 0;
+ int16 width = 0;
+ while (TxtSurfaces[i][j] != NULL) {
+ width += TxtSurfaces[i][j]->w;
+ j++;
+ }
+ dx = 0;
+ for (int32_t jj = 0; jj < j; jj++) {
+ if (TxtJustify[i] == TXT_JUSTIFY_LEFT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_CENTER)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ dx += TxtSurfaces[i][jj]->w;
+ }
+
+ dy += TxtPoint[i];
+ }
+
+ for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++)
+ for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ if (TxtSurfaces[i][j] != NULL) {
+ TxtSurfaces[i][j]->free();
+ delete TxtSurfaces[i][j];
+ }
+}
+
+Common::String readWideLine(Common::SeekableReadStream &stream) {
+ Common::String asciiString;
+
+ while (!stream.eos()) {
+ uint32 value = stream.readUint16LE();
+ // 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 < 0x80) {
+ asciiString += (char)(value & 0x7F);
+ } else if (value >= 0x80 && value < 0x800) {
+ asciiString += (char)(0xC0 | ((value >> 6) & 0x1F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value >= 0x800 && value < 0x10000) {
+ asciiString += (char)(0xE0 | ((value >> 12) & 0xF));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value >= 0x10000 && value < 0x200000) {
+ asciiString += (char)(0xF0);
+ asciiString += (char)(0x80 | ((value >> 12) & 0x3F));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ }
+ }
+
+ return asciiString;
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/text.h b/engines/zvision/text.h
new file mode 100644
index 0000000..40244f7
--- /dev/null
+++ b/engines/zvision/text.h
@@ -0,0 +1,97 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifndef ZVISION_TEXT_H
+#define ZVISION_TEXT_H
+
+#include "zvision/detection.h"
+#include "zvision/truetype_font.h"
+#include "zvision/zvision.h"
+
+
+namespace Graphics {
+class FontManager;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+enum txtJustify {
+ TXT_JUSTIFY_CENTER = 0,
+ TXT_JUSTIFY_LEFT = 1,
+ TXT_JUSTIFY_RIGHT = 2
+};
+
+enum txtReturn {
+ TXT_RET_NOTHING = 0x0,
+ TXT_RET_FNTCHG = 0x1,
+ TXT_RET_FNTSTL = 0x2,
+ TXT_RET_NEWLN = 0x4,
+ TXT_RET_HASSTBOX = 0x8
+};
+
+class cTxtStyle {
+public:
+ cTxtStyle();
+ txtReturn parseStyle(const Common::String &strin, int16 len);
+ void readAllStyle(const Common::String &txt);
+ void setFontStyle(sTTFont &font);
+ void setFont(sTTFont &font);
+
+public:
+ Common::String fontname;
+ txtJustify justify; // 0 - center, 1-left, 2-right
+ int16 size;
+ uint8 red; // 0-255
+ uint8 green; // 0-255
+ uint8 blue; // 0-255
+ int8 newline;
+ int8 escapement;
+ bool italic;
+ bool bold;
+ bool underline;
+ bool strikeout;
+ bool skipcolor;
+ int32 statebox;
+ // char image ??
+};
+
+class textRenderer {
+public:
+ textRenderer(ZVision *engine): _engine(engine) {};
+
+ void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
+ int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst);
+ Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style);
+ void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst);
+
+private:
+ ZVision *_engine;
+};
+
+Common::String readWideLine(Common::SeekableReadStream &stream);
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index bf945f8..178c797 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -34,6 +34,7 @@
#include "zvision/detection.h"
#include "zvision/menu.h"
#include "zvision/search_manager.h"
+#include "zvision/text.h"
#include "common/config-manager.h"
#include "common/str.h"
@@ -93,6 +94,7 @@ void ZVision::initialize() {
_searchManager = new sManager(ConfMan.get("path"), 6);
+ _searchManager->addDir("FONTS");
_searchManager->addDir("addon");
if (_gameDescription->gameId == GID_GRANDINQUISITOR) {
@@ -152,6 +154,7 @@ void ZVision::initialize() {
_saveManager = new SaveManager(this);
_stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
+ _textRenderer = new textRenderer(this);
if (_gameDescription->gameId == GID_GRANDINQUISITOR)
_menu = new menuZgi(this);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 983d5a5..bbcaf3c 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -53,6 +53,7 @@ class StringManager;
class SaveManager;
class RlfAnimation;
class menuHandler;
+class textRenderer;
class ZVision : public Engine {
public:
@@ -101,6 +102,7 @@ private:
StringManager *_stringManager;
menuHandler *_menu;
sManager *_searchManager;
+ textRenderer *_textRenderer;
// Clock
Clock _clock;
@@ -140,6 +142,9 @@ public:
sManager *getSearchManager() const {
return _searchManager;
}
+ textRenderer *getTextRenderer() const {
+ return _textRenderer;
+ }
Common::RandomSource *getRandomSource() const {
return _rnd;
}
Commit: ac9b74dd16fb5950cdaa6c540b1e0d2e968ed129
https://github.com/scummvm/scummvm/commit/ac9b74dd16fb5950cdaa6c540b1e0d2e968ed129
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T22:43:09+07:00
Commit Message:
ZVISION: Implement subtitle handle class
Changed paths:
A engines/zvision/subtitles.cpp
engines/zvision/module.mk
engines/zvision/subtitles.h
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index ea70b4b..c8f629d 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -37,7 +37,8 @@ MODULE_OBJS := \
menu.o \
meta_animation.o \
search_manager.o \
- text.o
+ text.o \
+ subtitles.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp
new file mode 100644
index 0000000..1942e3c
--- /dev/null
+++ b/engines/zvision/subtitles.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "zvision/subtitles.h"
+#include "zvision/render_manager.h"
+#include "zvision/search_manager.h"
+#include "zvision/text.h"
+
+namespace ZVision {
+
+Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
+ _engine(engine),
+ _areaId(-1),
+ _subId(-1) {
+ Common::File file;
+ if (_engine->getSearchManager()->openFile(file, subname)) {
+ while (!file.eos()) {
+ Common::String str = file.readLine();
+ if (str.lastChar() == '~')
+ str.deleteLastChar();
+
+ if (str.matchString("*Initialization*", true)) {
+ // Not used
+ } else if (str.matchString("*Rectangle*", true)) {
+ int32 x1, y1, x2, y2;
+ sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
+ Common::Rect rct = Common::Rect(x1, y1, x2, y2);
+ _areaId = _engine->getRenderManager()->createSubArea(rct);
+ } else if (str.matchString("*TextFile*", true)) {
+ char filename[64];
+ sscanf(str.c_str(), "%*[^:]:%s", filename);
+ Common::File txt;
+ if (_engine->getSearchManager()->openFile(txt, filename)) {
+ while (!txt.eos()) {
+ Common::String txtline = readWideLine(txt);
+ sub cur_sub;
+ cur_sub.start = -1;
+ cur_sub.stop = -1;
+ cur_sub.sub = txtline;
+
+ _subs.push_back(cur_sub);
+ }
+ txt.close();
+ }
+ } else {
+ int32 st;
+ int32 en;
+ int32 sb;
+ if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
+ if (sb <= (int32)_subs.size()) {
+ _subs[sb].start = st;
+ _subs[sb].stop = en;
+ }
+ }
+ }
+ }
+ }
+}
+
+Subtitle::~Subtitle() {
+ if (_areaId != -1)
+ _engine->getRenderManager()->deleteSubArea(_areaId);
+
+ _subs.clear();
+}
+
+void Subtitle::process(int32 time) {
+ int16 j = -1;
+ for (uint16 i = 0; i < _subs.size(); i++)
+ if (time >= _subs[i].start && time <= _subs[i].stop) {
+ j = i;
+ break;
+ }
+
+ if (j == -1 && _subId != -1) {
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, "");
+ _subId = -1;
+ }
+
+ if (j != -1 && j != _subId) {
+ if (_subs[j].sub.size())
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub);
+ _subId = j;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h
index 13426e0..d14cb6f 100644
--- a/engines/zvision/subtitles.h
+++ b/engines/zvision/subtitles.h
@@ -24,6 +24,30 @@
#ifndef ZVISION_SUBTITLES_H
#define ZVISION_SUBTITLES_H
-// TODO: Implement Subtitles
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class Subtitle {
+public:
+ Subtitle(ZVision *engine, const Common::String &subname);
+ ~Subtitle();
+
+ void process(int32 time);
+private:
+ ZVision *_engine;
+ int32 _areaId;
+ int16 _subId;
+
+ struct sub {
+ int start;
+ int stop;
+ Common::String sub;
+ };
+
+ Common::Array<sub> _subs;
+};
+
+}
#endif
Commit: 8e02e06db153a68e86239c09b79565b0372cd789
https://github.com/scummvm/scummvm/commit/8e02e06db153a68e86239c09b79565b0372cd789
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T22:46:00+07:00
Commit Message:
ZVISION: Change rendermanager code for correct subtitles handle.
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 6cfc050..071afff 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -24,6 +24,7 @@
#include "zvision/zvision.h"
#include "zvision/render_manager.h"
+#include "zvision/text.h"
#include "zvision/lzss_read_stream.h"
@@ -746,9 +747,14 @@ void RenderManager::updateSubArea(uint16 id, const Common::String &txt) {
}
}
-void RenderManager::renderSubsToScreen() {
+void RenderManager::processSubs(uint16 deltatime) {
bool redraw = false;
for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
+ if (it->_value.timer != -1) {
+ it->_value.timer -= deltatime;
+ if (it->_value.timer <= 0)
+ it->_value.todelete = true;
+ }
if (it->_value.todelete) {
_subsList.erase(it);
redraw = true;
@@ -761,7 +767,16 @@ void RenderManager::renderSubsToScreen() {
_subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0);
for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
- //draw subs
+ oneSub *sub = &it->_value;
+ if (sub->_txt.size()) {
+ Graphics::Surface *rndr = new Graphics::Surface();
+ rndr->create(sub->_r.width(), sub->_r.height(), _pixelFormat);
+ _engine->getTextRenderer()->drawTxtInOneLine(sub->_txt, *rndr);
+ blitSurfaceToSurface(*rndr, _subWnd, sub->_r.left - _subWndRect.left + _workingWindow.left, sub->_r.top - _subWndRect.top + _workingWindow.top);
+ rndr->free();
+ delete rndr;
+ }
+ sub->redraw = false;
}
_system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch,
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 3c03331..668c8ac 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -236,7 +236,7 @@ public:
void deleteSubArea(uint16 id);
void deleteSubArea(uint16 id, int16 delay);
void updateSubArea(uint16 id, const Common::String &txt);
- void renderSubsToScreen();
+ void processSubs(uint16 deltatime);
Common::Point getBkgSize();
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 178c797..4c5164c 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -192,7 +192,7 @@ Common::Error ZVision::run() {
// Render the backBuffer to the screen
_renderManager->prepareBkg();
_renderManager->renderMenuToScreen();
- _renderManager->renderSubsToScreen();
+ _renderManager->processSubs(deltaTime);
_renderManager->renderBackbufferToScreen();
// Update the screen
Commit: 1af6f404f441a7a2d77bb0f23d1dbb1c838cf56c
https://github.com/scummvm/scummvm/commit/1af6f404f441a7a2d77bb0f23d1dbb1c838cf56c
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T22:47:28+07:00
Commit Message:
ZVISION: Add subtitles support for MusicNode.
Changed paths:
engines/zvision/music_node.cpp
engines/zvision/music_node.h
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index 31d222a..b716b3e 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -46,6 +46,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
_attenuate = 0;
_pantrack = false;
_pantrack_X = 0;
+ _sub = NULL;
Audio::RewindableAudioStream *audioStream;
@@ -69,12 +70,22 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 1);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
}
MusicNode::~MusicNode() {
_engine->_mixer->stopHandle(_handle);
if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
+ if (_sub)
+ delete _sub;
debug(1, "MusicNode: %d destroyed\n", _key);
}
@@ -117,6 +128,9 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
if (_pantrack || _volume != _newvol)
setVolume(_newvol);
+
+ if (_sub)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
}
return false;
}
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
index 6e3033f..d24496f 100644
--- a/engines/zvision/music_node.h
+++ b/engines/zvision/music_node.h
@@ -25,6 +25,7 @@
#include "audio/mixer.h"
#include "zvision/sidefx.h"
+#include "zvision/subtitles.h"
namespace Common {
class String;
@@ -64,6 +65,7 @@ private:
int32 _crossfade_time;
bool _stereo;
Audio::SoundHandle _handle;
+ Subtitle *_sub;
};
class PanTrackNode : public SideFX {
Commit: 3608a0f6c6be65cc86aac7b75dbed5505859f267
https://github.com/scummvm/scummvm/commit/3608a0f6c6be65cc86aac7b75dbed5505859f267
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-02-24T22:49:44+07:00
Commit Message:
ZVISION: Change changelocation code for identical work to original.
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index a100319..54d126f 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -58,10 +58,10 @@ void ScriptManager::initialize() {
cleanScriptScope(room);
cleanScriptScope(nodeview);
- _currentLocation.node = '0';
- _currentLocation.world = '0';
- _currentLocation.room = '0';
- _currentLocation.view = '0';
+ _currentLocation.node = 0;
+ _currentLocation.world = 0;
+ _currentLocation.room = 0;
+ _currentLocation.view = 0;
parseScrFile("universe.scr", universe);
changeLocation('g', 'a', 'r', 'y', 0);
@@ -489,46 +489,75 @@ void ScriptManager::do_changeLocation() {
setStateValue(StateKey_View, _nextLocation.view);
setStateValue(StateKey_ViewPos, _nextLocation.offset);
- // Clear all the containers
_referenceTable.clear();
- cleanScriptScope(nodeview);
- cleanScriptScope(room);
- cleanScriptScope(world);
-
addPuzzlesToReferenceTable(universe);
- // 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, nodeview);
- addPuzzlesToReferenceTable(nodeview);
+ if (_nextLocation.world != _currentLocation.world) {
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+ cleanScriptScope(world);
+
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
+
+ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
+ parseScrFile(fileName, room);
+ addPuzzlesToReferenceTable(room);
+
+ fileName = Common::String::format("%c.scr", _nextLocation.world);
+ parseScrFile(fileName, world);
+ addPuzzlesToReferenceTable(world);
+ } else if (_nextLocation.room != _currentLocation.room) {
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+
+ addPuzzlesToReferenceTable(world);
+
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
- fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
- parseScrFile(fileName, room);
- addPuzzlesToReferenceTable(room);
+ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
+ parseScrFile(fileName, room);
+ addPuzzlesToReferenceTable(room);
- fileName = Common::String::format("%c.scr", _nextLocation.world);
- parseScrFile(fileName, world);
- addPuzzlesToReferenceTable(world);
+ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
+ cleanScriptScope(nodeview);
+
+ addPuzzlesToReferenceTable(room);
+ addPuzzlesToReferenceTable(world);
+
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
+ }
_activeControls = &nodeview._controls;
// Revert to the idle cursor
_engine->getCursorManager()->changeCursor(CursorIndex_Idle);
- // Reset the background velocity
- //_engine->getRenderManager()->setBackgroundVelocity(0);
-
- // Remove any alphaEntries
- //_engine->getRenderManager()->clearAlphaEntries();
-
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- // Update _currentLocation
- _currentLocation = _nextLocation;
-
- execScope(room);
- execScope(nodeview);
+ if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) {
+ _currentLocation = _nextLocation;
+ execScope(world);
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.world != _currentLocation.world) {
+ _currentLocation = _nextLocation;
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.room != _currentLocation.room) {
+ _currentLocation = _nextLocation;
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
+ _currentLocation = _nextLocation;
+ execScope(nodeview);
+ }
}
void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
Commit: 665014033d2163f5029a3284c3dd3cbad8d7bf1d
https://github.com/scummvm/scummvm/commit/665014033d2163f5029a3284c3dd3cbad8d7bf1d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-01T20:39:24+07:00
Commit Message:
ZVISION: Add functions for framedelay controlling in animation_node
Changed paths:
engines/zvision/animation_node.cpp
engines/zvision/animation_node.h
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 89d0f5e..365ff74 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -191,4 +191,21 @@ bool AnimationNode::stop() {
return false;
}
+void AnimationNode::setNewFrameDelay(int32 newDelay) {
+ if (newDelay > 0) {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+ float percent = (float)nod->_delay / (float)_frmDelay;
+ nod->_delay = percent * newDelay; // Scale to new max
+ }
+
+ _frmDelay = newDelay;
+ }
+}
+
+int32 AnimationNode::getFrameDelay() {
+ return _frmDelay;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h
index 556ab8a..ff7636a 100644
--- a/engines/zvision/animation_node.h
+++ b/engines/zvision/animation_node.h
@@ -74,6 +74,9 @@ public:
void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1);
bool stop();
+
+ void setNewFrameDelay(int32 newDelay);
+ int32 getFrameDelay();
};
} // End of namespace ZVision
Commit: d90b325a3b0ec5ab455f8b8ae90bef9a528600df
https://github.com/scummvm/scummvm/commit/d90b325a3b0ec5ab455f8b8ae90bef9a528600df
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-01T20:41:13+07:00
Commit Message:
ZVISION: Implement syncsound sidefx class and action class.
Changed paths:
A engines/zvision/syncsound_node.cpp
A engines/zvision/syncsound_node.h
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index c3f85fe..bab1a5e 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -31,6 +31,7 @@
#include "zvision/zork_avi_decoder.h"
#include "zvision/timer_node.h"
#include "zvision/music_node.h"
+#include "zvision/syncsound_node.h"
#include "zvision/animation_node.h"
#include "common/file.h"
@@ -587,6 +588,35 @@ bool ActionStreamVideo::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionSyncSound
+//////////////////////////////////////////////////////////////////////////////
+
+ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char fileName[25];
+ int not_used;
+
+ sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬_used, fileName);
+
+ _fileName = Common::String(fileName);
+}
+
+bool ActionSyncSound::execute() {
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_syncto);
+ if (!fx)
+ return true;
+
+ if (!(fx->getType() & SideFX::SIDEFX_ANIM))
+ return true;
+
+ AnimationNode *animnode = (AnimationNode *)fx;
+ if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload
+ animnode->setNewFrameDelay(66); // ~15fps
+
+ _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotkey, _fileName, _syncto));
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionTimer
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index f4a2c0f..bc88a6d 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -381,6 +381,16 @@ private:
bool _skippable;
};
+class ActionSyncSound : public ResultAction {
+public:
+ ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ int _syncto;
+ Common::String _fileName;
+};
+
class ActionTimer : public ResultAction {
public:
ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index c8f629d..90a2975 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -38,7 +38,8 @@ MODULE_OBJS := \
meta_animation.o \
search_manager.o \
text.o \
- subtitles.o
+ subtitles.o \
+ syncsound_node.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index db4e8fa..347c3a6 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -277,7 +277,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("streamvideo", true)) {
actionList.push_back(new ActionStreamVideo(_engine, slot, args));
} else if (act.matchString("syncsound", true)) {
- // TODO: Implement ActionSyncSound
+ actionList.push_back(new ActionSyncSound(_engine, slot, args));
} else if (act.matchString("timer", true)) {
actionList.push_back(new ActionTimer(_engine, slot, args));
} else if (act.matchString("ttytext", true)) {
diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp
new file mode 100644
index 0000000..5d04c1f
--- /dev/null
+++ b/engines/zvision/syncsound_node.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/syncsound_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+
+namespace ZVision {
+
+SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
+ : SideFX(engine, key, SIDEFX_AUDIO) {
+ _syncto = syncto;
+ _sub = NULL;
+
+ Audio::RewindableAudioStream *audioStream;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+}
+
+SyncSoundNode::~SyncSoundNode() {
+ _engine->_mixer->stopHandle(_handle);
+ if (_sub)
+ delete _sub;
+}
+
+bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+
+ if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
+ return stop();
+
+ if (_sub)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h
new file mode 100644
index 0000000..7d875f2
--- /dev/null
+++ b/engines/zvision/syncsound_node.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SYNCSOUND_NODE_H
+#define ZVISION_SYNCSOUND_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/sidefx.h"
+#include "zvision/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class SyncSoundNode : public SideFX {
+public:
+ SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
+ ~SyncSoundNode();
+
+ /**
+ * 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:
+ int32 _syncto;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: eb9061e580ce7c055c4f7cafe9bd81823367f39d
https://github.com/scummvm/scummvm/commit/eb9061e580ce7c055c4f7cafe9bd81823367f39d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-02T00:03:25+07:00
Commit Message:
ZVISION: Refactor video-play and correct streamvideo for use subtitles and correct scale.
Changed paths:
engines/zvision/actions.cpp
engines/zvision/subtitles.h
engines/zvision/video.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index bab1a5e..99fa6a6 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -577,12 +577,22 @@ bool ActionStreamVideo::execute() {
return true;
}
- Common::Rect destRect;
- if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
- destRect = Common::Rect(_x1, _y1, _x2, _y2);
- }
+ Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
+
+ Common::String subname = _fileName;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ Subtitle *sub = NULL;
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ sub = new Subtitle(_engine, subname);
+
+ _engine->playVideo(decoder, destRect, _skippable, sub);
- _engine->playVideo(decoder, destRect, _skippable);
+ if (sub)
+ delete sub;
}
return true;
diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h
index d14cb6f..698561b 100644
--- a/engines/zvision/subtitles.h
+++ b/engines/zvision/subtitles.h
@@ -28,6 +28,8 @@
namespace ZVision {
+class ZVision;
+
class Subtitle {
public:
Subtitle(ZVision *engine, const Common::String &subname);
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp
index 6b7299e..0ad9000 100644
--- a/engines/zvision/video.cpp
+++ b/engines/zvision/video.cpp
@@ -26,6 +26,7 @@
#include "zvision/clock.h"
#include "zvision/render_manager.h"
+#include "zvision/subtitles.h"
#include "common/system.h"
@@ -38,90 +39,32 @@
namespace ZVision {
-// 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 * scaleAmount;
- const uint32 pitch = newWidth * bytesPerPixel;
- const byte *srcPtr = src;
-
- if (bytesPerPixel == 1) {
- 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) {
- dst[i] = color;
- dst[pitch + i] = color;
- }
- dst += scaleAmount;
- }
- 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++;
-
- 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;
- }
- dst += pitch;
- }
- }
-}
-
-void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
- byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
-
- uint16 origWidth = videoDecoder.getWidth();
- uint16 origHeight = videoDecoder.getHeight();
-
- uint scale = 1;
+void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) {
+ Common::Rect dst = destRect;
// 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
- scale = destRect.width() / origWidth;
+ if (dst.isEmpty())
+ dst = Common::Rect(vid.getWidth(), vid.getHeight());
- // TODO: Test if we need to support downscale.
- }
-
- uint16 pitch = origWidth * bytesPerPixel;
+ Graphics::Surface *scaled = NULL;
- uint16 finalWidth = origWidth * scale;
- uint16 finalHeight = origHeight * scale;
-
- byte *scaledVideoFrameBuffer;
- if (scale != 1) {
- scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
+ if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height()) {
+ scaled = new Graphics::Surface;
+ scaled->create(dst.width(), dst.height(), vid.getPixelFormat());
}
- uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
- uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;
+
+ uint16 x = _workingWindow.left + dst.left;
+ uint16 y = _workingWindow.top + dst.top;
+ uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width();
+ uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height();
_clock.stop();
- videoDecoder.start();
+ vid.start();
// Only continue while the video is still playing
- while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
+ while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
// Check for engine quit and video stop key presses
- while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
+ while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
@@ -131,7 +74,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
break;
case Common::KEYCODE_SPACE:
if (skippable) {
- videoDecoder.stop();
+ vid.stop();
}
break;
default:
@@ -142,29 +85,32 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
}
}
- if (videoDecoder.needsUpdate()) {
- const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
+ if (vid.needsUpdate()) {
+ const Graphics::Surface *frame = vid.decodeNextFrame();
+ if (sub)
+ sub->process(vid.getCurFrame());
if (frame) {
- if (scale != 1) {
- 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->getPixels(), pitch, x, y, finalWidth, finalHeight);
+ if (scaled) {
+ _renderManager->scaleBuffer(frame->getPixels(), scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, scaled->w, scaled->h);
+ frame = scaled;
}
+ _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, finalWidth, finalHeight);
+ _renderManager->processSubs(0);
}
}
// Always update the screen so the mouse continues to render
_system->updateScreen();
- _system->delayMillis(videoDecoder.getTimeToNextFrame());
+ _system->delayMillis(vid.getTimeToNextFrame() / 2);
}
_clock.start();
- if (scale != 1) {
- delete[] scaledVideoFrameBuffer;
+ if (scaled) {
+ scaled->free();
+ delete scaled;
}
}
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 4c5164c..b1615aa 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -35,6 +35,7 @@
#include "zvision/menu.h"
#include "zvision/search_manager.h"
#include "zvision/text.h"
+#include "zvision/truetype_font.h"
#include "common/config-manager.h"
#include "common/str.h"
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index bbcaf3c..982d3fd 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -54,6 +54,7 @@ class SaveManager;
class RlfAnimation;
class menuHandler;
class textRenderer;
+class Subtitle;
class ZVision : public Engine {
public:
@@ -161,7 +162,7 @@ public:
* @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);
+ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL);
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
Commit: 2a4e9a63588bc462c2a71195bb7597fe81ab0617
https://github.com/scummvm/scummvm/commit/2a4e9a63588bc462c2a71195bb7597fe81ab0617
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-03-05T16:21:03+07:00
Commit Message:
ZVISION: Refactor of save functions
Changed paths:
engines/zvision/save_manager.cpp
engines/zvision/save_manager.h
engines/zvision/script_manager.cpp
engines/zvision/script_manager.h
engines/zvision/timer_node.cpp
diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp
index e8947d8..15b7424 100644
--- a/engines/zvision/save_manager.cpp
+++ b/engines/zvision/save_manager.cpp
@@ -42,44 +42,27 @@ 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));
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
-
- // Write version
- file->writeByte(SAVE_VERSION);
+ writeSaveGameHeader(file, saveName);
- // Write savegame name
- file->writeString(saveName);
- file->writeByte(0);
+ _engine->getScriptManager()->serialize(file);
- // 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());
+ file->finalize();
+ delete file;
+}
- // Skip over the header info
- autoSaveFile->readSint32BE(); // SAVEGAME_ID
- autoSaveFile->readByte(); // Version
- autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL
+void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) {
+ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
- // Read the rest to a buffer
- uint32 size = autoSaveFile->size() - autoSaveFile->pos();
- byte *buffer = new byte[size];
- autoSaveFile->read(buffer, size);
+ writeSaveGameHeader(file, saveName);
- // Then write the buffer to the new file
- file->write(buffer, size);
+ file->write(stream->getData(), stream->size());
- // Cleanup
- delete[] buffer;
file->finalize();
delete file;
}
@@ -87,23 +70,26 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) {
void SaveManager::autoSave() {
Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
-
- // Version
- file->writeByte(SAVE_VERSION);
+ writeSaveGameHeader(file, "auto");
- file->writeString("auto");
- file->writeByte(0);
-
- writeSaveGameData(file);
+ _engine->getScriptManager()->serialize(file);
// Cleanup
file->finalize();
delete file;
}
-void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
+void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) {
+
+ file->writeUint32BE(SAVEGAME_ID);
+
+ // Write version
+ file->writeByte(SAVE_VERSION);
+
+ // Write savegame name
+ file->writeString(saveName);
+ file->writeByte(0);
+
// Create a thumbnail and save it
Graphics::saveThumbnail(*file);
@@ -115,26 +101,13 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
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);
-
}
Common::Error SaveManager::loadGame(uint slot) {
// The games only support 20 slots
- assert(slot <= 1 && slot <= 20);
+ //assert(slot <= 1 && slot <= 20);
- Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
+ Common::SeekableReadStream *saveFile = getSlotFile(slot);
if (saveFile == 0) {
return Common::kPathDoesNotExist;
}
@@ -145,24 +118,59 @@ Common::Error SaveManager::loadGame(uint slot) {
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();
+ // Update the state table values
+ scriptManager->deserialize(saveFile);
+
+ delete saveFile;
+ if (header.thumbnail)
+ delete header.thumbnail;
+
+ return Common::kNoError;
+}
+
+Common::Error SaveManager::loadGame(const Common::String &saveName) {
+ Common::File *saveFile = _engine->getSearchManager()->openFile(saveName);
+ if (saveFile == NULL) {
+ saveFile = new Common::File;
+ if (!saveFile->open(saveName)) {
+ delete saveFile;
+ return Common::kPathDoesNotExist;
+ }
+ }
+
+ // Read the header
+ SaveGameHeader header;
+ if (!readSaveGameHeader(saveFile, header)) {
+ return Common::kUnknownError;
+ }
ScriptManager *scriptManager = _engine->getScriptManager();
// Update the state table values
- scriptManager->deserializeStateTable(saveFile);
+ scriptManager->deserialize(saveFile);
- // Load the room
- scriptManager->changeLocation(world, room, node, view, offset);
+ delete saveFile;
+ if (header.thumbnail)
+ delete header.thumbnail;
return Common::kNoError;
}
bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
- if (in->readUint32BE() != SAVEGAME_ID) {
+ uint32 tag = in->readUint32BE();
+ if (tag == MKTAG('Z', 'N', 'S', 'G')) {
+ header.saveYear = 0;
+ header.saveMonth = 0;
+ header.saveDay = 0;
+ header.saveHour = 0;
+ header.saveMinutes = 0;
+ header.saveName = "Original Save";
+ header.thumbnail = NULL;
+ header.version = SAVE_ORIGINAL;
+ in->seek(-4, SEEK_CUR);
+ return true;
+ }
+ if (tag != SAVEGAME_ID) {
warning("File is not a ZVision save file. Aborting load");
return false;
}
@@ -198,4 +206,29 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea
return true;
}
+Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
+ Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
+ if (saveFile == NULL) {
+ // Try to load standart save file
+ Common::String filename;
+ if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ filename.format("inqsav%u.sav", slot);
+ else if (_engine->getGameId() == GID_NEMESIS)
+ filename.format("nemsav%u.sav", slot);
+
+ saveFile = _engine->getSearchManager()->openFile(filename);
+ if (saveFile == NULL) {
+ Common::File *tmpFile = new Common::File;
+ if (!tmpFile->open(filename)) {
+ delete tmpFile;
+ } else {
+ saveFile = tmpFile;
+ }
+ }
+
+ }
+
+ return saveFile;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h
index ec80b37..84afc8c 100644
--- a/engines/zvision/save_manager.h
+++ b/engines/zvision/save_manager.h
@@ -24,6 +24,7 @@
#define ZVISION_SAVE_MANAGER_H
#include "common/savefile.h"
+#include "common/memstream.h"
namespace Common {
class String;
@@ -54,6 +55,7 @@ private:
static const uint32 SAVEGAME_ID;
enum {
+ SAVE_ORIGINAL = 0,
SAVE_VERSION = 1
};
@@ -73,6 +75,7 @@ public:
* @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);
+ void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream);
/**
* Loads the state data from the save file that slot references. Uses
* ZVision::generateSaveFileName(slot) to get the save file name.
@@ -80,10 +83,12 @@ public:
* @param slot The save slot to load. Must be [1, 20]
*/
Common::Error loadGame(uint slot);
+ Common::Error loadGame(const Common::String &saveName);
+ Common::SeekableReadStream *getSlotFile(uint slot);
+ bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header);
private:
- void writeSaveGameData(Common::OutSaveFile *file);
- bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
+ void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName);
};
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 54d126f..5e101cb 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -30,6 +30,7 @@
#include "zvision/save_manager.h"
#include "zvision/actions.h"
#include "zvision/utility.h"
+#include "zvision/timer_node.h"
#include "common/algorithm.h"
#include "common/hashmap.h"
@@ -283,6 +284,13 @@ void ScriptManager::setStateValue(uint32 key, int value) {
queuePuzzles(key);
}
+void ScriptManager::setStateValueSilent(uint32 key, int value) {
+ if (value == 0)
+ _globalState.erase(key);
+ else
+ _globalState[key] = value;
+}
+
uint ScriptManager::getStateFlag(uint32 key) {
if (_globalStateFlags.contains(key))
return _globalStateFlags[key];
@@ -296,6 +304,13 @@ void ScriptManager::setStateFlag(uint32 key, uint value) {
_globalStateFlags[key] |= value;
}
+void ScriptManager::setStateFlagSilent(uint32 key, uint value) {
+ if (value == 0)
+ _globalStateFlags.erase(key);
+ else
+ _globalStateFlags[key] = value;
+}
+
void ScriptManager::unsetStateFlag(uint32 key, uint value) {
queuePuzzles(key);
@@ -560,30 +575,114 @@ void ScriptManager::do_changeLocation() {
}
}
-void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
- // Write the number of state value entries
- stream->writeUint32LE(_globalState.size());
+void ScriptManager::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('Z', 'N', 'S', 'G'));
+ stream->writeUint32LE(4);
+ stream->writeUint32LE(0);
+ stream->writeUint32BE(MKTAG('L', 'O', 'C', ' '));
+ stream->writeUint32LE(8);
+ stream->writeByte(getStateValue(StateKey_World));
+ stream->writeByte(getStateValue(StateKey_Room));
+ stream->writeByte(getStateValue(StateKey_Node));
+ stream->writeByte(getStateValue(StateKey_View));
+ stream->writeUint32LE(getStateValue(StateKey_ViewPos));
- for (StateMap::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) {
- // Write out the key/value pair
- stream->writeUint32LE(iter->_key);
- stream->writeUint32LE(iter->_value);
- }
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter)
+ (*iter)->serialize(stream);
+
+ stream->writeUint32BE(MKTAG('F', 'L', 'A', 'G'));
+
+ int32 slots = 20000;
+ if (_engine->getGameId() == GID_NEMESIS)
+ slots = 30000;
+
+ stream->writeUint32LE(slots * 2);
+
+ for (int32 i = 0; i < slots; i++)
+ stream->writeUint16LE(getStateFlag(i));
+
+ stream->writeUint32BE(MKTAG('P', 'U', 'Z', 'Z'));
+
+ stream->writeUint32LE(slots * 2);
+
+ for (int32 i = 0; i < slots; i++)
+ stream->writeSint16LE(getStateValue(i));
}
-void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
+void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
// Clear out the current table values
_globalState.clear();
+ _globalStateFlags.clear();
- // Read the number of key/value pairs
- uint32 numberOfPairs = stream->readUint32LE();
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+ cleanScriptScope(world);
- 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
- _globalState[key] = value;
+ _currentLocation.node = 0;
+ _currentLocation.world = 0;
+ _currentLocation.room = 0;
+ _currentLocation.view = 0;
+
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++)
+ delete(*iter);
+
+ _activeSideFx.clear();
+
+ _referenceTable.clear();
+
+ if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) {
+ changeLocation('g', 'a', 'r', 'y', 0);
+ debug("ZNSG");
+ return;
}
+
+ stream->seek(4, SEEK_CUR);
+
+ if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) {
+ changeLocation('g', 'a', 'r', 'y', 0);
+ debug("LOC");
+ return;
+ }
+
+ Location next_loc;
+
+ next_loc.world = stream->readByte();
+ next_loc.room = stream->readByte();
+ next_loc.node = stream->readByte();
+ next_loc.view = stream->readByte();
+ next_loc.offset = stream->readUint32LE() & 0x0000FFFF;
+
+ // What the fck, eos is not 'return pos >= size'
+ // while (!stream->eos()) {*/
+ while (stream->pos() < stream->size()) {
+ uint32 tag = stream->readUint32BE();
+ uint32 tag_size = stream->readUint32LE();
+ switch (tag) {
+ case MKTAG('T', 'I', 'M', 'R'): {
+ uint32 key = stream->readUint32LE();
+ uint32 time = stream->readUint32LE();
+ addSideFX(new TimerNode(_engine, key, time));
+ }
+ break;
+ case MKTAG('F', 'L', 'A', 'G'):
+ for (uint32 i = 0; i < tag_size / 2; i++)
+ setStateFlagSilent(i, stream->readUint16LE());
+ break;
+ case MKTAG('P', 'U', 'Z', 'Z'):
+ for (uint32 i = 0; i < tag_size / 2; i++)
+ setStateValueSilent(i, stream->readUint16LE());
+ break;
+ default:
+ stream->seek(tag_size, SEEK_CUR);
+ }
+ }
+
+ _nextLocation = next_loc;
+
+ do_changeLocation();
+ // Place for read prefs
+ _engine->setRenderDelay(10);
+ setStateValue(StateKey_RestoreFlag, 1);
}
Location ScriptManager::getCurrentLocation() const {
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 2f585b6..6adade5 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -230,8 +230,8 @@ public:
/** Mark next location */
void changeLocation(char world, char room, char node, char view, uint32 offset);
- void serializeStateTable(Common::WriteStream *stream);
- void deserializeStateTable(Common::SeekableReadStream *stream);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
Location getCurrentLocation() const;
@@ -253,6 +253,8 @@ private:
int16 invertory_getItem(int8 id);
void invertory_setItem(int8 id, int16 item);
+ void setStateFlagSilent(uint32 key, uint value);
+ void setStateValueSilent(uint32 key, int value);
public:
void invertory_add(int16 item);
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index f8da0bc..0d7f9b1 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -67,8 +67,10 @@ bool TimerNode::stop() {
}
void TimerNode::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
+ stream->writeUint32LE(8); // size
stream->writeUint32LE(_key);
- stream->writeUint32LE(_timeLeft);
+ stream->writeUint32LE(_timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100));
}
void TimerNode::deserialize(Common::SeekableReadStream *stream) {
Commit: 5eb6462d60a27ef158afbfc23b578b6f57f8f789
https://github.com/scummvm/scummvm/commit/5eb6462d60a27ef158afbfc23b578b6f57f8f789
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-05T18:29:55+07:00
Commit Message:
ZVISION: Remove forgotten debug prints
Changed paths:
engines/zvision/script_manager.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 5e101cb..2178887 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -632,7 +632,6 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) {
changeLocation('g', 'a', 'r', 'y', 0);
- debug("ZNSG");
return;
}
@@ -640,7 +639,6 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) {
changeLocation('g', 'a', 'r', 'y', 0);
- debug("LOC");
return;
}
Commit: 5f92871a9c76d5f8bda74c10ef304c3ec1a328f5
https://github.com/scummvm/scummvm/commit/5f92871a9c76d5f8bda74c10ef304c3ec1a328f5
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-05T18:44:23+07:00
Commit Message:
ZVISION: Fix timer values for savegame
Changed paths:
engines/zvision/script_manager.cpp
engines/zvision/timer_node.cpp
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 2178887..1a56739 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -659,6 +659,10 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
case MKTAG('T', 'I', 'M', 'R'): {
uint32 key = stream->readUint32LE();
uint32 time = stream->readUint32LE();
+ if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ time /= 100;
+ else if (_engine->getGameId() == GID_NEMESIS)
+ time /= 1000;
addSideFX(new TimerNode(_engine, key, time));
}
break;
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index 0d7f9b1..a94f6db 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -70,7 +70,7 @@ void TimerNode::serialize(Common::WriteStream *stream) {
stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
stream->writeUint32LE(8); // size
stream->writeUint32LE(_key);
- stream->writeUint32LE(_timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100));
+ stream->writeUint32LE(_timeLeft);
}
void TimerNode::deserialize(Common::SeekableReadStream *stream) {
Commit: 26d923e354d22a3d8aeb007f4d6f1e5dc669efb4
https://github.com/scummvm/scummvm/commit/26d923e354d22a3d8aeb007f4d6f1e5dc669efb4
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-05T18:47:52+07:00
Commit Message:
ZVISION: Fix incompatibility of puzzle flugs with original saves.
Changed paths:
engines/zvision/puzzle.h
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index e06b087..4d50756 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -65,8 +65,8 @@ struct Puzzle {
enum StateFlags {
ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
- DISABLED = 0x04
+ DISABLED = 0x02,
+ DO_ME_NOW = 0x04
};
uint32 key;
Commit: 7d1c4ec27cb197ea729ab468ecd7f4cbd4594202
https://github.com/scummvm/scummvm/commit/7d1c4ec27cb197ea729ab468ecd7f4cbd4594202
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-03-06T15:22:05+07:00
Commit Message:
ZVISION: Fix rlf incorrect ABS -128 issue
Changed paths:
engines/zvision/rlf_animation.cpp
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index f23f569..5784df0 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -268,6 +268,7 @@ void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) {
void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
uint32 sourceOffset = 0;
uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
while (sourceOffset < sourceSize) {
int8 numberOfSamples = source[sourceOffset];
@@ -276,9 +277,9 @@ 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);
+ numberOfCopy = -numberOfSamples;
- while (numberOfSamples > 0) {
+ while (numberOfCopy > 0) {
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
@@ -293,7 +294,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
sourceOffset += 2;
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
// If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
@@ -314,6 +315,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
uint32 sourceOffset = 0;
uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
while (sourceOffset < sourceSize) {
int8 numberOfSamples = source[sourceOffset];
@@ -322,9 +324,9 @@ 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);
+ numberOfCopy = -numberOfSamples;
- while (numberOfSamples > 0) {
+ while (numberOfCopy > 0) {
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
@@ -339,7 +341,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
sourceOffset += 2;
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
// If numberOfSamples is >= 0, copy one sample from source to the
@@ -354,8 +356,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
sourceOffset += 2;
- numberOfSamples += 2;
- while (numberOfSamples > 0) {
+ numberOfCopy = numberOfSamples + 2;
+ while (numberOfCopy > 0) {
if (destOffset + 1 >= destSize) {
debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
@@ -363,7 +365,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
WRITE_UINT16(dest + destOffset, sampleColor);
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
}
}
Commit: 84681a2439047b9c6a5fd0c89f9be383bd51ad7e
https://github.com/scummvm/scummvm/commit/84681a2439047b9c6a5fd0c89f9be383bd51ad7e
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-03-06T15:24:18+07:00
Commit Message:
ZVISION: SearchManager dir index in ZIX-file started from 1 not 0, include up border
Changed paths:
engines/zvision/search_manager.cpp
diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp
index 5c94ff0..124a499 100644
--- a/engines/zvision/search_manager.cpp
+++ b/engines/zvision/search_manager.cpp
@@ -211,7 +211,7 @@ void sManager::loadZix(const Common::String &name) {
uint dr = 0;
char buf[32];
if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
- if (dr < archives.size() && dr > 0) {
+ if (dr <= archives.size() && dr > 0) {
addFile(Common::String(buf), archives[dr - 1]);
}
}
Commit: 74fe47748e11cc58aee46e986d6670636c027e32
https://github.com/scummvm/scummvm/commit/74fe47748e11cc58aee46e986d6670636c027e32
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-07T08:16:17+07:00
Commit Message:
ZVISION: Fix slot rendering for item-to-item click
Changed paths:
engines/zvision/slot_control.cpp
diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp
index 418aa8f..111a7c6 100644
--- a/engines/zvision/slot_control.cpp
+++ b/engines/zvision/slot_control.cpp
@@ -168,11 +168,18 @@ bool SlotControl::process(uint32 deltaTimeInMillis) {
if (_engine->canRender()) {
int cur_item = _engine->getScriptManager()->getStateValue(_key);
if (cur_item != _rendered_item) {
- if (_rendered_item == 0) {
- if (_bkg)
- delete _bkg;
+ if (_rendered_item != 0 && cur_item == 0) {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ _rendered_item = cur_item;
+ } else {
+ if (_rendered_item == 0) {
+ if (_bkg)
+ delete _bkg;
- _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
+ _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
+ } else {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ }
char buf[16];
if (_engine->getGameId() == GID_NEMESIS)
@@ -196,9 +203,6 @@ bool SlotControl::process(uint32 deltaTimeInMillis) {
delete srf;
_rendered_item = cur_item;
- } else {
- _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
- _rendered_item = cur_item;
}
}
}
Commit: ea6e151047641563f588b6578aea80141f51bbd0
https://github.com/scummvm/scummvm/commit/ea6e151047641563f588b6578aea80141f51bbd0
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-09T23:18:05+07:00
Commit Message:
ZVISION: Add support for sharp(monochrome) font loading
Changed paths:
engines/zvision/text.cpp
engines/zvision/text.h
engines/zvision/truetype_font.cpp
engines/zvision/truetype_font.h
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp
index 575ca03..e96bf4b 100644
--- a/engines/zvision/text.cpp
+++ b/engines/zvision/text.cpp
@@ -58,6 +58,7 @@ cTxtStyle::cTxtStyle() {
strikeout = false;
underline = false;
statebox = 0;
+ sharp = false;
}
txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
@@ -263,6 +264,9 @@ void cTxtStyle::setFontStyle(sTTFont &font) {
if (strikeout)
temp_stl |= sTTFont::STTF_STRIKEOUT;
+ if (sharp)
+ temp_stl |= sTTFont::STTF_SHARP;
+
font.setStyle(temp_stl);
}
@@ -281,6 +285,9 @@ void cTxtStyle::setFont(sTTFont &font) {
if (strikeout)
temp_stl |= sTTFont::STTF_STRIKEOUT;
+ if (sharp)
+ temp_stl |= sTTFont::STTF_SHARP;
+
font.loadFont(fontname, size, temp_stl);
}
diff --git a/engines/zvision/text.h b/engines/zvision/text.h
index 40244f7..6937832 100644
--- a/engines/zvision/text.h
+++ b/engines/zvision/text.h
@@ -74,6 +74,7 @@ public:
bool strikeout;
bool skipcolor;
int32 statebox;
+ bool sharp;
// char image ??
};
diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp
index 5e1bc7a..e3eea40 100644
--- a/engines/zvision/truetype_font.cpp
+++ b/engines/zvision/truetype_font.cpp
@@ -189,6 +189,8 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
newFontName = "arial.ttf";
}
+ bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
+
Common::File *file = _engine->getSearchManager()->openFile(newFontName);
if (!file) {
@@ -210,7 +212,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
if (themeArchive->hasFile("FreeSans.ttf")) {
Common::SeekableReadStream *stream = nullptr;
stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
- Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60); // 66 dpi for 640 x 480 on 14" display
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
@@ -223,7 +225,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
themeArchive = nullptr;
}
} else {
- Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60); // 66 dpi for 640 x 480 on 14" display
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
@@ -241,7 +243,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
}
void sTTFont::setStyle(uint newStyle) {
- if ((_style & (STTF_BOLD | STTF_ITALIC)) != (newStyle & (STTF_BOLD | STTF_ITALIC))) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) {
_style = newStyle;
loadFont(_fntName, _lineHeight);
} else {
diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h
index 0462f35..497ac76 100644
--- a/engines/zvision/truetype_font.h
+++ b/engines/zvision/truetype_font.h
@@ -86,7 +86,8 @@ public:
STTF_BOLD = 1,
STTF_ITALIC = 2,
STTF_UNDERLINE = 4,
- STTF_STRIKEOUT = 8
+ STTF_STRIKEOUT = 8,
+ STTF_SHARP = 16
};
private:
Commit: 6ca301c3205cf04e4aa37c16e21224223233ea9b
https://github.com/scummvm/scummvm/commit/6ca301c3205cf04e4aa37c16e21224223233ea9b
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-09T23:19:17+07:00
Commit Message:
ZVISION: Add utf8 char length and utf8->uint16 functions
Changed paths:
engines/zvision/text.cpp
engines/zvision/text.h
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp
index e96bf4b..2fdfafc 100644
--- a/engines/zvision/text.cpp
+++ b/engines/zvision/text.cpp
@@ -515,5 +515,35 @@ Common::String readWideLine(Common::SeekableReadStream &stream) {
return asciiString;
}
+int8 getUtf8CharSize(char chr) {
+ if ((chr & 0x80) == 0)
+ return 1;
+ else if ((chr & 0xE0) == 0xC0)
+ return 2;
+ else if ((chr & 0xF0) == 0xE0)
+ return 3;
+ else if ((chr & 0xF8) == 0xF0)
+ return 4;
+ else if ((chr & 0xFC) == 0xF8)
+ return 5;
+ else if ((chr & 0xFE) == 0xFC)
+ return 6;
+
+ return 1;
+}
+
+uint16 readUtf8Char(const char *chr) {
+ uint16 result = 0;
+ if ((chr[0] & 0x80) == 0)
+ result = chr[0];
+ else if ((chr[0] & 0xE0) == 0xC0)
+ result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F);
+ else if ((chr[0] & 0xF0) == 0xE0)
+ result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F);
+ else
+ result = chr[0];
+
+ return result;
+}
} // End of namespace ZVision
diff --git a/engines/zvision/text.h b/engines/zvision/text.h
index 6937832..c1dc0c1 100644
--- a/engines/zvision/text.h
+++ b/engines/zvision/text.h
@@ -92,6 +92,8 @@ private:
};
Common::String readWideLine(Common::SeekableReadStream &stream);
+int8 getUtf8CharSize(char chr);
+uint16 readUtf8Char(const char *chr);
} // End of namespace ZVision
Commit: 48360645dcd5f8fddb135b6e31ae5cae4be8d77f
https://github.com/scummvm/scummvm/commit/48360645dcd5f8fddb135b6e31ae5cae4be8d77f
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-03-09T23:20:27+07:00
Commit Message:
ZVISION: Implement ttyText action
Changed paths:
A engines/zvision/ttytext_node.cpp
A engines/zvision/ttytext_node.h
engines/zvision/actions.cpp
engines/zvision/actions.h
engines/zvision/module.mk
engines/zvision/scr_file_handling.cpp
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 99fa6a6..f60a697 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -33,6 +33,7 @@
#include "zvision/music_node.h"
#include "zvision/syncsound_node.h"
#include "zvision/animation_node.h"
+#include "zvision/ttytext_node.h"
#include "common/file.h"
@@ -653,4 +654,28 @@ bool ActionTimer::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionTtyText
+//////////////////////////////////////////////////////////////////////////////
+
+ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char filename[64];
+ int32 x1, y1, x2, y2;
+ sscanf(line.c_str(), "%d %d %d %d %s %u", &x1, &y1, &x2, &y2, filename, &_delay);
+ _r = Common::Rect(x1, y1, x2, y2);
+ _filename = Common::String(filename);
+}
+
+ActionTtyText::~ActionTtyText() {
+ _engine->getScriptManager()->killSideFx(_slotkey);
+}
+
+bool ActionTtyText::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
+ return true;
+ _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotkey, _filename, _r, _delay));
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index bc88a6d..82532ce 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -24,6 +24,7 @@
#define ZVISION_ACTIONS_H
#include "common/str.h"
+#include "common/rect.h"
#include "audio/mixer.h"
@@ -401,6 +402,17 @@ private:
ValueSlot *_time;
};
+class ActionTtyText : public ResultAction {
+public:
+ ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionTtyText();
+ bool execute();
+
+private:
+ Common::String _filename;
+ uint32 _delay;
+ Common::Rect _r;
+};
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 90a2975..d6d0dd7 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -39,7 +39,8 @@ MODULE_OBJS := \
search_manager.o \
text.o \
subtitles.o \
- syncsound_node.o
+ syncsound_node.o \
+ ttytext_node.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 347c3a6..9d1d0bf 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -281,7 +281,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("timer", true)) {
actionList.push_back(new ActionTimer(_engine, slot, args));
} else if (act.matchString("ttytext", true)) {
- // TODO: Implement ActionTTYText
+ actionList.push_back(new ActionTtyText(_engine, slot, args));
} else if (act.matchString("universe_music", true)) {
actionList.push_back(new ActionMusic(_engine, slot, args, true));
} else if (act.matchString("copy_file", true)) {
diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp
new file mode 100644
index 0000000..4f64800
--- /dev/null
+++ b/engines/zvision/ttytext_node.cpp
@@ -0,0 +1,175 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/ttytext_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/script_manager.h"
+#include "zvision/render_manager.h"
+#include "zvision/text.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+
+
+namespace ZVision {
+
+ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
+ SideFX(engine, key, SIDEFX_TTYTXT),
+ _fnt(engine) {
+ _delay = delay;
+ _r = r;
+ _txtpos = 0;
+ _nexttime = 0;
+ _dx = 0;
+ _dy = 0;
+
+ Common::File *infile = _engine->getSearchManager()->openFile(file);
+ if (infile) {
+ while (!infile->eos()) {
+ Common::String asciiLine = readWideLine(*infile);
+ if (asciiLine.empty()) {
+ continue;
+ }
+ _txtbuf += asciiLine;
+ }
+
+ delete infile;
+ }
+ _img.create(_r.width(), _r.height(), _engine->_pixelFormat);
+ _style.sharp = true;
+ _style.readAllStyle(_txtbuf);
+ _style.setFont(_fnt);
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+ttyTextNode::~ttyTextNode() {
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ _img.free();
+}
+
+bool ttyTextNode::process(uint32 deltaTimeInMillis) {
+ _nexttime -= deltaTimeInMillis;
+
+ if (_nexttime < 0) {
+ if (_txtpos < _txtbuf.size()) {
+ if (_txtbuf[_txtpos] == '<') {
+ int32 strt = _txtpos;
+ int32 endt = 0;
+ int16 ret = 0;
+ while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
+ _txtpos++;
+ endt = _txtpos;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (ret & TXT_RET_FNTCHG)
+ _style.setFont(_fnt);
+ if (ret & TXT_RET_FNTSTL)
+ _style.setFontStyle(_fnt);
+
+ if (ret & TXT_RET_NEWLN)
+ newline();
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf;
+ buf.format("%d", _style.statebox);
+
+ for (uint8 j = 0; j < buf.size(); j++)
+ outchar(buf[j]);
+ }
+
+ _txtpos++;
+ } else {
+ int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
+
+ uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ if (chr == ' ') {
+ uint32 i = _txtpos + charsz;
+ uint16 width = _fnt.getCharWidth(chr);
+
+ while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
+
+ int8 chsz = getUtf8CharSize(_txtbuf[i]);
+ uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ width += _fnt.getCharWidth(uchr);
+
+ i += chsz;
+ }
+
+ if (_dx + width > _r.width())
+ newline();
+ else
+ outchar(chr);
+ } else
+ outchar(chr);
+
+ _txtpos += charsz;
+ }
+ _nexttime = _delay;
+ _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
+ } else
+ return stop();
+ }
+
+ return false;
+}
+
+void ttyTextNode::scroll() {
+ int32 scrl = 0;
+ while (_dy - scrl > _r.height() - _fnt.getFontHeight())
+ scrl += _fnt.getFontHeight();
+ int8 *pixels = (int8 *)_img.getPixels();
+ for (uint16 h = scrl; h < _img.h; h++)
+ memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
+
+ _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
+ _dy -= scrl;
+}
+
+void ttyTextNode::newline() {
+ _dy += _fnt.getFontHeight();
+ _dx = 0;
+}
+
+void ttyTextNode::outchar(uint16 chr) {
+ uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue);
+
+ if (_dx + _fnt.getCharWidth(chr) > _r.width())
+ newline();
+
+ if (_dy + _fnt.getFontHeight() >= _r.height())
+ scroll();
+
+ _fnt.drawChar(&_img, chr, _dx, _dy, clr);
+
+ _dx += _fnt.getCharWidth(chr);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h
new file mode 100644
index 0000000..6c3e6f4
--- /dev/null
+++ b/engines/zvision/ttytext_node.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_TTYTEXT_NODE_H
+#define ZVISION_TTYTEXT_NODE_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "zvision/sidefx.h"
+#include "zvision/text.h"
+#include "zvision/truetype_font.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class ttyTextNode : public SideFX {
+public:
+ ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
+ ~ttyTextNode();
+
+ /**
+ * 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:
+ Common::Rect _r;
+ //int16 x;
+ //int16 y;
+ //uint16 w;
+ //uint16 h;
+ cTxtStyle _style;
+ sTTFont _fnt;
+ Common::String _txtbuf;
+ uint32 _txtpos;
+ //int32 txtsize;
+ int32 _delay;
+ int32 _nexttime;
+ Graphics::Surface _img;
+ int16 _dx;
+ int16 _dy;
+private:
+
+ void newline();
+ void scroll();
+ void outchar(uint16 chr);
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 45589950c0fb1a449351e6a00ef10d42290d8bae
https://github.com/scummvm/scummvm/commit/45589950c0fb1a449351e6a00ef10d42290d8bae
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-06-13T21:43:04+07:00
Commit Message:
Merge remote-tracking branch 'upstream/master' into zvision
Conflicts:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation_control.h
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/inventory/inventory_manager.h
engines/zvision/inventory_manager.h
engines/zvision/meta_animation.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/animation_control.cpp
engines/zvision/scripting/controls/animation_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/timer_node.cpp
engines/zvision/scripting/controls/timer_node.h
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/sidefx.cpp
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
Changed paths:
A backends/graphics/opengl/debug.cpp
A backends/graphics/opengl/debug.h
A backends/graphics/opengl/extensions.cpp
A backends/graphics/opengl/extensions.h
A backends/graphics/opengl/opengl-sys.h
A backends/graphics/opengl/texture.cpp
A backends/graphics/opengl/texture.h
A backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
A backends/platform/ps2/Makefile.ps2.dev
A backends/platform/ps2/README.PS2
A backends/platform/symbian/help/Custom.xml
A backends/platform/symbian/help/ScummVM.rtf
A backends/platform/symbian/help/ScummVM.xml
A backends/platform/symbian/help/build_help.mk
A backends/platform/symbian/mmp/scummvm_avalanche.mmp.in
A backends/platform/symbian/mmp/scummvm_bbvs.mmp.in
A backends/platform/symbian/mmp/scummvm_dreamweb.mmp.in
A backends/platform/symbian/mmp/scummvm_fullpipe.mmp.in
A backends/platform/symbian/mmp/scummvm_mads.mmp.in
A backends/platform/symbian/mmp/scummvm_mortevielle.mmp.in
A backends/platform/symbian/mmp/scummvm_neverhood.mmp.in
A backends/platform/symbian/mmp/scummvm_sword25.mmp.in
A backends/platform/symbian/mmp/scummvm_testbed.mmp.in
A backends/platform/symbian/mmp/scummvm_voyeur.mmp.in
A backends/platform/symbian/mmp/scummvm_zvision.mmp.in
A backends/taskbar/macosx/macosx-taskbar.h
A backends/taskbar/macosx/macosx-taskbar.mm
A common/ustr.cpp
A common/ustr.h
A devtools/create_kyradat/resources.cpp
A devtools/create_kyradat/resources.h
A devtools/create_kyradat/resources/eob1_dos.h
A devtools/create_kyradat/resources/eob1_dos_english.h
A devtools/create_kyradat/resources/eob1_dos_german.h
A devtools/create_kyradat/resources/eob2_dos.h
A devtools/create_kyradat/resources/eob2_dos_english.h
A devtools/create_kyradat/resources/eob2_dos_german.h
A devtools/create_kyradat/resources/hof_dos.h
A devtools/create_kyradat/resources/hof_dos_cd.h
A devtools/create_kyradat/resources/hof_dos_cd_english.h
A devtools/create_kyradat/resources/hof_dos_cd_french.h
A devtools/create_kyradat/resources/hof_dos_cd_german.h
A devtools/create_kyradat/resources/hof_dos_cd_italian.h
A devtools/create_kyradat/resources/hof_dos_cd_russian.h
A devtools/create_kyradat/resources/hof_dos_cddemo.h
A devtools/create_kyradat/resources/hof_dos_cddemo_english.h
A devtools/create_kyradat/resources/hof_dos_cddemo_french.h
A devtools/create_kyradat/resources/hof_dos_cddemo_german.h
A devtools/create_kyradat/resources/hof_dos_demo.h
A devtools/create_kyradat/resources/hof_dos_english.h
A devtools/create_kyradat/resources/hof_dos_french.h
A devtools/create_kyradat/resources/hof_dos_german.h
A devtools/create_kyradat/resources/hof_dos_italian.h
A devtools/create_kyradat/resources/hof_dos_russian.h
A devtools/create_kyradat/resources/hof_fmtowns.h
A devtools/create_kyradat/resources/hof_fmtowns_english.h
A devtools/create_kyradat/resources/hof_fmtowns_japanese.h
A devtools/create_kyradat/resources/hof_pc98.h
A devtools/create_kyradat/resources/hof_pc98_english.h
A devtools/create_kyradat/resources/hof_pc98_japanese.h
A devtools/create_kyradat/resources/lok_amiga.h
A devtools/create_kyradat/resources/lok_amiga_english.h
A devtools/create_kyradat/resources/lok_amiga_german.h
A devtools/create_kyradat/resources/lok_dos.h
A devtools/create_kyradat/resources/lok_dos_cd.h
A devtools/create_kyradat/resources/lok_dos_cd_english.h
A devtools/create_kyradat/resources/lok_dos_cd_french.h
A devtools/create_kyradat/resources/lok_dos_cd_german.h
A devtools/create_kyradat/resources/lok_dos_cd_italian.h
A devtools/create_kyradat/resources/lok_dos_cddemo.h
A devtools/create_kyradat/resources/lok_dos_cddemo_english.h
A devtools/create_kyradat/resources/lok_dos_demo.h
A devtools/create_kyradat/resources/lok_dos_demo_english.h
A devtools/create_kyradat/resources/lok_dos_english.h
A devtools/create_kyradat/resources/lok_dos_french.h
A devtools/create_kyradat/resources/lok_dos_german.h
A devtools/create_kyradat/resources/lok_dos_italian.h
A devtools/create_kyradat/resources/lok_dos_oldfloppy.h
A devtools/create_kyradat/resources/lok_dos_oldfloppy_russian.h
A devtools/create_kyradat/resources/lok_dos_spanish.h
A devtools/create_kyradat/resources/lok_fmtowns.h
A devtools/create_kyradat/resources/lok_fmtowns_english.h
A devtools/create_kyradat/resources/lok_fmtowns_japanese.h
A devtools/create_kyradat/resources/lok_pc98.h
A devtools/create_kyradat/resources/lok_pc98_japanese.h
A devtools/create_kyradat/resources/lol_dos.h
A devtools/create_kyradat/resources/lol_dos_cd.h
A devtools/create_kyradat/resources/lol_dos_cd_english.h
A devtools/create_kyradat/resources/lol_dos_cd_french.h
A devtools/create_kyradat/resources/lol_dos_cd_german.h
A devtools/create_kyradat/resources/lol_dos_cd_italian.h
A devtools/create_kyradat/resources/lol_dos_cd_russian.h
A devtools/create_kyradat/resources/lol_dos_demo.h
A devtools/create_kyradat/resources/lol_dos_demo_english.h
A devtools/create_kyradat/resources/lol_dos_english.h
A devtools/create_kyradat/resources/lol_dos_french.h
A devtools/create_kyradat/resources/lol_dos_german.h
A devtools/create_kyradat/resources/lol_dos_russian.h
A devtools/create_kyradat/resources/lol_fmtowns.h
A devtools/create_kyradat/resources/lol_fmtowns_japanese.h
A devtools/create_kyradat/resources/lol_pc98.h
A devtools/create_kyradat/resources/lol_pc98_japanese.h
A devtools/create_kyradat/resources/mr_dos_cd.h
A devtools/create_kyradat/types.cpp
A devtools/create_kyradat/types.h
A devtools/create_project/scripts/install-natvis.bat
A devtools/create_project/scripts/scummvm.natvis
A engines/agi/configure.engine
A engines/agos/configure.engine
A engines/avalanche/clock.cpp
A engines/avalanche/clock.h
A engines/avalanche/configure.engine
A engines/avalanche/dropdown.cpp
A engines/avalanche/dropdown.h
A engines/avalanche/ghostroom.cpp
A engines/avalanche/ghostroom.h
A engines/avalanche/help.cpp
A engines/avalanche/help.h
A engines/avalanche/highscore.cpp
A engines/avalanche/highscore.h
A engines/avalanche/mainmenu.cpp
A engines/avalanche/mainmenu.h
A engines/avalanche/nim.cpp
A engines/avalanche/nim.h
A engines/avalanche/shootemup.cpp
A engines/avalanche/shootemup.h
A engines/bbvs/bbvs.cpp
A engines/bbvs/bbvs.h
A engines/bbvs/configure.engine
A engines/bbvs/detection.cpp
A engines/bbvs/dialogs.cpp
A engines/bbvs/dialogs.h
A engines/bbvs/gamemodule.cpp
A engines/bbvs/gamemodule.h
A engines/bbvs/graphics.cpp
A engines/bbvs/graphics.h
A engines/bbvs/logic.cpp
A engines/bbvs/minigames/bbairguitar.cpp
A engines/bbvs/minigames/bbairguitar.h
A engines/bbvs/minigames/bbairguitar_anims.cpp
A engines/bbvs/minigames/bbant.cpp
A engines/bbvs/minigames/bbant.h
A engines/bbvs/minigames/bbant_anims.cpp
A engines/bbvs/minigames/bbloogie.cpp
A engines/bbvs/minigames/bbloogie.h
A engines/bbvs/minigames/bbloogie_anims.cpp
A engines/bbvs/minigames/bbtennis.cpp
A engines/bbvs/minigames/bbtennis.h
A engines/bbvs/minigames/bbtennis_anims.cpp
A engines/bbvs/minigames/minigame.cpp
A engines/bbvs/minigames/minigame.h
A engines/bbvs/module.mk
A engines/bbvs/saveload.cpp
A engines/bbvs/scene.cpp
A engines/bbvs/sound.cpp
A engines/bbvs/sound.h
A engines/bbvs/spritemodule.cpp
A engines/bbvs/spritemodule.h
A engines/bbvs/videoplayer.cpp
A engines/bbvs/walk.cpp
A engines/cge/configure.engine
A engines/cine/configure.engine
A engines/composer/configure.engine
A engines/composer/console.cpp
A engines/composer/console.h
A engines/cruise/configure.engine
A engines/draci/configure.engine
A engines/drascula/configure.engine
A engines/dreamweb/configure.engine
A engines/fullpipe/configure.engine
A engines/fullpipe/console.cpp
A engines/fullpipe/console.h
A engines/fullpipe/floaters.cpp
A engines/fullpipe/floaters.h
A engines/fullpipe/messagehandlers.cpp
A engines/fullpipe/scenes/scene01.cpp
A engines/fullpipe/scenes/scene02.cpp
A engines/fullpipe/scenes/scene03.cpp
A engines/fullpipe/scenes/scene04.cpp
A engines/fullpipe/scenes/scene05.cpp
A engines/fullpipe/scenes/scene06.cpp
A engines/fullpipe/scenes/scene07.cpp
A engines/fullpipe/scenes/scene08.cpp
A engines/fullpipe/scenes/scene09.cpp
A engines/fullpipe/scenes/scene10.cpp
A engines/fullpipe/scenes/scene11.cpp
A engines/fullpipe/scenes/scene12.cpp
A engines/fullpipe/scenes/scene13.cpp
A engines/fullpipe/scenes/scene14.cpp
A engines/fullpipe/scenes/scene15.cpp
A engines/fullpipe/scenes/scene16.cpp
A engines/fullpipe/scenes/scene17.cpp
A engines/fullpipe/scenes/scene18and19.cpp
A engines/fullpipe/scenes/scene20.cpp
A engines/fullpipe/scenes/scene21.cpp
A engines/fullpipe/scenes/scene22.cpp
A engines/fullpipe/scenes/scene23.cpp
A engines/fullpipe/scenes/scene24.cpp
A engines/fullpipe/scenes/scene25.cpp
A engines/fullpipe/scenes/scene26.cpp
A engines/fullpipe/scenes/scene27.cpp
A engines/fullpipe/scenes/scene28.cpp
A engines/fullpipe/scenes/scene29.cpp
A engines/fullpipe/scenes/scene30.cpp
A engines/fullpipe/scenes/scene31.cpp
A engines/fullpipe/scenes/scene32.cpp
A engines/fullpipe/scenes/scene33.cpp
A engines/fullpipe/scenes/scene34.cpp
A engines/fullpipe/scenes/scene35.cpp
A engines/fullpipe/scenes/scene36.cpp
A engines/fullpipe/scenes/scene37.cpp
A engines/fullpipe/scenes/scene38.cpp
A engines/fullpipe/scenes/sceneDbg.cpp
A engines/fullpipe/scenes/sceneFinal.cpp
A engines/fullpipe/scenes/sceneIntro.cpp
A engines/gob/configure.engine
A engines/gob/detection/tables_crousti.h
A engines/groovie/configure.engine
A engines/hopkins/configure.engine
A engines/hugo/configure.engine
A engines/kyra/configure.engine
A engines/lastexpress/configure.engine
A engines/lure/configure.engine
A engines/made/configure.engine
A engines/mads/action.cpp
A engines/mads/action.h
A engines/mads/animation.cpp
A engines/mads/animation.h
A engines/mads/assets.cpp
A engines/mads/assets.h
A engines/mads/audio.cpp
A engines/mads/audio.h
A engines/mads/compression.cpp
A engines/mads/compression.h
A engines/mads/configure.engine
A engines/mads/debugger.cpp
A engines/mads/debugger.h
A engines/mads/detection.cpp
A engines/mads/detection_tables.h
A engines/mads/dialogs.cpp
A engines/mads/dialogs.h
A engines/mads/dragonsphere/dragonsphere_scenes.cpp
A engines/mads/dragonsphere/dragonsphere_scenes.h
A engines/mads/dragonsphere/game_dragonsphere.cpp
A engines/mads/dragonsphere/game_dragonsphere.h
A engines/mads/events.cpp
A engines/mads/events.h
A engines/mads/font.cpp
A engines/mads/font.h
A engines/mads/game.cpp
A engines/mads/game.h
A engines/mads/game_data.cpp
A engines/mads/game_data.h
A engines/mads/globals.cpp
A engines/mads/globals.h
A engines/mads/hotspots.cpp
A engines/mads/hotspots.h
A engines/mads/inventory.cpp
A engines/mads/inventory.h
A engines/mads/mads.cpp
A engines/mads/mads.h
A engines/mads/messages.cpp
A engines/mads/messages.h
A engines/mads/module.mk
A engines/mads/msurface.cpp
A engines/mads/msurface.h
A engines/mads/nebular/dialogs_nebular.cpp
A engines/mads/nebular/dialogs_nebular.h
A engines/mads/nebular/game_nebular.cpp
A engines/mads/nebular/game_nebular.h
A engines/mads/nebular/globals_nebular.cpp
A engines/mads/nebular/globals_nebular.h
A engines/mads/nebular/nebular_scenes.cpp
A engines/mads/nebular/nebular_scenes.h
A engines/mads/nebular/nebular_scenes1.cpp
A engines/mads/nebular/nebular_scenes1.h
A engines/mads/nebular/nebular_scenes2.cpp
A engines/mads/nebular/nebular_scenes2.h
A engines/mads/nebular/nebular_scenes3.cpp
A engines/mads/nebular/nebular_scenes3.h
A engines/mads/nebular/nebular_scenes4.cpp
A engines/mads/nebular/nebular_scenes4.h
A engines/mads/nebular/nebular_scenes5.cpp
A engines/mads/nebular/nebular_scenes5.h
A engines/mads/nebular/nebular_scenes6.cpp
A engines/mads/nebular/nebular_scenes6.h
A engines/mads/nebular/nebular_scenes7.cpp
A engines/mads/nebular/nebular_scenes7.h
A engines/mads/nebular/nebular_scenes8.cpp
A engines/mads/nebular/nebular_scenes8.h
A engines/mads/nebular/sound_nebular.cpp
A engines/mads/nebular/sound_nebular.h
A engines/mads/palette.cpp
A engines/mads/palette.h
A engines/mads/phantom/game_phantom.cpp
A engines/mads/phantom/game_phantom.h
A engines/mads/phantom/phantom_scenes.cpp
A engines/mads/phantom/phantom_scenes.h
A engines/mads/player.cpp
A engines/mads/player.h
A engines/mads/rails.cpp
A engines/mads/rails.h
A engines/mads/resources.cpp
A engines/mads/resources.h
A engines/mads/scene.cpp
A engines/mads/scene.h
A engines/mads/scene_data.cpp
A engines/mads/scene_data.h
A engines/mads/screen.cpp
A engines/mads/screen.h
A engines/mads/sequence.cpp
A engines/mads/sequence.h
A engines/mads/sound.cpp
A engines/mads/sound.h
A engines/mads/sprites.cpp
A engines/mads/sprites.h
A engines/mads/staticres.cpp
A engines/mads/staticres.h
A engines/mads/user_interface.cpp
A engines/mads/user_interface.h
A engines/mohawk/configure.engine
A engines/mortevielle/configure.engine
A engines/neverhood/configure.engine
A engines/parallaction/configure.engine
A engines/pegasus/configure.engine
A engines/queen/configure.engine
A engines/queen/detection.cpp
A engines/saga/configure.engine
A engines/sci/configure.engine
A engines/sci/engine/script_patches.h
A engines/scumm/configure.engine
A engines/scumm/players/player_ad.cpp
A engines/scumm/players/player_ad.h
A engines/scumm/players/player_apple2.cpp
A engines/scumm/players/player_apple2.h
A engines/scumm/players/player_mac.cpp
A engines/scumm/players/player_mac.h
A engines/scumm/players/player_mod.cpp
A engines/scumm/players/player_mod.h
A engines/scumm/players/player_nes.cpp
A engines/scumm/players/player_nes.h
A engines/scumm/players/player_pce.cpp
A engines/scumm/players/player_pce.h
A engines/scumm/players/player_sid.cpp
A engines/scumm/players/player_sid.h
A engines/scumm/players/player_towns.cpp
A engines/scumm/players/player_towns.h
A engines/scumm/players/player_v1.cpp
A engines/scumm/players/player_v1.h
A engines/scumm/players/player_v2.cpp
A engines/scumm/players/player_v2.h
A engines/scumm/players/player_v2a.cpp
A engines/scumm/players/player_v2a.h
A engines/scumm/players/player_v2base.cpp
A engines/scumm/players/player_v2base.h
A engines/scumm/players/player_v2cms.cpp
A engines/scumm/players/player_v2cms.h
A engines/scumm/players/player_v3a.cpp
A engines/scumm/players/player_v3a.h
A engines/scumm/players/player_v3m.cpp
A engines/scumm/players/player_v3m.h
A engines/scumm/players/player_v4a.cpp
A engines/scumm/players/player_v4a.h
A engines/scumm/players/player_v5m.cpp
A engines/scumm/players/player_v5m.h
A engines/sky/configure.engine
A engines/sword1/configure.engine
A engines/sword2/configure.engine
A engines/sword25/configure.engine
A engines/teenagent/configure.engine
A engines/testbed/configure.engine
A engines/tinsel/configure.engine
A engines/toltecs/configure.engine
A engines/tony/configure.engine
A engines/toon/configure.engine
A engines/touche/configure.engine
A engines/tsage/configure.engine
A engines/tucker/configure.engine
A engines/voyeur/animation.cpp
A engines/voyeur/animation.h
A engines/voyeur/configure.engine
A engines/voyeur/data.cpp
A engines/voyeur/data.h
A engines/voyeur/debugger.cpp
A engines/voyeur/debugger.h
A engines/voyeur/detection.cpp
A engines/voyeur/detection_tables.h
A engines/voyeur/events.cpp
A engines/voyeur/events.h
A engines/voyeur/files.cpp
A engines/voyeur/files.h
A engines/voyeur/files_threads.cpp
A engines/voyeur/graphics.cpp
A engines/voyeur/graphics.h
A engines/voyeur/module.mk
A engines/voyeur/sound.cpp
A engines/voyeur/sound.h
A engines/voyeur/staticres.cpp
A engines/voyeur/staticres.h
A engines/voyeur/voyeur.cpp
A engines/voyeur/voyeur.h
A engines/voyeur/voyeur_game.cpp
A engines/wintermute/configure.engine
A engines/zvision/animation/rlf_animation.cpp
A engines/zvision/animation/rlf_animation.h
A engines/zvision/archives/zfs_archive.cpp
A engines/zvision/archives/zfs_archive.h
A engines/zvision/configure.engine
A engines/zvision/core/console.cpp
A engines/zvision/core/console.h
A engines/zvision/core/events.cpp
A engines/zvision/core/menu.h
A engines/zvision/core/save_manager.cpp
A engines/zvision/core/save_manager.h
A engines/zvision/cursors/cursor.cpp
A engines/zvision/cursors/cursor.h
A engines/zvision/cursors/cursor_manager.cpp
A engines/zvision/cursors/cursor_manager.h
A engines/zvision/fonts/truetype_font.cpp
A engines/zvision/fonts/truetype_font.h
A engines/zvision/graphics/render_manager.cpp
A engines/zvision/graphics/render_manager.h
A engines/zvision/graphics/render_table.cpp
A engines/zvision/graphics/render_table.h
A engines/zvision/scripting/actions.cpp
A engines/zvision/scripting/actions.h
A engines/zvision/scripting/control.cpp
A engines/zvision/scripting/control.h
A engines/zvision/scripting/controls/input_control.cpp
A engines/zvision/scripting/controls/input_control.h
A engines/zvision/scripting/controls/lever_control.cpp
A engines/zvision/scripting/controls/lever_control.h
A engines/zvision/scripting/controls/push_toggle_control.cpp
A engines/zvision/scripting/controls/push_toggle_control.h
A engines/zvision/scripting/controls/timer_node.cpp
A engines/zvision/scripting/controls/timer_node.h
A engines/zvision/scripting/puzzle.h
A engines/zvision/scripting/scr_file_handling.cpp
A engines/zvision/scripting/script_manager.cpp
A engines/zvision/scripting/script_manager.h
A engines/zvision/sound/zork_raw.cpp
A engines/zvision/sound/zork_raw.h
A engines/zvision/strings/string_manager.cpp
A engines/zvision/strings/string_manager.h
A engines/zvision/subtitles/subtitles.h
A engines/zvision/utility/clock.cpp
A engines/zvision/utility/clock.h
A engines/zvision/utility/lzss_read_stream.cpp
A engines/zvision/utility/lzss_read_stream.h
A engines/zvision/utility/single_value_container.cpp
A engines/zvision/utility/single_value_container.h
A engines/zvision/utility/utility.cpp
A engines/zvision/utility/utility.h
A engines/zvision/video/video.cpp
A engines/zvision/video/zork_avi_decoder.cpp
A engines/zvision/video/zork_avi_decoder.h
A image/bmp.cpp
A image/bmp.h
A image/codecs/bmp_raw.cpp
A image/codecs/bmp_raw.h
A image/codecs/cdtoons.cpp
A image/codecs/cdtoons.h
A image/codecs/cinepak.cpp
A image/codecs/cinepak.h
A image/codecs/codec.cpp
A image/codecs/codec.h
A image/codecs/indeo3.cpp
A image/codecs/indeo3.h
A image/codecs/mjpeg.cpp
A image/codecs/mjpeg.h
A image/codecs/mpeg.cpp
A image/codecs/mpeg.h
A image/codecs/msrle.cpp
A image/codecs/msrle.h
A image/codecs/msvideo1.cpp
A image/codecs/msvideo1.h
A image/codecs/qtrle.cpp
A image/codecs/qtrle.h
A image/codecs/rpza.cpp
A image/codecs/rpza.h
A image/codecs/smc.cpp
A image/codecs/smc.h
A image/codecs/svq1.cpp
A image/codecs/svq1.h
A image/codecs/svq1_cb.h
A image/codecs/svq1_vlc.h
A image/codecs/truemotion1.cpp
A image/codecs/truemotion1.h
A image/codecs/truemotion1data.h
A image/iff.cpp
A image/iff.h
A image/image_decoder.h
A image/jpeg.cpp
A image/jpeg.h
A image/module.mk
A image/pcx.cpp
A image/pcx.h
A image/pict.cpp
A image/pict.h
A image/png.cpp
A image/png.h
A image/tga.cpp
A image/tga.h
R backends/graphics/opengl/glerrorcheck.cpp
R backends/graphics/opengl/glerrorcheck.h
R backends/graphics/opengl/gltexture.cpp
R backends/graphics/opengl/gltexture.h
R backends/platform/ps2/Makefile.gdb
R devtools/create_kyradat/extract.cpp
R devtools/create_kyradat/extract.h
R devtools/create_kyradat/search.cpp
R devtools/create_kyradat/search.h
R devtools/create_kyradat/tables.cpp
R devtools/create_kyradat/tables.h
R engines/avalanche/menu.cpp
R engines/avalanche/menu.h
R engines/avalanche/pingo.cpp
R engines/avalanche/pingo.h
R engines/configure.engines
R engines/engines.mk
R engines/plugins_table.h
R engines/scumm/player_ad.cpp
R engines/scumm/player_ad.h
R engines/scumm/player_apple2.cpp
R engines/scumm/player_apple2.h
R engines/scumm/player_mac.cpp
R engines/scumm/player_mac.h
R engines/scumm/player_mod.cpp
R engines/scumm/player_mod.h
R engines/scumm/player_nes.cpp
R engines/scumm/player_nes.h
R engines/scumm/player_pce.cpp
R engines/scumm/player_pce.h
R engines/scumm/player_sid.cpp
R engines/scumm/player_sid.h
R engines/scumm/player_towns.cpp
R engines/scumm/player_towns.h
R engines/scumm/player_v1.cpp
R engines/scumm/player_v1.h
R engines/scumm/player_v2.cpp
R engines/scumm/player_v2.h
R engines/scumm/player_v2a.cpp
R engines/scumm/player_v2a.h
R engines/scumm/player_v2base.cpp
R engines/scumm/player_v2base.h
R engines/scumm/player_v2cms.cpp
R engines/scumm/player_v2cms.h
R engines/scumm/player_v3a.cpp
R engines/scumm/player_v3a.h
R engines/scumm/player_v3m.cpp
R engines/scumm/player_v3m.h
R engines/scumm/player_v4a.cpp
R engines/scumm/player_v4a.h
R engines/scumm/player_v5m.cpp
R engines/scumm/player_v5m.h
R engines/zvision/actions.cpp
R engines/zvision/actions.h
R engines/zvision/clock.cpp
R engines/zvision/clock.h
R engines/zvision/console.cpp
R engines/zvision/console.h
R engines/zvision/control.cpp
R engines/zvision/control.h
R engines/zvision/cursor.cpp
R engines/zvision/cursor.h
R engines/zvision/cursor_manager.cpp
R engines/zvision/cursor_manager.h
R engines/zvision/events.cpp
R engines/zvision/input_control.cpp
R engines/zvision/input_control.h
R engines/zvision/lever_control.cpp
R engines/zvision/lever_control.h
R engines/zvision/lzss_read_stream.cpp
R engines/zvision/lzss_read_stream.h
R engines/zvision/menu.h
R engines/zvision/push_toggle_control.cpp
R engines/zvision/push_toggle_control.h
R engines/zvision/puzzle.h
R engines/zvision/render_manager.cpp
R engines/zvision/render_manager.h
R engines/zvision/render_table.cpp
R engines/zvision/render_table.h
R engines/zvision/rlf_animation.cpp
R engines/zvision/rlf_animation.h
R engines/zvision/save_manager.cpp
R engines/zvision/save_manager.h
R engines/zvision/scr_file_handling.cpp
R engines/zvision/script_manager.cpp
R engines/zvision/script_manager.h
R engines/zvision/single_value_container.cpp
R engines/zvision/single_value_container.h
R engines/zvision/string_manager.cpp
R engines/zvision/string_manager.h
R engines/zvision/subtitles.h
R engines/zvision/timer_node.cpp
R engines/zvision/timer_node.h
R engines/zvision/truetype_font.cpp
R engines/zvision/truetype_font.h
R engines/zvision/utility.cpp
R engines/zvision/utility.h
R engines/zvision/video.cpp
R engines/zvision/zfs_archive.cpp
R engines/zvision/zfs_archive.h
R engines/zvision/zork_avi_decoder.cpp
R engines/zvision/zork_avi_decoder.h
R engines/zvision/zork_raw.cpp
R engines/zvision/zork_raw.h
R graphics/decoders/bmp.cpp
R graphics/decoders/bmp.h
R graphics/decoders/iff.cpp
R graphics/decoders/iff.h
R graphics/decoders/image_decoder.h
R graphics/decoders/jpeg.cpp
R graphics/decoders/jpeg.h
R graphics/decoders/pcx.cpp
R graphics/decoders/pcx.h
R graphics/decoders/pict.cpp
R graphics/decoders/pict.h
R graphics/decoders/png.cpp
R graphics/decoders/png.h
R graphics/decoders/tga.cpp
R graphics/decoders/tga.h
R video/codecs/cdtoons.cpp
R video/codecs/cdtoons.h
R video/codecs/cinepak.cpp
R video/codecs/cinepak.h
R video/codecs/codec.h
R video/codecs/indeo3.cpp
R video/codecs/indeo3.h
R video/codecs/mjpeg.cpp
R video/codecs/mjpeg.h
R video/codecs/mpeg.cpp
R video/codecs/mpeg.h
R video/codecs/msrle.cpp
R video/codecs/msrle.h
R video/codecs/msvideo1.cpp
R video/codecs/msvideo1.h
R video/codecs/qtrle.cpp
R video/codecs/qtrle.h
R video/codecs/rpza.cpp
R video/codecs/rpza.h
R video/codecs/smc.cpp
R video/codecs/smc.h
R video/codecs/svq1.cpp
R video/codecs/svq1.h
R video/codecs/svq1_cb.h
R video/codecs/svq1_vlc.h
R video/codecs/truemotion1.cpp
R video/codecs/truemotion1.h
R video/codecs/truemotion1data.h
.gitignore
AUTHORS
COPYRIGHT
Makefile
Makefile.common
NEWS
README
audio/audiostream.cpp
audio/audiostream.h
audio/decoders/adpcm.cpp
audio/decoders/adpcm.h
audio/decoders/adpcm_intern.h
audio/decoders/aiff.cpp
audio/decoders/aiff.h
audio/decoders/flac.cpp
audio/decoders/flac.h
audio/decoders/iff_sound.cpp
audio/decoders/iff_sound.h
audio/decoders/mac_snd.cpp
audio/decoders/mac_snd.h
audio/decoders/mp3.cpp
audio/decoders/mp3.h
audio/decoders/qdm2.cpp
audio/decoders/qdm2.h
audio/decoders/qdm2data.h
audio/decoders/quicktime.cpp
audio/decoders/raw.cpp
audio/decoders/raw.h
audio/decoders/voc.cpp
audio/decoders/voc.h
audio/decoders/vorbis.cpp
audio/decoders/vorbis.h
audio/decoders/wave.cpp
audio/decoders/wave.h
audio/decoders/xa.cpp
audio/decoders/xa.h
audio/fmopl.cpp
audio/fmopl.h
audio/mididrv.cpp
audio/mididrv.h
audio/midiparser.cpp
audio/midiparser.h
audio/midiparser_qt.cpp
audio/midiparser_qt.h
audio/midiparser_smf.cpp
audio/midiparser_xmidi.cpp
audio/midiplayer.cpp
audio/midiplayer.h
audio/mixer.cpp
audio/mixer.h
audio/mixer_intern.h
audio/mods/infogrames.cpp
audio/mods/infogrames.h
audio/mods/maxtrax.cpp
audio/mods/maxtrax.h
audio/mods/module.cpp
audio/mods/module.h
audio/mods/paula.cpp
audio/mods/paula.h
audio/mods/protracker.cpp
audio/mods/protracker.h
audio/mods/rjp1.cpp
audio/mods/rjp1.h
audio/mods/soundfx.cpp
audio/mods/soundfx.h
audio/mods/tfmx.cpp
audio/mods/tfmx.h
audio/mpu401.cpp
audio/mpu401.h
audio/musicplugin.cpp
audio/musicplugin.h
audio/null.cpp
audio/null.h
audio/rate.cpp
audio/rate.h
audio/rate_arm.cpp
audio/rate_arm_asm.s
audio/softsynth/adlib.cpp
audio/softsynth/appleiigs.cpp
audio/softsynth/cms.cpp
audio/softsynth/cms.h
audio/softsynth/eas.cpp
audio/softsynth/emumidi.h
audio/softsynth/fluidsynth.cpp
audio/softsynth/fmtowns_pc98/towns_audio.cpp
audio/softsynth/fmtowns_pc98/towns_audio.h
audio/softsynth/fmtowns_pc98/towns_euphony.cpp
audio/softsynth/fmtowns_pc98/towns_euphony.h
audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_driver.h
audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
audio/softsynth/mt32.cpp
audio/softsynth/opl/dosbox.cpp
audio/softsynth/opl/dosbox.h
audio/softsynth/opl/mame.cpp
audio/softsynth/opl/mame.h
audio/softsynth/pcspk.cpp
audio/softsynth/pcspk.h
audio/softsynth/sid.cpp
audio/softsynth/sid.h
audio/softsynth/wave6581.cpp
audio/timestamp.cpp
audio/timestamp.h
backends/audiocd/audiocd.h
backends/audiocd/default/default-audiocd.cpp
backends/audiocd/default/default-audiocd.h
backends/audiocd/sdl/sdl-audiocd.cpp
backends/audiocd/sdl/sdl-audiocd.h
backends/base-backend.h
backends/events/default/default-events.cpp
backends/events/default/default-events.h
backends/events/dinguxsdl/dinguxsdl-events.cpp
backends/events/dinguxsdl/dinguxsdl-events.h
backends/events/gph/gph-events.cpp
backends/events/gph/gph-events.h
backends/events/linuxmotosdl/linuxmotosdl-events.cpp
backends/events/linuxmotosdl/linuxmotosdl-events.h
backends/events/maemosdl/maemosdl-events.cpp
backends/events/maemosdl/maemosdl-events.h
backends/events/openpandora/op-events.cpp
backends/events/openpandora/op-events.h
backends/events/ps3sdl/ps3sdl-events.cpp
backends/events/ps3sdl/ps3sdl-events.h
backends/events/samsungtvsdl/samsungtvsdl-events.cpp
backends/events/samsungtvsdl/samsungtvsdl-events.h
backends/events/sdl/sdl-events.cpp
backends/events/sdl/sdl-events.h
backends/events/symbiansdl/symbiansdl-events.cpp
backends/events/symbiansdl/symbiansdl-events.h
backends/events/webossdl/webossdl-events.cpp
backends/events/webossdl/webossdl-events.h
backends/events/wincesdl/wincesdl-events.cpp
backends/events/wincesdl/wincesdl-events.h
backends/fs/abstract-fs.cpp
backends/fs/abstract-fs.h
backends/fs/amigaos4/amigaos4-fs-factory.cpp
backends/fs/amigaos4/amigaos4-fs-factory.h
backends/fs/amigaos4/amigaos4-fs.cpp
backends/fs/amigaos4/amigaos4-fs.h
backends/fs/ds/ds-fs-factory.cpp
backends/fs/ds/ds-fs-factory.h
backends/fs/ds/ds-fs.cpp
backends/fs/ds/ds-fs.h
backends/fs/fs-factory.h
backends/fs/n64/n64-fs-factory.cpp
backends/fs/n64/n64-fs-factory.h
backends/fs/n64/n64-fs.h
backends/fs/n64/romfsstream.cpp
backends/fs/n64/romfsstream.h
backends/fs/posix/posix-fs-factory.cpp
backends/fs/posix/posix-fs-factory.h
backends/fs/posix/posix-fs.cpp
backends/fs/posix/posix-fs.h
backends/fs/ps2/ps2-fs-factory.cpp
backends/fs/ps2/ps2-fs-factory.h
backends/fs/ps2/ps2-fs.cpp
backends/fs/ps2/ps2-fs.h
backends/fs/ps3/ps3-fs-factory.cpp
backends/fs/ps3/ps3-fs-factory.h
backends/fs/psp/psp-fs-factory.cpp
backends/fs/psp/psp-fs-factory.h
backends/fs/psp/psp-fs.cpp
backends/fs/psp/psp-fs.h
backends/fs/psp/psp-stream.cpp
backends/fs/psp/psp-stream.h
backends/fs/stdiostream.cpp
backends/fs/stdiostream.h
backends/fs/symbian/symbian-fs-factory.cpp
backends/fs/symbian/symbian-fs-factory.h
backends/fs/symbian/symbian-fs.cpp
backends/fs/symbian/symbian-fs.h
backends/fs/symbian/symbianstream.cpp
backends/fs/symbian/symbianstream.h
backends/fs/wii/wii-fs-factory.cpp
backends/fs/wii/wii-fs.cpp
backends/fs/wii/wii-fs.h
backends/fs/windows/windows-fs-factory.cpp
backends/fs/windows/windows-fs-factory.h
backends/fs/windows/windows-fs.cpp
backends/fs/windows/windows-fs.h
backends/graphics/default-palette.h
backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
backends/graphics/dinguxsdl/dinguxsdl-graphics.h
backends/graphics/gph/gph-graphics.cpp
backends/graphics/gph/gph-graphics.h
backends/graphics/graphics.h
backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
backends/graphics/maemosdl/maemosdl-graphics.cpp
backends/graphics/maemosdl/maemosdl-graphics.h
backends/graphics/null/null-graphics.h
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.h
backends/graphics/openpandora/op-graphics.cpp
backends/graphics/openpandora/op-graphics.h
backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp
backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h
backends/graphics/sdl/sdl-graphics.cpp
backends/graphics/sdl/sdl-graphics.h
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
backends/graphics/symbiansdl/symbiansdl-graphics.cpp
backends/graphics/symbiansdl/symbiansdl-graphics.h
backends/graphics/wincesdl/wincesdl-graphics.cpp
backends/graphics/wincesdl/wincesdl-graphics.h
backends/keymapper/action.cpp
backends/keymapper/action.h
backends/keymapper/hardware-input.cpp
backends/keymapper/hardware-input.h
backends/keymapper/keymap.cpp
backends/keymapper/keymap.h
backends/keymapper/keymapper-defaults.h
backends/keymapper/keymapper.cpp
backends/keymapper/keymapper.h
backends/keymapper/remap-dialog.cpp
backends/keymapper/remap-dialog.h
backends/midi/alsa.cpp
backends/midi/camd.cpp
backends/midi/coreaudio.cpp
backends/midi/coremidi.cpp
backends/midi/dmedia.cpp
backends/midi/seq.cpp
backends/midi/sndio.cpp
backends/midi/stmidi.cpp
backends/midi/timidity.cpp
backends/midi/windows.cpp
backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h
backends/mixer/nullmixer/nullsdl-mixer.cpp
backends/mixer/nullmixer/nullsdl-mixer.h
backends/mixer/sdl/sdl-mixer.cpp
backends/mixer/sdl/sdl-mixer.h
backends/mixer/sdl13/sdl13-mixer.cpp
backends/mixer/sdl13/sdl13-mixer.h
backends/mixer/symbiansdl/symbiansdl-mixer.cpp
backends/mixer/symbiansdl/symbiansdl-mixer.h
backends/mixer/wincesdl/wincesdl-mixer.cpp
backends/mixer/wincesdl/wincesdl-mixer.h
backends/modular-backend.cpp
backends/modular-backend.h
backends/module.mk
backends/mutex/mutex.h
backends/mutex/null/null-mutex.h
backends/mutex/sdl/sdl-mutex.cpp
backends/mutex/sdl/sdl-mutex.h
backends/platform/android/android.cpp
backends/platform/android/android.h
backends/platform/android/android.mk
backends/platform/android/asset-archive.cpp
backends/platform/android/asset-archive.h
backends/platform/android/events.cpp
backends/platform/android/gfx.cpp
backends/platform/android/jni.cpp
backends/platform/android/jni.h
backends/platform/android/org/scummvm/scummvm/ScummVM.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
backends/platform/android/texture.cpp
backends/platform/android/texture.h
backends/platform/dc/DCLauncherDialog.h
backends/platform/dc/audio.cpp
backends/platform/dc/dc-fs.cpp
backends/platform/dc/dc.h
backends/platform/dc/dcloader.cpp
backends/platform/dc/dcloader.h
backends/platform/dc/dcmain.cpp
backends/platform/dc/display.cpp
backends/platform/dc/icon.cpp
backends/platform/dc/icon.h
backends/platform/dc/input.cpp
backends/platform/dc/ip.txt.in
backends/platform/dc/label.cpp
backends/platform/dc/label.h
backends/platform/dc/plugins.cpp
backends/platform/dc/portdefs.h
backends/platform/dc/selector.cpp
backends/platform/dc/softkbd.cpp
backends/platform/dc/softkbd.h
backends/platform/dc/time.cpp
backends/platform/dc/vmsave.cpp
backends/platform/dingux/dingux.cpp
backends/platform/dingux/dingux.h
backends/platform/dingux/main.cpp
backends/platform/ds/arm7/source/main.cpp
backends/platform/ds/arm9/source/blitters.cpp
backends/platform/ds/arm9/source/blitters.h
backends/platform/ds/arm9/source/cdaudio.cpp
backends/platform/ds/arm9/source/cdaudio.h
backends/platform/ds/arm9/source/dsmain.cpp
backends/platform/ds/arm9/source/dsmain.h
backends/platform/ds/arm9/source/dsoptions.cpp
backends/platform/ds/arm9/source/dsoptions.h
backends/platform/ds/arm9/source/gbampsave.cpp
backends/platform/ds/arm9/source/gbampsave.h
backends/platform/ds/arm9/source/keys.h
backends/platform/ds/arm9/source/osystem_ds.cpp
backends/platform/ds/arm9/source/osystem_ds.h
backends/platform/ds/arm9/source/portdefs.h
backends/platform/ds/arm9/source/scummhelp.cpp
backends/platform/ds/arm9/source/scummhelp.h
backends/platform/ds/arm9/source/touchkeyboard.cpp
backends/platform/ds/arm9/source/touchkeyboard.h
backends/platform/ds/arm9/source/wordcompletion.cpp
backends/platform/ds/arm9/source/wordcompletion.h
backends/platform/ds/arm9/source/zipreader.cpp
backends/platform/ds/arm9/source/zipreader.h
backends/platform/ds/commoninclude/NDS/scummvm_ipc.h
backends/platform/gph/gph-backend.cpp
backends/platform/gph/gph-hw.cpp
backends/platform/gph/gph-hw.h
backends/platform/gph/gph-main.cpp
backends/platform/gph/gph.h
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_keyboard.h
backends/platform/iphone/iphone_keyboard.mm
backends/platform/iphone/iphone_main.mm
backends/platform/iphone/iphone_video.h
backends/platform/iphone/iphone_video.mm
backends/platform/iphone/osys_events.cpp
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_sound.cpp
backends/platform/iphone/osys_video.mm
backends/platform/linuxmoto/hardwarekeys.cpp
backends/platform/linuxmoto/linuxmoto-main.cpp
backends/platform/linuxmoto/linuxmoto-sdl.cpp
backends/platform/linuxmoto/linuxmoto-sdl.h
backends/platform/maemo/maemo-common.h
backends/platform/maemo/maemo.cpp
backends/platform/maemo/maemo.h
backends/platform/maemo/main.cpp
backends/platform/n64/framfs_save_manager.cpp
backends/platform/n64/framfs_save_manager.h
backends/platform/n64/nintendo64.cpp
backends/platform/n64/osys_n64.h
backends/platform/n64/osys_n64_base.cpp
backends/platform/n64/osys_n64_events.cpp
backends/platform/n64/osys_n64_utilities.cpp
backends/platform/n64/pakfs_save_manager.cpp
backends/platform/n64/pakfs_save_manager.h
backends/platform/n64/portdefs.h
backends/platform/null/null.cpp
backends/platform/openpandora/op-backend.cpp
backends/platform/openpandora/op-main.cpp
backends/platform/openpandora/op-options.cpp
backends/platform/openpandora/op-options.h
backends/platform/openpandora/op-sdl.h
backends/platform/ps2/DmaPipe.cpp
backends/platform/ps2/DmaPipe.h
backends/platform/ps2/Gs2dScreen.cpp
backends/platform/ps2/Gs2dScreen.h
backends/platform/ps2/GsDefs.h
backends/platform/ps2/Makefile.ps2
backends/platform/ps2/asyncfio.cpp
backends/platform/ps2/asyncfio.h
backends/platform/ps2/cd.c
backends/platform/ps2/eecodyvdfs.h
backends/platform/ps2/fileio.cpp
backends/platform/ps2/fileio.h
backends/platform/ps2/icon.cpp
backends/platform/ps2/icon.h
backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h
backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.h
backends/platform/ps2/iop/CoDyVDfs/iop/irx_imports.h
backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
backends/platform/ps2/iop/rpckbd/src/irx_imports.h
backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
backends/platform/ps2/irxboot.cpp
backends/platform/ps2/irxboot.h
backends/platform/ps2/module.mk
backends/platform/ps2/ps2debug.cpp
backends/platform/ps2/ps2debug.h
backends/platform/ps2/ps2input.cpp
backends/platform/ps2/ps2input.h
backends/platform/ps2/ps2mutex.cpp
backends/platform/ps2/ps2pad.cpp
backends/platform/ps2/ps2pad.h
backends/platform/ps2/ps2temp.h
backends/platform/ps2/ps2time.cpp
backends/platform/ps2/rpckbd.c
backends/platform/ps2/rpckbd.h
backends/platform/ps2/savefilemgr.cpp
backends/platform/ps2/savefilemgr.h
backends/platform/ps2/sysdefs.h
backends/platform/ps2/systemps2.cpp
backends/platform/ps2/systemps2.h
backends/platform/psp/audio.cpp
backends/platform/psp/audio.h
backends/platform/psp/cursor.cpp
backends/platform/psp/cursor.h
backends/platform/psp/default_display_client.cpp
backends/platform/psp/default_display_client.h
backends/platform/psp/display_client.cpp
backends/platform/psp/display_client.h
backends/platform/psp/display_manager.cpp
backends/platform/psp/display_manager.h
backends/platform/psp/dummy.cpp
backends/platform/psp/image_viewer.cpp
backends/platform/psp/image_viewer.h
backends/platform/psp/input.cpp
backends/platform/psp/input.h
backends/platform/psp/memory.cpp
backends/platform/psp/memory.h
backends/platform/psp/mp3.cpp
backends/platform/psp/mp3.h
backends/platform/psp/osys_psp.cpp
backends/platform/psp/osys_psp.h
backends/platform/psp/png_loader.cpp
backends/platform/psp/png_loader.h
backends/platform/psp/portdefs.h
backends/platform/psp/powerman.cpp
backends/platform/psp/powerman.h
backends/platform/psp/psp_main.cpp
backends/platform/psp/pspkeyboard.cpp
backends/platform/psp/pspkeyboard.h
backends/platform/psp/psppixelformat.cpp
backends/platform/psp/psppixelformat.h
backends/platform/psp/rtc.cpp
backends/platform/psp/rtc.h
backends/platform/psp/tests.cpp
backends/platform/psp/tests.h
backends/platform/psp/thread.cpp
backends/platform/psp/thread.h
backends/platform/psp/trace.cpp
backends/platform/psp/trace.h
backends/platform/samsungtv/main.cpp
backends/platform/samsungtv/samsungtv.cpp
backends/platform/samsungtv/samsungtv.h
backends/platform/sdl/amigaos/amigaos-main.cpp
backends/platform/sdl/amigaos/amigaos.cpp
backends/platform/sdl/amigaos/amigaos.h
backends/platform/sdl/macosx/appmenu_osx.h
backends/platform/sdl/macosx/appmenu_osx.mm
backends/platform/sdl/macosx/macosx-main.cpp
backends/platform/sdl/macosx/macosx.cpp
backends/platform/sdl/macosx/macosx.h
backends/platform/sdl/posix/posix-main.cpp
backends/platform/sdl/posix/posix.cpp
backends/platform/sdl/posix/posix.h
backends/platform/sdl/ps3/ps3-main.cpp
backends/platform/sdl/ps3/ps3.cpp
backends/platform/sdl/ps3/ps3.h
backends/platform/sdl/sdl-sys.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
backends/platform/sdl/win32/win32-main.cpp
backends/platform/sdl/win32/win32.cpp
backends/platform/sdl/win32/win32.h
backends/platform/symbian/AdaptAllMMPs.pl
backends/platform/symbian/BuildPackageUpload_AllVersions.pl
backends/platform/symbian/BuildPackageUpload_LocalSettings.pl
backends/platform/symbian/README
backends/platform/symbian/S60/ScummVM_S60.mmp.in
backends/platform/symbian/S60/ScummVM_S60_App.mmp
backends/platform/symbian/S60v3/BLD.INF.in
backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
backends/platform/symbian/S80/ScummVM_S80.mmp.in
backends/platform/symbian/S80/ScummVM_S80_App.mmp
backends/platform/symbian/S90/Scummvm_S90.mmp.in
backends/platform/symbian/S90/Scummvm_S90_App.mmp
backends/platform/symbian/UIQ2/ScummVM.rss
backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in
backends/platform/symbian/UIQ3/ScummVM.rss
backends/platform/symbian/UIQ3/ScummVM_A0000658.rss
backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss
backends/platform/symbian/mmp/scummvm_agi.mmp.in
backends/platform/symbian/mmp/scummvm_agos.mmp.in
backends/platform/symbian/mmp/scummvm_base.mmp.in
backends/platform/symbian/mmp/scummvm_cge.mmp.in
backends/platform/symbian/mmp/scummvm_cine.mmp.in
backends/platform/symbian/mmp/scummvm_composer.mmp.in
backends/platform/symbian/mmp/scummvm_cruise.mmp.in
backends/platform/symbian/mmp/scummvm_draci.mmp.in
backends/platform/symbian/mmp/scummvm_drascula.mmp.in
backends/platform/symbian/mmp/scummvm_gob.mmp.in
backends/platform/symbian/mmp/scummvm_groovie.mmp.in
backends/platform/symbian/mmp/scummvm_hopkins.mmp.in
backends/platform/symbian/mmp/scummvm_hugo.mmp.in
backends/platform/symbian/mmp/scummvm_kyra.mmp.in
backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
backends/platform/symbian/mmp/scummvm_lure.mmp.in
backends/platform/symbian/mmp/scummvm_m4.mmp.in
backends/platform/symbian/mmp/scummvm_made.mmp.in
backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
backends/platform/symbian/mmp/scummvm_pegasus.mmp.in
backends/platform/symbian/mmp/scummvm_queen.mmp.in
backends/platform/symbian/mmp/scummvm_saga.mmp.in
backends/platform/symbian/mmp/scummvm_sci.mmp.in
backends/platform/symbian/mmp/scummvm_scumm.mmp.in
backends/platform/symbian/mmp/scummvm_sky.mmp.in
backends/platform/symbian/mmp/scummvm_sword1.mmp.in
backends/platform/symbian/mmp/scummvm_sword2.mmp.in
backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
backends/platform/symbian/mmp/scummvm_toltecs.mmp.in
backends/platform/symbian/mmp/scummvm_tony.mmp.in
backends/platform/symbian/mmp/scummvm_toon.mmp.in
backends/platform/symbian/mmp/scummvm_touche.mmp.in
backends/platform/symbian/mmp/scummvm_tsage.mmp.in
backends/platform/symbian/mmp/scummvm_tucker.mmp.in
backends/platform/symbian/mmp/scummvm_wintermute.mmp.in
backends/platform/symbian/res/ScummVmAif.rss
backends/platform/symbian/res/scummvm.rss
backends/platform/symbian/res/scummvm_A0000658.rss
backends/platform/symbian/src/ScummApp.cpp
backends/platform/symbian/src/ScummApp.h
backends/platform/symbian/src/ScummVm.hrh
backends/platform/symbian/src/SymbianActions.cpp
backends/platform/symbian/src/SymbianActions.h
backends/platform/symbian/src/SymbianMain.cpp
backends/platform/symbian/src/SymbianOS.cpp
backends/platform/symbian/src/SymbianOS.h
backends/platform/symbian/src/portdefs.h
backends/platform/tizen/application.cpp
backends/platform/tizen/application.h
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/fs.h
backends/platform/tizen/graphics.cpp
backends/platform/tizen/graphics.h
backends/platform/tizen/main.cpp
backends/platform/tizen/missing.cpp
backends/platform/tizen/portdefs.h
backends/platform/tizen/sscanf.cpp
backends/platform/tizen/system.cpp
backends/platform/tizen/system.h
backends/platform/webos/main.cpp
backends/platform/webos/webos.cpp
backends/platform/webos/webos.h
backends/platform/wii/main.cpp
backends/platform/wii/options.cpp
backends/platform/wii/options.h
backends/platform/wii/osystem.cpp
backends/platform/wii/osystem.h
backends/platform/wii/osystem_events.cpp
backends/platform/wii/osystem_gfx.cpp
backends/platform/wii/osystem_sfx.cpp
backends/platform/wii/wii.mk
backends/platform/wince/CEActionsPocket.cpp
backends/platform/wince/CEActionsPocket.h
backends/platform/wince/CEActionsSmartphone.cpp
backends/platform/wince/CEActionsSmartphone.h
backends/platform/wince/CEDevice.cpp
backends/platform/wince/CEDevice.h
backends/platform/wince/CEException.cpp
backends/platform/wince/CEException.h
backends/platform/wince/CELauncherDialog.cpp
backends/platform/wince/CELauncherDialog.h
backends/platform/wince/CEScaler.cpp
backends/platform/wince/CEScaler.h
backends/platform/wince/CEgui/CEGUI.h
backends/platform/wince/CEgui/GUIElement.cpp
backends/platform/wince/CEgui/GUIElement.h
backends/platform/wince/CEgui/ItemAction.cpp
backends/platform/wince/CEgui/ItemAction.h
backends/platform/wince/CEgui/ItemSwitch.cpp
backends/platform/wince/CEgui/ItemSwitch.h
backends/platform/wince/CEgui/Panel.cpp
backends/platform/wince/CEgui/Panel.h
backends/platform/wince/CEgui/PanelItem.cpp
backends/platform/wince/CEgui/PanelItem.h
backends/platform/wince/CEgui/PanelKeyboard.cpp
backends/platform/wince/CEgui/PanelKeyboard.h
backends/platform/wince/CEgui/SDL_ImageResource.cpp
backends/platform/wince/CEgui/SDL_ImageResource.h
backends/platform/wince/CEgui/Toolbar.cpp
backends/platform/wince/CEgui/Toolbar.h
backends/platform/wince/CEgui/ToolbarHandler.cpp
backends/platform/wince/CEgui/ToolbarHandler.h
backends/platform/wince/CEkeys/CEKeys.h
backends/platform/wince/CEkeys/EventsBuffer.cpp
backends/platform/wince/CEkeys/EventsBuffer.h
backends/platform/wince/missing/missing.cpp
backends/platform/wince/portdefs.h
backends/platform/wince/stub.cpp
backends/platform/wince/wince-sdl.cpp
backends/platform/wince/wince-sdl.h
backends/plugins/ds/ds-provider.cpp
backends/plugins/ds/ds-provider.h
backends/plugins/dynamic-plugin.h
backends/plugins/elf/arm-loader.cpp
backends/plugins/elf/arm-loader.h
backends/plugins/elf/elf-loader.cpp
backends/plugins/elf/elf-loader.h
backends/plugins/elf/elf-provider.cpp
backends/plugins/elf/elf-provider.h
backends/plugins/elf/elf32.h
backends/plugins/elf/memory-manager.cpp
backends/plugins/elf/memory-manager.h
backends/plugins/elf/mips-loader.cpp
backends/plugins/elf/mips-loader.h
backends/plugins/elf/ppc-loader.cpp
backends/plugins/elf/ppc-loader.h
backends/plugins/elf/shorts-segment-manager.cpp
backends/plugins/elf/shorts-segment-manager.h
backends/plugins/elf/version.cpp
backends/plugins/elf/version.h
backends/plugins/posix/posix-provider.cpp
backends/plugins/posix/posix-provider.h
backends/plugins/ps2/ps2-provider.cpp
backends/plugins/ps2/ps2-provider.h
backends/plugins/psp/psp-provider.cpp
backends/plugins/psp/psp-provider.h
backends/plugins/sdl/sdl-provider.cpp
backends/plugins/sdl/sdl-provider.h
backends/plugins/wii/wii-provider.cpp
backends/plugins/wii/wii-provider.h
backends/plugins/win32/win32-provider.cpp
backends/plugins/win32/win32-provider.h
backends/saves/default/default-saves.cpp
backends/saves/default/default-saves.h
backends/saves/posix/posix-saves.cpp
backends/saves/posix/posix-saves.h
backends/saves/psp/psp-saves.cpp
backends/saves/psp/psp-saves.h
backends/saves/recorder/recorder-saves.cpp
backends/saves/recorder/recorder-saves.h
backends/saves/savefile.cpp
backends/saves/windows/windows-saves.cpp
backends/saves/windows/windows-saves.h
backends/taskbar/unity/unity-taskbar.cpp
backends/taskbar/unity/unity-taskbar.h
backends/timer/default/default-timer.cpp
backends/timer/default/default-timer.h
backends/timer/psp/timer.cpp
backends/timer/psp/timer.h
backends/timer/sdl/sdl-timer.cpp
backends/timer/sdl/sdl-timer.h
backends/timer/tizen/timer.cpp
backends/timer/tizen/timer.h
backends/updates/macosx/macosx-updates.h
backends/updates/macosx/macosx-updates.mm
backends/vkeybd/virtual-keyboard-gui.cpp
backends/vkeybd/virtual-keyboard-gui.h
backends/vkeybd/virtual-keyboard-parser.cpp
base/commandLine.cpp
base/commandLine.h
base/main.cpp
base/main.h
base/plugins.cpp
base/plugins.h
base/version.cpp
base/version.h
common/EventDispatcher.cpp
common/EventMapper.cpp
common/algorithm.h
common/archive.cpp
common/archive.h
common/array.h
common/bitstream.h
common/bufferedstream.h
common/c++11-compat.h
common/config-manager.cpp
common/config-manager.h
common/coroutines.cpp
common/coroutines.h
common/cosinetables.cpp
common/cosinetables.h
common/dcl.cpp
common/dcl.h
common/dct.cpp
common/dct.h
common/debug-channels.h
common/debug.cpp
common/debug.h
common/endian.h
common/error.cpp
common/error.h
common/events.h
common/fft.cpp
common/fft.h
common/file.cpp
common/file.h
common/forbidden.h
common/frac.h
common/fs.cpp
common/fs.h
common/func.h
common/gui_options.cpp
common/gui_options.h
common/hash-str.h
common/hashmap.cpp
common/hashmap.h
common/huffman.cpp
common/huffman.h
common/iff_container.cpp
common/iff_container.h
common/ini-file.cpp
common/ini-file.h
common/installshield_cab.cpp
common/installshield_cab.h
common/keyboard.h
common/language.cpp
common/language.h
common/list.h
common/list_intern.h
common/localization.cpp
common/localization.h
common/macresman.cpp
common/macresman.h
common/math.h
common/md5.cpp
common/md5.h
common/memory.h
common/memorypool.cpp
common/memorypool.h
common/memstream.h
common/module.mk
common/mutex.cpp
common/mutex.h
common/noncopyable.h
common/pack-end.h
common/pack-start.h
common/platform.cpp
common/platform.h
common/ptr.h
common/queue.h
common/quicktime.cpp
common/quicktime.h
common/random.cpp
common/random.h
common/rational.cpp
common/rational.h
common/rdft.cpp
common/rdft.h
common/recorderfile.cpp
common/recorderfile.h
common/rect.h
common/rendermode.cpp
common/rendermode.h
common/savefile.h
common/scummsys.h
common/serializer.h
common/sinetables.cpp
common/sinetables.h
common/singleton.h
common/stack.h
common/str-array.h
common/str.cpp
common/str.h
common/stream.cpp
common/stream.h
common/substream.h
common/system.cpp
common/system.h
common/textconsole.cpp
common/textconsole.h
common/timer.h
common/tokenizer.cpp
common/tokenizer.h
common/translation.cpp
common/translation.h
common/types.h
common/unzip.cpp
common/unzip.h
common/updates.h
common/util.cpp
common/util.h
common/winexe.cpp
common/winexe.h
common/winexe_ne.cpp
common/winexe_ne.h
common/winexe_pe.cpp
common/winexe_pe.h
common/zlib.cpp
common/zlib.h
configure
devtools/convbdf.cpp
devtools/create_drascula/create_drascula.cpp
devtools/create_drascula/create_drascula.h
devtools/create_drascula/staticdata.h
devtools/create_hugo/create_hugo.cpp
devtools/create_hugo/create_hugo.h
devtools/create_hugo/staticdata.h
devtools/create_hugo/staticdisplay.h
devtools/create_hugo/staticengine.h
devtools/create_hugo/staticfont.h
devtools/create_hugo/staticintro.h
devtools/create_hugo/staticmouse.h
devtools/create_hugo/staticparser.h
devtools/create_hugo/staticutil.h
devtools/create_kyradat/create_kyradat.cpp
devtools/create_kyradat/create_kyradat.h
devtools/create_kyradat/games.cpp
devtools/create_kyradat/md5.cpp
devtools/create_kyradat/md5.h
devtools/create_kyradat/module.mk
devtools/create_kyradat/pak.cpp
devtools/create_kyradat/pak.h
devtools/create_kyradat/util.cpp
devtools/create_kyradat/util.h
devtools/create_lure/create_lure_dat.cpp
devtools/create_lure/create_lure_dat.h
devtools/create_lure/process_actions.cpp
devtools/create_mortdat/create_mortdat.cpp
devtools/create_mortdat/create_mortdat.h
devtools/create_mortdat/enginetext.h
devtools/create_mortdat/gametext.h
devtools/create_mortdat/menudata.h
devtools/create_neverhood/create_neverhood.cpp
devtools/create_neverhood/create_neverhood.h
devtools/create_neverhood/md5.cpp
devtools/create_neverhood/md5.h
devtools/create_neverhood/tables.h
devtools/create_neverhood/util.cpp
devtools/create_neverhood/util.h
devtools/create_project/codeblocks.cpp
devtools/create_project/config.h
devtools/create_project/create_project.cpp
devtools/create_project/create_project.h
devtools/create_project/msbuild.cpp
devtools/create_project/visualstudio.cpp
devtools/create_project/xcode.cpp
devtools/create_teenagent/create_teenagent.cpp
devtools/create_teenagent/static_tables.h
devtools/create_teenagent/util.cpp
devtools/create_teenagent/util.h
devtools/create_tony/create_tony.cpp
devtools/create_tony/create_tony.h
devtools/create_tony/staticdata.h
devtools/create_toon/create_toon.cpp
devtools/create_toon/create_toon.h
devtools/create_toon/staticdata.h
devtools/create_translations/create_translations.cpp
devtools/create_translations/create_translations.h
devtools/create_translations/po_parser.cpp
devtools/create_translations/po_parser.h
devtools/credits.pl
devtools/extract_mort/extract_mort.cpp
devtools/sci/musicplayer.cpp
devtools/sci/scidisasm.cpp
devtools/sci/scipack.cpp
devtools/skycpt/AsciiCptCompile.cpp
devtools/skycpt/KmpSearch.cpp
devtools/skycpt/KmpSearch.h
devtools/skycpt/TextFile.cpp
devtools/skycpt/TextFile.h
devtools/skycpt/cptcompiler.cpp
devtools/skycpt/cpthelp.cpp
devtools/skycpt/cpthelp.h
devtools/skycpt/idFinder.cpp
devtools/skycpt/stdafx.cpp
devtools/skycpt/stdafx.h
dists/debian/copyright
dists/engine-data/README
dists/engine-data/kyra.dat
dists/engine-data/lure.dat
dists/engine-data/neverhood.dat
dists/iphone/Info.plist
dists/iphone/Info.plist.in
dists/macosx/Info.plist
dists/macosx/Info.plist.in
dists/msvc11/readme.txt
dists/msvc12/readme.txt
dists/scummvm.rc
dists/scummvm.rc.in
dists/win32/ScummVM.iss
dists/win32/migration.bat
dists/win32/scummvm.nsi
dists/win32/scummvm.nsi.in
doc/cz/PrectiMe
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/agi/agi.cpp
engines/agi/agi.h
engines/agi/checks.cpp
engines/agi/console.cpp
engines/agi/console.h
engines/agi/cycle.cpp
engines/agi/detection.cpp
engines/agi/detection_tables.h
engines/agi/font.h
engines/agi/global.cpp
engines/agi/graphics.cpp
engines/agi/graphics.h
engines/agi/id.cpp
engines/agi/inv.cpp
engines/agi/keyboard.cpp
engines/agi/keyboard.h
engines/agi/loader_v1.cpp
engines/agi/loader_v2.cpp
engines/agi/loader_v3.cpp
engines/agi/logic.cpp
engines/agi/logic.h
engines/agi/lzw.cpp
engines/agi/lzw.h
engines/agi/menu.cpp
engines/agi/menu.h
engines/agi/motion.cpp
engines/agi/objects.cpp
engines/agi/op_cmd.cpp
engines/agi/op_dbg.cpp
engines/agi/op_test.cpp
engines/agi/opcodes.cpp
engines/agi/opcodes.h
engines/agi/picture.cpp
engines/agi/picture.h
engines/agi/preagi.cpp
engines/agi/preagi.h
engines/agi/preagi_mickey.cpp
engines/agi/preagi_mickey.h
engines/agi/preagi_troll.cpp
engines/agi/preagi_troll.h
engines/agi/preagi_winnie.cpp
engines/agi/preagi_winnie.h
engines/agi/saveload.cpp
engines/agi/sound.cpp
engines/agi/sound.h
engines/agi/sound_2gs.cpp
engines/agi/sound_2gs.h
engines/agi/sound_coco3.cpp
engines/agi/sound_coco3.h
engines/agi/sound_midi.cpp
engines/agi/sound_midi.h
engines/agi/sound_pcjr.cpp
engines/agi/sound_pcjr.h
engines/agi/sound_sarien.cpp
engines/agi/sound_sarien.h
engines/agi/sprite.cpp
engines/agi/sprite.h
engines/agi/text.cpp
engines/agi/view.cpp
engines/agi/view.h
engines/agi/wagparser.cpp
engines/agi/wagparser.h
engines/agi/words.cpp
engines/agos/agos.cpp
engines/agos/agos.h
engines/agos/animation.cpp
engines/agos/animation.h
engines/agos/charset-fontdata.cpp
engines/agos/charset.cpp
engines/agos/contain.cpp
engines/agos/cursor.cpp
engines/agos/debug.cpp
engines/agos/debug.h
engines/agos/debugger.cpp
engines/agos/debugger.h
engines/agos/detection.cpp
engines/agos/detection_tables.h
engines/agos/draw.cpp
engines/agos/event.cpp
engines/agos/feeble.cpp
engines/agos/gfx.cpp
engines/agos/icons.cpp
engines/agos/input.cpp
engines/agos/input_pn.cpp
engines/agos/intern.h
engines/agos/items.cpp
engines/agos/menus.cpp
engines/agos/midi.cpp
engines/agos/midi.h
engines/agos/midiparser_s1d.cpp
engines/agos/oracle.cpp
engines/agos/pn.cpp
engines/agos/res.cpp
engines/agos/res_ami.cpp
engines/agos/res_snd.cpp
engines/agos/rooms.cpp
engines/agos/saveload.cpp
engines/agos/script.cpp
engines/agos/script_dp.cpp
engines/agos/script_e1.cpp
engines/agos/script_e2.cpp
engines/agos/script_ff.cpp
engines/agos/script_pn.cpp
engines/agos/script_pp.cpp
engines/agos/script_s1.cpp
engines/agos/script_s2.cpp
engines/agos/script_ww.cpp
engines/agos/sound.cpp
engines/agos/sound.h
engines/agos/string.cpp
engines/agos/string_pn.cpp
engines/agos/subroutine.cpp
engines/agos/verb.cpp
engines/agos/verb_pn.cpp
engines/agos/vga.cpp
engines/agos/vga.h
engines/agos/vga_e2.cpp
engines/agos/vga_ff.cpp
engines/agos/vga_pn.cpp
engines/agos/vga_s1.cpp
engines/agos/vga_s2.cpp
engines/agos/vga_ww.cpp
engines/agos/window.cpp
engines/agos/zones.cpp
engines/avalanche/animation.cpp
engines/avalanche/animation.h
engines/avalanche/avalanche.cpp
engines/avalanche/avalanche.h
engines/avalanche/avalot.cpp
engines/avalanche/avalot.h
engines/avalanche/background.cpp
engines/avalanche/background.h
engines/avalanche/closing.cpp
engines/avalanche/closing.h
engines/avalanche/console.cpp
engines/avalanche/console.h
engines/avalanche/detection.cpp
engines/avalanche/dialogs.cpp
engines/avalanche/dialogs.h
engines/avalanche/enums.h
engines/avalanche/graphics.cpp
engines/avalanche/graphics.h
engines/avalanche/module.mk
engines/avalanche/parser.cpp
engines/avalanche/parser.h
engines/avalanche/sequence.cpp
engines/avalanche/sequence.h
engines/avalanche/sound.cpp
engines/avalanche/sound.h
engines/avalanche/timer.cpp
engines/avalanche/timer.h
engines/cge/bitmap.cpp
engines/cge/bitmap.h
engines/cge/cge.cpp
engines/cge/cge.h
engines/cge/cge_main.cpp
engines/cge/cge_main.h
engines/cge/console.cpp
engines/cge/console.h
engines/cge/detection.cpp
engines/cge/events.cpp
engines/cge/events.h
engines/cge/fileio.cpp
engines/cge/fileio.h
engines/cge/game.cpp
engines/cge/game.h
engines/cge/general.h
engines/cge/module.mk
engines/cge/snail.cpp
engines/cge/snail.h
engines/cge/sound.cpp
engines/cge/sound.h
engines/cge/talk.cpp
engines/cge/talk.h
engines/cge/text.cpp
engines/cge/text.h
engines/cge/vga13h.cpp
engines/cge/vga13h.h
engines/cge/vmenu.cpp
engines/cge/vmenu.h
engines/cge/walk.cpp
engines/cge/walk.h
engines/cine/anim.cpp
engines/cine/anim.h
engines/cine/bg.cpp
engines/cine/bg.h
engines/cine/bg_list.cpp
engines/cine/bg_list.h
engines/cine/cine.cpp
engines/cine/cine.h
engines/cine/console.cpp
engines/cine/console.h
engines/cine/detection.cpp
engines/cine/detection_tables.h
engines/cine/gfx.cpp
engines/cine/gfx.h
engines/cine/main_loop.cpp
engines/cine/main_loop.h
engines/cine/msg.cpp
engines/cine/msg.h
engines/cine/object.cpp
engines/cine/object.h
engines/cine/pal.cpp
engines/cine/pal.h
engines/cine/part.cpp
engines/cine/part.h
engines/cine/prc.cpp
engines/cine/prc.h
engines/cine/rel.cpp
engines/cine/rel.h
engines/cine/saveload.cpp
engines/cine/saveload.h
engines/cine/script.h
engines/cine/script_fw.cpp
engines/cine/script_os.cpp
engines/cine/sound.cpp
engines/cine/sound.h
engines/cine/texte.cpp
engines/cine/texte.h
engines/cine/unpack.cpp
engines/cine/unpack.h
engines/cine/various.cpp
engines/cine/various.h
engines/composer/composer.cpp
engines/composer/composer.h
engines/composer/detection.cpp
engines/composer/graphics.cpp
engines/composer/graphics.h
engines/composer/module.mk
engines/composer/resource.cpp
engines/composer/resource.h
engines/composer/scripting.cpp
engines/cruise/actor.cpp
engines/cruise/actor.h
engines/cruise/background.cpp
engines/cruise/background.h
engines/cruise/backgroundIncrust.cpp
engines/cruise/backgroundIncrust.h
engines/cruise/cell.cpp
engines/cruise/cell.h
engines/cruise/cruise.cpp
engines/cruise/cruise.h
engines/cruise/cruise_main.cpp
engines/cruise/cruise_main.h
engines/cruise/ctp.cpp
engines/cruise/ctp.h
engines/cruise/dataLoader.cpp
engines/cruise/dataLoader.h
engines/cruise/debugger.cpp
engines/cruise/debugger.h
engines/cruise/decompiler.cpp
engines/cruise/delphine-unpack.cpp
engines/cruise/detection.cpp
engines/cruise/font.cpp
engines/cruise/font.h
engines/cruise/function.cpp
engines/cruise/function.h
engines/cruise/gfxModule.cpp
engines/cruise/gfxModule.h
engines/cruise/linker.cpp
engines/cruise/linker.h
engines/cruise/mainDraw.cpp
engines/cruise/mainDraw.h
engines/cruise/menu.cpp
engines/cruise/menu.h
engines/cruise/mouse.cpp
engines/cruise/mouse.h
engines/cruise/object.cpp
engines/cruise/object.h
engines/cruise/overlay.cpp
engines/cruise/overlay.h
engines/cruise/perso.cpp
engines/cruise/perso.h
engines/cruise/polys.cpp
engines/cruise/polys.h
engines/cruise/saveload.cpp
engines/cruise/saveload.h
engines/cruise/script.cpp
engines/cruise/script.h
engines/cruise/sound.cpp
engines/cruise/sound.h
engines/cruise/stack.cpp
engines/cruise/stack.h
engines/cruise/staticres.cpp
engines/cruise/staticres.h
engines/cruise/various.cpp
engines/cruise/various.h
engines/cruise/vars.cpp
engines/cruise/vars.h
engines/cruise/volume.cpp
engines/cruise/volume.h
engines/dialogs.cpp
engines/dialogs.h
engines/draci/animation.cpp
engines/draci/animation.h
engines/draci/barchive.cpp
engines/draci/barchive.h
engines/draci/console.cpp
engines/draci/console.h
engines/draci/detection.cpp
engines/draci/draci.cpp
engines/draci/draci.h
engines/draci/font.cpp
engines/draci/font.h
engines/draci/game.cpp
engines/draci/game.h
engines/draci/module.mk
engines/draci/mouse.cpp
engines/draci/mouse.h
engines/draci/music.cpp
engines/draci/music.h
engines/draci/saveload.cpp
engines/draci/saveload.h
engines/draci/screen.cpp
engines/draci/screen.h
engines/draci/script.cpp
engines/draci/script.h
engines/draci/sound.cpp
engines/draci/sound.h
engines/draci/sprite.cpp
engines/draci/sprite.h
engines/draci/surface.cpp
engines/draci/surface.h
engines/draci/walking.cpp
engines/draci/walking.h
engines/drascula/actors.cpp
engines/drascula/animation.cpp
engines/drascula/console.cpp
engines/drascula/console.h
engines/drascula/converse.cpp
engines/drascula/detection.cpp
engines/drascula/drascula.cpp
engines/drascula/drascula.h
engines/drascula/graphics.cpp
engines/drascula/interface.cpp
engines/drascula/objects.cpp
engines/drascula/palette.cpp
engines/drascula/resource.cpp
engines/drascula/rooms.cpp
engines/drascula/saveload.cpp
engines/drascula/sound.cpp
engines/drascula/talk.cpp
engines/dreamweb/backdrop.cpp
engines/dreamweb/console.cpp
engines/dreamweb/console.h
engines/dreamweb/detection.cpp
engines/dreamweb/detection_tables.h
engines/dreamweb/dreamweb.cpp
engines/dreamweb/dreamweb.h
engines/dreamweb/keypad.cpp
engines/dreamweb/monitor.cpp
engines/dreamweb/mouse.cpp
engines/dreamweb/newplace.cpp
engines/dreamweb/object.cpp
engines/dreamweb/pathfind.cpp
engines/dreamweb/people.cpp
engines/dreamweb/print.cpp
engines/dreamweb/rain.cpp
engines/dreamweb/saveload.cpp
engines/dreamweb/sound.cpp
engines/dreamweb/sound.h
engines/dreamweb/sprite.cpp
engines/dreamweb/structs.h
engines/dreamweb/stubs.cpp
engines/dreamweb/talk.cpp
engines/dreamweb/titles.cpp
engines/dreamweb/use.cpp
engines/dreamweb/vgafades.cpp
engines/dreamweb/vgagrafx.cpp
engines/engine.cpp
engines/engine.h
engines/fullpipe/behavior.cpp
engines/fullpipe/behavior.h
engines/fullpipe/constants.h
engines/fullpipe/detection.cpp
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/lift.cpp
engines/fullpipe/messages.cpp
engines/fullpipe/messages.h
engines/fullpipe/modal.cpp
engines/fullpipe/modal.h
engines/fullpipe/module.mk
engines/fullpipe/motion.cpp
engines/fullpipe/motion.h
engines/fullpipe/ngiarchive.cpp
engines/fullpipe/objectnames.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/game.cpp
engines/game.h
engines/gob/anifile.cpp
engines/gob/anifile.h
engines/gob/aniobject.cpp
engines/gob/aniobject.h
engines/gob/backbuffer.cpp
engines/gob/backbuffer.h
engines/gob/cheater.cpp
engines/gob/cheater.h
engines/gob/cheater_geisha.cpp
engines/gob/cmpfile.cpp
engines/gob/cmpfile.h
engines/gob/console.cpp
engines/gob/console.h
engines/gob/databases.cpp
engines/gob/databases.h
engines/gob/dataio.cpp
engines/gob/dataio.h
engines/gob/dbase.cpp
engines/gob/dbase.h
engines/gob/decfile.cpp
engines/gob/decfile.h
engines/gob/demos/batplayer.cpp
engines/gob/demos/batplayer.h
engines/gob/demos/demoplayer.cpp
engines/gob/demos/demoplayer.h
engines/gob/demos/scnplayer.cpp
engines/gob/demos/scnplayer.h
engines/gob/detection/detection.cpp
engines/gob/detection/tables.h
engines/gob/detection/tables_adi2.h
engines/gob/detection/tables_adi4.h
engines/gob/detection/tables_adibou.h
engines/gob/detection/tables_ajworld.h
engines/gob/detection/tables_bargon.h
engines/gob/detection/tables_dynasty.h
engines/gob/detection/tables_fallback.h
engines/gob/detection/tables_fascin.h
engines/gob/detection/tables_geisha.h
engines/gob/detection/tables_gob1.h
engines/gob/detection/tables_gob2.h
engines/gob/detection/tables_gob3.h
engines/gob/detection/tables_inca2.h
engines/gob/detection/tables_lit.h
engines/gob/detection/tables_littlered.h
engines/gob/detection/tables_onceupon.h
engines/gob/detection/tables_playtoons.h
engines/gob/detection/tables_urban.h
engines/gob/detection/tables_ween.h
engines/gob/detection/tables_woodruff.h
engines/gob/draw.cpp
engines/gob/draw.h
engines/gob/draw_bargon.cpp
engines/gob/draw_fascin.cpp
engines/gob/draw_playtoons.cpp
engines/gob/draw_v1.cpp
engines/gob/draw_v2.cpp
engines/gob/expression.cpp
engines/gob/expression.h
engines/gob/game.cpp
engines/gob/game.h
engines/gob/global.cpp
engines/gob/global.h
engines/gob/gob.cpp
engines/gob/gob.h
engines/gob/goblin.cpp
engines/gob/goblin.h
engines/gob/goblin_v1.cpp
engines/gob/goblin_v2.cpp
engines/gob/goblin_v3.cpp
engines/gob/goblin_v4.cpp
engines/gob/hotspots.cpp
engines/gob/hotspots.h
engines/gob/iniconfig.cpp
engines/gob/iniconfig.h
engines/gob/init.cpp
engines/gob/init.h
engines/gob/init_fascin.cpp
engines/gob/init_geisha.cpp
engines/gob/init_v1.cpp
engines/gob/init_v2.cpp
engines/gob/init_v3.cpp
engines/gob/init_v4.cpp
engines/gob/init_v6.cpp
engines/gob/init_v7.cpp
engines/gob/inter.cpp
engines/gob/inter.h
engines/gob/inter_bargon.cpp
engines/gob/inter_fascin.cpp
engines/gob/inter_geisha.cpp
engines/gob/inter_inca2.cpp
engines/gob/inter_littlered.cpp
engines/gob/inter_playtoons.cpp
engines/gob/inter_v1.cpp
engines/gob/inter_v2.cpp
engines/gob/inter_v3.cpp
engines/gob/inter_v4.cpp
engines/gob/inter_v5.cpp
engines/gob/inter_v6.cpp
engines/gob/inter_v7.cpp
engines/gob/map.cpp
engines/gob/map.h
engines/gob/map_v1.cpp
engines/gob/map_v2.cpp
engines/gob/minigames/geisha/diving.cpp
engines/gob/minigames/geisha/diving.h
engines/gob/minigames/geisha/evilfish.cpp
engines/gob/minigames/geisha/evilfish.h
engines/gob/minigames/geisha/meter.cpp
engines/gob/minigames/geisha/meter.h
engines/gob/minigames/geisha/mouth.cpp
engines/gob/minigames/geisha/mouth.h
engines/gob/minigames/geisha/oko.cpp
engines/gob/minigames/geisha/oko.h
engines/gob/minigames/geisha/penetration.cpp
engines/gob/minigames/geisha/penetration.h
engines/gob/minigames/geisha/submarine.cpp
engines/gob/minigames/geisha/submarine.h
engines/gob/mult.cpp
engines/gob/mult.h
engines/gob/mult_v2.cpp
engines/gob/palanim.cpp
engines/gob/palanim.h
engines/gob/pregob/gctfile.cpp
engines/gob/pregob/gctfile.h
engines/gob/pregob/onceupon/abracadabra.cpp
engines/gob/pregob/onceupon/abracadabra.h
engines/gob/pregob/onceupon/babayaga.cpp
engines/gob/pregob/onceupon/babayaga.h
engines/gob/pregob/onceupon/brokenstrings.h
engines/gob/pregob/onceupon/chargenchild.cpp
engines/gob/pregob/onceupon/chargenchild.h
engines/gob/pregob/onceupon/onceupon.cpp
engines/gob/pregob/onceupon/onceupon.h
engines/gob/pregob/onceupon/palettes.h
engines/gob/pregob/onceupon/parents.cpp
engines/gob/pregob/onceupon/parents.h
engines/gob/pregob/onceupon/stork.cpp
engines/gob/pregob/onceupon/stork.h
engines/gob/pregob/onceupon/title.cpp
engines/gob/pregob/onceupon/title.h
engines/gob/pregob/pregob.cpp
engines/gob/pregob/pregob.h
engines/gob/pregob/seqfile.cpp
engines/gob/pregob/seqfile.h
engines/gob/pregob/txtfile.cpp
engines/gob/pregob/txtfile.h
engines/gob/resources.cpp
engines/gob/resources.h
engines/gob/rxyfile.cpp
engines/gob/rxyfile.h
engines/gob/save/saveconverter.cpp
engines/gob/save/saveconverter.h
engines/gob/save/saveconverter_v2.cpp
engines/gob/save/saveconverter_v3.cpp
engines/gob/save/saveconverter_v4.cpp
engines/gob/save/savefile.cpp
engines/gob/save/savefile.h
engines/gob/save/savehandler.cpp
engines/gob/save/savehandler.h
engines/gob/save/saveload.cpp
engines/gob/save/saveload.h
engines/gob/save/saveload_ajworld.cpp
engines/gob/save/saveload_fascin.cpp
engines/gob/save/saveload_geisha.cpp
engines/gob/save/saveload_inca2.cpp
engines/gob/save/saveload_playtoons.cpp
engines/gob/save/saveload_v2.cpp
engines/gob/save/saveload_v3.cpp
engines/gob/save/saveload_v4.cpp
engines/gob/save/saveload_v6.cpp
engines/gob/save/saveload_v7.cpp
engines/gob/scenery.cpp
engines/gob/scenery.h
engines/gob/scenery_v1.cpp
engines/gob/scenery_v2.cpp
engines/gob/script.cpp
engines/gob/script.h
engines/gob/sound/adlib.cpp
engines/gob/sound/adlib.h
engines/gob/sound/adlplayer.cpp
engines/gob/sound/adlplayer.h
engines/gob/sound/bgatmosphere.cpp
engines/gob/sound/bgatmosphere.h
engines/gob/sound/cdrom.cpp
engines/gob/sound/cdrom.h
engines/gob/sound/infogrames.cpp
engines/gob/sound/infogrames.h
engines/gob/sound/musplayer.cpp
engines/gob/sound/musplayer.h
engines/gob/sound/pcspeaker.cpp
engines/gob/sound/pcspeaker.h
engines/gob/sound/protracker.cpp
engines/gob/sound/protracker.h
engines/gob/sound/sound.cpp
engines/gob/sound/sound.h
engines/gob/sound/soundblaster.cpp
engines/gob/sound/soundblaster.h
engines/gob/sound/sounddesc.cpp
engines/gob/sound/sounddesc.h
engines/gob/sound/soundmixer.cpp
engines/gob/sound/soundmixer.h
engines/gob/surface.cpp
engines/gob/surface.h
engines/gob/totfile.cpp
engines/gob/totfile.h
engines/gob/util.cpp
engines/gob/util.h
engines/gob/variables.cpp
engines/gob/variables.h
engines/gob/video.cpp
engines/gob/video.h
engines/gob/video_v1.cpp
engines/gob/video_v2.cpp
engines/gob/video_v6.cpp
engines/gob/videoplayer.cpp
engines/gob/videoplayer.h
engines/groovie/cell.cpp
engines/groovie/cell.h
engines/groovie/cursor.cpp
engines/groovie/cursor.h
engines/groovie/debug.cpp
engines/groovie/debug.h
engines/groovie/detection.cpp
engines/groovie/detection.h
engines/groovie/font.cpp
engines/groovie/font.h
engines/groovie/graphics.cpp
engines/groovie/graphics.h
engines/groovie/groovie.cpp
engines/groovie/groovie.h
engines/groovie/lzss.cpp
engines/groovie/lzss.h
engines/groovie/module.mk
engines/groovie/music.cpp
engines/groovie/music.h
engines/groovie/player.cpp
engines/groovie/player.h
engines/groovie/resource.cpp
engines/groovie/resource.h
engines/groovie/roq.cpp
engines/groovie/roq.h
engines/groovie/saveload.cpp
engines/groovie/saveload.h
engines/groovie/script.cpp
engines/groovie/script.h
engines/groovie/stuffit.cpp
engines/groovie/stuffit.h
engines/groovie/vdx.cpp
engines/groovie/vdx.h
engines/hopkins/anim.cpp
engines/hopkins/anim.h
engines/hopkins/computer.cpp
engines/hopkins/computer.h
engines/hopkins/debugger.cpp
engines/hopkins/debugger.h
engines/hopkins/detection.cpp
engines/hopkins/detection_tables.h
engines/hopkins/dialogs.cpp
engines/hopkins/dialogs.h
engines/hopkins/events.cpp
engines/hopkins/events.h
engines/hopkins/files.cpp
engines/hopkins/files.h
engines/hopkins/font.cpp
engines/hopkins/font.h
engines/hopkins/globals.cpp
engines/hopkins/globals.h
engines/hopkins/graphics.cpp
engines/hopkins/graphics.h
engines/hopkins/hopkins.cpp
engines/hopkins/hopkins.h
engines/hopkins/lines.cpp
engines/hopkins/lines.h
engines/hopkins/menu.cpp
engines/hopkins/menu.h
engines/hopkins/objects.cpp
engines/hopkins/objects.h
engines/hopkins/saveload.cpp
engines/hopkins/saveload.h
engines/hopkins/script.cpp
engines/hopkins/script.h
engines/hopkins/sound.cpp
engines/hopkins/sound.h
engines/hopkins/talk.cpp
engines/hopkins/talk.h
engines/hugo/console.cpp
engines/hugo/console.h
engines/hugo/detection.cpp
engines/hugo/dialogs.cpp
engines/hugo/dialogs.h
engines/hugo/display.cpp
engines/hugo/display.h
engines/hugo/file.cpp
engines/hugo/file.h
engines/hugo/file_v1d.cpp
engines/hugo/file_v1w.cpp
engines/hugo/file_v2d.cpp
engines/hugo/file_v2w.cpp
engines/hugo/file_v3d.cpp
engines/hugo/game.h
engines/hugo/hugo.cpp
engines/hugo/hugo.h
engines/hugo/intro.cpp
engines/hugo/intro.h
engines/hugo/inventory.cpp
engines/hugo/inventory.h
engines/hugo/mouse.cpp
engines/hugo/mouse.h
engines/hugo/object.cpp
engines/hugo/object.h
engines/hugo/object_v1d.cpp
engines/hugo/object_v1w.cpp
engines/hugo/object_v2d.cpp
engines/hugo/object_v3d.cpp
engines/hugo/parser.cpp
engines/hugo/parser.h
engines/hugo/parser_v1d.cpp
engines/hugo/parser_v1w.cpp
engines/hugo/parser_v2d.cpp
engines/hugo/parser_v3d.cpp
engines/hugo/route.cpp
engines/hugo/route.h
engines/hugo/schedule.cpp
engines/hugo/schedule.h
engines/hugo/sound.cpp
engines/hugo/sound.h
engines/hugo/text.cpp
engines/hugo/text.h
engines/hugo/util.cpp
engines/hugo/util.h
engines/kyra/animator_hof.cpp
engines/kyra/animator_lok.cpp
engines/kyra/animator_lok.h
engines/kyra/animator_mr.cpp
engines/kyra/animator_tim.cpp
engines/kyra/animator_v2.cpp
engines/kyra/chargen.cpp
engines/kyra/darkmoon.cpp
engines/kyra/darkmoon.h
engines/kyra/debugger.cpp
engines/kyra/debugger.h
engines/kyra/detection_tables.h
engines/kyra/eob.cpp
engines/kyra/eob.h
engines/kyra/eobcommon.cpp
engines/kyra/eobcommon.h
engines/kyra/gui.cpp
engines/kyra/gui.h
engines/kyra/gui_eob.cpp
engines/kyra/gui_eob.h
engines/kyra/gui_hof.cpp
engines/kyra/gui_hof.h
engines/kyra/gui_lok.cpp
engines/kyra/gui_lok.h
engines/kyra/gui_lol.cpp
engines/kyra/gui_lol.h
engines/kyra/gui_mr.cpp
engines/kyra/gui_mr.h
engines/kyra/gui_rpg.cpp
engines/kyra/gui_v1.cpp
engines/kyra/gui_v1.h
engines/kyra/gui_v2.cpp
engines/kyra/gui_v2.h
engines/kyra/item.h
engines/kyra/items_eob.cpp
engines/kyra/items_hof.cpp
engines/kyra/items_lok.cpp
engines/kyra/items_lol.cpp
engines/kyra/items_mr.cpp
engines/kyra/items_v2.cpp
engines/kyra/kyra_hof.cpp
engines/kyra/kyra_hof.h
engines/kyra/kyra_lok.cpp
engines/kyra/kyra_lok.h
engines/kyra/kyra_mr.cpp
engines/kyra/kyra_mr.h
engines/kyra/kyra_rpg.cpp
engines/kyra/kyra_rpg.h
engines/kyra/kyra_v1.cpp
engines/kyra/kyra_v1.h
engines/kyra/kyra_v2.cpp
engines/kyra/kyra_v2.h
engines/kyra/lol.cpp
engines/kyra/lol.h
engines/kyra/magic_eob.cpp
engines/kyra/resource.cpp
engines/kyra/resource.h
engines/kyra/resource_intern.cpp
engines/kyra/resource_intern.h
engines/kyra/saveload.cpp
engines/kyra/saveload_eob.cpp
engines/kyra/saveload_hof.cpp
engines/kyra/saveload_lok.cpp
engines/kyra/saveload_lol.cpp
engines/kyra/saveload_mr.cpp
engines/kyra/saveload_rpg.cpp
engines/kyra/scene_eob.cpp
engines/kyra/scene_hof.cpp
engines/kyra/scene_lok.cpp
engines/kyra/scene_lol.cpp
engines/kyra/scene_mr.cpp
engines/kyra/scene_rpg.cpp
engines/kyra/scene_v1.cpp
engines/kyra/scene_v2.cpp
engines/kyra/screen.cpp
engines/kyra/screen.h
engines/kyra/screen_eob.cpp
engines/kyra/screen_eob.h
engines/kyra/screen_hof.cpp
engines/kyra/screen_hof.h
engines/kyra/screen_lok.cpp
engines/kyra/screen_lok.h
engines/kyra/screen_lol.cpp
engines/kyra/screen_lol.h
engines/kyra/screen_mr.cpp
engines/kyra/screen_mr.h
engines/kyra/screen_v2.cpp
engines/kyra/screen_v2.h
engines/kyra/script.cpp
engines/kyra/script.h
engines/kyra/script_eob.cpp
engines/kyra/script_eob.h
engines/kyra/script_hof.cpp
engines/kyra/script_lok.cpp
engines/kyra/script_lol.cpp
engines/kyra/script_mr.cpp
engines/kyra/script_tim.cpp
engines/kyra/script_tim.h
engines/kyra/script_v1.cpp
engines/kyra/script_v2.cpp
engines/kyra/seqplayer.cpp
engines/kyra/seqplayer.h
engines/kyra/sequences_darkmoon.cpp
engines/kyra/sequences_eob.cpp
engines/kyra/sequences_hof.cpp
engines/kyra/sequences_hof.h
engines/kyra/sequences_lok.cpp
engines/kyra/sequences_lol.cpp
engines/kyra/sequences_mr.cpp
engines/kyra/sequences_v2.cpp
engines/kyra/sound.cpp
engines/kyra/sound_adlib.cpp
engines/kyra/sound_amiga.cpp
engines/kyra/sound_digital.cpp
engines/kyra/sound_lok.cpp
engines/kyra/sound_lol.cpp
engines/kyra/sound_midi.cpp
engines/kyra/sound_pcspk.cpp
engines/kyra/sound_towns.cpp
engines/kyra/sprites.cpp
engines/kyra/sprites.h
engines/kyra/sprites_eob.cpp
engines/kyra/sprites_lol.cpp
engines/kyra/sprites_rpg.cpp
engines/kyra/staticres.cpp
engines/kyra/staticres_eob.cpp
engines/kyra/staticres_lol.cpp
engines/kyra/staticres_rpg.cpp
engines/kyra/text.cpp
engines/kyra/text.h
engines/kyra/text_hof.cpp
engines/kyra/text_hof.h
engines/kyra/text_lok.cpp
engines/kyra/text_lol.cpp
engines/kyra/text_lol.h
engines/kyra/text_mr.cpp
engines/kyra/text_mr.h
engines/kyra/text_rpg.cpp
engines/kyra/text_rpg.h
engines/kyra/timer.cpp
engines/kyra/timer.h
engines/kyra/timer_eob.cpp
engines/kyra/timer_hof.cpp
engines/kyra/timer_lok.cpp
engines/kyra/timer_lol.cpp
engines/kyra/timer_mr.cpp
engines/kyra/timer_rpg.cpp
engines/kyra/util.cpp
engines/kyra/util.h
engines/kyra/vqa.cpp
engines/kyra/vqa.h
engines/kyra/wsamovie.cpp
engines/kyra/wsamovie.h
engines/lastexpress/data/animation.cpp
engines/lastexpress/data/animation.h
engines/lastexpress/data/archive.cpp
engines/lastexpress/data/archive.h
engines/lastexpress/data/background.cpp
engines/lastexpress/data/background.h
engines/lastexpress/data/cursor.cpp
engines/lastexpress/data/cursor.h
engines/lastexpress/data/font.cpp
engines/lastexpress/data/font.h
engines/lastexpress/data/scene.cpp
engines/lastexpress/data/scene.h
engines/lastexpress/data/sequence.cpp
engines/lastexpress/data/sequence.h
engines/lastexpress/data/snd.cpp
engines/lastexpress/data/snd.h
engines/lastexpress/data/subtitle.cpp
engines/lastexpress/data/subtitle.h
engines/lastexpress/debug.cpp
engines/lastexpress/debug.h
engines/lastexpress/detection.cpp
engines/lastexpress/drawable.h
engines/lastexpress/entities/abbot.cpp
engines/lastexpress/entities/abbot.h
engines/lastexpress/entities/alexei.cpp
engines/lastexpress/entities/alexei.h
engines/lastexpress/entities/alouan.cpp
engines/lastexpress/entities/alouan.h
engines/lastexpress/entities/anna.cpp
engines/lastexpress/entities/anna.h
engines/lastexpress/entities/august.cpp
engines/lastexpress/entities/august.h
engines/lastexpress/entities/boutarel.cpp
engines/lastexpress/entities/boutarel.h
engines/lastexpress/entities/chapters.cpp
engines/lastexpress/entities/chapters.h
engines/lastexpress/entities/cooks.cpp
engines/lastexpress/entities/cooks.h
engines/lastexpress/entities/coudert.cpp
engines/lastexpress/entities/coudert.h
engines/lastexpress/entities/entity.cpp
engines/lastexpress/entities/entity.h
engines/lastexpress/entities/entity39.cpp
engines/lastexpress/entities/entity39.h
engines/lastexpress/entities/entity_intern.h
engines/lastexpress/entities/francois.cpp
engines/lastexpress/entities/francois.h
engines/lastexpress/entities/gendarmes.cpp
engines/lastexpress/entities/gendarmes.h
engines/lastexpress/entities/hadija.cpp
engines/lastexpress/entities/hadija.h
engines/lastexpress/entities/ivo.cpp
engines/lastexpress/entities/ivo.h
engines/lastexpress/entities/kahina.cpp
engines/lastexpress/entities/kahina.h
engines/lastexpress/entities/kronos.cpp
engines/lastexpress/entities/kronos.h
engines/lastexpress/entities/mahmud.cpp
engines/lastexpress/entities/mahmud.h
engines/lastexpress/entities/max.cpp
engines/lastexpress/entities/max.h
engines/lastexpress/entities/mertens.cpp
engines/lastexpress/entities/mertens.h
engines/lastexpress/entities/milos.cpp
engines/lastexpress/entities/milos.h
engines/lastexpress/entities/mmeboutarel.cpp
engines/lastexpress/entities/mmeboutarel.h
engines/lastexpress/entities/pascale.cpp
engines/lastexpress/entities/pascale.h
engines/lastexpress/entities/rebecca.cpp
engines/lastexpress/entities/rebecca.h
engines/lastexpress/entities/salko.cpp
engines/lastexpress/entities/salko.h
engines/lastexpress/entities/servers0.cpp
engines/lastexpress/entities/servers0.h
engines/lastexpress/entities/servers1.cpp
engines/lastexpress/entities/servers1.h
engines/lastexpress/entities/sophie.cpp
engines/lastexpress/entities/sophie.h
engines/lastexpress/entities/tables.cpp
engines/lastexpress/entities/tables.h
engines/lastexpress/entities/tatiana.cpp
engines/lastexpress/entities/tatiana.h
engines/lastexpress/entities/train.cpp
engines/lastexpress/entities/train.h
engines/lastexpress/entities/vassili.cpp
engines/lastexpress/entities/vassili.h
engines/lastexpress/entities/verges.cpp
engines/lastexpress/entities/verges.h
engines/lastexpress/entities/vesna.cpp
engines/lastexpress/entities/vesna.h
engines/lastexpress/entities/yasmin.cpp
engines/lastexpress/entities/yasmin.h
engines/lastexpress/eventhandler.h
engines/lastexpress/fight/fight.cpp
engines/lastexpress/fight/fight.h
engines/lastexpress/fight/fighter.cpp
engines/lastexpress/fight/fighter.h
engines/lastexpress/fight/fighter_anna.cpp
engines/lastexpress/fight/fighter_anna.h
engines/lastexpress/fight/fighter_ivo.cpp
engines/lastexpress/fight/fighter_ivo.h
engines/lastexpress/fight/fighter_milos.cpp
engines/lastexpress/fight/fighter_milos.h
engines/lastexpress/fight/fighter_salko.cpp
engines/lastexpress/fight/fighter_salko.h
engines/lastexpress/fight/fighter_vesna.cpp
engines/lastexpress/fight/fighter_vesna.h
engines/lastexpress/game/action.cpp
engines/lastexpress/game/action.h
engines/lastexpress/game/beetle.cpp
engines/lastexpress/game/beetle.h
engines/lastexpress/game/entities.cpp
engines/lastexpress/game/entities.h
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/inventory.h
engines/lastexpress/game/logic.cpp
engines/lastexpress/game/logic.h
engines/lastexpress/game/object.cpp
engines/lastexpress/game/object.h
engines/lastexpress/game/savegame.cpp
engines/lastexpress/game/savegame.h
engines/lastexpress/game/savepoint.cpp
engines/lastexpress/game/savepoint.h
engines/lastexpress/game/scenes.cpp
engines/lastexpress/game/state.cpp
engines/lastexpress/game/state.h
engines/lastexpress/graphics.cpp
engines/lastexpress/graphics.h
engines/lastexpress/helpers.h
engines/lastexpress/lastexpress.cpp
engines/lastexpress/lastexpress.h
engines/lastexpress/menu/clock.cpp
engines/lastexpress/menu/clock.h
engines/lastexpress/menu/menu.cpp
engines/lastexpress/menu/menu.h
engines/lastexpress/menu/trainline.cpp
engines/lastexpress/menu/trainline.h
engines/lastexpress/resource.cpp
engines/lastexpress/resource.h
engines/lastexpress/shared.h
engines/lastexpress/sound/entry.cpp
engines/lastexpress/sound/entry.h
engines/lastexpress/sound/queue.cpp
engines/lastexpress/sound/queue.h
engines/lastexpress/sound/sound.cpp
engines/lastexpress/sound/sound.h
engines/lure/animseq.cpp
engines/lure/animseq.h
engines/lure/debugger.cpp
engines/lure/debugger.h
engines/lure/decode.cpp
engines/lure/decode.h
engines/lure/detection.cpp
engines/lure/disk.cpp
engines/lure/disk.h
engines/lure/events.cpp
engines/lure/events.h
engines/lure/fights.cpp
engines/lure/fights.h
engines/lure/game.cpp
engines/lure/game.h
engines/lure/hotspots.cpp
engines/lure/hotspots.h
engines/lure/intro.cpp
engines/lure/intro.h
engines/lure/lure.cpp
engines/lure/lure.h
engines/lure/luredefs.h
engines/lure/memory.cpp
engines/lure/memory.h
engines/lure/menu.cpp
engines/lure/menu.h
engines/lure/palette.cpp
engines/lure/palette.h
engines/lure/res.cpp
engines/lure/res.h
engines/lure/res_struct.cpp
engines/lure/res_struct.h
engines/lure/room.cpp
engines/lure/room.h
engines/lure/screen.cpp
engines/lure/screen.h
engines/lure/scripts.cpp
engines/lure/scripts.h
engines/lure/sound.cpp
engines/lure/sound.h
engines/lure/strings.cpp
engines/lure/strings.h
engines/lure/surface.cpp
engines/lure/surface.h
engines/made/console.cpp
engines/made/console.h
engines/made/database.cpp
engines/made/database.h
engines/made/detection.cpp
engines/made/graphics.cpp
engines/made/graphics.h
engines/made/made.cpp
engines/made/made.h
engines/made/music.cpp
engines/made/music.h
engines/made/pmvplayer.cpp
engines/made/pmvplayer.h
engines/made/redreader.cpp
engines/made/redreader.h
engines/made/resource.cpp
engines/made/resource.h
engines/made/screen.cpp
engines/made/screen.h
engines/made/screenfx.cpp
engines/made/screenfx.h
engines/made/script.cpp
engines/made/script.h
engines/made/scriptfuncs.cpp
engines/made/scriptfuncs.h
engines/made/sound.cpp
engines/made/sound.h
engines/metaengine.h
engines/mohawk/bitmap.cpp
engines/mohawk/bitmap.h
engines/mohawk/console.cpp
engines/mohawk/console.h
engines/mohawk/cstime.cpp
engines/mohawk/cstime.h
engines/mohawk/cstime_cases.cpp
engines/mohawk/cstime_cases.h
engines/mohawk/cstime_game.cpp
engines/mohawk/cstime_game.h
engines/mohawk/cstime_graphics.cpp
engines/mohawk/cstime_graphics.h
engines/mohawk/cstime_ui.cpp
engines/mohawk/cstime_ui.h
engines/mohawk/cstime_view.cpp
engines/mohawk/cstime_view.h
engines/mohawk/cursors.cpp
engines/mohawk/cursors.h
engines/mohawk/detection.cpp
engines/mohawk/detection_tables.h
engines/mohawk/dialogs.cpp
engines/mohawk/dialogs.h
engines/mohawk/graphics.cpp
engines/mohawk/graphics.h
engines/mohawk/installer_archive.cpp
engines/mohawk/installer_archive.h
engines/mohawk/livingbooks.cpp
engines/mohawk/livingbooks.h
engines/mohawk/livingbooks_code.cpp
engines/mohawk/livingbooks_code.h
engines/mohawk/livingbooks_graphics.cpp
engines/mohawk/livingbooks_graphics.h
engines/mohawk/livingbooks_lbx.cpp
engines/mohawk/livingbooks_lbx.h
engines/mohawk/mohawk.cpp
engines/mohawk/mohawk.h
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
engines/mohawk/myst_graphics.cpp
engines/mohawk/myst_graphics.h
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_scripts.h
engines/mohawk/myst_stacks/channelwood.cpp
engines/mohawk/myst_stacks/channelwood.h
engines/mohawk/myst_stacks/credits.cpp
engines/mohawk/myst_stacks/credits.h
engines/mohawk/myst_stacks/demo.cpp
engines/mohawk/myst_stacks/demo.h
engines/mohawk/myst_stacks/dni.cpp
engines/mohawk/myst_stacks/dni.h
engines/mohawk/myst_stacks/intro.cpp
engines/mohawk/myst_stacks/intro.h
engines/mohawk/myst_stacks/makingof.cpp
engines/mohawk/myst_stacks/makingof.h
engines/mohawk/myst_stacks/mechanical.cpp
engines/mohawk/myst_stacks/mechanical.h
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/myst.h
engines/mohawk/myst_stacks/preview.cpp
engines/mohawk/myst_stacks/preview.h
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_stacks/selenitic.h
engines/mohawk/myst_stacks/slides.cpp
engines/mohawk/myst_stacks/slides.h
engines/mohawk/myst_stacks/stoneship.cpp
engines/mohawk/myst_stacks/stoneship.h
engines/mohawk/myst_state.cpp
engines/mohawk/myst_state.h
engines/mohawk/resource.cpp
engines/mohawk/resource.h
engines/mohawk/resource_cache.cpp
engines/mohawk/resource_cache.h
engines/mohawk/riven.cpp
engines/mohawk/riven.h
engines/mohawk/riven_external.cpp
engines/mohawk/riven_external.h
engines/mohawk/riven_graphics.cpp
engines/mohawk/riven_graphics.h
engines/mohawk/riven_saveload.cpp
engines/mohawk/riven_saveload.h
engines/mohawk/riven_scripts.cpp
engines/mohawk/riven_scripts.h
engines/mohawk/riven_vars.cpp
engines/mohawk/sound.cpp
engines/mohawk/sound.h
engines/mohawk/video.cpp
engines/mohawk/video.h
engines/mohawk/view.cpp
engines/mohawk/view.h
engines/mortevielle/actions.cpp
engines/mortevielle/debugger.cpp
engines/mortevielle/debugger.h
engines/mortevielle/detection.cpp
engines/mortevielle/detection_tables.h
engines/mortevielle/dialogs.cpp
engines/mortevielle/dialogs.h
engines/mortevielle/graphics.cpp
engines/mortevielle/graphics.h
engines/mortevielle/menu.cpp
engines/mortevielle/menu.h
engines/mortevielle/module.mk
engines/mortevielle/mortevielle.cpp
engines/mortevielle/mortevielle.h
engines/mortevielle/mouse.cpp
engines/mortevielle/mouse.h
engines/mortevielle/outtext.cpp
engines/mortevielle/outtext.h
engines/mortevielle/saveload.cpp
engines/mortevielle/saveload.h
engines/mortevielle/sound.cpp
engines/mortevielle/sound.h
engines/mortevielle/utils.cpp
engines/neverhood/background.cpp
engines/neverhood/background.h
engines/neverhood/blbarchive.cpp
engines/neverhood/blbarchive.h
engines/neverhood/console.cpp
engines/neverhood/console.h
engines/neverhood/detection.cpp
engines/neverhood/diskplayerscene.cpp
engines/neverhood/diskplayerscene.h
engines/neverhood/entity.cpp
engines/neverhood/entity.h
engines/neverhood/gamemodule.cpp
engines/neverhood/gamemodule.h
engines/neverhood/gamevars.cpp
engines/neverhood/gamevars.h
engines/neverhood/graphics.cpp
engines/neverhood/graphics.h
engines/neverhood/klaymen.cpp
engines/neverhood/klaymen.h
engines/neverhood/menumodule.cpp
engines/neverhood/menumodule.h
engines/neverhood/messages.h
engines/neverhood/microtiles.cpp
engines/neverhood/microtiles.h
engines/neverhood/module.cpp
engines/neverhood/module.h
engines/neverhood/modules/module1000.cpp
engines/neverhood/modules/module1000.h
engines/neverhood/modules/module1000_sprites.cpp
engines/neverhood/modules/module1000_sprites.h
engines/neverhood/modules/module1100.cpp
engines/neverhood/modules/module1100.h
engines/neverhood/modules/module1100_sprites.cpp
engines/neverhood/modules/module1100_sprites.h
engines/neverhood/modules/module1200.cpp
engines/neverhood/modules/module1200.h
engines/neverhood/modules/module1200_sprites.cpp
engines/neverhood/modules/module1200_sprites.h
engines/neverhood/modules/module1300.cpp
engines/neverhood/modules/module1300.h
engines/neverhood/modules/module1300_sprites.cpp
engines/neverhood/modules/module1300_sprites.h
engines/neverhood/modules/module1400.cpp
engines/neverhood/modules/module1400.h
engines/neverhood/modules/module1400_sprites.cpp
engines/neverhood/modules/module1400_sprites.h
engines/neverhood/modules/module1500.cpp
engines/neverhood/modules/module1500.h
engines/neverhood/modules/module1600.cpp
engines/neverhood/modules/module1600.h
engines/neverhood/modules/module1600_sprites.cpp
engines/neverhood/modules/module1600_sprites.h
engines/neverhood/modules/module1700.cpp
engines/neverhood/modules/module1700.h
engines/neverhood/modules/module1700_sprites.cpp
engines/neverhood/modules/module1700_sprites.h
engines/neverhood/modules/module1800.cpp
engines/neverhood/modules/module1800.h
engines/neverhood/modules/module1900.cpp
engines/neverhood/modules/module1900.h
engines/neverhood/modules/module1900_sprites.cpp
engines/neverhood/modules/module1900_sprites.h
engines/neverhood/modules/module2000.cpp
engines/neverhood/modules/module2000.h
engines/neverhood/modules/module2000_sprites.cpp
engines/neverhood/modules/module2000_sprites.h
engines/neverhood/modules/module2100.cpp
engines/neverhood/modules/module2100.h
engines/neverhood/modules/module2100_sprites.cpp
engines/neverhood/modules/module2100_sprites.h
engines/neverhood/modules/module2200.cpp
engines/neverhood/modules/module2200.h
engines/neverhood/modules/module2200_sprites.cpp
engines/neverhood/modules/module2200_sprites.h
engines/neverhood/modules/module2300.cpp
engines/neverhood/modules/module2300.h
engines/neverhood/modules/module2400.cpp
engines/neverhood/modules/module2400.h
engines/neverhood/modules/module2400_sprites.cpp
engines/neverhood/modules/module2400_sprites.h
engines/neverhood/modules/module2500.cpp
engines/neverhood/modules/module2500.h
engines/neverhood/modules/module2500_sprites.cpp
engines/neverhood/modules/module2500_sprites.h
engines/neverhood/modules/module2600.cpp
engines/neverhood/modules/module2600.h
engines/neverhood/modules/module2600_sprites.cpp
engines/neverhood/modules/module2600_sprites.h
engines/neverhood/modules/module2700.cpp
engines/neverhood/modules/module2700.h
engines/neverhood/modules/module2700_sprites.cpp
engines/neverhood/modules/module2700_sprites.h
engines/neverhood/modules/module2800.cpp
engines/neverhood/modules/module2800.h
engines/neverhood/modules/module2800_sprites.cpp
engines/neverhood/modules/module2800_sprites.h
engines/neverhood/modules/module2900.cpp
engines/neverhood/modules/module2900.h
engines/neverhood/modules/module2900_sprites.cpp
engines/neverhood/modules/module2900_sprites.h
engines/neverhood/modules/module3000.cpp
engines/neverhood/modules/module3000.h
engines/neverhood/modules/module3000_sprites.cpp
engines/neverhood/modules/module3000_sprites.h
engines/neverhood/mouse.cpp
engines/neverhood/mouse.h
engines/neverhood/navigationscene.cpp
engines/neverhood/navigationscene.h
engines/neverhood/neverhood.cpp
engines/neverhood/neverhood.h
engines/neverhood/palette.cpp
engines/neverhood/palette.h
engines/neverhood/resource.cpp
engines/neverhood/resource.h
engines/neverhood/resourceman.cpp
engines/neverhood/resourceman.h
engines/neverhood/saveload.cpp
engines/neverhood/scene.cpp
engines/neverhood/scene.h
engines/neverhood/screen.cpp
engines/neverhood/screen.h
engines/neverhood/smackerplayer.cpp
engines/neverhood/smackerplayer.h
engines/neverhood/smackerscene.cpp
engines/neverhood/smackerscene.h
engines/neverhood/sound.cpp
engines/neverhood/sound.h
engines/neverhood/sprite.cpp
engines/neverhood/sprite.h
engines/neverhood/staticdata.cpp
engines/neverhood/staticdata.h
engines/obsolete.cpp
engines/obsolete.h
engines/parallaction/adlib.cpp
engines/parallaction/balloons.cpp
engines/parallaction/callables_br.cpp
engines/parallaction/callables_ns.cpp
engines/parallaction/debug.cpp
engines/parallaction/debug.h
engines/parallaction/detection.cpp
engines/parallaction/dialogue.cpp
engines/parallaction/disk.h
engines/parallaction/disk_br.cpp
engines/parallaction/disk_ns.cpp
engines/parallaction/exec.cpp
engines/parallaction/exec.h
engines/parallaction/exec_br.cpp
engines/parallaction/exec_ns.cpp
engines/parallaction/font.cpp
engines/parallaction/gfxbase.cpp
engines/parallaction/graphics.cpp
engines/parallaction/graphics.h
engines/parallaction/gui.cpp
engines/parallaction/gui.h
engines/parallaction/gui_br.cpp
engines/parallaction/gui_ns.cpp
engines/parallaction/input.cpp
engines/parallaction/input.h
engines/parallaction/inventory.cpp
engines/parallaction/inventory.h
engines/parallaction/objects.cpp
engines/parallaction/objects.h
engines/parallaction/parallaction.cpp
engines/parallaction/parallaction.h
engines/parallaction/parallaction_br.cpp
engines/parallaction/parallaction_ns.cpp
engines/parallaction/parser.cpp
engines/parallaction/parser.h
engines/parallaction/parser_br.cpp
engines/parallaction/parser_ns.cpp
engines/parallaction/saveload.cpp
engines/parallaction/saveload.h
engines/parallaction/sound.h
engines/parallaction/sound_br.cpp
engines/parallaction/sound_ns.cpp
engines/parallaction/staticres.cpp
engines/parallaction/walk.cpp
engines/parallaction/walk.h
engines/pegasus/ai/ai_area.cpp
engines/pegasus/console.cpp
engines/pegasus/cursor.cpp
engines/pegasus/energymonitor.cpp
engines/pegasus/fader.cpp
engines/pegasus/input.cpp
engines/pegasus/input.h
engines/pegasus/interface.cpp
engines/pegasus/items/inventorypicture.cpp
engines/pegasus/items/item.cpp
engines/pegasus/items/item.h
engines/pegasus/items/itemlist.cpp
engines/pegasus/items/itemlist.h
engines/pegasus/menu.cpp
engines/pegasus/neighborhood/caldoria/caldoria.cpp
engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
engines/pegasus/neighborhood/caldoria/caldoriabomb.h
engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
engines/pegasus/neighborhood/caldoria/caldoriamessages.h
engines/pegasus/neighborhood/mars/mars.cpp
engines/pegasus/neighborhood/neighborhood.cpp
engines/pegasus/neighborhood/neighborhood.h
engines/pegasus/neighborhood/norad/delta/globegame.cpp
engines/pegasus/neighborhood/norad/delta/globegame.h
engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
engines/pegasus/neighborhood/norad/delta/noraddelta.h
engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
engines/pegasus/neighborhood/tsa/fulltsa.cpp
engines/pegasus/neighborhood/tsa/tinytsa.cpp
engines/pegasus/neighborhood/wsc/wsc.cpp
engines/pegasus/pegasus.cpp
engines/pegasus/pegasus.h
engines/pegasus/surface.cpp
engines/pegasus/timers.cpp
engines/queen/bankman.cpp
engines/queen/bankman.h
engines/queen/command.cpp
engines/queen/command.h
engines/queen/credits.cpp
engines/queen/credits.h
engines/queen/cutaway.cpp
engines/queen/cutaway.h
engines/queen/debug.cpp
engines/queen/debug.h
engines/queen/defs.h
engines/queen/display.cpp
engines/queen/display.h
engines/queen/graphics.cpp
engines/queen/graphics.h
engines/queen/grid.cpp
engines/queen/grid.h
engines/queen/input.cpp
engines/queen/input.h
engines/queen/journal.cpp
engines/queen/journal.h
engines/queen/logic.cpp
engines/queen/logic.h
engines/queen/midiadlib.cpp
engines/queen/module.mk
engines/queen/music.cpp
engines/queen/music.h
engines/queen/musicdata.cpp
engines/queen/queen.cpp
engines/queen/queen.h
engines/queen/resource.cpp
engines/queen/resource.h
engines/queen/restables.cpp
engines/queen/sound.cpp
engines/queen/sound.h
engines/queen/state.cpp
engines/queen/state.h
engines/queen/structs.h
engines/queen/talk.cpp
engines/queen/talk.h
engines/queen/walk.cpp
engines/queen/walk.h
engines/saga/actor.cpp
engines/saga/actor.h
engines/saga/actor_path.cpp
engines/saga/actor_walk.cpp
engines/saga/animation.cpp
engines/saga/animation.h
engines/saga/console.cpp
engines/saga/console.h
engines/saga/detection.cpp
engines/saga/detection_tables.h
engines/saga/displayinfo.h
engines/saga/events.cpp
engines/saga/events.h
engines/saga/font.cpp
engines/saga/font.h
engines/saga/font_map.cpp
engines/saga/gfx.cpp
engines/saga/gfx.h
engines/saga/image.cpp
engines/saga/input.cpp
engines/saga/interface.cpp
engines/saga/interface.h
engines/saga/introproc_ihnm.cpp
engines/saga/introproc_ite.cpp
engines/saga/introproc_saga2.cpp
engines/saga/isomap.cpp
engines/saga/isomap.h
engines/saga/itedata.cpp
engines/saga/itedata.h
engines/saga/music.cpp
engines/saga/music.h
engines/saga/objectmap.cpp
engines/saga/objectmap.h
engines/saga/palanim.cpp
engines/saga/palanim.h
engines/saga/puzzle.cpp
engines/saga/puzzle.h
engines/saga/render.cpp
engines/saga/render.h
engines/saga/resource.cpp
engines/saga/resource.h
engines/saga/resource_hrs.cpp
engines/saga/resource_res.cpp
engines/saga/resource_rsc.cpp
engines/saga/saga.cpp
engines/saga/saga.h
engines/saga/saveload.cpp
engines/saga/scene.cpp
engines/saga/scene.h
engines/saga/script.cpp
engines/saga/script.h
engines/saga/sfuncs.cpp
engines/saga/sfuncs_ihnm.cpp
engines/saga/shorten.cpp
engines/saga/shorten.h
engines/saga/sndres.cpp
engines/saga/sndres.h
engines/saga/sound.cpp
engines/saga/sound.h
engines/saga/sprite.cpp
engines/saga/sprite.h
engines/saga/sthread.cpp
engines/savestate.cpp
engines/savestate.h
engines/sci/console.cpp
engines/sci/console.h
engines/sci/debug.h
engines/sci/decompressor.cpp
engines/sci/decompressor.h
engines/sci/detection.cpp
engines/sci/detection_tables.h
engines/sci/engine/features.cpp
engines/sci/engine/features.h
engines/sci/engine/file.cpp
engines/sci/engine/file.h
engines/sci/engine/gc.cpp
engines/sci/engine/gc.h
engines/sci/engine/kernel.cpp
engines/sci/engine/kernel.h
engines/sci/engine/kernel_tables.h
engines/sci/engine/kevent.cpp
engines/sci/engine/kfile.cpp
engines/sci/engine/kgraphics.cpp
engines/sci/engine/kgraphics32.cpp
engines/sci/engine/klists.cpp
engines/sci/engine/kmath.cpp
engines/sci/engine/kmenu.cpp
engines/sci/engine/kmisc.cpp
engines/sci/engine/kmovement.cpp
engines/sci/engine/kparse.cpp
engines/sci/engine/kpathing.cpp
engines/sci/engine/kscripts.cpp
engines/sci/engine/ksound.cpp
engines/sci/engine/kstring.cpp
engines/sci/engine/kvideo.cpp
engines/sci/engine/message.cpp
engines/sci/engine/message.h
engines/sci/engine/object.cpp
engines/sci/engine/object.h
engines/sci/engine/savegame.cpp
engines/sci/engine/savegame.h
engines/sci/engine/script.cpp
engines/sci/engine/script.h
engines/sci/engine/script_patches.cpp
engines/sci/engine/scriptdebug.cpp
engines/sci/engine/seg_manager.cpp
engines/sci/engine/seg_manager.h
engines/sci/engine/segment.cpp
engines/sci/engine/segment.h
engines/sci/engine/selector.cpp
engines/sci/engine/selector.h
engines/sci/engine/state.cpp
engines/sci/engine/state.h
engines/sci/engine/static_selectors.cpp
engines/sci/engine/vm.cpp
engines/sci/engine/vm.h
engines/sci/engine/vm_types.cpp
engines/sci/engine/vm_types.h
engines/sci/engine/workarounds.cpp
engines/sci/engine/workarounds.h
engines/sci/event.cpp
engines/sci/event.h
engines/sci/graphics/animate.cpp
engines/sci/graphics/animate.h
engines/sci/graphics/cache.cpp
engines/sci/graphics/cache.h
engines/sci/graphics/compare.cpp
engines/sci/graphics/compare.h
engines/sci/graphics/controls16.cpp
engines/sci/graphics/controls16.h
engines/sci/graphics/controls32.cpp
engines/sci/graphics/controls32.h
engines/sci/graphics/coordadjuster.cpp
engines/sci/graphics/coordadjuster.h
engines/sci/graphics/cursor.cpp
engines/sci/graphics/cursor.h
engines/sci/graphics/font.cpp
engines/sci/graphics/font.h
engines/sci/graphics/fontsjis.cpp
engines/sci/graphics/fontsjis.h
engines/sci/graphics/frameout.cpp
engines/sci/graphics/frameout.h
engines/sci/graphics/helpers.h
engines/sci/graphics/maciconbar.cpp
engines/sci/graphics/maciconbar.h
engines/sci/graphics/menu.cpp
engines/sci/graphics/menu.h
engines/sci/graphics/paint.cpp
engines/sci/graphics/paint.h
engines/sci/graphics/paint16.cpp
engines/sci/graphics/paint16.h
engines/sci/graphics/paint32.cpp
engines/sci/graphics/paint32.h
engines/sci/graphics/palette.cpp
engines/sci/graphics/palette.h
engines/sci/graphics/picture.cpp
engines/sci/graphics/picture.h
engines/sci/graphics/portrait.cpp
engines/sci/graphics/portrait.h
engines/sci/graphics/ports.cpp
engines/sci/graphics/ports.h
engines/sci/graphics/screen.cpp
engines/sci/graphics/screen.h
engines/sci/graphics/text16.cpp
engines/sci/graphics/text16.h
engines/sci/graphics/text32.cpp
engines/sci/graphics/text32.h
engines/sci/graphics/transitions.cpp
engines/sci/graphics/transitions.h
engines/sci/graphics/view.cpp
engines/sci/graphics/view.h
engines/sci/parser/grammar.cpp
engines/sci/parser/said.cpp
engines/sci/parser/vocabulary.cpp
engines/sci/parser/vocabulary.h
engines/sci/resource.cpp
engines/sci/resource.h
engines/sci/resource_audio.cpp
engines/sci/resource_intern.h
engines/sci/sci.cpp
engines/sci/sci.h
engines/sci/sound/audio.cpp
engines/sci/sound/audio.h
engines/sci/sound/drivers/adlib.cpp
engines/sci/sound/drivers/amigamac.cpp
engines/sci/sound/drivers/cms.cpp
engines/sci/sound/drivers/fb01.cpp
engines/sci/sound/drivers/fmtowns.cpp
engines/sci/sound/drivers/gm_names.h
engines/sci/sound/drivers/map-mt32-to-gm.h
engines/sci/sound/drivers/midi.cpp
engines/sci/sound/drivers/mididriver.h
engines/sci/sound/drivers/pcjr.cpp
engines/sci/sound/midiparser_sci.cpp
engines/sci/sound/midiparser_sci.h
engines/sci/sound/music.cpp
engines/sci/sound/music.h
engines/sci/sound/soundcmd.cpp
engines/sci/sound/soundcmd.h
engines/sci/util.cpp
engines/sci/util.h
engines/sci/video/robot_decoder.cpp
engines/sci/video/robot_decoder.h
engines/sci/video/seq_decoder.cpp
engines/sci/video/seq_decoder.h
engines/scumm/actor.cpp
engines/scumm/actor.h
engines/scumm/actor_he.h
engines/scumm/akos.cpp
engines/scumm/akos.h
engines/scumm/base-costume.cpp
engines/scumm/base-costume.h
engines/scumm/bomp.cpp
engines/scumm/bomp.h
engines/scumm/boxes.cpp
engines/scumm/boxes.h
engines/scumm/camera.cpp
engines/scumm/charset-fontdata.cpp
engines/scumm/charset.cpp
engines/scumm/charset.h
engines/scumm/costume.cpp
engines/scumm/costume.h
engines/scumm/cursor.cpp
engines/scumm/debugger.cpp
engines/scumm/debugger.h
engines/scumm/detection.cpp
engines/scumm/detection.h
engines/scumm/detection_tables.h
engines/scumm/dialogs.cpp
engines/scumm/dialogs.h
engines/scumm/gfx.cpp
engines/scumm/gfx.h
engines/scumm/gfxARM.s
engines/scumm/gfx_towns.cpp
engines/scumm/he/animation_he.cpp
engines/scumm/he/animation_he.h
engines/scumm/he/cup_player_he.cpp
engines/scumm/he/cup_player_he.h
engines/scumm/he/floodfill_he.cpp
engines/scumm/he/floodfill_he.h
engines/scumm/he/intern_he.h
engines/scumm/he/logic/baseball2001.cpp
engines/scumm/he/logic/basketball.cpp
engines/scumm/he/logic/football.cpp
engines/scumm/he/logic/funshop.cpp
engines/scumm/he/logic/moonbase.cpp
engines/scumm/he/logic/puttrace.cpp
engines/scumm/he/logic/soccer.cpp
engines/scumm/he/logic_he.cpp
engines/scumm/he/logic_he.h
engines/scumm/he/palette_he.cpp
engines/scumm/he/resource_he.cpp
engines/scumm/he/resource_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v60he.cpp
engines/scumm/he/script_v70he.cpp
engines/scumm/he/script_v71he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v80he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sound_he.cpp
engines/scumm/he/sound_he.h
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/imuse/imuse.cpp
engines/scumm/imuse/imuse.h
engines/scumm/imuse/imuse_internal.h
engines/scumm/imuse/imuse_part.cpp
engines/scumm/imuse/imuse_player.cpp
engines/scumm/imuse/instrument.cpp
engines/scumm/imuse/instrument.h
engines/scumm/imuse/mac_m68k.cpp
engines/scumm/imuse/mac_m68k.h
engines/scumm/imuse/pcspk.cpp
engines/scumm/imuse/pcspk.h
engines/scumm/imuse/sysex.h
engines/scumm/imuse/sysex_samnmax.cpp
engines/scumm/imuse/sysex_scumm.cpp
engines/scumm/imuse_digi/dimuse.cpp
engines/scumm/imuse_digi/dimuse.h
engines/scumm/imuse_digi/dimuse_bndmgr.cpp
engines/scumm/imuse_digi/dimuse_bndmgr.h
engines/scumm/imuse_digi/dimuse_codecs.cpp
engines/scumm/imuse_digi/dimuse_codecs.h
engines/scumm/imuse_digi/dimuse_music.cpp
engines/scumm/imuse_digi/dimuse_script.cpp
engines/scumm/imuse_digi/dimuse_sndmgr.cpp
engines/scumm/imuse_digi/dimuse_sndmgr.h
engines/scumm/imuse_digi/dimuse_tables.cpp
engines/scumm/imuse_digi/dimuse_tables.h
engines/scumm/imuse_digi/dimuse_track.cpp
engines/scumm/imuse_digi/dimuse_track.h
engines/scumm/input.cpp
engines/scumm/insane/insane.cpp
engines/scumm/insane/insane.h
engines/scumm/insane/insane_ben.cpp
engines/scumm/insane/insane_enemy.cpp
engines/scumm/insane/insane_iact.cpp
engines/scumm/insane/insane_scenes.cpp
engines/scumm/midiparser_ro.cpp
engines/scumm/module.mk
engines/scumm/music.h
engines/scumm/nut_renderer.cpp
engines/scumm/nut_renderer.h
engines/scumm/object.cpp
engines/scumm/object.h
engines/scumm/palette.cpp
engines/scumm/proc3ARM.s
engines/scumm/resource.cpp
engines/scumm/resource.h
engines/scumm/resource_v2.cpp
engines/scumm/resource_v3.cpp
engines/scumm/resource_v4.cpp
engines/scumm/room.cpp
engines/scumm/saveload.cpp
engines/scumm/saveload.h
engines/scumm/script.cpp
engines/scumm/script.h
engines/scumm/script_v0.cpp
engines/scumm/script_v2.cpp
engines/scumm/script_v3.cpp
engines/scumm/script_v4.cpp
engines/scumm/script_v5.cpp
engines/scumm/script_v6.cpp
engines/scumm/script_v8.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
engines/scumm/scumm_v0.h
engines/scumm/scumm_v2.h
engines/scumm/scumm_v3.h
engines/scumm/scumm_v4.h
engines/scumm/scumm_v5.h
engines/scumm/scumm_v6.h
engines/scumm/scumm_v7.h
engines/scumm/scumm_v8.h
engines/scumm/smush/channel.cpp
engines/scumm/smush/channel.h
engines/scumm/smush/codec1.cpp
engines/scumm/smush/codec37.cpp
engines/scumm/smush/codec37.h
engines/scumm/smush/codec47.cpp
engines/scumm/smush/codec47.h
engines/scumm/smush/codec47ARM.s
engines/scumm/smush/imuse_channel.cpp
engines/scumm/smush/saud_channel.cpp
engines/scumm/smush/smush_font.cpp
engines/scumm/smush/smush_font.h
engines/scumm/smush/smush_mixer.cpp
engines/scumm/smush/smush_mixer.h
engines/scumm/smush/smush_player.cpp
engines/scumm/smush/smush_player.h
engines/scumm/sound.cpp
engines/scumm/sound.h
engines/scumm/string.cpp
engines/scumm/vars.cpp
engines/scumm/verbs.cpp
engines/scumm/verbs.h
engines/sky/autoroute.cpp
engines/sky/autoroute.h
engines/sky/control.cpp
engines/sky/control.h
engines/sky/debug.cpp
engines/sky/detection.cpp
engines/sky/disk.cpp
engines/sky/disk.h
engines/sky/grid.cpp
engines/sky/grid.h
engines/sky/hufftext.cpp
engines/sky/intro.cpp
engines/sky/intro.h
engines/sky/logic.cpp
engines/sky/logic.h
engines/sky/mouse.cpp
engines/sky/mouse.h
engines/sky/music/adlibchannel.cpp
engines/sky/music/adlibchannel.h
engines/sky/music/adlibmusic.cpp
engines/sky/music/adlibmusic.h
engines/sky/music/gmchannel.cpp
engines/sky/music/gmchannel.h
engines/sky/music/gmmusic.cpp
engines/sky/music/gmmusic.h
engines/sky/music/mt32music.cpp
engines/sky/music/mt32music.h
engines/sky/music/musicbase.cpp
engines/sky/music/musicbase.h
engines/sky/rnc_deco.cpp
engines/sky/rnc_deco.h
engines/sky/screen.cpp
engines/sky/screen.h
engines/sky/sky.cpp
engines/sky/sky.h
engines/sky/skydefs.h
engines/sky/sound.cpp
engines/sky/sound.h
engines/sky/struc.h
engines/sky/text.cpp
engines/sky/text.h
engines/sword1/animation.cpp
engines/sword1/animation.h
engines/sword1/collision.h
engines/sword1/console.cpp
engines/sword1/console.h
engines/sword1/control.cpp
engines/sword1/control.h
engines/sword1/debug.cpp
engines/sword1/debug.h
engines/sword1/detection.cpp
engines/sword1/eventman.cpp
engines/sword1/eventman.h
engines/sword1/logic.cpp
engines/sword1/logic.h
engines/sword1/memman.cpp
engines/sword1/memman.h
engines/sword1/menu.cpp
engines/sword1/menu.h
engines/sword1/module.mk
engines/sword1/mouse.cpp
engines/sword1/mouse.h
engines/sword1/music.cpp
engines/sword1/music.h
engines/sword1/object.h
engines/sword1/objectman.cpp
engines/sword1/objectman.h
engines/sword1/resman.cpp
engines/sword1/resman.h
engines/sword1/router.cpp
engines/sword1/router.h
engines/sword1/screen.cpp
engines/sword1/screen.h
engines/sword1/sound.cpp
engines/sword1/sound.h
engines/sword1/staticres.cpp
engines/sword1/sword1.cpp
engines/sword1/sword1.h
engines/sword1/sworddefs.h
engines/sword1/swordres.h
engines/sword1/text.cpp
engines/sword1/text.h
engines/sword2/console.cpp
engines/sword2/resman.cpp
engines/sword2/sound.cpp
engines/sword25/console.cpp
engines/sword25/console.h
engines/sword25/detection.cpp
engines/sword25/detection_tables.h
engines/sword25/fmv/movieplayer.cpp
engines/sword25/fmv/movieplayer.h
engines/sword25/fmv/movieplayer_script.cpp
engines/sword25/gfx/animation.cpp
engines/sword25/gfx/animation.h
engines/sword25/gfx/animationdescription.cpp
engines/sword25/gfx/animationdescription.h
engines/sword25/gfx/animationresource.cpp
engines/sword25/gfx/animationresource.h
engines/sword25/gfx/animationtemplate.cpp
engines/sword25/gfx/animationtemplate.h
engines/sword25/gfx/animationtemplateregistry.cpp
engines/sword25/gfx/animationtemplateregistry.h
engines/sword25/gfx/bitmap.cpp
engines/sword25/gfx/bitmap.h
engines/sword25/gfx/bitmapresource.h
engines/sword25/gfx/dynamicbitmap.cpp
engines/sword25/gfx/dynamicbitmap.h
engines/sword25/gfx/fontresource.cpp
engines/sword25/gfx/fontresource.h
engines/sword25/gfx/graphicengine.cpp
engines/sword25/gfx/graphicengine.h
engines/sword25/gfx/graphicengine_script.cpp
engines/sword25/gfx/image/art.cpp
engines/sword25/gfx/image/art.h
engines/sword25/gfx/image/image.h
engines/sword25/gfx/image/imgloader.cpp
engines/sword25/gfx/image/imgloader.h
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/gfx/image/renderedimage.h
engines/sword25/gfx/image/swimage.cpp
engines/sword25/gfx/image/swimage.h
engines/sword25/gfx/image/vectorimage.cpp
engines/sword25/gfx/image/vectorimage.h
engines/sword25/gfx/image/vectorimagerenderer.cpp
engines/sword25/gfx/microtiles.cpp
engines/sword25/gfx/microtiles.h
engines/sword25/gfx/panel.cpp
engines/sword25/gfx/panel.h
engines/sword25/gfx/renderobject.cpp
engines/sword25/gfx/renderobject.h
engines/sword25/gfx/renderobjectmanager.cpp
engines/sword25/gfx/renderobjectmanager.h
engines/sword25/gfx/renderobjectptr.h
engines/sword25/gfx/renderobjectregistry.h
engines/sword25/gfx/rootrenderobject.h
engines/sword25/gfx/screenshot.cpp
engines/sword25/gfx/screenshot.h
engines/sword25/gfx/staticbitmap.cpp
engines/sword25/gfx/staticbitmap.h
engines/sword25/gfx/text.cpp
engines/sword25/gfx/text.h
engines/sword25/gfx/timedrenderobject.cpp
engines/sword25/gfx/timedrenderobject.h
engines/sword25/input/inputengine.cpp
engines/sword25/input/inputengine.h
engines/sword25/input/inputengine_script.cpp
engines/sword25/kernel/common.h
engines/sword25/kernel/filesystemutil.cpp
engines/sword25/kernel/filesystemutil.h
engines/sword25/kernel/inputpersistenceblock.cpp
engines/sword25/kernel/inputpersistenceblock.h
engines/sword25/kernel/kernel.cpp
engines/sword25/kernel/kernel.h
engines/sword25/kernel/kernel_script.cpp
engines/sword25/kernel/objectregistry.h
engines/sword25/kernel/outputpersistenceblock.cpp
engines/sword25/kernel/outputpersistenceblock.h
engines/sword25/kernel/persistable.h
engines/sword25/kernel/persistenceblock.h
engines/sword25/kernel/persistenceservice.cpp
engines/sword25/kernel/persistenceservice.h
engines/sword25/kernel/resmanager.cpp
engines/sword25/kernel/resmanager.h
engines/sword25/kernel/resource.cpp
engines/sword25/kernel/resource.h
engines/sword25/kernel/resservice.h
engines/sword25/kernel/service.h
engines/sword25/math/geometry.h
engines/sword25/math/geometry_script.cpp
engines/sword25/math/line.h
engines/sword25/math/polygon.cpp
engines/sword25/math/polygon.h
engines/sword25/math/region.cpp
engines/sword25/math/region.h
engines/sword25/math/regionregistry.cpp
engines/sword25/math/regionregistry.h
engines/sword25/math/vertex.cpp
engines/sword25/math/vertex.h
engines/sword25/math/walkregion.cpp
engines/sword25/math/walkregion.h
engines/sword25/package/packagemanager.cpp
engines/sword25/package/packagemanager.h
engines/sword25/package/packagemanager_script.cpp
engines/sword25/script/lua_extensions.cpp
engines/sword25/script/luabindhelper.cpp
engines/sword25/script/luabindhelper.h
engines/sword25/script/luacallback.cpp
engines/sword25/script/luacallback.h
engines/sword25/script/luascript.cpp
engines/sword25/script/luascript.h
engines/sword25/script/script.h
engines/sword25/sfx/soundengine.cpp
engines/sword25/sfx/soundengine.h
engines/sword25/sfx/soundengine_script.cpp
engines/sword25/sword25.cpp
engines/sword25/sword25.h
engines/sword25/util/lua/lopcodes.cpp
engines/sword25/util/lua/loslib.cpp
engines/sword25/util/lua/lua.h
engines/sword25/util/lua/scummvm_file.cpp
engines/sword25/util/lua/scummvm_file.h
engines/sword25/util/pluto/pluto.cpp
engines/teenagent/actor.cpp
engines/teenagent/actor.h
engines/teenagent/animation.cpp
engines/teenagent/animation.h
engines/teenagent/callbacks.cpp
engines/teenagent/console.cpp
engines/teenagent/console.h
engines/teenagent/detection.cpp
engines/teenagent/dialog.cpp
engines/teenagent/dialog.h
engines/teenagent/font.cpp
engines/teenagent/font.h
engines/teenagent/inventory.cpp
engines/teenagent/inventory.h
engines/teenagent/music.cpp
engines/teenagent/music.h
engines/teenagent/objects.cpp
engines/teenagent/objects.h
engines/teenagent/pack.cpp
engines/teenagent/pack.h
engines/teenagent/resources.cpp
engines/teenagent/resources.h
engines/teenagent/scene.cpp
engines/teenagent/scene.h
engines/teenagent/segment.cpp
engines/teenagent/segment.h
engines/teenagent/surface.cpp
engines/teenagent/surface.h
engines/teenagent/surface_list.cpp
engines/teenagent/surface_list.h
engines/teenagent/teenagent.cpp
engines/teenagent/teenagent.h
engines/testbed/config-params.cpp
engines/testbed/config-params.h
engines/testbed/config.cpp
engines/testbed/config.h
engines/testbed/detection.cpp
engines/testbed/events.cpp
engines/testbed/events.h
engines/testbed/fs.cpp
engines/testbed/fs.h
engines/testbed/graphics.cpp
engines/testbed/graphics.h
engines/testbed/midi.cpp
engines/testbed/midi.h
engines/testbed/misc.cpp
engines/testbed/misc.h
engines/testbed/savegame.cpp
engines/testbed/savegame.h
engines/testbed/sound.cpp
engines/testbed/sound.h
engines/testbed/template.h
engines/testbed/testbed.cpp
engines/testbed/testbed.h
engines/testbed/testsuite.cpp
engines/testbed/testsuite.h
engines/tinsel/actors.cpp
engines/tinsel/actors.h
engines/tinsel/adpcm.cpp
engines/tinsel/adpcm.h
engines/tinsel/anim.cpp
engines/tinsel/anim.h
engines/tinsel/background.cpp
engines/tinsel/background.h
engines/tinsel/bg.cpp
engines/tinsel/bmv.cpp
engines/tinsel/bmv.h
engines/tinsel/cliprect.cpp
engines/tinsel/cliprect.h
engines/tinsel/config.cpp
engines/tinsel/config.h
engines/tinsel/cursor.cpp
engines/tinsel/cursor.h
engines/tinsel/debugger.cpp
engines/tinsel/debugger.h
engines/tinsel/detection.cpp
engines/tinsel/detection_tables.h
engines/tinsel/dialogs.cpp
engines/tinsel/dialogs.h
engines/tinsel/drives.cpp
engines/tinsel/drives.h
engines/tinsel/dw.h
engines/tinsel/effect.cpp
engines/tinsel/events.cpp
engines/tinsel/events.h
engines/tinsel/faders.cpp
engines/tinsel/faders.h
engines/tinsel/film.h
engines/tinsel/font.cpp
engines/tinsel/font.h
engines/tinsel/graphics.cpp
engines/tinsel/graphics.h
engines/tinsel/handle.cpp
engines/tinsel/handle.h
engines/tinsel/heapmem.cpp
engines/tinsel/heapmem.h
engines/tinsel/mareels.cpp
engines/tinsel/mareels.h
engines/tinsel/move.cpp
engines/tinsel/move.h
engines/tinsel/multiobj.cpp
engines/tinsel/multiobj.h
engines/tinsel/music.cpp
engines/tinsel/music.h
engines/tinsel/object.cpp
engines/tinsel/object.h
engines/tinsel/palette.cpp
engines/tinsel/palette.h
engines/tinsel/pcode.cpp
engines/tinsel/pcode.h
engines/tinsel/pdisplay.cpp
engines/tinsel/pdisplay.h
engines/tinsel/pid.h
engines/tinsel/play.cpp
engines/tinsel/play.h
engines/tinsel/polygons.cpp
engines/tinsel/polygons.h
engines/tinsel/rince.cpp
engines/tinsel/rince.h
engines/tinsel/saveload.cpp
engines/tinsel/savescn.cpp
engines/tinsel/savescn.h
engines/tinsel/scene.cpp
engines/tinsel/scene.h
engines/tinsel/sched.cpp
engines/tinsel/sched.h
engines/tinsel/scn.cpp
engines/tinsel/scn.h
engines/tinsel/scroll.cpp
engines/tinsel/scroll.h
engines/tinsel/sound.cpp
engines/tinsel/sound.h
engines/tinsel/strres.cpp
engines/tinsel/strres.h
engines/tinsel/sysvar.cpp
engines/tinsel/sysvar.h
engines/tinsel/text.cpp
engines/tinsel/text.h
engines/tinsel/timers.cpp
engines/tinsel/timers.h
engines/tinsel/tinlib.cpp
engines/tinsel/tinlib.h
engines/tinsel/tinsel.cpp
engines/tinsel/tinsel.h
engines/tinsel/token.cpp
engines/tinsel/token.h
engines/toltecs/animation.cpp
engines/toltecs/animation.h
engines/toltecs/console.cpp
engines/toltecs/console.h
engines/toltecs/detection.cpp
engines/toltecs/menu.cpp
engines/toltecs/menu.h
engines/toltecs/microtiles.cpp
engines/toltecs/microtiles.h
engines/toltecs/movie.cpp
engines/toltecs/movie.h
engines/toltecs/music.cpp
engines/toltecs/music.h
engines/toltecs/palette.cpp
engines/toltecs/palette.h
engines/toltecs/render.cpp
engines/toltecs/render.h
engines/toltecs/resource.cpp
engines/toltecs/resource.h
engines/toltecs/saveload.cpp
engines/toltecs/screen.cpp
engines/toltecs/screen.h
engines/toltecs/script.cpp
engines/toltecs/script.h
engines/toltecs/segmap.cpp
engines/toltecs/segmap.h
engines/toltecs/sound.cpp
engines/toltecs/sound.h
engines/toltecs/sprite.cpp
engines/toltecs/toltecs.cpp
engines/toltecs/toltecs.h
engines/tony/custom.cpp
engines/tony/custom.h
engines/tony/debugger.cpp
engines/tony/debugger.h
engines/tony/detection.cpp
engines/tony/detection_tables.h
engines/tony/font.cpp
engines/tony/font.h
engines/tony/game.cpp
engines/tony/game.h
engines/tony/gfxcore.cpp
engines/tony/gfxcore.h
engines/tony/gfxengine.cpp
engines/tony/gfxengine.h
engines/tony/globals.cpp
engines/tony/globals.h
engines/tony/input.cpp
engines/tony/input.h
engines/tony/inventory.cpp
engines/tony/inventory.h
engines/tony/loc.cpp
engines/tony/loc.h
engines/tony/mpal/expr.cpp
engines/tony/mpal/expr.h
engines/tony/mpal/loadmpc.cpp
engines/tony/mpal/loadmpc.h
engines/tony/mpal/lzo.cpp
engines/tony/mpal/lzo.h
engines/tony/mpal/memory.cpp
engines/tony/mpal/memory.h
engines/tony/mpal/mpal.cpp
engines/tony/mpal/mpal.h
engines/tony/mpal/mpaldll.h
engines/tony/mpal/mpalutils.cpp
engines/tony/mpal/mpalutils.h
engines/tony/resid.h
engines/tony/sound.cpp
engines/tony/sound.h
engines/tony/tony.cpp
engines/tony/tony.h
engines/tony/tonychar.cpp
engines/tony/tonychar.h
engines/tony/utils.cpp
engines/tony/utils.h
engines/tony/window.cpp
engines/tony/window.h
engines/toon/anim.cpp
engines/toon/anim.h
engines/toon/audio.cpp
engines/toon/audio.h
engines/toon/character.cpp
engines/toon/character.h
engines/toon/console.cpp
engines/toon/console.h
engines/toon/conversation.cpp
engines/toon/conversation.h
engines/toon/detection.cpp
engines/toon/drew.cpp
engines/toon/drew.h
engines/toon/flux.cpp
engines/toon/flux.h
engines/toon/font.cpp
engines/toon/font.h
engines/toon/hotspot.cpp
engines/toon/hotspot.h
engines/toon/movie.cpp
engines/toon/movie.h
engines/toon/path.cpp
engines/toon/path.h
engines/toon/picture.cpp
engines/toon/picture.h
engines/toon/resource.cpp
engines/toon/resource.h
engines/toon/script.cpp
engines/toon/script.h
engines/toon/script_func.cpp
engines/toon/script_func.h
engines/toon/state.cpp
engines/toon/state.h
engines/toon/text.cpp
engines/toon/text.h
engines/toon/tools.cpp
engines/toon/tools.h
engines/toon/toon.cpp
engines/toon/toon.h
engines/touche/console.cpp
engines/touche/console.h
engines/touche/detection.cpp
engines/touche/graphics.cpp
engines/touche/graphics.h
engines/touche/menu.cpp
engines/touche/midi.cpp
engines/touche/midi.h
engines/touche/opcodes.cpp
engines/touche/resource.cpp
engines/touche/saveload.cpp
engines/touche/staticres.cpp
engines/touche/touche.cpp
engines/touche/touche.h
engines/tsage/blue_force/blueforce_dialogs.cpp
engines/tsage/blue_force/blueforce_dialogs.h
engines/tsage/blue_force/blueforce_logic.cpp
engines/tsage/blue_force/blueforce_logic.h
engines/tsage/blue_force/blueforce_scenes0.cpp
engines/tsage/blue_force/blueforce_scenes0.h
engines/tsage/blue_force/blueforce_scenes1.cpp
engines/tsage/blue_force/blueforce_scenes1.h
engines/tsage/blue_force/blueforce_scenes2.cpp
engines/tsage/blue_force/blueforce_scenes2.h
engines/tsage/blue_force/blueforce_scenes3.cpp
engines/tsage/blue_force/blueforce_scenes3.h
engines/tsage/blue_force/blueforce_scenes4.cpp
engines/tsage/blue_force/blueforce_scenes4.h
engines/tsage/blue_force/blueforce_scenes5.cpp
engines/tsage/blue_force/blueforce_scenes5.h
engines/tsage/blue_force/blueforce_scenes6.cpp
engines/tsage/blue_force/blueforce_scenes6.h
engines/tsage/blue_force/blueforce_scenes7.cpp
engines/tsage/blue_force/blueforce_scenes7.h
engines/tsage/blue_force/blueforce_scenes8.cpp
engines/tsage/blue_force/blueforce_scenes8.h
engines/tsage/blue_force/blueforce_scenes9.cpp
engines/tsage/blue_force/blueforce_scenes9.h
engines/tsage/blue_force/blueforce_speakers.cpp
engines/tsage/blue_force/blueforce_speakers.h
engines/tsage/converse.cpp
engines/tsage/converse.h
engines/tsage/core.cpp
engines/tsage/core.h
engines/tsage/debugger.cpp
engines/tsage/debugger.h
engines/tsage/detection.cpp
engines/tsage/detection_tables.h
engines/tsage/dialogs.cpp
engines/tsage/dialogs.h
engines/tsage/events.cpp
engines/tsage/events.h
engines/tsage/globals.cpp
engines/tsage/globals.h
engines/tsage/graphics.cpp
engines/tsage/graphics.h
engines/tsage/resources.cpp
engines/tsage/resources.h
engines/tsage/ringworld/ringworld_demo.cpp
engines/tsage/ringworld/ringworld_demo.h
engines/tsage/ringworld/ringworld_dialogs.cpp
engines/tsage/ringworld/ringworld_dialogs.h
engines/tsage/ringworld/ringworld_logic.cpp
engines/tsage/ringworld/ringworld_logic.h
engines/tsage/ringworld/ringworld_scenes1.cpp
engines/tsage/ringworld/ringworld_scenes1.h
engines/tsage/ringworld/ringworld_scenes10.cpp
engines/tsage/ringworld/ringworld_scenes10.h
engines/tsage/ringworld/ringworld_scenes2.cpp
engines/tsage/ringworld/ringworld_scenes2.h
engines/tsage/ringworld/ringworld_scenes3.cpp
engines/tsage/ringworld/ringworld_scenes3.h
engines/tsage/ringworld/ringworld_scenes4.cpp
engines/tsage/ringworld/ringworld_scenes4.h
engines/tsage/ringworld/ringworld_scenes5.cpp
engines/tsage/ringworld/ringworld_scenes5.h
engines/tsage/ringworld/ringworld_scenes6.cpp
engines/tsage/ringworld/ringworld_scenes6.h
engines/tsage/ringworld/ringworld_scenes8.cpp
engines/tsage/ringworld/ringworld_scenes8.h
engines/tsage/ringworld/ringworld_speakers.cpp
engines/tsage/ringworld/ringworld_speakers.h
engines/tsage/ringworld2/ringworld2_dialogs.cpp
engines/tsage/ringworld2/ringworld2_dialogs.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_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/saveload.cpp
engines/tsage/saveload.h
engines/tsage/scenes.cpp
engines/tsage/scenes.h
engines/tsage/sound.cpp
engines/tsage/sound.h
engines/tsage/staticres.cpp
engines/tsage/staticres.h
engines/tsage/tsage.cpp
engines/tsage/tsage.h
engines/tsage/user_interface.cpp
engines/tsage/user_interface.h
engines/tucker/console.cpp
engines/tucker/console.h
engines/tucker/detection.cpp
engines/tucker/graphics.cpp
engines/tucker/graphics.h
engines/tucker/locations.cpp
engines/tucker/resource.cpp
engines/tucker/saveload.cpp
engines/tucker/sequences.cpp
engines/tucker/staticres.cpp
engines/tucker/tucker.cpp
engines/tucker/tucker.h
engines/util.h
engines/wintermute/ad/ad_actor.cpp
engines/wintermute/ad/ad_actor.h
engines/wintermute/ad/ad_entity.cpp
engines/wintermute/ad/ad_entity.h
engines/wintermute/ad/ad_game.cpp
engines/wintermute/ad/ad_game.h
engines/wintermute/ad/ad_inventory.cpp
engines/wintermute/ad/ad_inventory.h
engines/wintermute/ad/ad_inventory_box.cpp
engines/wintermute/ad/ad_inventory_box.h
engines/wintermute/ad/ad_item.cpp
engines/wintermute/ad/ad_item.h
engines/wintermute/ad/ad_layer.cpp
engines/wintermute/ad/ad_layer.h
engines/wintermute/ad/ad_node_state.cpp
engines/wintermute/ad/ad_node_state.h
engines/wintermute/ad/ad_object.cpp
engines/wintermute/ad/ad_object.h
engines/wintermute/ad/ad_path.cpp
engines/wintermute/ad/ad_path.h
engines/wintermute/ad/ad_path_point.cpp
engines/wintermute/ad/ad_path_point.h
engines/wintermute/ad/ad_region.cpp
engines/wintermute/ad/ad_region.h
engines/wintermute/ad/ad_response.cpp
engines/wintermute/ad/ad_response.h
engines/wintermute/ad/ad_response_box.cpp
engines/wintermute/ad/ad_response_box.h
engines/wintermute/ad/ad_response_context.cpp
engines/wintermute/ad/ad_response_context.h
engines/wintermute/ad/ad_rot_level.cpp
engines/wintermute/ad/ad_rot_level.h
engines/wintermute/ad/ad_scale_level.cpp
engines/wintermute/ad/ad_scale_level.h
engines/wintermute/ad/ad_scene.cpp
engines/wintermute/ad/ad_scene.h
engines/wintermute/ad/ad_scene_node.cpp
engines/wintermute/ad/ad_scene_node.h
engines/wintermute/ad/ad_scene_state.cpp
engines/wintermute/ad/ad_scene_state.h
engines/wintermute/ad/ad_sentence.cpp
engines/wintermute/ad/ad_sentence.h
engines/wintermute/ad/ad_sprite_set.cpp
engines/wintermute/ad/ad_sprite_set.h
engines/wintermute/ad/ad_talk_def.cpp
engines/wintermute/ad/ad_talk_def.h
engines/wintermute/ad/ad_talk_holder.cpp
engines/wintermute/ad/ad_talk_holder.h
engines/wintermute/ad/ad_talk_node.cpp
engines/wintermute/ad/ad_talk_node.h
engines/wintermute/ad/ad_types.h
engines/wintermute/ad/ad_waypoint_group.cpp
engines/wintermute/ad/ad_waypoint_group.h
engines/wintermute/base/base.cpp
engines/wintermute/base/base.h
engines/wintermute/base/base_active_rect.cpp
engines/wintermute/base/base_active_rect.h
engines/wintermute/base/base_dynamic_buffer.cpp
engines/wintermute/base/base_dynamic_buffer.h
engines/wintermute/base/base_engine.cpp
engines/wintermute/base/base_engine.h
engines/wintermute/base/base_fader.cpp
engines/wintermute/base/base_fader.h
engines/wintermute/base/base_file_manager.cpp
engines/wintermute/base/base_file_manager.h
engines/wintermute/base/base_frame.cpp
engines/wintermute/base/base_frame.h
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_game.h
engines/wintermute/base/base_game_music.cpp
engines/wintermute/base/base_game_music.h
engines/wintermute/base/base_game_settings.cpp
engines/wintermute/base/base_game_settings.h
engines/wintermute/base/base_keyboard_state.cpp
engines/wintermute/base/base_keyboard_state.h
engines/wintermute/base/base_named_object.cpp
engines/wintermute/base/base_named_object.h
engines/wintermute/base/base_object.cpp
engines/wintermute/base/base_object.h
engines/wintermute/base/base_parser.cpp
engines/wintermute/base/base_parser.h
engines/wintermute/base/base_persistence_manager.cpp
engines/wintermute/base/base_persistence_manager.h
engines/wintermute/base/base_point.cpp
engines/wintermute/base/base_point.h
engines/wintermute/base/base_quick_msg.cpp
engines/wintermute/base/base_quick_msg.h
engines/wintermute/base/base_region.cpp
engines/wintermute/base/base_region.h
engines/wintermute/base/base_script_holder.cpp
engines/wintermute/base/base_script_holder.h
engines/wintermute/base/base_scriptable.cpp
engines/wintermute/base/base_scriptable.h
engines/wintermute/base/base_sprite.cpp
engines/wintermute/base/base_sprite.h
engines/wintermute/base/base_string_table.cpp
engines/wintermute/base/base_string_table.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/base_sub_frame.h
engines/wintermute/base/base_surface_storage.cpp
engines/wintermute/base/base_surface_storage.h
engines/wintermute/base/base_transition_manager.cpp
engines/wintermute/base/base_transition_manager.h
engines/wintermute/base/base_viewport.cpp
engines/wintermute/base/base_viewport.h
engines/wintermute/base/file/base_disk_file.cpp
engines/wintermute/base/file/base_disk_file.h
engines/wintermute/base/file/base_file.cpp
engines/wintermute/base/file/base_file.h
engines/wintermute/base/file/base_file_entry.cpp
engines/wintermute/base/file/base_file_entry.h
engines/wintermute/base/file/base_package.cpp
engines/wintermute/base/file/base_package.h
engines/wintermute/base/file/base_save_thumb_file.cpp
engines/wintermute/base/file/base_save_thumb_file.h
engines/wintermute/base/file/dcpackage.h
engines/wintermute/base/font/base_font.cpp
engines/wintermute/base/font/base_font.h
engines/wintermute/base/font/base_font_bitmap.cpp
engines/wintermute/base/font/base_font_bitmap.h
engines/wintermute/base/font/base_font_storage.cpp
engines/wintermute/base/font/base_font_storage.h
engines/wintermute/base/font/base_font_truetype.cpp
engines/wintermute/base/font/base_font_truetype.h
engines/wintermute/base/gfx/base_image.cpp
engines/wintermute/base/gfx/base_image.h
engines/wintermute/base/gfx/base_renderer.cpp
engines/wintermute/base/gfx/base_renderer.h
engines/wintermute/base/gfx/base_surface.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.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/base/gfx/osystem/render_ticket.h
engines/wintermute/base/particles/part_emitter.cpp
engines/wintermute/base/particles/part_emitter.h
engines/wintermute/base/particles/part_force.cpp
engines/wintermute/base/particles/part_force.h
engines/wintermute/base/particles/part_particle.cpp
engines/wintermute/base/particles/part_particle.h
engines/wintermute/base/save_thumb_helper.cpp
engines/wintermute/base/save_thumb_helper.h
engines/wintermute/base/saveload.cpp
engines/wintermute/base/saveload.h
engines/wintermute/base/scriptables/dcscript.h
engines/wintermute/base/scriptables/script.cpp
engines/wintermute/base/scriptables/script.h
engines/wintermute/base/scriptables/script_engine.cpp
engines/wintermute/base/scriptables/script_engine.h
engines/wintermute/base/scriptables/script_ext_array.cpp
engines/wintermute/base/scriptables/script_ext_array.h
engines/wintermute/base/scriptables/script_ext_date.cpp
engines/wintermute/base/scriptables/script_ext_date.h
engines/wintermute/base/scriptables/script_ext_file.cpp
engines/wintermute/base/scriptables/script_ext_file.h
engines/wintermute/base/scriptables/script_ext_math.cpp
engines/wintermute/base/scriptables/script_ext_math.h
engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
engines/wintermute/base/scriptables/script_ext_mem_buffer.h
engines/wintermute/base/scriptables/script_ext_object.cpp
engines/wintermute/base/scriptables/script_ext_object.h
engines/wintermute/base/scriptables/script_ext_string.cpp
engines/wintermute/base/scriptables/script_ext_string.h
engines/wintermute/base/scriptables/script_stack.cpp
engines/wintermute/base/scriptables/script_stack.h
engines/wintermute/base/scriptables/script_value.cpp
engines/wintermute/base/scriptables/script_value.h
engines/wintermute/base/sound/base_sound.cpp
engines/wintermute/base/sound/base_sound.h
engines/wintermute/base/sound/base_sound_buffer.cpp
engines/wintermute/base/sound/base_sound_buffer.h
engines/wintermute/base/sound/base_sound_manager.cpp
engines/wintermute/base/sound/base_sound_manager.h
engines/wintermute/base/timer.cpp
engines/wintermute/base/timer.h
engines/wintermute/coll_templ.h
engines/wintermute/dcgf.h
engines/wintermute/dctypes.h
engines/wintermute/debugger.cpp
engines/wintermute/debugger.h
engines/wintermute/detection.cpp
engines/wintermute/detection_tables.h
engines/wintermute/graphics/transform_struct.cpp
engines/wintermute/graphics/transform_struct.h
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
engines/wintermute/math/floatpoint.h
engines/wintermute/math/math_util.cpp
engines/wintermute/math/math_util.h
engines/wintermute/math/matrix4.cpp
engines/wintermute/math/matrix4.h
engines/wintermute/math/rect32.h
engines/wintermute/math/vector2.cpp
engines/wintermute/math/vector2.h
engines/wintermute/module.mk
engines/wintermute/persistent.cpp
engines/wintermute/persistent.h
engines/wintermute/platform_osystem.cpp
engines/wintermute/platform_osystem.h
engines/wintermute/system/sys_class.cpp
engines/wintermute/system/sys_class.h
engines/wintermute/system/sys_class_registry.cpp
engines/wintermute/system/sys_class_registry.h
engines/wintermute/system/sys_instance.cpp
engines/wintermute/system/sys_instance.h
engines/wintermute/ui/ui_button.cpp
engines/wintermute/ui/ui_button.h
engines/wintermute/ui/ui_edit.cpp
engines/wintermute/ui/ui_edit.h
engines/wintermute/ui/ui_entity.cpp
engines/wintermute/ui/ui_entity.h
engines/wintermute/ui/ui_object.cpp
engines/wintermute/ui/ui_object.h
engines/wintermute/ui/ui_text.cpp
engines/wintermute/ui/ui_text.h
engines/wintermute/ui/ui_tiled_image.cpp
engines/wintermute/ui/ui_tiled_image.h
engines/wintermute/ui/ui_window.cpp
engines/wintermute/ui/ui_window.h
engines/wintermute/utils/path_util.cpp
engines/wintermute/utils/path_util.h
engines/wintermute/utils/string_util.cpp
engines/wintermute/utils/string_util.h
engines/wintermute/utils/utils.cpp
engines/wintermute/utils/utils.h
engines/wintermute/video/video_player.cpp
engines/wintermute/video/video_player.h
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
engines/wintermute/wintermute.cpp
engines/wintermute/wintermute.h
engines/wintermute/wintypes.h
engines/zvision/detection.cpp
engines/zvision/detection.h
graphics/VectorRendererSpec.cpp
graphics/colormasks.h
graphics/conversion.cpp
graphics/conversion.h
graphics/cursor.h
graphics/cursorman.cpp
graphics/cursorman.h
graphics/font.cpp
graphics/font.h
graphics/fontman.cpp
graphics/fontman.h
graphics/fonts/bdf.cpp
graphics/fonts/bdf.h
graphics/fonts/ttf.cpp
graphics/fonts/ttf.h
graphics/fonts/winfont.cpp
graphics/fonts/winfont.h
graphics/maccursor.cpp
graphics/maccursor.h
graphics/module.mk
graphics/palette.h
graphics/pixelformat.h
graphics/primitives.cpp
graphics/primitives.h
graphics/scaler.cpp
graphics/scaler.h
graphics/scaler/2xsai.cpp
graphics/scaler/Normal2xARM.s
graphics/scaler/aspect.cpp
graphics/scaler/aspect.h
graphics/scaler/downscaler.cpp
graphics/scaler/downscaler.h
graphics/scaler/downscalerARM.s
graphics/scaler/hq2x.cpp
graphics/scaler/hq3x.cpp
graphics/scaler/intern.h
graphics/scaler/scale2xARM.s
graphics/scaler/thumbnail_intern.cpp
graphics/sjis.cpp
graphics/sjis.h
graphics/surface.cpp
graphics/surface.h
graphics/thumbnail.cpp
graphics/thumbnail.h
graphics/wincursor.cpp
graphics/wincursor.h
gui/Actions.cpp
gui/Actions.h
gui/EventRecorder.cpp
gui/EventRecorder.h
gui/Key.cpp
gui/Key.h
gui/KeysDialog.cpp
gui/KeysDialog.h
gui/ThemeEngine.cpp
gui/Tooltip.cpp
gui/Tooltip.h
gui/about.cpp
gui/about.h
gui/browser.cpp
gui/browser.h
gui/chooser.cpp
gui/chooser.h
gui/console.cpp
gui/console.h
gui/credits.h
gui/debugger.cpp
gui/debugger.h
gui/dialog.cpp
gui/dialog.h
gui/editrecorddialog.cpp
gui/editrecorddialog.h
gui/error.cpp
gui/error.h
gui/fluidsynth-dialog.cpp
gui/fluidsynth-dialog.h
gui/gui-manager.cpp
gui/gui-manager.h
gui/launcher.cpp
gui/launcher.h
gui/massadd.cpp
gui/massadd.h
gui/message.cpp
gui/message.h
gui/object.cpp
gui/object.h
gui/onscreendialog.cpp
gui/onscreendialog.h
gui/options.cpp
gui/options.h
gui/predictivedialog.cpp
gui/predictivedialog.h
gui/recorderdialog.cpp
gui/recorderdialog.h
gui/saveload-dialog.cpp
gui/saveload-dialog.h
gui/saveload.cpp
gui/saveload.h
gui/themebrowser.cpp
gui/themebrowser.h
gui/themes/default.inc
gui/themes/scummclassic.zip
gui/themes/scummclassic/classic_layout_lowres.stx
gui/themes/scummtheme.py
gui/themes/translations.dat
gui/widget.cpp
gui/widget.h
gui/widgets/editable.cpp
gui/widgets/editable.h
gui/widgets/edittext.cpp
gui/widgets/edittext.h
gui/widgets/list.cpp
gui/widgets/list.h
gui/widgets/popup.cpp
gui/widgets/popup.h
gui/widgets/scrollbar.cpp
gui/widgets/scrollbar.h
gui/widgets/tab.cpp
gui/widgets/tab.h
po/be_BY.po
po/ca_ES.po
po/cs_CZ.po
po/da_DA.po
po/de_DE.po
po/es_ES.po
po/eu.po
po/fi_FI.po
po/fr_FR.po
po/gl_ES.po
po/hu_HU.po
po/it_IT.po
po/nb_NO.po
po/nn_NO.po
po/pl_PL.po
po/pt_BR.po
po/ru_RU.po
po/scummvm.pot
po/se_SE.po
po/uk_UA.po
ports.mk
test/common/util.h
test/cxxtest_mingw.h
video/avi_decoder.cpp
video/avi_decoder.h
video/bink_decoder.cpp
video/bink_decoder.h
video/binkdata.h
video/coktel_decoder.cpp
video/coktel_decoder.h
video/dxa_decoder.cpp
video/dxa_decoder.h
video/flic_decoder.cpp
video/flic_decoder.h
video/module.mk
video/psx_decoder.cpp
video/psx_decoder.h
video/qt_decoder.cpp
video/qt_decoder.h
video/smk_decoder.cpp
video/smk_decoder.h
video/theora_decoder.cpp
video/theora_decoder.h
video/video_decoder.cpp
video/video_decoder.h
diff --cc engines/zvision/animation/rlf_animation.cpp
index 0000000,945461e..5784df0
mode 000000,100644..100644
--- a/engines/zvision/animation/rlf_animation.cpp
+++ b/engines/zvision/animation/rlf_animation.cpp
@@@ -1,0 -1,331 +1,374 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/animation/rlf_animation.h"
++#include "zvision/rlf_animation.h"
+
+ #include "common/str.h"
+ #include "common/file.h"
+ #include "common/textconsole.h"
+ #include "common/debug.h"
+ #include "common/endian.h"
+
+ #include "graphics/colormasks.h"
+
+
+ namespace ZVision {
+
+ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
- : _stream(stream),
- _lastFrameRead(0),
- _frameCount(0),
- _width(0),
- _height(0),
- _frameTime(0),
- _frames(0),
- _currentFrame(-1),
- _frameBufferByteSize(0) {
- if (!_file.open(fileName)) {
++ : _stream(stream),
++ _readStream(NULL),
++ _lastFrameRead(0),
++ _frameCount(0),
++ _width(0),
++ _height(0),
++ _frameTime(0),
++ _frames(0),
++ _currentFrame(0),
++ _frameBufferByteSize(0) {
++
++ Common::File *_file = new Common::File;
++ if (!_file->open(fileName)) {
+ warning("RLF animation file %s could not be opened", fileName.c_str());
+ return;
+ }
+
++ _readStream = _file;
++
+ if (!readHeader()) {
+ warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str());
+ return;
+ }
+
+ _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>());
+ _frameBufferByteSize = _width * _height * sizeof(uint16);
+
+ if (!stream) {
+ _frames = new Frame[_frameCount];
+
+ // Read in each frame
+ for (uint i = 0; i < _frameCount; ++i) {
+ _frames[i] = readNextFrame();
+ }
+ }
+ }
+
++RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream)
++ : _stream(stream),
++ _readStream(rstream),
++ _lastFrameRead(0),
++ _frameCount(0),
++ _width(0),
++ _height(0),
++ _frameTime(0),
++ _frames(0),
++ _currentFrame(0),
++ _frameBufferByteSize(0) {
++
++ if (!readHeader()) {
++ warning("Stream is not a RLF animation. Wrong magic number");
++ return;
++ }
++
++ _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>());
++ _frameBufferByteSize = _width * _height * sizeof(uint16);
++
++ if (!stream) {
++ _frames = new Frame[_frameCount];
++
++ // Read in each frame
++ for (uint i = 0; i < _frameCount; ++i) {
++ _frames[i] = readNextFrame();
++ }
++ }
++}
++
+ RlfAnimation::~RlfAnimation() {
+ for (uint i = 0; i < _frameCount; ++i) {
+ delete[] _frames[i].encodedData;
+ }
+ delete[] _frames;
++ delete _readStream;
+ _currentFrameBuffer.free();
+ }
+
+ bool RlfAnimation::readHeader() {
- if (_file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
++ if (_readStream->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
++ _readStream->readUint32LE(); // Size1
++ _readStream->readUint32LE(); // Unknown1
++ _readStream->readUint32LE(); // Unknown2
++ _frameCount = _readStream->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);
++ _readStream->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
++ //_readStream->readUint32BE(); // Magic number FNIC
++ //_readStream->readUint32LE(); // Size2
++ //_readStream->readUint32LE(); // Unknown3
++ //_readStream->readUint32LE(); // Unknown4
++ //_readStream->readUint32LE(); // Unknown5
++ //_readStream->seek(0x18, SEEK_CUR); // VRLE
++ //_readStream->readUint32LE(); // LRVD
++ //_readStream->readUint32LE(); // Unknown6
++ //_readStream->seek(0x18, SEEK_CUR); // HRLE
++ //_readStream->readUint32LE(); // ELHD
++ //_readStream->readUint32LE(); // Unknown7
++ //_readStream->seek(0x18, SEEK_CUR); // HKEY
++ //_readStream->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
++ //_readStream->readUint32BE(); // Magic number FNIM
++ //_readStream->readUint32LE(); // Size3
++ //_readStream->readUint32LE(); // OEDV
++ //_readStream->readUint32LE(); // Unknown8
++ //_readStream->readUint32LE(); // Unknown9
++ //_readStream->readUint32LE(); // Unknown10
++ _width = _readStream->readUint32LE(); // Width
++ _height = _readStream->readUint32LE(); // Height
+
+ // Read time header
- _file.readUint32BE(); // Magic number EMIT
- _file.readUint32LE(); // Size4
- _file.readUint32LE(); // Unknown11
- _frameTime = _file.readUint32LE() / 10; // Frame time in microseconds
++ _readStream->readUint32BE(); // Magic number EMIT
++ _readStream->readUint32LE(); // Size4
++ _readStream->readUint32LE(); // Unknown11
++ _frameTime = _readStream->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
++ _readStream->readUint32BE(); // Magic number MARF
++ uint32 size = _readStream->readUint32LE(); // Size
++ _readStream->readUint32LE(); // Unknown1
++ _readStream->readUint32LE(); // Unknown2
++ uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH
++ uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
++ _readStream->readUint32LE(); // Unknown3
+
+ frame.encodedSize = size - headerSize;
+ frame.encodedData = new int8[frame.encodedSize];
- _file.read(frame.encodedData, frame.encodedSize);
++ _readStream->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;
+ }
+
+ void RlfAnimation::seekToFrame(int frameNumber) {
+ assert(!_stream);
+ assert(frameNumber < (int)_frameCount || frameNumber >= -1);
+
- if (frameNumber == -1) {
- _currentFrame = -1;
++ if (_currentFrame == frameNumber)
++ return;
++
++ if (frameNumber < 0) {
++ _currentFrame = 0;
+ return;
+ }
+
+ int closestFrame = _currentFrame;
+ int distance = (int)frameNumber - _currentFrame;
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
+ int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
- if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
++ if (newDistance < 0)
++ break;
++ if (newDistance > 0 && newDistance < distance) {
+ closestFrame = _completeFrames[i];
+ distance = newDistance;
+ }
+ }
+
- for (int i = closestFrame; i <= frameNumber; ++i) {
++ for (int i = closestFrame; i < frameNumber; ++i) {
+ applyFrameToCurrent(i);
+ }
+
+ _currentFrame = 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) {
++ // decodeNextFrame() it's cheap.
++ if ((int)frameNumber == _currentFrame - 1) {
+ return &_currentFrameBuffer;
- } else if (_currentFrame + 1 == (int)frameNumber) {
- return getNextFrame();
++ } else if (_currentFrame == (int)frameNumber) {
++ return decodeNextFrame();
+ }
+
+ seekToFrame(frameNumber);
- return &_currentFrameBuffer;
++ return decodeNextFrame();
+ }
+
-const Graphics::Surface *RlfAnimation::getNextFrame() {
- assert(_currentFrame + 1 < (int)_frameCount);
++const Graphics::Surface *RlfAnimation::decodeNextFrame() {
++ assert(_currentFrame < (int)_frameCount);
+
+ if (_stream) {
+ applyFrameToCurrent(readNextFrame());
+ } else {
- applyFrameToCurrent(_currentFrame + 1);
++ applyFrameToCurrent(_currentFrame);
+ }
+
+ _currentFrame++;
+ return &_currentFrameBuffer;
+ }
+
+ void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
+ if (_frames[frameNumber].type == Masked) {
+ decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ } else if (_frames[frameNumber].type == Simple) {
+ 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.getPixels(), frame.encodedSize, _frameBufferByteSize);
+ } else if (frame.type == Simple) {
+ decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize);
+ }
+ }
+
+ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
+ uint32 sourceOffset = 0;
+ uint32 destOffset = 0;
++ int16 numberOfCopy = 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);
++ numberOfCopy = -numberOfSamples;
+
- while (numberOfSamples > 0) {
++ while (numberOfCopy > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ 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);
+ WRITE_UINT16(dest + destOffset, destColor);
+
+ sourceOffset += 2;
+ destOffset += 2;
- numberOfSamples--;
++ numberOfCopy--;
+ }
+
- // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
- // This function assumes the dest buffer has been memset with 0's.
++ // 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) {
+ debug(2, "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;
++ int16 numberOfCopy = 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);
++ numberOfCopy = -numberOfSamples;
+
- while (numberOfSamples > 0) {
++ while (numberOfCopy > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ 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);
+ WRITE_UINT16(dest + destOffset, destColor);
+
+ sourceOffset += 2;
+ destOffset += 2;
- numberOfSamples--;
++ numberOfCopy--;
+ }
+
- // If numberOfSamples is >= 0, copy one sample from source to the
- // next (numberOfSamples + 2) dest spots
++ // If numberOfSamples is >= 0, copy one sample from source to the
++ // next (numberOfSamples + 2) dest spots
+ } else {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ }
+
+ 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);
+ sourceOffset += 2;
+
- numberOfSamples += 2;
- while (numberOfSamples > 0) {
++ numberOfCopy = numberOfSamples + 2;
++ while (numberOfCopy > 0) {
+ if (destOffset + 1 >= destSize) {
+ debug(2, "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--;
++ numberOfCopy--;
+ }
+ }
+ }
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/animation/rlf_animation.h
index 0000000,4bb7793..dfb2a60
mode 000000,100644..100644
--- a/engines/zvision/animation/rlf_animation.h
+++ b/engines/zvision/animation/rlf_animation.h
@@@ -1,0 -1,163 +1,173 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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
+
+ #include "common/file.h"
+
+ #include "graphics/surface.h"
+
+
+ namespace Common {
+ class String;
+ }
+
+ namespace ZVision {
+
+ class RlfAnimation {
+ public:
+ RlfAnimation(const Common::String &fileName, bool stream = true);
++ RlfAnimation(Common::SeekableReadStream *rstream, bool stream);
+ ~RlfAnimation();
+
+ private:
+ enum EncodingType {
+ Masked,
+ Simple
+ };
+
+ struct Frame {
+ EncodingType type;
+ int8 *encodedData;
+ uint32 encodedSize;
+ };
+
+ private:
- Common::File _file;
++ Common::SeekableReadStream *_readStream;
+ bool _stream;
+ uint _lastFrameRead;
+
+ uint _frameCount;
+ uint _width;
+ uint _height;
+ uint32 _frameTime; // In milliseconds
+ Frame *_frames;
+ Common::Array<uint> _completeFrames;
+
+ int _currentFrame;
+ Graphics::Surface _currentFrameBuffer;
+ uint32 _frameBufferByteSize;
+
+ public:
- uint frameCount() { return _frameCount; }
- uint width() { return _width; }
- uint height() { return _height; }
- uint32 frameTime() { return _frameTime; }
++ uint frameCount() {
++ return _frameCount;
++ }
++ uint width() {
++ return _width;
++ }
++ 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
++ * decodeNextFrame() 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.
++ * Returns the pixel data of current frame and go to next. It is up to the user to
++ * check if the current frame is valid before calling this.
+ * IE. Use endOfAnimation()
+ *
+ * @return A pointer to the pixel data. Do NOT delete this.
+ */
- const Graphics::Surface *getNextFrame();
-
++ const Graphics::Surface *decodeNextFrame();
+ /**
+ * @return Is the currentFrame is the last frame in the animation?
+ */
- bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
++ bool endOfAnimation() {
++ return _currentFrame == (int)_frameCount;
++ }
+
+ 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;
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/archives/zfs_archive.cpp
index 0000000,f5fa6fc..ed4dcec
mode 000000,100644..100644
--- a/engines/zvision/archives/zfs_archive.cpp
+++ b/engines/zvision/archives/zfs_archive.cpp
@@@ -1,0 -1,157 +1,157 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #include "common/scummsys.h"
+
+ #include "zvision/archives/zfs_archive.h"
+
+ #include "common/memstream.h"
+ #include "common/debug.h"
+ #include "common/file.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(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(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size());
+ }
+
+ ZfsArchive::~ZfsArchive() {
+ debug(1, "ZfsArchive Destructor Called");
+ ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
- for ( ; it != _entryHeaders.end(); ++it) {
++ 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 (uint32 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);
+
+ // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory
- byte* buffer = (byte *)malloc(entryHeader->size);
++ byte *buffer = (byte *)malloc(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, uint32 length, const byte *xorKey) const {
+ for (uint32 i = 0; i < length; ++i)
+ buffer[i] ^= xorKey[i % 4];
+ }
+
+ } // End of namespace ZVision
+
+
diff --cc engines/zvision/archives/zfs_archive.h
index 0000000,3509cfe..44e2c4b
mode 000000,100644..100644
--- a/engines/zvision/archives/zfs_archive.h
+++ b/engines/zvision/archives/zfs_archive.h
@@@ -1,0 -1,126 +1,126 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #ifndef ZVISION_ZFS_ARCHIVE_H
+ #define ZVISION_ZFS_ARCHIVE_H
+
+ #include "common/archive.h"
+ #include "common/hashmap.h"
+ #include "common/hash-str.h"
+
+
+ namespace Common {
+ class String;
+ }
+
+ 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;
++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, uint32 length, const byte *xorKey) const;
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/core/console.cpp
index 0000000,e610f34..252a4b7
mode 000000,100644..100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@@ -1,0 -1,218 +1,217 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/core/console.h"
++#include "zvision/console.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/strings/string_manager.h"
-#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/sound/zork_raw.h"
-#include "zvision/utility/utility.h"
-#include "zvision/cursors/cursor.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"
++#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 {
+
+ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
- registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage));
- registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
- registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound));
- registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
- registerCmd("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState));
- registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
- registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
- registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
- registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
- registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
- registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
- registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText));
++ 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));
++ 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));
++ 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) {
- if (argc == 4)
- _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
- else {
- debugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
- return true;
- }
++// if (argc == 4)
++// _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
++// else {
++// DebugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
++// return true;
++// }
+
+ return true;
+ }
+
+ bool Console::cmdLoadVideo(int argc, const char **argv) {
+ if (argc != 2) {
- debugPrintf("Use loadvideo <fileName> to load a video to the screen\n");
++ DebugPrintf("Use loadvideo <fileName> to load a video to the screen\n");
+ return true;
+ }
+
+ ZorkAVIDecoder videoDecoder;
+ if (videoDecoder.loadFile(argv[1])) {
+ _engine->playVideo(videoDecoder);
+ }
+
+ return true;
+ }
+
+ bool Console::cmdLoadSound(int argc, const char **argv) {
+ if (!Common::File::exists(argv[1])) {
- debugPrintf("File does not exist\n");
++ DebugPrintf("File does not exist\n");
+ return true;
+ }
+
+ 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");
++ DebugPrintf("Use loadsound <fileName> [<rate> <isStereo: 1 or 0>] to load a sound\n");
+ return true;
+ }
+
+ 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");
++ DebugPrintf("Use raw2wav <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n");
+ return true;
+ }
+
+ 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");
++ 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()->getRenderTable()->setRenderState(RenderTable::PANORAMA);
+ else if (renderState.matchString("tilt", true))
+ _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::TILT);
+ else if (renderState.matchString("flat", true))
+ _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
+ else
- debugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
++ DebugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+
+ return true;
+ }
+
+ bool Console::cmdGenerateRenderTable(int argc, const char **argv) {
+ _engine->getRenderManager()->getRenderTable()->generateRenderTable();
+
+ return true;
+ }
+
+ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
+ if (argc != 2) {
- debugPrintf("Use setpanoramafov <fieldOfView> to change the current panorama field of view\n");
++ 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");
++ DebugPrintf("Use setpanoramascale <scale> to change the current panorama scale\n");
+ return true;
+ }
+
+ _engine->getRenderManager()->getRenderTable()->setPanoramaScale(atof(argv[1]));
+
+ 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\n");
++ DebugPrintf("Use changelocation <char: world> <char: room> <char:node> <char:view> <int: x position> to change your location\n");
+ return true;
+ }
+
+ _engine->getScriptManager()->changeLocation(*(argv[1]), *(argv[2]), *(argv[3]), *(argv[4]), atoi(argv[5]));
+
+ return true;
+ }
+
+ bool Console::cmdDumpFile(int argc, const char **argv) {
+ if (argc != 2) {
- debugPrintf("Use dumpfile <fileName> to dump a file\n");
++ DebugPrintf("Use dumpfile <fileName> to dump a file\n");
+ return true;
+ }
+
+ writeFileContentsToFile(argv[1], argv[1]);
+
+ 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;
+ }
+
+ 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");
++ 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(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);
++ //StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
++ //_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
diff --cc engines/zvision/core/events.cpp
index 0000000,83d6c17..189bf00
mode 000000,100644..100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@@ -1,0 -1,186 +1,211 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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/core/console.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/animation/rlf_animation.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 "zvision/menu.h"
+
+ #include "common/events.h"
+ #include "common/system.h"
+ #include "common/rational.h"
+
+ #include "engines/util.h"
+
+
+ namespace ZVision {
+
+ void ZVision::processEvents() {
+ while (_eventMan->pollEvent(_event)) {
+ switch (_event.type) {
+ case Common::EVENT_LBUTTONDOWN:
++ _cursorManager->cursorDown(true);
++ _scriptManager->setStateValue(StateKey_LMouse, 1);
+ onMouseDown(_event.mouse);
+ break;
+
+ case Common::EVENT_LBUTTONUP:
++ _cursorManager->cursorDown(false);
++ _scriptManager->setStateValue(StateKey_LMouse, 0);
+ onMouseUp(_event.mouse);
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
++ _cursorManager->cursorDown(true);
++ _scriptManager->setStateValue(StateKey_RMouse, 1);
+ // TODO: Inventory logic
+ break;
+
++ case Common::EVENT_RBUTTONUP:
++ _cursorManager->cursorDown(false);
++ _scriptManager->setStateValue(StateKey_RMouse, 0);
++ 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
+ _console->attach();
+ _console->onFrame();
+ }
+ break;
+ case Common::KEYCODE_q:
+ if (_event.kbd.hasFlags(Common::KBD_CTRL))
+ quitGame();
+ break;
+ default:
+ break;
+ }
+
+ _scriptManager->onKeyDown(_event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ _scriptManager->onKeyUp(_event.kbd);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ void ZVision::onMouseDown(const Common::Point &pos) {
- _cursorManager->cursorDown(true);
++ _menu->onMouseDown(pos);
+
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
+ _scriptManager->onMouseDown(pos, imageCoord);
+ }
+
+ void ZVision::onMouseUp(const Common::Point &pos) {
- _cursorManager->cursorDown(false);
++ _menu->onMouseUp(pos);
+
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
+ _scriptManager->onMouseUp(pos, imageCoord);
+ }
+
+ void ZVision::onMouseMove(const Common::Point &pos) {
++ _menu->onMouseMove(pos);
+ Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
+
- bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
++ bool cursorWasChanged = false;
+
+ // Graph of the function governing rotation velocity:
+ //
+ // |---------------- working window ------------------|
+ // ^ |---------|
+ // | |
+ // +Max velocity | rotation screen edge offset
+ // | /|
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // | / |
+ // Zero velocity |______________________________ ______________________________/_________|__________________________>
+ // | Position -> | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // | | /
+ // -Max velocity | |/
+ // |
+ // |
+ // ^
+
+ if (_workingWindow.contains(pos)) {
++ cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
++
+ 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();
++
++ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
++ if (mspeed <= 0)
++ mspeed = 400 >> 4;
++ _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
++
++ _cursorManager->changeCursor(CursorIndex_Left);
+ 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();
++
++ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
++ if (mspeed <= 0)
++ mspeed = 400 >> 4;
++ _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
++
++ _cursorManager->changeCursor(CursorIndex_Right);
+ cursorWasChanged = true;
+ } else {
- _renderManager->setBackgroundVelocity(0);
++ _velocity = 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();
++
++ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
++ if (mspeed <= 0)
++ mspeed = 400 >> 4;
++ _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
++
++ _cursorManager->changeCursor(CursorIndex_UpArr);
+ 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();
++
++ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
++ if (mspeed <= 0)
++ mspeed = 400 >> 4;
++ _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
++
++ _cursorManager->changeCursor(CursorIndex_DownArr);
+ cursorWasChanged = true;
+ } else {
- _renderManager->setBackgroundVelocity(0);
++ _velocity = 0;
+ }
++ } else {
++ _velocity = 0;
+ }
+ } else {
- _renderManager->setBackgroundVelocity(0);
++ _velocity = 0;
+ }
+
+ if (!cursorWasChanged) {
- _cursorManager->revertToIdle();
++ _cursorManager->changeCursor(CursorIndex_Idle);
+ }
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/core/menu.h
index 0000000,3ab6d4c..7be03f6
mode 000000,100644..100644
--- a/engines/zvision/core/menu.h
+++ b/engines/zvision/core/menu.h
@@@ -1,0 -1,28 +1,120 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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
++#include "graphics/surface.h"
++#include "common/rect.h"
++
++#include "zvision/zvision.h"
++#include "zvision/script_manager.h"
++
++namespace ZVision {
++
++enum menuBar {
++ menuBar_Exit = 0x1,
++ menuBar_Settings = 0x2,
++ menuBar_Restore = 0x4,
++ menuBar_Save = 0x8,
++ menuBar_Items = 0x100,
++ menuBar_Magic = 0x200
++};
++
++class menuHandler {
++public:
++ menuHandler(ZVision *engine);
++ virtual ~menuHandler() {};
++ virtual void onMouseMove(const Common::Point &Pos) {};
++ virtual void onMouseDown(const Common::Point &Pos) {};
++ virtual void onMouseUp(const Common::Point &Pos) {};
++ virtual void process(uint32 deltaTimeInMillis) {};
++protected:
++ uint16 menu_bar_flag;
++ ZVision *_engine;
++};
++
++class menuZgi: public menuHandler {
++public:
++ menuZgi(ZVision *engine);
++ ~menuZgi();
++ void onMouseMove(const Common::Point &Pos);
++ void onMouseUp(const Common::Point &Pos);
++ void process(uint32 deltaTimeInMillis);
++private:
++ Graphics::Surface menuback[3][2];
++ Graphics::Surface menubar[4][2];
++
++
++ Graphics::Surface *items[50][2];
++ uint item_id[50];
++
++ Graphics::Surface *magic[12][2];
++ uint magic_id[12];
++
++ int menu_mousefocus;
++ bool inmenu;
++
++ int mouse_on_item;
++
++ bool scrolled[3];
++ float scrollPos[3];
++
++ enum {
++ menu_ITEM = 0,
++ menu_MAGIC = 1,
++ menu_MAIN = 2
++ };
++
++ bool clean;
++ bool redraw;
++
++};
++
++class menuNem: public menuHandler {
++public:
++ menuNem(ZVision *engine);
++ ~menuNem();
++ void onMouseMove(const Common::Point &Pos);
++ void onMouseUp(const Common::Point &Pos);
++ void process(uint32 deltaTimeInMillis);
++private:
++ Graphics::Surface but[4][6];
++ Graphics::Surface menubar;
++
++ bool inmenu;
++
++ int mouse_on_item;
++
++ bool scrolled;
++ float scrollPos;
++
++ bool redraw;
++
++ int frm;
++ int16 delay;
++
++};
++
++}
+
+ #endif
diff --cc engines/zvision/core/save_manager.cpp
index 0000000,07fb763..8ec4f4d
mode 000000,100644..100644
--- a/engines/zvision/core/save_manager.cpp
+++ b/engines/zvision/core/save_manager.cpp
@@@ -1,0 -1,206 +1,234 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #include "common/scummsys.h"
+
+ #include "zvision/core/save_manager.h"
+
+ #include "zvision/zvision.h"
+ #include "zvision/scripting/script_manager.h"
+ #include "zvision/graphics/render_manager.h"
+
+ #include "common/system.h"
+
+ #include "graphics/surface.h"
+ #include "graphics/thumbnail.h"
+
+ #include "gui/message.h"
+
+
+ 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);
++ //assert(slot <= 1 && slot <= 20);
+
+ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
+
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
-
- // Write version
- file->writeByte(SAVE_VERSION);
++ writeSaveGameHeader(file, saveName);
+
- // Write savegame name
- file->writeString(saveName);
- file->writeByte(0);
++ _engine->getScriptManager()->serialize(file);
+
- // 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());
++ file->finalize();
++ delete file;
++}
+
- // Skip over the header info
- autoSaveFile->readSint32BE(); // SAVEGAME_ID
- autoSaveFile->readByte(); // Version
- autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL
++void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) {
++ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
++ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
+
- // Read the rest to a buffer
- uint32 size = autoSaveFile->size() - autoSaveFile->pos();
- byte *buffer = new byte[size];
- autoSaveFile->read(buffer, size);
++ writeSaveGameHeader(file, saveName);
+
- // Then write the buffer to the new file
- file->write(buffer, size);
++ file->write(stream->getData(), stream->size());
+
- // Cleanup
- delete[] buffer;
+ file->finalize();
+ delete file;
+ }
+
+ void SaveManager::autoSave() {
+ Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());
+
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
++ writeSaveGameHeader(file, "auto");
+
- // Version
- file->writeByte(SAVE_VERSION);
-
- file->writeString("auto");
- file->writeByte(0);
-
- writeSaveGameData(file);
++ _engine->getScriptManager()->serialize(file);
+
+ // Cleanup
+ file->finalize();
+ delete file;
+ }
+
-void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
++void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) {
++
++ file->writeUint32BE(SAVEGAME_ID);
++
++ // Write version
++ file->writeByte(SAVE_VERSION);
++
++ // Write savegame name
++ file->writeString(saveName);
++ file->writeByte(0);
++
+ // 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) {
+ // The games only support 20 slots
- assert(slot <= 1 && slot <= 20);
++ //assert(slot <= 1 && slot <= 20);
+
- Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
++ Common::SeekableReadStream *saveFile = getSlotFile(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();
+ // Update the state table values
- scriptManager->deserializeStateTable(saveFile);
++ scriptManager->deserialize(saveFile);
++
++ delete saveFile;
++ if (header.thumbnail)
++ delete header.thumbnail;
++
++ return Common::kNoError;
++}
++
++Common::Error SaveManager::loadGame(const Common::String &saveName) {
++ Common::File *saveFile = _engine->getSearchManager()->openFile(saveName);
++ if (saveFile == NULL) {
++ saveFile = new Common::File;
++ if (!saveFile->open(saveName)) {
++ delete saveFile;
++ return Common::kPathDoesNotExist;
++ }
++ }
++
++ // Read the header
++ SaveGameHeader header;
++ if (!readSaveGameHeader(saveFile, header)) {
++ return Common::kUnknownError;
++ }
+
- // Load the room
- scriptManager->changeLocation(world, room, node, view, offset);
++ ScriptManager *scriptManager = _engine->getScriptManager();
++ // Update the state table values
++ scriptManager->deserialize(saveFile);
+
- // Update the controls
- scriptManager->deserializeControls(saveFile);
++ delete saveFile;
++ if (header.thumbnail)
++ delete header.thumbnail;
+
+ return Common::kNoError;
+ }
+
+ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
- if (in->readUint32BE() != SAVEGAME_ID) {
++ uint32 tag = in->readUint32BE();
++ if (tag == MKTAG('Z', 'N', 'S', 'G')) {
++ header.saveYear = 0;
++ header.saveMonth = 0;
++ header.saveDay = 0;
++ header.saveHour = 0;
++ header.saveMinutes = 0;
++ header.saveName = "Original Save";
++ header.thumbnail = NULL;
++ header.version = SAVE_ORIGINAL;
++ in->seek(-4, SEEK_CUR);
++ return true;
++ }
++ if (tag != SAVEGAME_ID) {
+ warning("File is not a ZVision save file. Aborting load");
+ return false;
+ }
-
++
+ // 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;
+ 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;
+ }
+
++Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
++ Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
++ if (saveFile == NULL) {
++ // Try to load standart save file
++ Common::String filename;
++ if (_engine->getGameId() == GID_GRANDINQUISITOR)
++ filename.format("inqsav%u.sav", slot);
++ else if (_engine->getGameId() == GID_NEMESIS)
++ filename.format("nemsav%u.sav", slot);
++
++ saveFile = _engine->getSearchManager()->openFile(filename);
++ if (saveFile == NULL) {
++ Common::File *tmpFile = new Common::File;
++ if (!tmpFile->open(filename)) {
++ delete tmpFile;
++ } else {
++ saveFile = tmpFile;
++ }
++ }
++
++ }
++
++ return saveFile;
++}
++
+ } // End of namespace ZVision
diff --cc engines/zvision/core/save_manager.h
index 0000000,43fb0c0..8ed64a3
mode 000000,100644..100644
--- a/engines/zvision/core/save_manager.h
+++ b/engines/zvision/core/save_manager.h
@@@ -1,0 -1,91 +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_SAVE_MANAGER_H
+ #define ZVISION_SAVE_MANAGER_H
+
+ #include "common/savefile.h"
++#include "common/memstream.h"
+
+ namespace Common {
+ class String;
+ }
+
+ namespace Graphics {
+ struct Surface;
+ }
+
+ namespace ZVision {
+
+ class ZVision;
+
+ struct SaveGameHeader {
+ byte version;
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+ int saveYear, saveMonth, saveDay;
+ int saveHour, saveMinutes;
+ };
+
+ class SaveManager {
+ public:
+ SaveManager(ZVision *engine) : _engine(engine) {}
+
+ private:
+ ZVision *_engine;
+ static const uint32 SAVEGAME_ID;
+
+ enum {
++ SAVE_ORIGINAL = 0,
+ SAVE_VERSION = 1
+ };
+
+ 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);
++ void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream);
+ /**
+ * 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);
++ Common::Error loadGame(const Common::String &saveName);
+
++ Common::SeekableReadStream *getSlotFile(uint slot);
++ bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header);
+ private:
- void writeSaveGameData(Common::OutSaveFile *file);
- bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
++ void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName);
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/cursors/cursor.cpp
index 0000000,9b9b9a3..e2e3d7e
mode 000000,100644..100644
--- a/engines/zvision/cursors/cursor.cpp
+++ b/engines/zvision/cursors/cursor.cpp
@@@ -1,0 -1,94 +1,123 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/cursors/cursor.h"
++#include "zvision/cursor.h"
+
+ #include "common/str.h"
+ #include "common/file.h"
+
+
+ namespace ZVision {
+
+ ZorkCursor::ZorkCursor()
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0) {
+ }
+
+ ZorkCursor::ZorkCursor(const Common::String &fileName)
- : _width(0),
- _height(0),
- _hotspotX(0),
- _hotspotY(0) {
++ : _width(0),
++ _height(0),
++ _hotspotX(0),
++ _hotspotY(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 * 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, 5, 0, 11, 5, 0, 0));
++}
++
++ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName)
++ : _width(0),
++ _height(0),
++ _hotspotX(0),
++ _hotspotY(0) {
++ Common::File file;
++ if (!engine->getSearchManager()->openFile(file, 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 * 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, 5, 0, 11, 5, 0, 0));
+ }
+
+ ZorkCursor::ZorkCursor(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ _surface.copyFrom(other._surface);
+ }
+
+ ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ _surface.free();
+ _surface.copyFrom(other._surface);
+
+ return *this;
+ }
+
+ ZorkCursor::~ZorkCursor() {
+ _surface.free();
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/cursors/cursor.h
index 0000000,be9fae6..57db561
mode 000000,100644..100644
--- a/engines/zvision/cursors/cursor.h
+++ b/engines/zvision/cursors/cursor.h
@@@ -1,0 -1,66 +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 ZVISION_CURSOR_H
+ #define ZVISION_CURSOR_H
+
+ #include "graphics/surface.h"
++#include "zvision/zvision.h"
+
+
+ namespace Common {
+ class String;
+ }
+
+ namespace ZVision {
+
+ /**
+ * Utility class to parse and hold cursor data
+ * Modeled off Graphics::Cursor
+ */
+ class ZorkCursor {
+ public:
+ ZorkCursor();
+ ZorkCursor(const Common::String &fileName);
++ ZorkCursor(ZVision *engine, const Common::String &fileName);
+ ZorkCursor(const ZorkCursor &other);
+ ~ZorkCursor();
+
+ private:
+ uint16 _width;
+ uint16 _height;
+ uint16 _hotspotX;
+ uint16 _hotspotY;
+ Graphics::Surface _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 (const byte *)_surface.getPixels(); }
++ 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 (const byte *)_surface.getPixels();
++ }
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/cursors/cursor_manager.cpp
index 0000000,7f70c8b..c66fa65
mode 000000,100644..100644
--- a/engines/zvision/cursors/cursor_manager.cpp
+++ b/engines/zvision/cursors/cursor_manager.cpp
@@@ -1,0 -1,152 +1,154 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/cursors/cursor_manager.h"
++#include "zvision/cursor_manager.h"
+
+ #include "zvision/zvision.h"
+
+ #include "common/system.h"
+
+ #include "graphics/pixelformat.h"
+ #include "graphics/cursorman.h"
+
+
+ namespace ZVision {
+
+ 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" };
++ "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow"
++ };
+
+ 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" };
++ "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr"
++ };
+
+ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
++ "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 IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
- if (_engine->getGameId() == GID_NEMESIS) {
- Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
- _idleCursor = ZorkCursor(name);
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]);
++ : _engine(engine),
++ _pixelFormat(pixelFormat),
++ _cursorIsPushed(false),
++ _item(0),
++ _lastitem(0) {
++ for (int i = 0; i < NUM_CURSORS; i++) {
++ if (_engine->getGameId() == GID_NEMESIS) {
++ Common::String name;
++ name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]);
++ _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor
++ name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]);
++ _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor
++ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
++ _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor
++ char buffer[25];
++ strcpy(buffer, _zgiCursorFileNames[i]);
++ buffer[3] += 2;
++ _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor
++ }
+ }
+ }
+
-void CursorManager::initialize() {
- revertToIdle();
- CursorMan.showMouse(true);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName) {
- changeCursor(cursorName, _cursorIsPushed);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) {
- if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed)
- return;
-
- if (_cursorIsPushed != pushed)
- _cursorIsPushed = pushed;
-
- if (cursorName == "idle" && !pushed) {
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- return;
- }
-
- for (int i = 0; i < NUM_CURSORS; ++i) {
- if (_engine->getGameId() == GID_NEMESIS) {
- 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());
-
- changeCursor(ZorkCursor(name));
++void CursorManager::setItemID(int id) {
++ if (id != _item) {
++ if (id) {
++ Common::String file;
++ if (_engine->getGameId() == GID_NEMESIS) {
++ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a');
++ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
++ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b');
++ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
++ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a');
++ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
++ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b');
++ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
++ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
++ file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id);
++ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
++ file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id);
++ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
++ file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id);
++ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
++ file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id);
++ _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file);
++ } else
+ return;
- }
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- if (cursorName.equals(_cursorNames[i])) {
- _currentCursor = 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;
- changeCursor(ZorkCursor(buffer));
- }
- return;
- }
+ }
++ _item = id;
++ changeCursor(CursorIndex_Idle);
+ }
++}
+
- // If we get here, something went wrong
- warning("No cursor found for identifier %s", cursorName.c_str());
++void CursorManager::initialize() {
++ changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]);
++ showMouse(true);
+ }
+
+ void CursorManager::changeCursor(const ZorkCursor &cursor) {
+ CursorMan.replaceCursor(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::setLeftCursor() {
- changeCursor("leftarrow");
++ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
+ }
+
-void CursorManager::setRightCursor() {
- changeCursor("rightarrow");
-}
++void CursorManager::changeCursor(int id) {
++ int _id = id;
++
++ if (_item &&
++ (_id == CursorIndex_Active ||
++ _id == CursorIndex_Idle ||
++ _id == CursorIndex_HandPu)) {
+
-void CursorManager::setUpCursor() {
- changeCursor("zuparrow");
++ if (_id == CursorIndex_Idle)
++ _id = CursorIndex_ItemIdle;
++ else
++ _id = CursorIndex_ItemAct;
++ }
++
++ if (_currentCursor != _id ||
++ ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) {
++ _currentCursor = _id;
++ _lastitem = _item;
++ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
++ }
+ }
+
-void CursorManager::setDownCursor() {
- changeCursor("downarrow");
++int CursorManager::getCursorId(Common::String &name) {
++ for (int i = 0; i < NUM_CURSORS; i++)
++ if (name.equals(_cursorNames[i]))
++ return i;
++ return CursorIndex_Idle;
+ }
+
-void CursorManager::revertToIdle() {
- _currentCursor = "idle";
- if (!_cursorIsPushed)
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- else
- changeCursor(_currentCursor, _cursorIsPushed);
++void CursorManager::showMouse(bool vis) {
++ CursorMan.showMouse(vis);
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/cursors/cursor_manager.h
index 0000000,0576517..0521a17
mode 000000,100644..100644
--- a/engines/zvision/cursors/cursor_manager.h
+++ b/engines/zvision/cursors/cursor_manager.h
@@@ -1,0 -1,114 +1,135 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #ifndef ZVISION_CURSOR_MANAGER_H
+ #define ZVISION_CURSOR_MANAGER_H
+
-#include "zvision/cursors/cursor.h"
++#include "zvision/cursor.h"
+
+ #include "common/str.h"
+
+
+ namespace Graphics {
+ struct PixelFormat;
+ }
+
+ namespace ZVision {
+
+ class ZVision;
+
+ /**
++ * Mostly usable cursors
++ */
++enum CursorIndex {
++ CursorIndex_Active = 0,
++ CursorIndex_DownArr = 3,
++ CursorIndex_HandPu = 6,
++ CursorIndex_Idle = 11,
++ CursorIndex_Left = 12,
++ CursorIndex_Right = 13,
++ CursorIndex_UpArr = 17,
++ CursorIndex_ItemIdle = 18,
++ CursorIndex_ItemAct = 19
++};
++
++/**
+ * 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);
+
+ 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
- };
++ static const int NUM_CURSORS = 18;
++
++ // 18 default cursors in up/down states, +2 for items idle/act cursors
++ ZorkCursor _cursors[NUM_CURSORS + 2][2];
+
+ ZVision *_engine;
+ const Graphics::PixelFormat *_pixelFormat;
- ZorkCursor _idleCursor;
- Common::String _currentCursor;
+ bool _cursorIsPushed;
++ int _item;
++ int _lastitem;
++ int _currentCursor;
+
+ static const char *_cursorNames[];
+ static const char *_zgiCursorFileNames[];
+ 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
++ * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item.
+ *
- * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
++ * @param id Wanted cursor id.
+ */
- void changeCursor(const Common::String &cursorName);
++
++ void changeCursor(int id);
++
+ /**
- * Parses a cursor name into a cursor file then creates and shows that cursor.
++ * Return founded id for string contains cursor name
+ *
- * @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)
++ * @param name Cursor name
++ * @return Id of cursor or idle cursor id if not found
+ */
- void changeCursor(const Common::String &cursorName, bool pushed);
++
++ int getCursorId(Common::String &name);
++
++ /**
++ * Load cursor for item by id, and try to change cursor to item cursor if it's not 0
++ *
++ * @param id Item id or 0 for no item cursor
++ */
++
++ void setItemID(int id);
++
+ /**
+ * 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();
++ /**
++ * Show or hide mouse cursor.
++ *
++ * @param vis Should the cursor be showed (true) or hide (false)
++ */
++ void showMouse(bool vis);
+
+ private:
+ /**
+ * Calls CursorMan.replaceCursor() using the data in cursor
+ *
+ * @param cursor The cursor to show
+ */
+ void changeCursor(const ZorkCursor &cursor);
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/fonts/truetype_font.cpp
index 0000000,ba4d72b..e3eea40
mode 000000,100644..100644
--- a/engines/zvision/fonts/truetype_font.cpp
+++ b/engines/zvision/fonts/truetype_font.cpp
@@@ -1,0 -1,113 +1,344 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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/fonts/truetype_font.h"
++#include "zvision/truetype_font.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
++#include "zvision/render_manager.h"
+
++#include "common/config-manager.h"
+ #include "common/debug.h"
+ #include "common/file.h"
+ #include "common/system.h"
++#include "common/unzip.h"
+
+ #include "graphics/font.h"
+ #include "graphics/fonts/ttf.h"
+ #include "graphics/surface.h"
+
+
+ namespace ZVision {
+
+ TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight)
- : _fontHeight(fontHeight),
- _font(0),
- _lineHeight(0) {
++ : _engine(engine),
++ _fontHeight(fontHeight),
++ _font(0),
++ _lineHeight(0),
++ _maxCharWidth(0),
++ _maxCharHeight(0) {
+ }
+
+ TruetypeFont::~TruetypeFont(void) {
+ delete _font;
+ }
+
+ 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());
+ fileOpened = file.open("arial.ttf");
+ } else {
+ fileOpened = file.open(filename);
+ }
+
+ if (!fileOpened) {
+ debug("TTF file could not be opened");
+ return false;
+ }
+
+ _font = Graphics::loadTTFFont(file, _fontHeight);
+ _lineHeight = _font->getFontHeight();
+
+ return true;
+ }
+
+ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
+ if (text.equals("")) {
+ return nullptr;
+ }
+
+ 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));
+ // 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, 0, 0, maxWidth, textColor, align);
+ return surface;
+ }
+
+ Common::Array<Common::String> lines;
+ _font->wordWrapText(text, maxWidth, lines);
+
+ while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) {
+ lines.pop_back();
+ }
+ if (lines.size() == 0) {
+ return nullptr;
+ }
+
+ surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ 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, 0, 0 + heightOffset, maxWidth, textColor, align);
+ heightOffset += _lineHeight;
+ }
+
+ return surface;
+ }
+
++sTTFont::sTTFont(ZVision *engine) {
++ _engine = engine;
++ _style = 0;
++ _font = NULL;
++ _lineHeight = 0;
++}
++
++sTTFont::~sTTFont() {
++ if (_font)
++ delete _font;
++}
++
++bool sTTFont::loadFont(const Common::String &fontName, int32 point, uint style) {
++ _style = style;
++ return loadFont(fontName, point);
++}
++
++bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
++ Common::String newFontName;
++ if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
++ newFontName = "timesbi.ttf";
++ else if (_style & STTF_BOLD)
++ newFontName = "timesbd.ttf";
++ else if (_style & STTF_ITALIC)
++ newFontName = "timesi.ttf";
++ else
++ newFontName = "times.ttf";
++
++ } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
++ newFontName = "courbi.ttf";
++ else if (_style & STTF_BOLD)
++ newFontName = "courbd.ttf";
++ else if (_style & STTF_ITALIC)
++ newFontName = "couri.ttf";
++ else
++ newFontName = "cour.ttf";
++
++ } else if (fontName.matchString("*century schoolbook*", true)) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
++ newFontName = "censcbkbi.ttf";
++ else if (_style & STTF_BOLD)
++ newFontName = "censcbkbd.ttf";
++ else if (_style & STTF_ITALIC)
++ newFontName = "censcbki.ttf";
++ else
++ newFontName = "censcbk.ttf";
++
++ } else if (fontName.matchString("*garamond*", true)) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
++ newFontName = "garabi.ttf";
++ else if (_style & STTF_BOLD)
++ newFontName = "garabd.ttf";
++ else if (_style & STTF_ITALIC)
++ newFontName = "garai.ttf";
++ else
++ newFontName = "gara.ttf";
++
++ } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
++ newFontName = "arialbi.ttf";
++ else if (_style & STTF_BOLD)
++ newFontName = "arialbd.ttf";
++ else if (_style & STTF_ITALIC)
++ newFontName = "ariali.ttf";
++ else
++ newFontName = "arial.ttf";
++
++ } else {
++ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
++ newFontName = "arial.ttf";
++ }
++
++ bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
++
++ Common::File *file = _engine->getSearchManager()->openFile(newFontName);
++
++ if (!file) {
++ Common::SeekableReadStream *themeFile = nullptr;
++ if (ConfMan.hasKey("themepath")) {
++ Common::FSNode themePath(ConfMan.get("themepath"));
++ if (themePath.exists()) {
++ Common::FSNode scummModern = themePath.getChild("scummmodern.zip");
++ if (scummModern.exists()) {
++ themeFile = scummModern.createReadStream();
++ }
++ }
++ }
++ if (!themeFile) { // Fallback 2.5: Search for ScummModern.zip in SearchMan.
++ themeFile = SearchMan.createReadStreamForMember("scummmodern.zip");
++ }
++ if (themeFile) {
++ Common::Archive *themeArchive = Common::makeZipArchive(themeFile);
++ if (themeArchive->hasFile("FreeSans.ttf")) {
++ Common::SeekableReadStream *stream = nullptr;
++ stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
++ Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
++ if (_newFont) {
++ if (!_font)
++ delete _font;
++ _font = _newFont;
++ }
++ if (stream)
++ delete stream;
++ }
++ delete themeArchive;
++ themeArchive = nullptr;
++ }
++ } else {
++ Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
++ if (_newFont) {
++ if (!_font)
++ delete _font;
++ _font = _newFont;
++ }
++ delete file;
++ }
++
++ _fntName = fontName;
++ _lineHeight = point;
++
++ if (_font)
++ return true;
++ return false;
++}
++
++void sTTFont::setStyle(uint newStyle) {
++ if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) {
++ _style = newStyle;
++ loadFont(_fntName, _lineHeight);
++ } else {
++ _style = newStyle;
++ }
++}
++
++int sTTFont::getFontHeight() {
++ if (_font)
++ return _font->getFontHeight();
++ return 0;
++}
++
++int sTTFont::getMaxCharWidth() {
++ if (_font)
++ return _font->getMaxCharWidth();
++ return 0;
++}
++
++int sTTFont::getCharWidth(byte chr) {
++ if (_font)
++ return _font->getCharWidth(chr);
++ return 0;
++}
++
++int sTTFont::getKerningOffset(byte left, byte right) {
++ if (_font)
++ return _font->getKerningOffset(left, right);
++ return 0;
++}
++
++void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) {
++ if (_font) {
++ _font->drawChar(dst, chr, x, y, color);
++ if (_style & STTF_UNDERLINE) {
++ int16 pos = floor(_font->getFontHeight() * 0.87);
++ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
++ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
++ }
++ if (_style & STTF_STRIKEOUT) {
++ int16 pos = floor(_font->getFontHeight() * 0.60);
++ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
++ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
++ }
++ }
++}
++
++void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) {
++ if (_font) {
++ _font->drawString(dst, str, x, y, w, color, align);
++ if (_style & STTF_UNDERLINE) {
++ int16 pos = floor(_font->getFontHeight() * 0.87);
++ int16 wd = MIN(_font->getStringWidth(str), w);
++ int16 stX = x;
++ if (align == Graphics::kTextAlignCenter)
++ stX += (w - wd) / 2;
++ else if (align == Graphics::kTextAlignRight)
++ stX += (w - wd);
++
++ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
++
++ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
++ }
++ if (_style & STTF_STRIKEOUT) {
++ int16 pos = floor(_font->getFontHeight() * 0.60);
++ int16 wd = MIN(_font->getStringWidth(str), w);
++ int16 stX = x;
++ if (align == Graphics::kTextAlignCenter)
++ stX += (w - wd) / 2;
++ else if (align == Graphics::kTextAlignRight)
++ stX += (w - wd);
++
++ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
++
++ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
++ }
++ }
++}
++
++int sTTFont::getStringWidth(const Common::String &str) {
++ if (_font)
++ return _font->getStringWidth(str);
++ return 0;
++}
++
++Graphics::Surface *sTTFont::renderSolidText(const Common::String &str, uint32 color) {
++ Graphics::Surface *tmp = new Graphics::Surface;
++ if (_font) {
++ int16 w = _font->getStringWidth(str);
++ if (w && w < 1024) {
++ tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat);
++ drawString(tmp, str, 0, 0, w, color);
++ }
++ }
++ return tmp;
++}
++
+ } // End of namespace ZVision
diff --cc engines/zvision/fonts/truetype_font.h
index 0000000,64f53a2..bed1d55
mode 000000,100644..100644
--- a/engines/zvision/fonts/truetype_font.h
+++ b/engines/zvision/fonts/truetype_font.h
@@@ -1,0 -1,81 +1,124 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ // This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp
+
+ #ifndef ZVISION_TRUETYPE_FONT_H
+ #define ZVISION_TRUETYPE_FONT_H
+
+ #include "graphics/font.h"
+ #include "graphics/pixelformat.h"
+
+
+ namespace Graphics {
+ struct Surface;
+ }
+
+ namespace ZVision {
+
+ class ZVision;
+
+ class TruetypeFont {
+ public:
+ TruetypeFont(ZVision *engine, int32 fontHeight);
+ ~TruetypeFont();
+
+ private:
+ // ZVision *_engine;
+ Graphics::Font *_font;
+ int _lineHeight;
+
+ // size_t _maxCharWidth;
+ // size_t _maxCharHeight;
+
+ 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);
+ };
+
++// Styled TTF
++class sTTFont {
++public:
++ sTTFont(ZVision *engine);
++ ~sTTFont();
++
++ enum {
++ STTF_BOLD = 1,
++ STTF_ITALIC = 2,
++ STTF_UNDERLINE = 4,
++ STTF_STRIKEOUT = 8,
++ STTF_SHARP = 16
++ };
++
++private:
++ ZVision *_engine;
++ Graphics::Font *_font;
++ int _lineHeight;
++ uint _style;
++ Common::String _fntName;
++
++public:
++ bool loadFont(const Common::String &fontName, int32 point);
++ bool loadFont(const Common::String &fontName, int32 point, uint style);
++ void setStyle(uint newStyle);
++
++ int getFontHeight();
++ int getMaxCharWidth();
++ int getCharWidth(byte chr);
++ int getKerningOffset(byte left, byte right);
++
++ void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color);
++
++ void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft);
++ int getStringWidth(const Common::String &str);
++
++ Graphics::Surface *renderSolidText(const Common::String &str, uint32 color);
++
++ bool isLoaded() {
++ return _font != NULL;
++ };
++};
++
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/graphics/render_manager.cpp
index 0000000,aed30ea..071afff
mode 000000,100644..100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@@ -1,0 -1,526 +1,794 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/graphics/render_manager.h"
++#include "zvision/zvision.h"
++#include "zvision/render_manager.h"
++#include "zvision/text.h"
+
-#include "zvision/utility/lzss_read_stream.h"
++#include "zvision/lzss_read_stream.h"
+
+ #include "common/file.h"
+ #include "common/system.h"
+ #include "common/stream.h"
+
+ #include "engines/util.h"
+
-#include "image/tga.h"
++#include "graphics/decoders/tga.h"
+
+
+ namespace ZVision {
+
-RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
- : _system(system),
- _workingWidth(workingWindow.width()),
- _workingHeight(workingWindow.height()),
- _screenCenterX(_workingWidth / 2),
- _screenCenterY(_workingHeight / 2),
- _workingWindow(workingWindow),
- _pixelFormat(pixelFormat),
- _backgroundWidth(0),
- _backgroundHeight(0),
- _backgroundInverseVelocity(0),
- _backgroundOffset(0, 0),
- _accumulatedVelocityMilliseconds(0),
- _renderTable(_workingWidth, _workingHeight) {
-
- _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat);
- _backBuffer.create(windowWidth, windowHeight, pixelFormat);
++RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
++ : _engine(engine),
++ _system(engine->_system),
++ _wrkWidth(workingWindow.width()),
++ _wrkHeight(workingWindow.height()),
++ _screenCenterX(_wrkWidth / 2),
++ _screenCenterY(_wrkHeight / 2),
++ _workingWindow(workingWindow),
++ _pixelFormat(pixelFormat),
++ _bkgWidth(0),
++ _bkgHeight(0),
++ _bkgOff(0),
++ _renderTable(_wrkWidth, _wrkHeight) {
++
++ _wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
++ _outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
++ _menuWnd.create(windowWidth, workingWindow.top, _pixelFormat);
++ _subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat);
++
++ _menuWndRect = Common::Rect(0, 0, windowWidth, workingWindow.top);
++ _subWndRect = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight);
++
++ _subid = 0;
+ }
+
+ RenderManager::~RenderManager() {
- _workingWindowBuffer.free();
- _currentBackground.free();
- _backBuffer.free();
-
- for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
- iter->_value.data->free();
- delete iter->_value.data;
- }
-}
-
-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) {
- _accumulatedVelocityMilliseconds += deltaTimeInMillis;
-
- uint absVelocity = uint(abs(_backgroundInverseVelocity));
-
- 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);
- }
++ _curBkg.free();
++ _wrkWnd.free();
++ _outWnd.free();
+ }
+
+ void RenderManager::renderBackbufferToScreen() {
- 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());
- }
++ Graphics::Surface *out = &_outWnd;
+
- // Translate the working window dirty rect to screen coords
- _workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top);
- // Then extend the backbuffer dirty rect to contain it
- if (_backBufferDirtyRect.isEmpty()) {
- _backBufferDirtyRect = _workingWindowDirtyRect;
- } else {
- _backBufferDirtyRect.extend(_workingWindowDirtyRect);
++ RenderTable::RenderState state = _renderTable.getRenderState();
++ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
++ if (!_wrkWndDirtyRect.isEmpty()) {
++ _renderTable.mutateImage(&_outWnd, &_wrkWnd);
++ out = &_outWnd;
++ _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight);
+ }
-
- // Clear the dirty rect
- _workingWindowDirtyRect = Common::Rect();
++ } else {
++ out = &_wrkWnd;
++ _outWndDirtyRect = _wrkWndDirtyRect;
+ }
+
- // TODO: Add menu rendering
+
- // Render alpha entries
- processAlphaEntries();
++ if (!_outWndDirtyRect.isEmpty()) {
++ _system->copyRectToScreen(out->getBasePtr(_outWndDirtyRect.left, _outWndDirtyRect.top), out->pitch,
++ _outWndDirtyRect.left + _workingWindow.left,
++ _outWndDirtyRect.top + _workingWindow.top,
++ _outWndDirtyRect.width(),
++ _outWndDirtyRect.height());
+
- if (!_backBufferDirtyRect.isEmpty()) {
- _system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
- _backBufferDirtyRect = Common::Rect();
++ _outWndDirtyRect = Common::Rect();
+ }
+ }
+
-void RenderManager::processAlphaEntries() {
- // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
-
- 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);
- uint16 *entryPtr = (uint16 *)iter->_value.data->getPixels();
++void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) {
++ Graphics::Surface surface;
++ readImageToSurface(fileName, surface);
+
- 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;
- }
- }
++ blitSurfaceToBkg(surface, destX, destY);
++ surface.free();
++}
+
- destOffset += _backBuffer.w;
- sourceOffset += iter->_value.width;
- }
++void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) {
++ Graphics::Surface surface;
++ readImageToSurface(fileName, surface);
+
- 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));
- }
- }
++ blitSurfaceToBkg(surface, destX, destY, keycolor);
++ surface.free();
+ }
+
-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();
++void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
++ Common::File file;
+
- for (uint32 i = 0; i < workingWindowSize; ++i) {
- bufferPtr[i] = colorIn565;
++ if (!_engine->getSearchManager()->openFile(file, fileName)) {
++ warning("Could not open file %s", fileName.c_str());
++ return;
+ }
-}
+
-void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
- int16 subRectX = 0;
- int16 subRectY = 0;
++ // Read the magic number
++ // Some files are true TGA, while others are TGZ
++ uint32 fileType = file.readUint32BE();
+
- // Take care of negative destinations
- if (destinationX < 0) {
- subRectX = -destinationX;
- destinationX = 0;
- } else if (destinationX >= surface.w) {
- // Take care of extreme positive destinations
- destinationX -= surface.w;
- }
++ 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;
+
- // Take care of negative destinations
- if (destinationY < 0) {
- subRectY = -destinationY;
- destinationY = 0;
- } else if (destinationY >= surface.h) {
- // Take care of extreme positive destinations
- destinationY -= surface.h;
- }
++ bool isTGZ;
+
- if (wrap) {
- _backgroundWidth = surface.w;
- _backgroundHeight = surface.h;
++ // Check for TGZ files
++ if (fileType == MKTAG('T', 'G', 'Z', '\0')) {
++ isTGZ = true;
+
- if (destinationX > 0) {
- // Move destinationX to 0
- subRectX = surface.w - destinationX;
- destinationX = 0;
- }
++ // TGZ files have a header and then Bitmap data that is compressed with LZSS
++ uint32 decompressedSize = file.readSint32LE();
++ imageWidth = file.readSint32LE();
++ imageHeight = file.readSint32LE();
++
++ LzssReadStream lzssStream(&file);
++ buffer = (uint16 *)(new uint16[decompressedSize]);
++ lzssStream.read(buffer, decompressedSize);
++ } else {
++ isTGZ = false;
++
++ // Reset the cursor
++ file.seek(0);
+
- if (destinationY > 0) {
- // Move destinationY to 0
- subRectY = surface.h - destinationY;
- destinationY = 0;
++ // Decode
++ if (!tga.loadStream(file)) {
++ warning("Error while reading TGA image");
++ return;
+ }
++
++ Graphics::Surface tgaSurface = *(tga.getSurface());
++ imageWidth = tgaSurface.w;
++ imageHeight = tgaSurface.h;
++
++ buffer = (uint16 *)tgaSurface.getPixels();
+ }
+
- // Clip subRect to working window bounds
- Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight);
++ // Flip the width and height if transposed
++ if (isTransposed) {
++ uint16 temp = imageHeight;
++ imageHeight = imageWidth;
++ imageWidth = temp;
++ }
+
- if (!wrap) {
- // Clip to image bounds
- subRect.clip(surface.w, surface.h);
++ // 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);
+ }
+
- // Check destRect for validity
- if (!subRect.isValidRect() || subRect.isEmpty())
- return;
++ // 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();
+
- copyRectToWorkingWindow((const uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, surface.w, subRect.width(), subRect.height());
-}
++ for (uint32 y = 0; y < imageHeight; ++y) {
++ uint32 columnIndex = y * imageWidth;
+
-void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
- Graphics::Surface surface;
- readImageToSurface(fileName, surface);
++ for (uint32 x = 0; x < imageWidth; ++x) {
++ dest[columnIndex + x] = buffer[x * imageHeight + y];
++ }
++ }
++ } else {
++ memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel);
++ }
+
- renderSubRectToScreen(surface, destinationX, destinationY, wrap);
-}
++ // Cleanup
++ if (isTGZ) {
++ delete[] buffer;
++ } else {
++ tga.destroy();
++ }
+
-void RenderManager::renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
- renderSubRectToScreen(surface, destinationX, destinationY, wrap);
++ // Convert in place to RGB 565 from RGB 555
++ destination.convertToInPlace(_pixelFormat);
+ }
+
-void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
++void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) {
+ Common::File file;
+
- if (!file.open(fileName)) {
++ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("Could not open file %s", fileName.c_str());
+ return;
+ }
+
+ // Read the magic number
+ // Some files are true TGA, while others are TGZ
+ uint32 fileType = file.readUint32BE();
+
+ uint32 imageWidth;
+ uint32 imageHeight;
- Image::TGADecoder tga;
++ 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 = file.readSint32LE();
+ imageWidth = file.readSint32LE();
+ imageHeight = file.readSint32LE();
+
+ LzssReadStream lzssStream(&file);
+ buffer = (uint16 *)(new uint16[decompressedSize]);
+ lzssStream.read(buffer, decompressedSize);
+ } else {
+ isTGZ = false;
+
+ // Reset the cursor
+ file.seek(0);
+
+ // Decode
+ if (!tga.loadStream(file)) {
+ warning("Error while reading TGA image");
+ return;
+ }
+
+ Graphics::Surface tgaSurface = *(tga.getSurface());
+ imageWidth = tgaSurface.w;
+ imageHeight = tgaSurface.h;
+
+ buffer = (uint16 *)tgaSurface.getPixels();
+ }
+
+ // Flip the width and height if transposed
- if (isTransposed) {
++ if (transposed) {
+ 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 transposed, 'un-transpose' the data while copying it to the destination
+ // Otherwise, just do a simple copy
- if (isTransposed) {
++ if (transposed) {
+ 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);
+ }
+
+ // Cleanup
+ if (isTGZ) {
+ delete[] buffer;
+ } else {
+ tga.destroy();
+ }
+
+ // Convert in place to RGB 565 from RGB 555
+ destination.convertToInPlace(_pixelFormat);
+ }
+
-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);
++const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
++ if (_workingWindow.contains(point)) {
++ // Convert from screen space to working window space
++ Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
++
++ RenderTable::RenderState state = _renderTable.getRenderState();
++ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
++ newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
++ }
+
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x];
++ if (state == RenderTable::PANORAMA) {
++ newPoint += (Common::Point(_bkgOff - _screenCenterX, 0));
++ } else if (state == RenderTable::TILT) {
++ newPoint += (Common::Point(0, _bkgOff - _screenCenterY));
+ }
+
- destOffset += _workingWidth;
- sourceOffset += imageWidth;
- }
++ if (_bkgWidth)
++ newPoint.x %= _bkgWidth;
++ if (_bkgHeight)
++ newPoint.y %= _bkgHeight;
++
++ if (newPoint.x < 0)
++ newPoint.x += _bkgWidth;
++ if (newPoint.y < 0)
++ newPoint.y += _bkgHeight;
+
- if (_workingWindowDirtyRect.isEmpty()) {
- _workingWindowDirtyRect = Common::Rect(destX, destY, destX + width, destY + height);
++ return newPoint;
+ } else {
- _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
++ return Common::Point(0, 0);
+ }
++}
+
- // 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);
++RenderTable *RenderManager::getRenderTable() {
++ return &_renderTable;
+ }
+
-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();
- entry.data->create(width, height, _pixelFormat);
- entry.destX = destX;
- entry.destY = destY;
- entry.width = width;
- entry.height = height;
++void RenderManager::setBackgroundImage(const Common::String &fileName) {
++ readImageToSurface(fileName, _curBkg);
++ _bkgWidth = _curBkg.w;
++ _bkgHeight = _curBkg.h;
++ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
++}
+
- uint32 sourceOffset = 0;
- uint32 destOffset = 0;
- uint16 *surfacePtr = (uint16 *)entry.data->getPixels();
++void RenderManager::setBackgroundPosition(int offset) {
++ RenderTable::RenderState state = _renderTable.getRenderState();
++ if (state == RenderTable::TILT || state == RenderTable::PANORAMA)
++ if (_bkgOff != offset)
++ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
++ _bkgOff = offset;
++}
+
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- surfacePtr[destOffset + x] = buffer[sourceOffset + x];
- }
++uint32 RenderManager::getCurrentBackgroundOffset() {
++ RenderTable::RenderState state = _renderTable.getRenderState();
+
- destOffset += width;
- sourceOffset += imageWidth;
++ if (state == RenderTable::PANORAMA) {
++ return _bkgOff;
++ } else if (state == RenderTable::TILT) {
++ return _bkgOff;
++ } else {
++ return 0;
+ }
-
- _alphaDataEntries[idNumber] = entry;
+ }
+
-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;
- entry.destY = destY;
++Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surface) {
++ Graphics::Surface *tranposedSurface = new Graphics::Surface();
++ tranposedSurface->create(surface->h, surface->w, surface->format);
+
- // Draw the text to the working window
- entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap);
- entry.width = entry.data->w;
- entry.height = entry.data->h;
++ const uint16 *source = (const uint16 *)surface->getPixels();
++ uint16 *dest = (uint16 *)tranposedSurface->getPixels();
+
- _alphaDataEntries[idNumber] = entry;
++ for (uint32 y = 0; y < tranposedSurface->h; ++y) {
++ uint32 columnIndex = y * tranposedSurface->w;
+
- return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
++ for (uint32 x = 0; x < tranposedSurface->w; ++x) {
++ dest[columnIndex + x] = source[x * surface->w + y];
++ }
++ }
++
++ return tranposedSurface;
+ }
+
-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));
++void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight) {
++ assert(bytesPerPixel == 1 || bytesPerPixel == 2);
+
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
- }
++ const float xscale = (float)srcWidth / (float)dstWidth;
++ const float yscale = (float)srcHeight / (float)dstHeight;
+
- if (state == RenderTable::PANORAMA) {
- newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset);
- } else if (state == RenderTable::TILT) {
- newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset);
++ if (bytesPerPixel == 1) {
++ const byte *srcPtr = (const byte *)src;
++ byte *dstPtr = (byte *)dst;
++ for (uint32 y = 0; y < dstHeight; ++y) {
++ for (uint32 x = 0; x < dstWidth; ++x) {
++ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
++ dstPtr++;
++ }
++ }
++ } else if (bytesPerPixel == 2) {
++ const uint16 *srcPtr = (const uint16 *)src;
++ uint16 *dstPtr = (uint16 *)dst;
++ for (uint32 y = 0; y < dstHeight; ++y) {
++ for (uint32 x = 0; x < dstWidth; ++x) {
++ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
++ dstPtr++;
++ }
++ }
+ }
++}
+
- 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;
++void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) {
+
- return newPoint;
-}
++ if (src.format != dst.format)
++ return;
+
-const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) {
- Common::Point newPoint(point);
++ Common::Rect srcRect = _srcRect;
++ if (srcRect.isEmpty())
++ srcRect = Common::Rect(src.w, src.h);
++ srcRect.clip(src.w, src.h);
++ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
++ srcRect.clip(dstRect);
+
- 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);
- }
++ if (srcRect.isEmpty() || !srcRect.isValidRect())
++ return;
++
++ // Copy srcRect from src surface to dst surface
++ const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
++
++ int xx = _x;
++ int yy = _y;
++
++ if (xx < 0)
++ xx = 0;
++ if (yy < 0)
++ yy = 0;
+
- return newPoint;
++ if (_x >= dst.w || _y >= dst.h)
++ return;
++
++ byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
++
++ int32 w = srcRect.width();
++ int32 h = srcRect.height();
++
++ for (int32 y = 0; y < h; y++) {
++ memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel);
++ src_buf += src.pitch;
++ dst_buf += dst.pitch;
++ }
+ }
+
-bool RenderManager::clipRectToWorkingWindow(Common::Rect &rect) {
- if (!_workingWindow.contains(rect)) {
- return false;
++void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey) {
++
++ if (src.format != dst.format)
++ return;
++
++ Common::Rect srcRect = _srcRect;
++ if (srcRect.isEmpty())
++ srcRect = Common::Rect(src.w, src.h);
++ srcRect.clip(src.w, src.h);
++ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
++ srcRect.clip(dstRect);
++
++ if (srcRect.isEmpty() || !srcRect.isValidRect())
++ return;
++
++
++
++ uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1);
++
++ // Copy srcRect from src surface to dst surface
++ const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
++
++ int xx = _x;
++ int yy = _y;
++
++ if (xx < 0)
++ xx = 0;
++ if (yy < 0)
++ yy = 0;
++
++ if (_x >= dst.w || _y >= dst.h)
++ return;
++
++ byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
++
++ int32 w = srcRect.width();
++ int32 h = srcRect.height();
++
++ for (int32 y = 0; y < h; y++) {
++ switch (src.format.bytesPerPixel) {
++ case 1: {
++ const uint *src_tmp = (const uint *)src_buf;
++ uint *dst_tmp = (uint *)dst_buf;
++ for (int32 x = 0; x < w; x++) {
++ if (*src_tmp != _keycolor)
++ *dst_tmp = *src_tmp;
++ src_tmp++;
++ dst_tmp++;
++ }
++ }
++ break;
++
++ case 2: {
++ const uint16 *src_tmp = (const uint16 *)src_buf;
++ uint16 *dst_tmp = (uint16 *)dst_buf;
++ for (int32 x = 0; x < w; x++) {
++ if (*src_tmp != _keycolor)
++ *dst_tmp = *src_tmp;
++ src_tmp++;
++ dst_tmp++;
++ }
++ }
++ break;
++
++ case 4: {
++ const uint32 *src_tmp = (const uint32 *)src_buf;
++ uint32 *dst_tmp = (uint32 *)dst_buf;
++ for (int32 x = 0; x < w; x++) {
++ if (*src_tmp != _keycolor)
++ *dst_tmp = *src_tmp;
++ src_tmp++;
++ dst_tmp++;
++ }
++ }
++ break;
++
++ default:
++ break;
++ }
++ src_buf += src.pitch;
++ dst_buf += dst.pitch;
+ }
++}
+
- // 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;
++void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, dst, x, y);
+ }
+
-RenderTable *RenderManager::getRenderTable() {
- return &_renderTable;
++void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, dst, x, y, colorkey);
+ }
+
-void RenderManager::setBackgroundImage(const Common::String &fileName) {
- readImageToSurface(fileName, _currentBackground);
++void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, _curBkg, x, y);
++ Common::Rect dirty(src.w, src.h);
++ dirty.translate(x, y);
++ if (_bkgDirtyRect.isEmpty())
++ _bkgDirtyRect = dirty;
++ else
++ _bkgDirtyRect.extend(dirty);
++}
+
- moveBackground(0);
++void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, _curBkg, x, y, colorkey);
++ Common::Rect dirty(src.w, src.h);
++ dirty.translate(x, y);
++ if (_bkgDirtyRect.isEmpty())
++ _bkgDirtyRect = dirty;
++ else
++ _bkgDirtyRect.extend(dirty);
+ }
+
-void RenderManager::setBackgroundPosition(int offset) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = offset;
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset.x = offset;
- _backgroundOffset.y = 0;
- } else {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = 0;
- }
++void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, _menuWnd, x, y);
++ Common::Rect dirty(src.w, src.h);
++ dirty.translate(x, y);
++ if (_menuWndDirtyRect.isEmpty())
++ _menuWndDirtyRect = dirty;
++ else
++ _menuWndDirtyRect.extend(dirty);
+ }
+
-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::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) {
++ Common::Rect empt;
++ blitSurfaceToSurface(src, empt, _menuWnd, x, y, colorkey);
++ Common::Rect dirty(src.w, src.h);
++ dirty.translate(x, y);
++ if (_menuWndDirtyRect.isEmpty())
++ _menuWndDirtyRect = dirty;
++ else
++ _menuWndDirtyRect.extend(dirty);
+ }
+
-void RenderManager::moveBackground(int offset) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset += Common::Point(0, offset);
++Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) {
++ Common::Rect dst = rect;
++ dst.clip(_bkgWidth, _bkgHeight);
+
- _backgroundOffset.y = CLIP<int16>(_backgroundOffset.y, _screenCenterY, (int16)_backgroundHeight - _screenCenterY);
++ if (dst.isEmpty() || !dst.isValidRect())
++ return NULL;
+
- renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset += Common::Point(offset, 0);
++ Graphics::Surface *srf = new Graphics::Surface;
++ srf->create(dst.width(), dst.height(), _curBkg.format);
+
- if (_backgroundOffset.x <= -_backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
- else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x -= _backgroundWidth;
++ srf->copyRectToSurface(_curBkg, 0, 0, Common::Rect(dst));
+
- renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
- } else {
- renderImageToScreen(_currentBackground, 0, 0);
- }
++ return srf;
+ }
+
-uint32 RenderManager::getCurrentBackgroundOffset() {
++Graphics::Surface *RenderManager::loadImage(Common::String &file) {
++ Graphics::Surface *tmp = new Graphics::Surface;
++ readImageToSurface(file, *tmp);
++ return tmp;
++}
++
++Graphics::Surface *RenderManager::loadImage(const char *file) {
++ Common::String str = Common::String(file);
++ return loadImage(str);
++}
++
++Graphics::Surface *RenderManager::loadImage(Common::String &file, bool transposed) {
++ Graphics::Surface *tmp = new Graphics::Surface;
++ readImageToSurface(file, *tmp, transposed);
++ return tmp;
++}
++
++Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) {
++ Common::String str = Common::String(file);
++ return loadImage(str, transposed);
++}
++
++void RenderManager::prepareBkg() {
++ _bkgDirtyRect.clip(_bkgWidth, _bkgHeight);
+ RenderTable::RenderState state = _renderTable.getRenderState();
+
+ if (state == RenderTable::PANORAMA) {
- return _backgroundOffset.x;
++ Common::Rect viewPort(_wrkWidth, _wrkHeight);
++ viewPort.translate(-(_screenCenterX - _bkgOff), 0);
++ Common::Rect drawRect = _bkgDirtyRect;
++ drawRect.clip(viewPort);
++
++ if (!drawRect.isEmpty())
++ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - _bkgOff + drawRect.left, drawRect.top);
++
++ _wrkWndDirtyRect = _bkgDirtyRect;
++ _wrkWndDirtyRect.translate(_screenCenterX - _bkgOff, 0);
++
++ if (_bkgOff < _screenCenterX) {
++ viewPort.moveTo(-(_screenCenterX - (_bkgOff + _bkgWidth)), 0);
++ drawRect = _bkgDirtyRect;
++ drawRect.clip(viewPort);
++
++ if (!drawRect.isEmpty())
++ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - (_bkgOff + _bkgWidth) + drawRect.left, drawRect.top);
++
++ Common::Rect tmp = _bkgDirtyRect;
++ tmp.translate(_screenCenterX - (_bkgOff + _bkgWidth), 0);
++ if (!tmp.isEmpty())
++ _wrkWndDirtyRect.extend(tmp);
++
++ } else if (_bkgWidth - _bkgOff < _screenCenterX) {
++ viewPort.moveTo(-(_screenCenterX + _bkgWidth - _bkgOff), 0);
++ drawRect = _bkgDirtyRect;
++ drawRect.clip(viewPort);
++
++ if (!drawRect.isEmpty())
++ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX + _bkgWidth - _bkgOff + drawRect.left, drawRect.top);
++
++ Common::Rect tmp = _bkgDirtyRect;
++ tmp.translate(_screenCenterX + _bkgWidth - _bkgOff, 0);
++ if (!tmp.isEmpty())
++ _wrkWndDirtyRect.extend(tmp);
++
++ }
+ } else if (state == RenderTable::TILT) {
- return _backgroundOffset.y;
++ Common::Rect viewPort(_wrkWidth, _wrkHeight);
++ viewPort.translate(0, -(_screenCenterY - _bkgOff));
++ Common::Rect drawRect = _bkgDirtyRect;
++ drawRect.clip(viewPort);
++ if (!drawRect.isEmpty())
++ blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, drawRect.left, _screenCenterY - _bkgOff + drawRect.top);
++
++ _wrkWndDirtyRect = _bkgDirtyRect;
++ _wrkWndDirtyRect.translate(0, _screenCenterY - _bkgOff);
++
+ } else {
- return 0;
++ if (!_bkgDirtyRect.isEmpty())
++ blitSurfaceToSurface(_curBkg, _bkgDirtyRect, _wrkWnd, _bkgDirtyRect.left, _bkgDirtyRect.top);
++ _wrkWndDirtyRect = _bkgDirtyRect;
++ }
++
++ _bkgDirtyRect = Common::Rect();
++
++ _wrkWndDirtyRect.clip(_wrkWidth, _wrkHeight);
++}
++
++void RenderManager::clearMenuSurface() {
++ _menuWndDirtyRect = Common::Rect(0, 0, _menuWnd.w, _menuWnd.h);
++ _menuWnd.fillRect(_menuWndDirtyRect, 0);
++}
++
++void RenderManager::clearMenuSurface(const Common::Rect &r) {
++ if (_menuWndDirtyRect.isEmpty())
++ _menuWndDirtyRect = r;
++ else
++ _menuWndDirtyRect.extend(r);
++ _menuWnd.fillRect(r, 0);
++}
++
++void RenderManager::renderMenuToScreen() {
++ if (!_menuWndDirtyRect.isEmpty()) {
++ _menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h));
++ if (!_menuWndDirtyRect.isEmpty())
++ _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch,
++ _menuWndDirtyRect.left + _menuWndRect.left,
++ _menuWndDirtyRect.top + _menuWndRect.top,
++ _menuWndDirtyRect.width(),
++ _menuWndDirtyRect.height());
++ _menuWndDirtyRect = Common::Rect();
+ }
+ }
+
-Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surface) {
- Graphics::Surface *tranposedSurface = new Graphics::Surface();
- tranposedSurface->create(surface->h, surface->w, surface->format);
++uint16 RenderManager::createSubArea(const Common::Rect &area) {
++ _subid++;
+
- const uint16 *source = (const uint16 *)surface->getPixels();
- uint16 *dest = (uint16 *)tranposedSurface->getPixels();
++ oneSub sub;
++ sub.redraw = false;
++ sub.timer = -1;
++ sub.todelete = false;
++ sub._r = area;
+
- for (uint32 y = 0; y < tranposedSurface->h; ++y) {
- uint32 columnIndex = y * tranposedSurface->w;
++ _subsList[_subid] = sub;
+
- for (uint32 x = 0; x < tranposedSurface->w; ++x) {
- dest[columnIndex + x] = source[x * surface->w + y];
++ return _subid;
++}
++
++void RenderManager::deleteSubArea(uint16 id) {
++ if (_subsList.contains(id))
++ _subsList[id].todelete = true;
++}
++
++void RenderManager::deleteSubArea(uint16 id, int16 delay) {
++ if (_subsList.contains(id))
++ _subsList[id].timer = delay;
++}
++
++void RenderManager::updateSubArea(uint16 id, const Common::String &txt) {
++ if (_subsList.contains(id)) {
++ oneSub *sub = &_subsList[id];
++ sub->_txt = txt;
++ sub->redraw = true;
++ }
++}
++
++void RenderManager::processSubs(uint16 deltatime) {
++ bool redraw = false;
++ for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
++ if (it->_value.timer != -1) {
++ it->_value.timer -= deltatime;
++ if (it->_value.timer <= 0)
++ it->_value.todelete = true;
++ }
++ if (it->_value.todelete) {
++ _subsList.erase(it);
++ redraw = true;
++ } else if (it->_value.redraw) {
++ redraw = true;
+ }
+ }
+
- return tranposedSurface;
++ if (redraw) {
++ _subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0);
++
++ for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
++ oneSub *sub = &it->_value;
++ if (sub->_txt.size()) {
++ Graphics::Surface *rndr = new Graphics::Surface();
++ rndr->create(sub->_r.width(), sub->_r.height(), _pixelFormat);
++ _engine->getTextRenderer()->drawTxtInOneLine(sub->_txt, *rndr);
++ blitSurfaceToSurface(*rndr, _subWnd, sub->_r.left - _subWndRect.left + _workingWindow.left, sub->_r.top - _subWndRect.top + _workingWindow.top);
++ rndr->free();
++ delete rndr;
++ }
++ sub->redraw = false;
++ }
++
++ _system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch,
++ _subWndRect.left,
++ _subWndRect.top,
++ _subWnd.w,
++ _subWnd.h);
++ }
++}
++
++Common::Point RenderManager::getBkgSize() {
++ return Common::Point(_bkgWidth, _bkgHeight);
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/graphics/render_manager.h
index 0000000,9feff4c..668c8ac
mode 000000,100644..100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@@ -1,0 -1,328 +1,271 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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 "zvision/graphics/render_table.h"
-#include "zvision/fonts/truetype_font.h"
++#include "zvision/render_table.h"
++#include "zvision/truetype_font.h"
+
+ #include "common/rect.h"
+ #include "common/hashmap.h"
+
+ #include "graphics/surface.h"
+
+
+ class OSystem;
+
+ namespace Common {
+ class String;
+ class SeekableReadStream;
+ }
+
+ namespace Video {
+ class VideoDecoder;
+ }
+
+ namespace ZVision {
+
+ class RenderManager {
+ public:
- RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
++ RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
+ ~RenderManager();
+
+ private:
- struct AlphaDataEntry {
- Graphics::Surface *data;
- uint16 alphaColor;
- uint16 destX;
- uint16 destY;
- uint16 width;
- uint16 height;
++ struct oneSub {
++ Common::Rect _r;
++ Common::String _txt;
++ int16 timer;
++ bool todelete;
++ bool redraw;
+ };
-
- typedef Common::HashMap<uint32, AlphaDataEntry> AlphaEntryMap;
++// struct AlphaDataEntry {
++// Graphics::Surface *data;
++// uint16 alphaColor;
++// uint16 destX;
++// uint16 destY;
++// uint16 width;
++// uint16 height;
++// };
++//
++ typedef Common::HashMap<uint16, oneSub> subMap;
+
+ private:
++ ZVision *_engine;
+ OSystem *_system;
+ const Graphics::PixelFormat _pixelFormat;
+
++ // A buffer for blitting background image to working window
++ Graphics::Surface _wrkWnd;
++
++ Common::Rect _wrkWndDirtyRect;
++
++ Graphics::Surface _outWnd;
++
++ Common::Rect _outWndDirtyRect;
++
++ Common::Rect _bkgDirtyRect;
++
++ Graphics::Surface _subWnd;
++
++ Common::Rect _subWndDirtyRect;
++
++ Graphics::Surface _menuWnd;
++
++ Common::Rect _menuWndDirtyRect;
++
++
+ // A buffer the exact same size as the workingWindow
+ // This buffer stores everything un-warped, then does a warp at the end of the frame
- Graphics::Surface _workingWindowBuffer;
++ //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;
++ //Graphics::Surface _backBuffer;
+ // A list of Alpha Entries that need to be blitted to the backbuffer
- AlphaEntryMap _alphaDataEntries;
++ //AlphaEntryMap _alphaDataEntries;
+
+ // A rectangle representing the portion of the working window where the pixels have been changed since last frame
- Common::Rect _workingWindowDirtyRect;
++ //Common::Rect _workingWindowDirtyRect;
+ // A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame
- Common::Rect _backBufferDirtyRect;
++ //Common::Rect _backBufferDirtyRect;
+
+ /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
- const int _workingWidth;
++ const int _wrkWidth;
+ /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
- const int _workingHeight;
++ const int _wrkHeight;
+ /** 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
+ * edges of this Rectangle
+ */
+ const Common::Rect _workingWindow;
++
++ Common::Rect _subWndRect;
++
++ Common::Rect _menuWndRect;
++
+ /** Used to warp the background image */
+ RenderTable _renderTable;
+
- Graphics::Surface _currentBackground;
++ Graphics::Surface _curBkg;
+ /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
- Common::Point _backgroundOffset;
++ int16 _bkgOff;
+ /** The width of the current background image */
- uint16 _backgroundWidth;
++ uint16 _bkgWidth;
+ /** The height of the current background image */
- uint16 _backgroundHeight;
++ uint16 _bkgHeight;
++
++ uint16 _subid;
++
++ subMap _subsList;
+
+ /**
+ * 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;
++ //int _backgroundInverseVelocity;
+ /** Holds any 'leftover' milliseconds between frames */
- uint _accumulatedVelocityMilliseconds;
++ //uint _accumulatedVelocityMilliseconds;
+
+ 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);
+
+ /**
+ * Renders the current state of the backbuffer to the screen
+ */
+ 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);
-
- /**
- * 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)
- */
- 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.
- * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
++ * Blits the image or a portion of the image to the background.
+ *
+ * @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!
+ */
- void renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap = false);
++ void renderImageToBackground(const Common::String &fileName, int16 destinationX, int16 destinationY);
+
+ /**
- * 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!
++ * Blits the image or a portion of the image to the background.
+ *
- * @param stream Surface to read the image data from
++ * @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 colorkey Transparent color
+ */
- void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false);
++ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
+
+ /**
+ * 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);
+
+ /**
+ * 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);
- /**
- * 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);
-
- /**
- * 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();
- 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
- * 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(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap);
++ void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
++
++
++ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y);
++ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey);
++ void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y);
++ void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
++ void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y);
++ void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey);
++ void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y);
++ void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey);
++
++ uint16 createSubArea(const Common::Rect &area);
++ void deleteSubArea(uint16 id);
++ void deleteSubArea(uint16 id, int16 delay);
++ void updateSubArea(uint16 id, const Common::String &txt);
++ void processSubs(uint16 deltatime);
++
++ Common::Point getBkgSize();
++
++ Graphics::Surface *getBkgRect(Common::Rect &rect);
++ Graphics::Surface *loadImage(const char *file);
++ Graphics::Surface *loadImage(Common::String &file);
++ Graphics::Surface *loadImage(const char *file, bool transposed);
++ Graphics::Surface *loadImage(Common::String &file, bool transposed);
++
++ void clearMenuSurface();
++ void clearMenuSurface(const Common::Rect &r);
++ void renderMenuToScreen();
++
++ void prepareBkg();
+
+ /**
+ * 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);
++ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/graphics/render_table.cpp
index 0000000,49b934d..942420c
mode 000000,100644..100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@@ -1,0 -1,240 +1,262 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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/graphics/render_table.h"
+
+ #include "common/rect.h"
+
+ #include "graphics/colormasks.h"
+
+
+ namespace ZVision {
+
+ RenderTable::RenderTable(uint numColumns, uint numRows)
- : _numRows(numRows),
- _numColumns(numColumns),
- _renderState(FLAT) {
++ : _numRows(numRows),
++ _numColumns(numColumns),
++ _renderState(FLAT) {
+ 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 = 27.0f;
+ _panoramaOptions.linearScale = 0.55f;
+ _panoramaOptions.reverse = false;
+ break;
+ case TILT:
+ _tiltOptions.fieldOfView = 27.0f;
+ _tiltOptions.linearScale = 0.55f;
+ _tiltOptions.reverse = false;
+ break;
+ case FLAT:
+ // Intentionally left empty
+ break;
+ }
+ }
+
+ 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) {
+ int16 x = CLIP<int16>(point.x, 0, (int16)_numColumns);
+ int16 y = CLIP<int16>(point.y, 0, (int16)_numRows);
+ return Common::Point(x, y);
+ }
+
+ 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);
+
+ 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);
++ (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift);
+
+ return returnColor;
+ }
+
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
++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) {
+ uint32 sourceOffset = y * _numColumns;
+
+ for (int16 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;
+ uint32 sourceXIndex = x + _internalBuffer[index].x;
+
+ destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
+ }
+
+ destOffset += destWidth;
+ }
+ }
+
++void RenderTable::mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf) {
++ uint32 destOffset = 0;
++
++ uint16 *sourceBuffer = (uint16 *)srcBuf->getPixels();
++ uint16 *destBuffer = (uint16 *)dstBuf->getPixels();
++
++ for (int16 y = 0; y < srcBuf->h; ++y) {
++ uint32 sourceOffset = y * _numColumns;
++
++ for (int16 x = 0; x < srcBuf->w; ++x) {
++ uint32 index = sourceOffset + x;
++
++ // RenderTable only stores offsets from the original coordinates
++ uint32 sourceYIndex = y + _internalBuffer[index].y;
++ uint32 sourceXIndex = x + _internalBuffer[index].x;
++
++ destBuffer[destOffset] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
++ destOffset++;
++ }
++ }
++}
++
+ 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));
+
+ float halfWidth = (float)_numColumns / 2.0f;
+ float halfHeight = (float)_numRows / 2.0f;
+
+ float fovInRadians = (_panoramaOptions.fieldOfView * M_PI / 180.0f);
+ float cylinderRadius = halfHeight / tan(fovInRadians);
+
+ 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);
+
+ // 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) {
+ // 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 = xInCylinderCoords - x;
+ _internalBuffer[index].y = yInCylinderCoords - y;
+ }
+ }
+ }
+
+ void RenderTable::generateTiltLookupTable() {
+ 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 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
+ // We also scale it by _tiltOptions.linearScale
+ int32 yInCylinderCoords = int32(floor((cylinderRadius * _tiltOptions.linearScale * alpha) + halfHeight));
+
+ 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;
+ }
+ }
+ }
+
+ void RenderTable::setPanoramaFoV(float fov) {
+ assert(fov > 0.0f);
+
+ _panoramaOptions.fieldOfView = fov;
+ }
+
+ void RenderTable::setPanoramaScale(float scale) {
+ assert(scale > 0.0f);
+
+ _panoramaOptions.linearScale = scale;
+ }
+
+ void RenderTable::setPanoramaReverse(bool reverse) {
+ _panoramaOptions.reverse = reverse;
+ }
+
+ void RenderTable::setTiltFoV(float fov) {
+ assert(fov > 0.0f);
+
+ _tiltOptions.fieldOfView = fov;
+ }
+
+ void RenderTable::setTiltScale(float scale) {
+ assert(scale > 0.0f);
+
+ _tiltOptions.linearScale = scale;
+ }
+
+ void RenderTable::setTiltReverse(bool reverse) {
+ _tiltOptions.reverse = reverse;
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/graphics/render_table.h
index 0000000,f066187..0b4d6e3
mode 000000,100644..100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@@ -1,0 -1,85 +1,89 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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/rect.h"
++#include "graphics/surface.h"
+
+
+ namespace ZVision {
+
+ class RenderTable {
+ public:
+ RenderTable(uint numRows, uint numColumns);
+ ~RenderTable();
+
+ public:
+ enum RenderState {
+ PANORAMA,
+ TILT,
+ FLAT
+ };
+
+ private:
+ uint _numColumns, _numRows;
+ Common::Point *_internalBuffer;
+ RenderState _renderState;
+
+ 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:
- RenderState getRenderState() { return _renderState; }
++ RenderState getRenderState() {
++ return _renderState;
++ }
+ void setRenderState(RenderState newState);
+
+ const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
+
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect);
++ void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect);
++ void mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf);
+ void generateRenderTable();
+
+ 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();
+ void generateTiltLookupTable();
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/actions.cpp
index 0000000,e854378..f60a697
mode 000000,100644..100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@@ -1,0 -1,401 +1,681 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/actions.h"
++#include "zvision/actions.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/sound/zork_raw.h"
-#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/scripting/controls/timer_node.h"
-#include "zvision/scripting/controls/animation_control.h"
++#include "zvision/script_manager.h"
++#include "zvision/render_manager.h"
++#include "zvision/zork_raw.h"
++#include "zvision/zork_avi_decoder.h"
++#include "zvision/timer_node.h"
++#include "zvision/music_node.h"
++#include "zvision/syncsound_node.h"
++#include "zvision/animation_node.h"
++#include "zvision/ttytext_node.h"
+
+ #include "common/file.h"
+
+ #include "audio/decoders/wave.h"
+
+
+ namespace ZVision {
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionAdd
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionAdd::ActionAdd(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
++ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ sscanf(line.c_str(), "%u,%d", &_key, &_value);
+ }
+
-bool ActionAdd::execute(ZVision *engine) {
- engine->getScriptManager()->addToStateValue(_key, _value);
++bool ActionAdd::execute() {
++ _engine->getScriptManager()->setStateValue(_key, _engine->getScriptManager()->getStateValue(_key) + _value);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionAssign
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionAssign::ActionAssign(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
++ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char buf[64];
++ memset(buf, 0, 64);
++ sscanf(line.c_str(), "%u, %s", &_key, buf);
++ _value = new ValueSlot(_engine->getScriptManager(), buf);
+ }
+
-bool ActionAssign::execute(ZVision *engine) {
- engine->getScriptManager()->setStateValue(_key, _value);
++ActionAssign::~ActionAssign() {
++ if (_value)
++ delete _value;
++}
++
++bool ActionAssign::execute() {
++ _engine->getScriptManager()->setStateValue(_key, _value->getValue());
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionAttenuate
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionAttenuate::ActionAttenuate(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
++ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ sscanf(line.c_str(), "%u, %d", &_key, &_attenuation);
+ }
+
-bool ActionAttenuate::execute(ZVision *engine) {
- // TODO: Implement
++bool ActionAttenuate::execute() {
++ SideFX *fx = _engine->getScriptManager()->getSideFX(_key);
++ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
++ MusicNode *mus = (MusicNode *)fx;
++ mus->setVolume(255 - (abs(_attenuation) >> 7));
++ }
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionChangeLocation
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_offset);
++ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset);
+ }
+
-bool ActionChangeLocation::execute(ZVision *engine) {
++bool ActionChangeLocation::execute() {
+ // 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, _offset);
++ _engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset);
+ // Tell the puzzle system to stop checking any more puzzles
+ return false;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionCrossfade
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionCrossfade::ActionCrossfade(const Common::String &line) {
++ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(),
- "%*[^(](%u %u %u %u %u %u %u)",
- &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
++ "%u %u %d %d %d %d %d",
++ &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+ }
+
-bool ActionCrossfade::execute(ZVision *engine) {
- // TODO: Implement
++bool ActionCrossfade::execute() {
++ if (_keyOne) {
++ SideFX *fx = _engine->getScriptManager()->getSideFX(_keyOne);
++ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
++ MusicNode *mus = (MusicNode *)fx;
++ if (_oneStartVolume >= 0)
++ mus->setVolume((_oneStartVolume * 255) / 100);
++
++ mus->setFade(_timeInMillis, (_oneEndVolume * 255) / 100);
++ }
++ }
++
++ if (_keyTwo) {
++ SideFX *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
++ if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
++ MusicNode *mus = (MusicNode *)fx;
++ if (_twoStartVolume >= 0)
++ mus->setVolume((_twoStartVolume * 255) / 100);
++
++ mus->setFade(_timeInMillis, (_twoEndVolume * 255) / 100);
++ }
++ }
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionDisableControl
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionDisableControl::ActionDisableControl(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
++ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ sscanf(line.c_str(), "%u", &_key);
+ }
+
-bool ActionDisableControl::execute(ZVision *engine) {
- debug("Disabling control %u", _key);
-
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) | ScriptManager::DISABLED);
-
++bool ActionDisableControl::execute() {
++ _engine->getScriptManager()->setStateFlag(_key, Puzzle::DISABLED);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionEnableControl
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionEnableControl::ActionEnableControl(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
++ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ sscanf(line.c_str(), "%u", &_key);
+ }
+
-bool ActionEnableControl::execute(ZVision *engine) {
- debug("Enabling control %u", _key);
++bool ActionEnableControl::execute() {
++ _engine->getScriptManager()->unsetStateFlag(_key, Puzzle::DISABLED);
++ return true;
++}
++
++//////////////////////////////////////////////////////////////////////////////
++// ActionInventory
++//////////////////////////////////////////////////////////////////////////////
++
++ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char buf[25];
++ sscanf(line.c_str(), "%25s %d", buf, &_key);
+
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) & ~ScriptManager::DISABLED);
++ if (strcmp(buf, "add") == 0) {
++ _type = 0;
++ } else if (strcmp(buf, "addi") == 0) {
++ _type = 1;
++ } else if (strcmp(buf, "drop") == 0) {
++ _type = 2;
++ } else if (strcmp(buf, "dropi") == 0) {
++ _type = 3;
++ } else if (strcmp(buf, "cycle") == 0) {
++ _type = 4;
++ }
+
++}
++
++bool ActionInventory::execute() {
++ switch (_type) {
++ case 0: // add
++ _engine->getScriptManager()->invertory_add(_key);
++ break;
++ case 1: // addi
++ _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(_key));
++ break;
++ case 2: // drop
++ if (_key >= 0)
++ _engine->getScriptManager()->invertory_drop(_key);
++ else
++ _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem));
++ break;
++ case 3: // dropi
++ _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(_key));
++ break;
++ case 4: // cycle
++ _engine->getScriptManager()->invertory_cycle();
++ break;
++ default:
++ break;
++ }
++ return true;
++}
++
++
++//////////////////////////////////////////////////////////////////////////////
++// ActionKill
++//////////////////////////////////////////////////////////////////////////////
++
++ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ _key = 0;
++ _type = 0;
++ char keytype[25];
++ sscanf(line.c_str(), "%25s", keytype);
++ if (keytype[0] == '"') {
++ if (!scumm_stricmp(keytype, "\"ANIM\""))
++ _type = SideFX::SIDEFX_ANIM;
++ else if (!scumm_stricmp(keytype, "\"AUDIO\""))
++ _type = SideFX::SIDEFX_AUDIO;
++ else if (!scumm_stricmp(keytype, "\"DISTORT\""))
++ _type = SideFX::SIDEFX_DISTORT;
++ else if (!scumm_stricmp(keytype, "\"PANTRACK\""))
++ _type = SideFX::SIDEFX_PANTRACK;
++ else if (!scumm_stricmp(keytype, "\"REGION\""))
++ _type = SideFX::SIDEFX_REGION;
++ else if (!scumm_stricmp(keytype, "\"TIMER\""))
++ _type = SideFX::SIDEFX_TIMER;
++ else if (!scumm_stricmp(keytype, "\"TTYTEXT\""))
++ _type = SideFX::SIDEFX_TTYTXT;
++ else if (!scumm_stricmp(keytype, "\"ALL\""))
++ _type = SideFX::SIDEFX_ALL;
++ } else
++ _key = atoi(keytype);
++}
++
++bool ActionKill::execute() {
++ if (_type)
++ _engine->getScriptManager()->killSideFxType((SideFX::SideFXType)_type);
++ else
++ _engine->getScriptManager()->killSideFx(_key);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionMusic
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
++ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) :
++ ResultAction(engine, slotkey),
++ _volume(255),
++ _universe(global) {
+ uint type;
+ char fileNameBuffer[25];
+ uint loop;
+ uint volume = 255;
+
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
++ sscanf(line.c_str(), "%u %25s %u %u", &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;
++ActionMusic::~ActionMusic() {
++ if (!_universe)
++ _engine->getScriptManager()->killSideFx(_slotkey);
++}
+
- if (_fileName.contains(".wav")) {
- Common::File *file = new Common::File();
- if (file->open(_fileName)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- } else {
- warning("Unable to open %s", _fileName.c_str());
- return false;
- }
- } 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);
- }
++bool ActionMusic::execute() {
++ if (_engine->getScriptManager()->getSideFX(_slotkey))
++ return true;
++
++ if (!_engine->getSearchManager()->hasFile(_fileName))
++ return true;
++
++ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
+
+ return true;
+ }
+
++//////////////////////////////////////////////////////////////////////////////
++// ActionPanTrack
++//////////////////////////////////////////////////////////////////////////////
++
++ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey),
++ _pos(0),
++ _mus_slot(0) {
++
++ sscanf(line.c_str(), "%u %d", &_mus_slot, &_pos);
++}
++
++ActionPanTrack::~ActionPanTrack() {
++ _engine->getScriptManager()->killSideFx(_slotkey);
++}
++
++bool ActionPanTrack::execute() {
++ if (_engine->getScriptManager()->getSideFX(_slotkey))
++ return true;
++
++ _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotkey, _mus_slot, _pos));
++
++ return true;
++}
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionPreloadAnimation
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
++ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ char fileName[25];
+
+ // The two %*u are always 0 and dont seem to have a use
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
++ sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate);
++
++ if (_mask > 0) {
++ byte r, g, b;
++ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
++ _mask = _engine->_pixelFormat.RGBToColor(r, g, b);
++ }
+
+ _fileName = Common::String(fileName);
+ }
+
-bool ActionPreloadAnimation::execute(ZVision *engine) {
- // 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
++ActionPreloadAnimation::~ActionPreloadAnimation() {
++ _engine->getScriptManager()->deleteSideFx(_slotkey);
++}
+
- // Create the control, but disable it until PlayPreload is called
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->addControl(new AnimationControl(engine, _key, _fileName));
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) | ScriptManager::DISABLED);
++bool ActionPreloadAnimation::execute() {
++ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
+
++ if (!nod) {
++ nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false);
++ _engine->getScriptManager()->addSideFX(nod);
++ } else
++ nod->stop();
++ _engine->getScriptManager()->setStateValue(_slotkey, 2);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionPlayAnimation
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
++ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ char fileName[25];
+
+ // 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, &_loopCount, &_mask, &_framerate);
++ "%25s %u %u %u %u %u %u %d %*u %*u %d %d",
++ fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
++
++ if (_mask > 0) {
++ byte r, g, b;
++ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
++ _mask = _engine->_pixelFormat.RGBToColor(r, g, b);
++ }
+
+ _fileName = Common::String(fileName);
+ }
+
-bool ActionPlayAnimation::execute(ZVision *engine) {
- // TODO: Implement
++ActionPlayAnimation::~ActionPlayAnimation() {
++ _engine->getScriptManager()->deleteSideFx(_slotkey);
++}
++
++bool ActionPlayAnimation::execute() {
++ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
++
++ if (!nod) {
++ nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate);
++ _engine->getScriptManager()->addSideFX(nod);
++ } else
++ nod->stop();
++
++ if (nod)
++ nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount);
++
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionPlayPreloadAnimation
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) {
++ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(),
- "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)",
- &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
++ "%u %u %u %u %u %u %u %u",
++ &_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);
++bool ActionPlayPreloadAnimation::execute() {
++ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey);
+
- // Enable the control. ScriptManager will take care of the rest
- control->enable();
++ if (nod)
++ nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
+
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionQuit
+ //////////////////////////////////////////////////////////////////////////////
+
-bool ActionQuit::execute(ZVision *engine) {
- engine->quitGame();
++bool ActionQuit::execute() {
++ _engine->quitGame();
+
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionRandom
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionRandom::ActionRandom(const Common::String &line) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
++ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char max_buf[64];
++ memset(max_buf, 0, 64);
++ sscanf(line.c_str(), "%s", max_buf);
++ _max = new ValueSlot(_engine->getScriptManager(), max_buf);
++}
++
++ActionRandom::~ActionRandom() {
++ if (_max)
++ delete _max;
+ }
+
-bool ActionRandom::execute(ZVision *engine) {
- uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
- engine->getScriptManager()->setStateValue(_key, randNumber);
++bool ActionRandom::execute() {
++ uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue());
++ _engine->getScriptManager()->setStateValue(_slotkey, randNumber);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionSetPartialScreen
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
++ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ char fileName[25];
- uint color;
++ int color;
+
- sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color);
++ sscanf(line.c_str(), "%u %u %25s %*u %d", &_x, &_y, fileName, &color);
+
+ _fileName = Common::String(fileName);
+
- if (color > 0xFFFF) {
++ if (color >= 0) {
++ byte r, g, b;
++ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b);
++ _backgroundColor = _engine->_pixelFormat.RGBToColor(r, g, b);
++ } else {
++ _backgroundColor = color;
++ }
++
++ if (color > 65535) {
+ 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->clearWorkingWindowTo555Color(_backgroundColor);
- }
- renderManager->renderImageToScreen(_fileName, _x, _y);
++bool ActionSetPartialScreen::execute() {
++ RenderManager *renderManager = _engine->getRenderManager();
++ if (_backgroundColor >= 0)
++ renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
++ else
++ renderManager->renderImageToBackground(_fileName, _x, _y);
+
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionSetScreen
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionSetScreen::ActionSetScreen(const Common::String &line) {
++ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ char fileName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
++ sscanf(line.c_str(), "%25s", fileName);
+
+ _fileName = Common::String(fileName);
+ }
+
-bool ActionSetScreen::execute(ZVision *engine) {
- engine->getRenderManager()->setBackgroundImage(_fileName);
++bool ActionSetScreen::execute() {
++ _engine->getRenderManager()->setBackgroundImage(_fileName);
++
++ return true;
++}
++
++//////////////////////////////////////////////////////////////////////////////
++// ActionStop
++//////////////////////////////////////////////////////////////////////////////
++
++ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ _key = 0;
++ sscanf(line.c_str(), "%u", &_key);
++}
+
++bool ActionStop::execute() {
++ _engine->getScriptManager()->stopSideFx(_key);
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionStreamVideo
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
++ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
+ char fileName[25];
- uint skippable;
++ uint skipline; //skipline - render video with skip every second line, not skippable.
+
- sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable);
++ sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline);
+
+ _fileName = Common::String(fileName);
- _skippable = (skippable == 0) ? false : true;
++ _skippable = true;
+ }
+
-bool ActionStreamVideo::execute(ZVision *engine) {
++bool ActionStreamVideo::execute() {
+ ZorkAVIDecoder decoder;
- if (!decoder.loadFile(_fileName)) {
- return true;
- }
++ Common::File *_file = _engine->getSearchManager()->openFile(_fileName);
+
- Common::Rect destRect;
- if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
- destRect = Common::Rect(_x1, _y1, _x2, _y2);
++ if (_file) {
++ if (!decoder.loadStream(_file)) {
++ return true;
++ }
++
++ Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
++
++ Common::String subname = _fileName;
++ subname.setChar('s', subname.size() - 3);
++ subname.setChar('u', subname.size() - 2);
++ subname.setChar('b', subname.size() - 1);
++
++ Subtitle *sub = NULL;
++
++ if (_engine->getSearchManager()->hasFile(subname))
++ sub = new Subtitle(_engine, subname);
++
++ _engine->playVideo(decoder, destRect, _skippable, sub);
++
++ if (sub)
++ delete sub;
+ }
+
- engine->playVideo(decoder, destRect, _skippable);
+ return true;
+ }
+
++//////////////////////////////////////////////////////////////////////////////
++// ActionSyncSound
++//////////////////////////////////////////////////////////////////////////////
++
++ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char fileName[25];
++ int not_used;
++
++ sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬_used, fileName);
++
++ _fileName = Common::String(fileName);
++}
++
++bool ActionSyncSound::execute() {
++ SideFX *fx = _engine->getScriptManager()->getSideFX(_syncto);
++ if (!fx)
++ return true;
++
++ if (!(fx->getType() & SideFX::SIDEFX_ANIM))
++ return true;
++
++ AnimationNode *animnode = (AnimationNode *)fx;
++ if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload
++ animnode->setNewFrameDelay(66); // ~15fps
++
++ _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotkey, _fileName, _syncto));
++ return true;
++}
+
+ //////////////////////////////////////////////////////////////////////////////
+ // ActionTimer
+ //////////////////////////////////////////////////////////////////////////////
+
-ActionTimer::ActionTimer(const Common::String &line) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
++ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char time_buf[64];
++ memset(time_buf, 0, 64);
++ sscanf(line.c_str(), "%s", time_buf);
++ _time = new ValueSlot(_engine->getScriptManager(), time_buf);
+ }
+
-bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addControl(new TimerNode(engine, _key, _time));
++ActionTimer::~ActionTimer() {
++ if (_time)
++ delete _time;
++ _engine->getScriptManager()->killSideFx(_slotkey);
++}
++
++bool ActionTimer::execute() {
++ if (_engine->getScriptManager()->getSideFX(_slotkey))
++ return true;
++ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue()));
++ return true;
++}
++
++//////////////////////////////////////////////////////////////////////////////
++// ActionTtyText
++//////////////////////////////////////////////////////////////////////////////
++
++ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) :
++ ResultAction(engine, slotkey) {
++ char filename[64];
++ int32 x1, y1, x2, y2;
++ sscanf(line.c_str(), "%d %d %d %d %s %u", &x1, &y1, &x2, &y2, filename, &_delay);
++ _r = Common::Rect(x1, y1, x2, y2);
++ _filename = Common::String(filename);
++}
++
++ActionTtyText::~ActionTtyText() {
++ _engine->getScriptManager()->killSideFx(_slotkey);
++}
++
++bool ActionTtyText::execute() {
++ if (_engine->getScriptManager()->getSideFX(_slotkey))
++ return true;
++ _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotkey, _filename, _r, _delay));
+ return true;
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/actions.h
index 0000000,01457d2..c60aedc
mode 000000,100644..100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@@ -1,0 -1,346 +1,418 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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_ACTIONS_H
+ #define ZVISION_ACTIONS_H
+
+ #include "common/str.h"
++#include "common/rect.h"
+
+ #include "audio/mixer.h"
+
+
+ namespace ZVision {
+
+ // Forward declaration of ZVision. This file is included before ZVision is declared
+ class ZVision;
++class ValueSlot;
+
+ /**
+ * The base class that represents any action that a Puzzle can take.
+ * This class is purely virtual.
+ */
+ class ResultAction {
+ public:
++ ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {}
+ 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;
++ virtual bool execute() = 0;
++protected:
++ ZVision *_engine;
++ int32 _slotkey;
+ };
+
+
+ // The different types of actions
+ // DEBUG,
+ // 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(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint32 _key;
- uint _value;
++ int _value;
+ };
+
+ class ActionAssign : public ResultAction {
+ public:
- ActionAssign(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionAssign();
++ bool execute();
+
+ private:
+ uint32 _key;
- uint _value;
++ ValueSlot *_value;
+ };
+
+ class ActionAttenuate : public ResultAction {
+ public:
- ActionAttenuate(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint32 _key;
- int _attenuation;
++ int32 _attenuation;
+ };
+
+ class ActionChangeLocation : public ResultAction {
+ public:
- ActionChangeLocation(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ char _world;
+ char _room;
+ char _node;
+ char _view;
+ uint32 _offset;
+ };
+
+ class ActionCrossfade : public ResultAction {
+ public:
- ActionCrossfade(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint32 _keyOne;
+ uint32 _keyTwo;
- uint _oneStartVolume;
- uint _twoStartVolume;
- uint _oneEndVolume;
- uint _twoEndVolume;
- uint _timeInMillis;
++ int32 _oneStartVolume;
++ int32 _twoStartVolume;
++ int32 _oneEndVolume;
++ int32 _twoEndVolume;
++ int32 _timeInMillis;
+ };
+
+ class ActionDebug : public ResultAction {
+ public:
- ActionDebug(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ };
+
+ class ActionDelayRender : public ResultAction {
+ public:
- ActionDelayRender(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ // TODO: Check if this should actually be frames or if it should be milliseconds/seconds
+ uint32 framesToDelay;
+ };
+
+ class ActionDisableControl : public ResultAction {
+ public:
- ActionDisableControl(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint32 _key;
+ };
+
+ class ActionDisableVenus : public ResultAction {
+ public:
- ActionDisableVenus(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ };
+
+ class ActionDisplayMessage : public ResultAction {
+ public:
- ActionDisplayMessage(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ };
+
+ class ActionDissolve : public ResultAction {
+ public:
- ActionDissolve();
- bool execute(ZVision *engine);
++ ActionDissolve(ZVision *engine);
++ bool execute();
+ };
+
+ class ActionDistort : public ResultAction {
+ public:
- ActionDistort(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ };
+
+ class ActionEnableControl : public ResultAction {
+ public:
- ActionEnableControl(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint32 _key;
+ };
+
++class ActionInventory : public ResultAction {
++public:
++ ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
++private:
++ uint8 _type;
++ int32 _key;
++};
++
++class ActionKill : public ResultAction {
++public:
++ ActionKill(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
++
++private:
++ uint32 _key;
++ uint32 _type;
++};
++
+ class ActionMusic : public ResultAction {
+ public:
- ActionMusic(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global);
++ ~ActionMusic();
++ bool execute();
+
+ private:
+ uint32 _key;
+ Audio::Mixer::SoundType _soundType;
+ Common::String _fileName;
+ bool _loop;
+ byte _volume;
++ bool _universe;
++};
++
++class ActionPanTrack : public ResultAction {
++public:
++ ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionPanTrack();
++ bool execute();
++
++private:
++ int32 _pos;
++ uint32 _mus_slot;
+ };
+
+ class ActionPlayAnimation : public ResultAction {
+ public:
- ActionPlayAnimation(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionPlayAnimation();
++ bool execute();
+
+ private:
+ uint32 _key;
+ Common::String _fileName;
+ uint32 _x;
+ uint32 _y;
- uint32 _width;
- uint32 _height;
++ uint32 _x2;
++ uint32 _y2;
+ uint32 _start;
+ uint32 _end;
- uint _mask;
- uint _framerate;
- uint _loopCount;
++ int32 _mask;
++ int32 _framerate;
++ int32 _loopCount;
+ };
+
+ class ActionPlayPreloadAnimation : public ResultAction {
+ public:
- ActionPlayPreloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ 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);
- bool execute(ZVision *engine);
++ ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionPreloadAnimation();
++ bool execute();
+
+ private:
+ uint32 _key;
+ Common::String _fileName;
- uint _mask;
- uint _framerate;
++ int32 _mask;
++ int32 _framerate;
+ };
+
+ class ActionQuit : public ResultAction {
+ public:
- ActionQuit() {}
- bool execute(ZVision *engine);
++ ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {}
++ bool execute();
+ };
+
+ // 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);
++ ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+ };
+
+ class ActionRandom : public ResultAction {
+ public:
- ActionRandom(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionRandom();
++ bool execute();
+
+ private:
+ uint32 _key;
- uint _max;
++ ValueSlot *_max;
+ };
+
+ class ActionSetPartialScreen : public ResultAction {
+ public:
- ActionSetPartialScreen(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ uint _x;
+ uint _y;
+ Common::String _fileName;
- uint16 _backgroundColor;
++ int32 _backgroundColor;
+ };
+
+ class ActionSetScreen : public ResultAction {
+ public:
- ActionSetScreen(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
+ Common::String _fileName;
+ };
+
++class ActionStop : public ResultAction {
++public:
++ ActionStop(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
++
++private:
++ uint32 _key;
++};
++
+ class ActionStreamVideo : public ResultAction {
+ public:
- ActionStreamVideo(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ 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;
+ uint _x2;
+ uint _y2;
+ uint _flags;
+ bool _skippable;
+ };
+
-class ActionTimer : public ResultAction {
++class ActionSyncSound : public ResultAction {
+ public:
- ActionTimer(const Common::String &line);
- bool execute(ZVision *engine);
++ ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line);
++ bool execute();
+
+ private:
++ int _syncto;
++ Common::String _fileName;
++};
++
++class ActionTimer : public ResultAction {
++public:
++ ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionTimer();
++ bool execute();
++private:
+ uint32 _key;
- uint _time;
++ ValueSlot *_time;
+ };
+
++class ActionTtyText : public ResultAction {
++public:
++ ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line);
++ ~ActionTtyText();
++ bool execute();
++
++private:
++ Common::String _filename;
++ uint32 _delay;
++ Common::Rect _r;
++};
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/control.cpp
index 0000000,2343c83..ae717d6
mode 000000,100644..100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@@ -1,0 -1,124 +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.
+ *
+ */
+
+ #include "common/scummsys.h"
+
+ #include "zvision/scripting/control.h"
+
+ #include "zvision/zvision.h"
+ #include "zvision/graphics/render_manager.h"
+ #include "zvision/utility/utility.h"
+
+ #include "common/stream.h"
+
+
+ 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);
+ }
+
+ 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 (!stream.eos() && !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(), "linscale(%f)", &scale);
+ renderTable->setPanoramaScale(scale);
+ } else if (line.matchString("reversepana*", true)) {
+ uint reverse;
+ sscanf(line.c_str(), "reversepana(%u)", &reverse);
+ if (reverse == 1) {
+ renderTable->setPanoramaReverse(true);
+ }
+ } else if (line.matchString("zeropoint*", true)) {
+ // TODO: Implement
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ renderTable->generateRenderTable();
+ }
+
+ 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 (!stream.eos() && !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(), "linscale(%f)", &scale);
+ renderTable->setTiltScale(scale);
+ } else if (line.matchString("reversepana*", true)) {
+ uint reverse;
+ sscanf(line.c_str(), "reversepana(%u)", &reverse);
+ if (reverse == 1) {
+ renderTable->setTiltReverse(true);
+ }
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ renderTable->generateRenderTable();
+ }
+
++void Control::getParams(Common::String &input_str, Common::String ¶meter, Common::String &values) {
++ const char *chrs = input_str.c_str();
++ uint lbr;
++
++ for (lbr = 0; lbr < input_str.size(); lbr++)
++ if (chrs[lbr] == '(')
++ break;
++
++ if (lbr >= input_str.size())
++ return;
++
++ uint rbr;
++
++ for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
++ if (chrs[rbr] == ')')
++ break;
++
++ if (rbr >= input_str.size())
++ return;
++
++ parameter = Common::String(chrs, chrs + lbr);
++ values = Common::String(chrs + lbr + 1, chrs + rbr);
++}
++
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/control.h
index 0000000,ffeacb2..93ad5f5
mode 000000,100644..100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@@ -1,0 -1,146 +1,125 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #ifndef ZVISION_CONTROL_H
+ #define ZVISION_CONTROL_H
+
+ #include "common/keyboard.h"
++#include "common/str.h"
+
+
+ namespace Common {
+ class SeekableReadStream;
+ struct Point;
+ class WriteStream;
+ }
+
+ namespace ZVision {
+
+ class ZVision;
+
+ class Control {
+ public:
- Control() : _engine(0), _key(0), _enabled(false) {}
- Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
++ Control() : _engine(0), _key(0) {}
++ Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
+ virtual ~Control() {}
+
- uint32 getKey() { return _key; }
++ uint32 getKey() {
++ return _key;
++ }
+
- virtual void enable();
- virtual void disable();
+ virtual void focus() {}
+ virtual void unfocus() {}
+ /**
+ * 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) {}
++ virtual bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ return false;
++ }
+ /**
+ * 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) {}
++ virtual bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ return false;
++ }
+ /**
+ * 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; }
++ 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
+ * @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; }
++ virtual bool process(uint32 deltaTimeInMillis) {
++ return false;
++ }
+
+ protected:
- ZVision * _engine;
++ ZVision *_engine;
+ uint32 _key;
- bool _enabled;
+
++ void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values);
+ // 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);
+ };
+
+ // TODO: Implement InputControl
+ // TODO: Implement SaveControl
+ // TODO: Implement SlotControl
+ // TODO: Implement SafeControl
+ // TODO: Implement FistControl
+ // TODO: Implement HotMovieControl
+ // TODO: Implement PaintControl
+ // TODO: Implement TilterControl
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/controls/input_control.cpp
index 0000000,5cf5086..a366e06
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@@ -1,0 -1,142 +1,143 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #include "common/scummsys.h"
+
-#include "zvision/scripting/controls/input_control.h"
++#include "zvision/input_control.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/strings/string_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/utility/utility.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 {
+
+ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
- _nextTabstop(0),
- _focused(false),
- _textChanged(false),
- _cursorOffset(0) {
++ : 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) {
++bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ _engine->getScriptManager()->focusControl(_key);
++ return false;
+ }
+
+ 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());
++ //Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width());
+
- _cursorOffset = destRect.left - _textRectangle.left;
++ //_cursorOffset = destRect.left - _textRectangle.left;
+ }
+
+ // Render the next frame of the animation
+ // TODO: Implement animation handling
+
+ return false;
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/controls/input_control.h
index 0000000,3243243..4a63f22
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@@ -1,0 -1,60 +1,64 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #ifndef ZVISION_INPUT_CONTROL_H
+ #define ZVISION_INPUT_CONTROL_H
+
+ #include "zvision/scripting/control.h"
+ #include "zvision/strings/string_manager.h"
+
+ #include "common/rect.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 focus() {
++ _focused = true;
++ }
++ void unfocus() {
++ _focused = false;
++ }
++ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ void onKeyDown(Common::KeyState keyState);
+ bool process(uint32 deltaTimeInMillis);
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/controls/lever_control.cpp
index 0000000,9724e66..f68f256
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@@ -1,0 -1,402 +1,382 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/lever_control.h"
++#include "zvision/lever_control.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/rlf_animation.h"
-#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/utility/utility.h"
++#include "zvision/script_manager.h"
++#include "zvision/render_manager.h"
++#include "zvision/cursor_manager.h"
++#include "zvision/meta_animation.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)
- : Control(engine, key),
- _frameInfo(0),
- _frameCount(0),
- _startFrame(0),
- _currentFrame(0),
- _lastRenderedFrame(0),
- _mouseIsCaptured(false),
- _isReturning(false),
- _accumulatedTime(0),
- _returnRoutesCurrentFrame(0) {
++ : Control(engine, key),
++ _frameInfo(0),
++ _frameCount(0),
++ _startFrame(0),
++ _currentFrame(0),
++ _lastRenderedFrame(0),
++ _mouseIsCaptured(false),
++ _isReturning(false),
++ _accumulatedTime(0),
++ _returnRoutesCurrentFrame(0) {
+
+ // 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);
+ }
+
+ LeverControl::~LeverControl() {
- if (_fileType == AVI) {
- delete _animation.avi;
- } else if (_fileType == RLF) {
- delete _animation.rlf;
- }
-
++ if (_animation)
++ delete _animation;
++
+ delete[] _frameInfo;
+ }
+
+ void LeverControl::parseLevFile(const Common::String &fileName) {
+ Common::File file;
- if (!file.open(fileName)) {
++ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("LEV file %s could could be opened", fileName.c_str());
+ return;
+ }
+
- Common::String line = file.readLine();
++ Common::String line;
+
+ while (!file.eos()) {
++ line = file.readLine();
++
+ 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 animationFileName(fileNameBuffer);
+
- 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;
- }
++ if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf"))
++ _animation = new MetaAnimation(animationFileName, _engine);
++
+ } else if (line.matchString("*skipcolor*", true)) {
+ // Not used
+ } else if (line.matchString("*anim_coords*", true)) {
+ 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);
+
+ _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;
+
++ line.toLowercase();
++
+ 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, " ^=()");
++ Common::StringTokenizer tokenizer(line, " ^=()~");
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+
+ Common::String token = tokenizer.nextToken();
+ while (!tokenizer.empty()) {
- if (token == "D") {
++ 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")) {
++ } else if (token.hasPrefix("p")) {
+ // Format: P(<from> to <to>)
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+ token = tokenizer.nextToken();
+ uint to = atoi(token.c_str());
+
+ _frameInfo[frameNumber].returnRoute.push_back(to);
+ }
+
+ token = tokenizer.nextToken();
+ }
+ }
+
- line = file.readLine();
++ // Don't read lines in this place because last will not be parsed.
+ }
+ }
+
-void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
- }
-
++bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
++ return false;
++
+ if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ _mouseIsCaptured = true;
+ _lastMousePos = backgroundImageSpacePos;
+ }
++ return false;
+ }
+
-void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
- }
-
++bool LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
++ return false;
++
+ if (_mouseIsCaptured) {
+ _mouseIsCaptured = false;
+ _engine->getScriptManager()->setStateValue(_key, _currentFrame);
+
+ _isReturning = true;
+ _returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
+ _returnRoutesCurrentFrame = _currentFrame;
+ }
++ return false;
+ }
+
+ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
- }
-
++
+ 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 + ANGLE_DELTA) {
+ _currentFrame = iter->toFrame;
+ renderFrame(_currentFrame);
+ break;
+ }
+ }
+ }
+ } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_cursorName);
++ _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_cursorName));
+ cursorWasChanged = true;
+ }
+
+ return cursorWasChanged;
+ }
+
+ bool LeverControl::process(uint32 deltaTimeInMillis) {
- if (!_enabled) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
- }
+
+ 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;
+ return false;
+ }
+
+ uint toFrame = *_returnRoutesCurrentProgress;
+ if (_returnRoutesCurrentFrame < toFrame) {
+ _returnRoutesCurrentFrame++;
+ } else if (_returnRoutesCurrentFrame > toFrame) {
+ _returnRoutesCurrentFrame--;
+ }
+
+ _engine->getScriptManager()->setStateValue(_key, _returnRoutesCurrentFrame);
+ renderFrame(_returnRoutesCurrentFrame);
+ }
+ }
-
++
+ 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;
+
+ // Calculate the angle using arctan
+ // Then convert to degrees. (180 / 3.14159 = 57.2958)
- int angle = int(atan((float)yDist / (float)xDist) * 57);
++ int angle = int(atan((float)yDist / (float)abs(xDist)) * 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 1 \ | / Quadrant 0 |
+ // \ | / |
+ // \ | / |
+ // angle ( \|/ ) -angle |
+ // 180 <----------------------------------------> 0 |
+ // -angle ( /|\ ) angle |
+ // / | \ |
+ // / | \ |
+ // Quadrant 3 / | \ Quadrant 2 |
+ // / | \ |
+ // / | \ |
+ // / | \ |
+ // * | * |
+ // ^ |
+ // 270 |
+
+ // Convert the local angles to unit circle angles
+ switch (quadrant) {
+ case 0:
- angle = 180 + angle;
++ angle = -angle;
+ break;
+ case 1:
- // Do nothing
++ angle = angle + 180;
+ break;
+ case 2:
- angle = 180 + angle;
++ angle = 360 - angle;
+ break;
+ case 3:
- angle = 360 + angle;
++ angle = 180 + angle;
+ break;
+ }
+
+ return angle;
+ }
+ }
+
+ void LeverControl::renderFrame(uint frameNumber) {
+ if (frameNumber == 0) {
+ _lastRenderedFrame = frameNumber;
+ } else if (frameNumber < _lastRenderedFrame && _mirrored) {
+ _lastRenderedFrame = frameNumber;
+ frameNumber = (_frameCount * 2) - frameNumber - 1;
+ } else {
+ _lastRenderedFrame = frameNumber;
+ }
+
- const uint16 *frameData = 0;
++ const Graphics::Surface *frameData;
+ int x = _animationCoords.left;
+ int y = _animationCoords.top;
- int width = 0;
- int height = 0;
-
- if (_fileType == RLF) {
- // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- 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) {
- _animation.avi->seekToFrame(frameNumber);
- const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
- frameData = (const uint16 *)surface->getPixels();
- width = surface->w;
- height = surface->h;
- }
+
- _engine->getRenderManager()->copyRectToWorkingWindow(frameData, x, y, width, width, height);
++ frameData = _animation->getFrameData(frameNumber);
++ if (frameData)
++ _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/controls/lever_control.h
index 0000000,49e4fd3..712d688
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/lever_control.h
+++ b/engines/zvision/scripting/controls/lever_control.h
@@@ -1,0 -1,127 +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_LEVER_CONTROL_H
+ #define ZVISION_LEVER_CONTROL_H
+
+ #include "zvision/scripting/control.h"
+
+ #include "common/list.h"
+ #include "common/rect.h"
+
+
+ namespace ZVision {
+
+ class ZorkAVIDecoder;
-class RlfAnimation;
++class MetaAnimation;
+
+ class LeverControl : public Control {
+ public:
+ LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~LeverControl();
+
+ private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
+
+ struct Direction {
+ Direction(uint a, uint t) : angle(a), toFrame(t) {}
+
+ 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)
+ ANIMATION_FRAME_TIME = 30 // In millis
+ };
+
+ private:
- union {
- RlfAnimation *rlf;
- ZorkAVIDecoder *avi;
- } _animation;
- FileType _fileType;
++ MetaAnimation *_animation;
+
+ Common::String _cursorName;
+ Common::Rect _animationCoords;
+ bool _mirrored;
+ uint _frameCount;
+ uint _startFrame;
+ Common::Point _hotspotDelta;
+ FrameInfo *_frameInfo;
+
+ uint _currentFrame;
+ uint _lastRenderedFrame;
+ bool _mouseIsCaptured;
+ 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);
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
++ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
++ bool 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 --cc engines/zvision/scripting/controls/push_toggle_control.cpp
index 0000000,82736b7..16cd971
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@@ -1,0 -1,98 +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 "zvision/scripting/controls/push_toggle_control.h"
+
+ #include "zvision/zvision.h"
+ #include "zvision/scripting/script_manager.h"
+ #include "zvision/cursors/cursor_manager.h"
+ #include "zvision/utility/utility.h"
+
+ #include "common/stream.h"
+
+
+ namespace ZVision {
+
+ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
++ : Control(engine, key),
++ _countTo(2),
++ _event(Common::EVENT_LBUTTONUP) {
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
++ line.toLowercase();
+
+ 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);
++ } else if (line.matchString("animation*", true)) {
++ // Not used
++ } else if (line.matchString("sound*", true)) {
++ // Not used
++ } else if (line.matchString("count_to*", true)) {
++ sscanf(line.c_str(), "%*[^(](%u)", &_countTo);
++ } else if (line.matchString("mouse_event*", true)) {
++ char nameBuffer[25];
++
++ sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
++
++ Common::String evntStr(nameBuffer);
++ if (evntStr.equalsIgnoreCase("up")) {
++ _event = Common::EVENT_LBUTTONUP;
++ } else if (evntStr.equalsIgnoreCase("down")) {
++ _event = Common::EVENT_LBUTTONDOWN;
++ } else if (evntStr.equalsIgnoreCase("double")) {
++ // Not used
++ }
++ } else if (line.matchString("venus_id*", true)) {
++ // Not used
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ if (_hotspot.isEmpty() || _hoverCursor.empty()) {
+ warning("Push_toggle cursor %u was parsed incorrectly", key);
+ }
+ }
+
+ PushToggleControl::~PushToggleControl() {
- // Clear the state value back to 0
- _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+
-void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
++bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
++ return false;
++
++ if (_event != Common::EVENT_LBUTTONUP)
++ return false;
++
++ if (_hotspot.contains(backgroundImageSpacePos)) {
++ int32 val = _engine->getScriptManager()->getStateValue(_key);
++ val = (val + 1) % _countTo;
++ _engine->getScriptManager()->setStateValue(_key, val);
++ return true;
+ }
-
++ return false;
++}
++
++bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
++ return false;
++
++ if (_event != Common::EVENT_LBUTTONDOWN)
++ return false;
++
+ if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getScriptManager()->setStateValue(_key, 1);
++ int32 val = _engine->getScriptManager()->getStateValue(_key);
++ val = (val + 1) % _countTo;
++ _engine->getScriptManager()->setStateValue(_key, val);
++ return true;
+ }
++ return false;
+ }
+
+ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
++ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
- }
-
++
+ if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_hoverCursor);
++ _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor));
+ return true;
+ }
+
+ return false;
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/controls/push_toggle_control.h
index 0000000,3854fc2..6ba1bd7
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/push_toggle_control.h
+++ b/engines/zvision/scripting/controls/push_toggle_control.h
@@@ -1,0 -1,67 +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 ZVISION_PUSH_TOGGLE_CONTROL_H
+ #define ZVISION_PUSH_TOGGLE_CONTROL_H
+
+ #include "zvision/scripting/control.h"
+
+ #include "common/rect.h"
++#include "common/events.h"
+
+
+ namespace ZVision {
+
+ class PushToggleControl : public Control {
+ public:
+ PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~PushToggleControl();
+
+ /**
++ * 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
++ */
++ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
++ /**
+ * 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);
++ bool 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:
+ /**
+ * 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;
++ /** Button maximal values count */
++ uint _countTo;
++
++ Common::EventType _event;
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/controls/timer_node.cpp
index 0000000,c8c8a85..a94f6db
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/timer_node.cpp
+++ b/engines/zvision/scripting/controls/timer_node.cpp
@@@ -1,0 -1,73 +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.
+ *
+ */
+
+ #include "common/scummsys.h"
+
-#include "zvision/scripting/controls/timer_node.h"
++#include "zvision/timer_node.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
++#include "zvision/script_manager.h"
+
+ #include "common/stream.h"
+
+
+ namespace ZVision {
-
++
+ TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : Control(engine, key) {
- if (_engine->getGameId() == GID_NEMESIS) {
++ : SideFX(engine, key, SIDEFX_TIMER) {
++ if (_engine->getGameId() == GID_NEMESIS)
+ _timeLeft = timeInSeconds * 1000;
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
++ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ _timeLeft = timeInSeconds * 100;
- }
+
- _engine->getScriptManager()->setStateValue(_key, 1);
++ if (_key != StateKey_NotSet)
++ _engine->getScriptManager()->setStateValue(_key, 1);
+ }
+
+ TimerNode::~TimerNode() {
- if (_timeLeft <= 0)
++ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
- else
- _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
++ int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
++ if (timeLeft > 0)
++ _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
+ }
+
+ bool TimerNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
- if (_timeLeft <= 0) {
- // Let the destructor reset the state value
- return true;
- }
++ if (_timeLeft <= 0)
++ return stop();
+
+ return false;
+ }
+
++bool TimerNode::stop() {
++ if (_key != StateKey_NotSet)
++ _engine->getScriptManager()->setStateValue(_key, 2);
++ return true;
++}
++
+ void TimerNode::serialize(Common::WriteStream *stream) {
++ stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
++ stream->writeUint32LE(8); // size
+ stream->writeUint32LE(_key);
+ stream->writeUint32LE(_timeLeft);
+ }
+
+ void TimerNode::deserialize(Common::SeekableReadStream *stream) {
+ _timeLeft = stream->readUint32LE();
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/controls/timer_node.h
index 0000000,48b5fad..f6584be
mode 000000,100644..100644
--- a/engines/zvision/scripting/controls/timer_node.h
+++ b/engines/zvision/scripting/controls/timer_node.h
@@@ -1,0 -1,55 +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 ZVISION_TIMER_NODE_H
+ #define ZVISION_TIMER_NODE_H
+
-#include "zvision/scripting/control.h"
++#include "zvision/sidefx.h"
+
+ namespace ZVision {
+
+ class ZVision;
+
-class TimerNode : public Control {
++class TimerNode : public SideFX {
+ public:
+ TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
+ ~TimerNode();
+
+ /**
+ * 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);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
- inline bool needsSerialization() { return true; }
++ inline bool needsSerialization() {
++ return true;
++ }
++
++ bool stop();
+
+ private:
+ int32 _timeLeft;
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/puzzle.h
index 0000000,ee9ce52..4d50756
mode 000000,100644..100644
--- a/engines/zvision/scripting/puzzle.h
+++ b/engines/zvision/scripting/puzzle.h
@@@ -1,0 -1,74 +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.
+ *
+ */
+
+ #ifndef ZVISION_PUZZLE_H
+ #define ZVISION_PUZZLE_H
+
-#include "zvision/scripting/actions.h"
++#include "zvision/actions.h"
+
+ #include "common/list.h"
+ #include "common/ptr.h"
+
+
+ namespace ZVision {
+
+ struct Puzzle {
+ Puzzle() : key(0) {}
+
+ ~Puzzle() {
+ for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) {
+ delete *iter;
+ }
+ }
+
+ /** 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 CriteriaEntry {
+ /** 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,
++ DISABLED = 0x02,
++ DO_ME_NOW = 0x04
++ };
++
+ uint32 key;
+ Common::List<Common::List <CriteriaEntry> > criteriaList;
+ // This has to be list of pointers because ResultAction is abstract
+ Common::List<ResultAction *> resultActions;
++ bool addedBySetState;
+ };
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/scripting/scr_file_handling.cpp
index 0000000,753ce4a..9d1d0bf
mode 000000,100644..100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@@ -1,0 -1,302 +1,353 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/script_manager.h"
++#include "zvision/zvision.h"
++#include "zvision/script_manager.h"
+
-#include "zvision/utility/utility.h"
-#include "zvision/scripting/puzzle.h"
-#include "zvision/scripting/actions.h"
-#include "zvision/scripting/controls/push_toggle_control.h"
-#include "zvision/scripting/controls/lever_control.h"
++#include "zvision/utility.h"
++#include "zvision/puzzle.h"
++#include "zvision/actions.h"
++#include "zvision/push_toggle_control.h"
++#include "zvision/lever_control.h"
++#include "zvision/slot_control.h"
+
+ #include "common/textconsole.h"
+ #include "common/file.h"
+ #include "common/tokenizer.h"
+
+
+ namespace ZVision {
+
-void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
++void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) {
+ Common::File file;
- if (!file.open(fileName)) {
++ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("Script file not found: %s", fileName.c_str());
+ return;
+ }
+
- while(!file.eos()) {
++ while (!file.eos()) {
+ Common::String line = file.readLine();
+ if (file.err()) {
+ warning("Error parsing scr file: %s", fileName.c_str());
+ return;
+ }
+
+ trimCommentsAndWhiteSpace(&line);
+ if (line.empty())
+ continue;
+
+ if (line.matchString("puzzle:*", true)) {
+ Puzzle *puzzle = new Puzzle();
- sscanf(line.c_str(),"puzzle:%u",&(puzzle->key));
-
++ sscanf(line.c_str(), "puzzle:%u", &(puzzle->key));
++ if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST)
++ setStateValue(puzzle->key, 0);
+ parsePuzzle(puzzle, file);
- if (isGlobal) {
- _globalPuzzles.push_back(puzzle);
- } else {
- _activePuzzles.push_back(puzzle);
- }
++ scope._puzzles.push_back(puzzle);
++
+ } else if (line.matchString("control:*", true)) {
- parseControl(line, file);
++ Control *ctrl = parseControl(line, file);
++ if (ctrl)
++ scope._controls.push_back(ctrl);
+ }
+ }
++ scope.proc_count = 0;
+ }
+
+ 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);
+ } else if (line.matchString("results {", true)) {
+ parseResults(stream, puzzle->resultActions);
+ } else if (line.matchString("flags {", true)) {
- setStateFlags(puzzle->key, parseFlags(stream));
++ setStateFlag(puzzle->key, parseFlags(stream));
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
++
++ puzzle->addedBySetState = 0;
+ }
+
+ 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);
+
+ // Criteria can be empty
+ if (line.contains('}')) {
+ 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]", &(entry.key));
+
+ // Parse the operator out of the second token
+ token = tokenizer.nextToken();
+ if (token.c_str()[0] == '=')
+ entry.criteriaOperator = Puzzle::EQUAL_TO;
+ else if (token.c_str()[0] == '!')
+ entry.criteriaOperator = Puzzle::NOT_EQUAL_TO;
+ else if (token.c_str()[0] == '>')
+ entry.criteriaOperator = Puzzle::GREATER_THAN;
+ else if (token.c_str()[0] == '<')
+ 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]", &(entry.argument));
+ entry.argumentIsAKey = true;
+ } else {
+ sscanf(token.c_str(), "%u", &(entry.argument));
+ entry.argumentIsAKey = false;
+ }
+
+ criteriaList.back().push_back(entry);
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ return true;
+ }
+
+ 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);
++ line.toLowercase();
+
+ // TODO: Re-order the if-then statements in order of highest occurrence
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.empty()) {
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
-
++ line.toLowercase();
+ continue;
+ }
+
- // Parse for the action type
- if (line.matchString("*:add*", true)) {
- actionList.push_back(new ActionAdd(line));
- } else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(new ActionPlayAnimation(line));
- } else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(new ActionPreloadAnimation(line));
- } 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)) {
- 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)) {
- // 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)) {
- actionList.push_back(new ActionPlayPreloadAnimation(line));
- } 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)) {
- actionList.push_back(new ActionRandom(line));
- } 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)) {
- actionList.push_back(new ActionTimer(line));
- } 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 {
- warning("Unhandled result action type: %s", line.c_str());
++ const char *chrs = line.c_str();
++ uint pos;
++ for (pos = 0; pos < line.size(); pos++)
++ if (chrs[pos] == ':')
++ break;
++
++ if (pos < line.size()) {
++
++ uint startpos = pos + 1;
++
++ for (pos = startpos; pos < line.size(); pos++)
++ if (chrs[pos] == ':' || chrs[pos] == '(')
++ break;
++
++ if (pos < line.size()) {
++ int32 slot = 11;
++ Common::String args = "";
++ Common::String act(chrs + startpos, chrs + pos);
++
++ startpos = pos + 1;
++
++ if (chrs[pos] == ':') {
++ for (pos = startpos; pos < line.size(); pos++)
++ if (chrs[pos] == '(')
++ break;
++ Common::String s_slot(chrs + startpos, chrs + pos);
++ slot = atoi(s_slot.c_str());
++
++ startpos = pos + 1;
++ }
++
++ if (pos < line.size()) {
++ for (pos = startpos; pos < line.size(); pos++)
++ if (chrs[pos] == ')')
++ break;
++
++ args = Common::String(chrs + startpos, chrs + pos);
++ }
++
++
++
++ // Parse for the action type
++ if (act.matchString("add", true)) {
++ actionList.push_back(new ActionAdd(_engine, slot, args));
++ } else if (act.matchString("animplay", true)) {
++ actionList.push_back(new ActionPlayAnimation(_engine, slot, args));
++ } else if (act.matchString("animpreload", true)) {
++ actionList.push_back(new ActionPreloadAnimation(_engine, slot, args));
++ } else if (act.matchString("animunload", true)) {
++ //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
++ } else if (act.matchString("attenuate", true)) {
++ actionList.push_back(new ActionAttenuate(_engine, slot, args));
++ } else if (act.matchString("assign", true)) {
++ actionList.push_back(new ActionAssign(_engine, slot, args));
++ } else if (act.matchString("change_location", true)) {
++ actionList.push_back(new ActionChangeLocation(_engine, slot, args));
++ } else if (act.matchString("crossfade", true)) {
++ actionList.push_back(new ActionCrossfade(_engine, slot, args));
++ } else if (act.matchString("debug", true)) {
++ // TODO: Implement ActionDebug
++ } else if (act.matchString("delay_render", true)) {
++ // TODO: Implement ActionDelayRender
++ } else if (act.matchString("disable_control", true)) {
++ actionList.push_back(new ActionDisableControl(_engine, slot, args));
++ } else if (act.matchString("disable_venus", true)) {
++ // TODO: Implement ActionDisableVenus
++ } else if (act.matchString("display_message", true)) {
++ // TODO: Implement ActionDisplayMessage
++ } else if (act.matchString("dissolve", true)) {
++ // TODO: Implement ActionDissolve
++ } else if (act.matchString("distort", true)) {
++ // TODO: Implement ActionDistort
++ } else if (act.matchString("enable_control", true)) {
++ actionList.push_back(new ActionEnableControl(_engine, slot, args));
++ } else if (act.matchString("flush_mouse_events", true)) {
++ // TODO: Implement ActionFlushMouseEvents
++ } else if (act.matchString("inventory", true)) {
++ actionList.push_back(new ActionInventory(_engine, slot, args));
++ } else if (act.matchString("kill", true)) {
++ actionList.push_back(new ActionKill(_engine, slot, args));
++ } else if (act.matchString("menu_bar_enable", true)) {
++ // TODO: Implement ActionMenuBarEnable
++ } else if (act.matchString("music", true)) {
++ actionList.push_back(new ActionMusic(_engine, slot, args, false));
++ } else if (act.matchString("pan_track", true)) {
++ actionList.push_back(new ActionPanTrack(_engine, slot, args));
++ } else if (act.matchString("playpreload", true)) {
++ actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args));
++ } else if (act.matchString("preferences", true)) {
++ // TODO: Implement ActionPreferences
++ } else if (act.matchString("quit", true)) {
++ actionList.push_back(new ActionQuit(_engine, slot));
++ } else if (act.matchString("random", true)) {
++ actionList.push_back(new ActionRandom(_engine, slot, args));
++ } else if (act.matchString("region", true)) {
++ // TODO: Implement ActionRegion
++ } else if (act.matchString("restore_game", true)) {
++ // TODO: Implement ActionRestoreGame
++ } else if (act.matchString("rotate_to", true)) {
++ // TODO: Implement ActionRotateTo
++ } else if (act.matchString("save_game", true)) {
++ // TODO: Implement ActionSaveGame
++ } else if (act.matchString("set_partial_screen", true)) {
++ actionList.push_back(new ActionSetPartialScreen(_engine, slot, args));
++ } else if (act.matchString("set_screen", true)) {
++ actionList.push_back(new ActionSetScreen(_engine, slot, args));
++ } else if (act.matchString("set_venus", true)) {
++ // TODO: Implement ActionSetVenus
++ } else if (act.matchString("stop", true)) {
++ actionList.push_back(new ActionStop(_engine, slot, args));
++ } else if (act.matchString("streamvideo", true)) {
++ actionList.push_back(new ActionStreamVideo(_engine, slot, args));
++ } else if (act.matchString("syncsound", true)) {
++ actionList.push_back(new ActionSyncSound(_engine, slot, args));
++ } else if (act.matchString("timer", true)) {
++ actionList.push_back(new ActionTimer(_engine, slot, args));
++ } else if (act.matchString("ttytext", true)) {
++ actionList.push_back(new ActionTtyText(_engine, slot, args));
++ } else if (act.matchString("universe_music", true)) {
++ actionList.push_back(new ActionMusic(_engine, slot, args, true));
++ } else if (act.matchString("copy_file", true)) {
++ // Not used. Purposely left empty
++ } else {
++ warning("Unhandled result action type: %s", line.c_str());
++ }
++ }
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
++ line.toLowercase();
+ }
+
+ return;
+ }
+
+ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
+ uint flags = 0;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !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();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ return flags;
+ }
+
-void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
++Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
+ uint32 key;
+ char controlTypeBuffer[20];
+
+ sscanf(line.c_str(), "control:%u %s {", &key, controlTypeBuffer);
+
+ Common::String controlType(controlTypeBuffer);
+
+ if (controlType.equalsIgnoreCase("push_toggle")) {
- _activeControls.push_back(new PushToggleControl(_engine, key, stream));
- return;
++ return new PushToggleControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("flat")) {
+ Control::parseFlatControl(_engine);
- return;
++ return NULL;
+ } else if (controlType.equalsIgnoreCase("pana")) {
+ Control::parsePanoramaControl(_engine, stream);
- return;
++ return NULL;
+ } else if (controlType.equalsIgnoreCase("tilt")) {
+ Control::parseTiltControl(_engine, stream);
- return;
++ return NULL;
+ } else if (controlType.equalsIgnoreCase("lever")) {
- _activeControls.push_back(new LeverControl(_engine, key, stream));
- return;
++ return new LeverControl(_engine, key, stream);
++ } else if (controlType.equalsIgnoreCase("slot")) {
++ return new SlotControl(_engine, key, stream);
+ }
++ return NULL;
+ }
+
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/script_manager.cpp
index 0000000,41b835e..1a56739
mode 000000,100644..100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@@ -1,0 -1,444 +1,720 @@@
+ /* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
++*
++* ScummVM is the legal property of its developers, whose names
++* are too numerous to list here. Please refer to the COPYRIGHT
++* file distributed with this source distribution.
++*
++* This program is free software; you can redistribute it and/or
++* modify it under the terms of the GNU General Public License
++* as published by the Free Software Foundation; either version 2
++* of the License, or (at your option) any later version.
++
++* This program is distributed in the hope that it will be useful,
++* but WITHOUT ANY WARRANTY; without even the implied warranty of
++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++* GNU General Public License for more details.
++
++* You should have received a copy of the GNU General Public License
++* 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/scripting/script_manager.h"
++#include "zvision/script_manager.h"
+
+ #include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/core/save_manager.h"
-#include "zvision/scripting/actions.h"
-#include "zvision/utility/utility.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 "zvision/timer_node.h"
+
+ #include "common/algorithm.h"
+ #include "common/hashmap.h"
+ #include "common/debug.h"
+ #include "common/stream.h"
+
+
+ namespace ZVision {
+
+ ScriptManager::ScriptManager(ZVision *engine)
+ : _engine(engine),
- _currentlyFocusedControl(0) {
++ _currentlyFocusedControl(0),
++ _activeControls(NULL) {
+ }
+
+ ScriptManager::~ScriptManager() {
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
- }
- for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- delete (*iter);
- }
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
- }
++ cleanScriptScope(universe);
++ cleanScriptScope(world);
++ cleanScriptScope(room);
++ cleanScriptScope(nodeview);
+ }
+
+ void ScriptManager::initialize() {
- parseScrFile("universe.scr", true);
++ cleanScriptScope(universe);
++ cleanScriptScope(world);
++ cleanScriptScope(room);
++ cleanScriptScope(nodeview);
++
++ _currentLocation.node = 0;
++ _currentLocation.world = 0;
++ _currentLocation.room = 0;
++ _currentLocation.view = 0;
++
++ parseScrFile("universe.scr", universe);
+ changeLocation('g', 'a', 'r', 'y', 0);
+ }
+
+ void ScriptManager::update(uint deltaTimeMillis) {
++ if (_currentLocation.node != _nextLocation.node ||
++ _currentLocation.room != _nextLocation.room ||
++ _currentLocation.view != _nextLocation.view ||
++ _currentLocation.world != _nextLocation.world)
++ do_changeLocation();
++
+ updateNodes(deltaTimeMillis);
- checkPuzzleCriteria();
++ execScope(nodeview);
++ execScope(room);
++ execScope(world);
++ execScope(universe);
++ updateControls(deltaTimeMillis);
+ }
+
-void ScriptManager::createReferenceTable() {
- // Iterate through each local Puzzle
- 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
- 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);
- }
- }
- }
++void ScriptManager::execScope(script_scope &scope) {
++ // Swap queues
++ PuzzleList *tmp = scope.exec_queue;
++ scope.exec_queue = scope.scope_queue;
++ scope.scope_queue = tmp;
++ scope.scope_queue->clear();
++
++ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
++ (*PuzzleIter)->addedBySetState = 0;
++
++ if (scope.proc_count < 2 || getStateValue(76)) {
++ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
++ checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
++ } else {
++ for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter)
++ checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ }
+
- // Iterate through each global Puzzle
- for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
- Puzzle *puzzlePtr = (*globalPuzzleIter);
++ if (scope.proc_count < 2) {
++ scope.proc_count++;
++ }
++}
+
- // 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 (entryIter->argumentIsAKey) {
- _referenceTable[entryIter->argument].push_back(puzzlePtr);
- }
- }
- }
++void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
++ if (_referenceTable.contains(key)) {
++ Common::Array<puzzle_ref> *arr = &_referenceTable[key];
++ for (uint32 i = 0; i < arr->size(); i++)
++ if ((*arr)[i].puz == ref.puz)
++ return;
+ }
+
- // Remove duplicate entries
- for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
- removeDuplicateEntries(referenceTableIter->_value);
++ _referenceTable[key].push_back(ref);
++}
++
++void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) {
++ // Iterate through each local Puzzle
++ for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) {
++ Puzzle *puzzlePtr = (*PuzzleIter);
++
++ puzzle_ref ref;
++ ref.scope = &scope;
++ ref.puz = puzzlePtr;
++
++ referenceTableAddPuzzle(puzzlePtr->key, ref);
++
++ // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
++ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter)
++ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter)
++ referenceTableAddPuzzle(entryIter->key, ref);
+ }
+ }
+
+ void ScriptManager::updateNodes(uint deltaTimeMillis) {
+ // If process() returns true, it means the node can be deleted
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
+ if ((*iter)->process(deltaTimeMillis)) {
- delete (*iter);
++ delete(*iter);
+ // Remove the node
- iter = _activeControls.erase(iter);
++ iter = _activeSideFx.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+ }
+
-void ScriptManager::checkPuzzleCriteria() {
- while (!_puzzlesToCheck.empty()) {
- Puzzle *puzzle = _puzzlesToCheck.pop();
++void ScriptManager::updateControls(uint deltaTimeMillis) {
++ if (!_activeControls)
++ return;
++ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
++ (*iter)->process(deltaTimeMillis);
++}
+
- // Check if the puzzle is already finished
- // Also check that the puzzle isn't disabled
- if (getStateValue(puzzle->key) == 1 && (getStateFlags(puzzle->key) & DISABLED) == 0) {
- continue;
- }
++void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
++ // Check if the puzzle is already finished
++ // Also check that the puzzle isn't disabled
++ if (getStateValue(puzzle->key) == 1 &&
++ (getStateFlag(puzzle->key) & Puzzle::DISABLED) == 0) {
++ return;
++ }
+
- // Check each Criteria
-
- bool criteriaMet = false;
- 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;
- }
++ // Check each Criteria
++ if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0)
++ return;
++
++ bool criteriaMet = false;
++ 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
++ int 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 any of the Criteria are *fully* met, then execute the results
- if (criteriaMet) {
++ // If one check returns false, don't keep checking
++ if (!criteriaMet) {
+ break;
+ }
+ }
+
- // criteriaList can be empty. Aka, the puzzle should be executed immediately
- if (puzzle->criteriaList.empty() || criteriaMet) {
- debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
++ // If any of the Criteria are *fully* met, then execute the results
++ if (criteriaMet) {
++ break;
++ }
++ }
+
- // Set the puzzle as completed
- setStateValue(puzzle->key, 1);
++ // criteriaList can be empty. Aka, the puzzle should be executed immediately
++ if (puzzle->criteriaList.empty() || criteriaMet) {
++ debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
+
- 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
++ setStateValue(puzzle->key, 1);
+
++ bool shouldContinue = true;
++ for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
++ shouldContinue = shouldContinue && (*resultIter)->execute();
+ if (!shouldContinue) {
+ break;
+ }
+ }
++
++ if (!shouldContinue) {
++ return;
++ }
+ }
+ }
+
+ void ScriptManager::cleanStateTable() {
+ for (StateMap::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) {
++void ScriptManager::cleanScriptScope(script_scope &scope) {
++ scope._priv_queue_one.clear();
++ scope._priv_queue_two.clear();
++ scope.scope_queue = &scope._priv_queue_one;
++ scope.exec_queue = &scope._priv_queue_two;
++ for (PuzzleList::iterator iter = scope._puzzles.begin(); iter != scope._puzzles.end(); ++iter)
++ delete(*iter);
++
++ scope._puzzles.clear();
++
++ for (ControlList::iterator iter = scope._controls.begin(); iter != scope._controls.end(); ++iter)
++ delete(*iter);
++
++ scope._controls.clear();
++
++ scope.proc_count = 0;
++}
++
++int ScriptManager::getStateValue(uint32 key) {
+ if (_globalState.contains(key))
+ return _globalState[key];
+ else
+ return 0;
+ }
+
-void ScriptManager::setStateValue(uint32 key, uint value) {
- _globalState[key] = value;
-
++void ScriptManager::queuePuzzles(uint32 key) {
+ if (_referenceTable.contains(key)) {
- for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) {
- _puzzlesToCheck.push((*iter));
- }
++ Common::Array<puzzle_ref> *arr = &_referenceTable[key];
++ for (int32 i = arr->size() - 1; i >= 0; i--)
++ if (!(*arr)[i].puz->addedBySetState) {
++ (*arr)[i].scope->scope_queue->push_back((*arr)[i].puz);
++ (*arr)[i].puz->addedBySetState = true;
++ }
+ }
+ }
+
-uint ScriptManager::getStateFlags(uint32 key) {
++void ScriptManager::setStateValue(uint32 key, int value) {
++ if (value == 0)
++ _globalState.erase(key);
++ else
++ _globalState[key] = value;
++
++ queuePuzzles(key);
++}
++
++void ScriptManager::setStateValueSilent(uint32 key, int value) {
++ if (value == 0)
++ _globalState.erase(key);
++ else
++ _globalState[key] = value;
++}
++
++uint ScriptManager::getStateFlag(uint32 key) {
+ if (_globalStateFlags.contains(key))
+ return _globalStateFlags[key];
+ else
+ return 0;
+ }
+
-void ScriptManager::setStateFlags(uint32 key, uint flags) {
- _globalStateFlags[key] = flags;
++void ScriptManager::setStateFlag(uint32 key, uint value) {
++ queuePuzzles(key);
+
- if (_referenceTable.contains(key)) {
- for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) {
- _puzzlesToCheck.push((*iter));
- }
- }
++ _globalStateFlags[key] |= value;
+ }
+
-void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
- _globalState[key] += valueToAdd;
++void ScriptManager::setStateFlagSilent(uint32 key, uint value) {
++ if (value == 0)
++ _globalStateFlags.erase(key);
++ else
++ _globalStateFlags[key] = value;
+ }
+
-void ScriptManager::addControl(Control *control) {
- _activeControls.push_back(control);
++void ScriptManager::unsetStateFlag(uint32 key, uint value) {
++ queuePuzzles(key);
++
++ if (_globalStateFlags.contains(key)) {
++ _globalStateFlags[key] &= ~value;
++
++ if (_globalStateFlags[key] == 0)
++ _globalStateFlags.erase(key);
++ }
+ }
+
+ Control *ScriptManager::getControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- return (*iter);
- }
- }
+
+ return nullptr;
+ }
+
+ void ScriptManager::focusControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
++ if (!_activeControls)
++ return;
++ for (ControlList::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::addSideFX(SideFX *fx) {
++ _activeSideFx.push_back(fx);
++}
++
++SideFX *ScriptManager::getSideFX(uint32 key) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
++ if ((*iter)->getKey() == key) {
++ return (*iter);
++ }
++ }
++
++ return nullptr;
++}
++
++void ScriptManager::deleteSideFx(uint32 key) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
++ if ((*iter)->getKey() == key) {
++ delete(*iter);
++ _activeSideFx.erase(iter);
++ break;
++ }
++ }
++}
++
++void ScriptManager::stopSideFx(uint32 key) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
++ if ((*iter)->getKey() == key) {
++ bool ret = (*iter)->stop();
++ if (ret) {
++ delete(*iter);
++ _activeSideFx.erase(iter);
++ }
++ break;
++ }
++ }
++}
++
++void ScriptManager::killSideFx(uint32 key) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
++ if ((*iter)->getKey() == key) {
++ (*iter)->kill();
++ delete(*iter);
++ _activeSideFx.erase(iter);
++ break;
++ }
++ }
++}
++
++void ScriptManager::killSideFxType(SideFX::SideFXType type) {
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
++ if ((*iter)->getType() & type) {
++ (*iter)->kill();
++ delete(*iter);
++ iter = _activeSideFx.erase(iter);
++ } else {
++ ++iter;
++ }
++ }
++}
++
+ void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
++ if (!_activeControls)
++ return;
++ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
++ if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos))
++ return;
+ }
+ }
+
+ void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
++ if (!_activeControls)
++ return;
++ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
++ if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos))
++ return;
+ }
+ }
+
+ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- bool cursorWasChanged = false;
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
++ if (!_activeControls)
++ return false;
++
++ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
++ if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos))
++ return true;
+ }
+
- return cursorWasChanged;
++ return false;
+ }
+
+ void ScriptManager::onKeyDown(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
++ if (!_activeControls)
++ return;
++ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
+ (*iter)->onKeyDown(keyState);
+ }
+ }
+
+ void ScriptManager::onKeyUp(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
++ if (!_activeControls)
++ return;
++ for (ControlList::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(1, "Changing location to: %c %c %c %c %u", world, room, node, view, offset);
++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;
++ // If next location 0000 - it's indicate to go to previous location.
++ if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') {
++ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
++ _nextLocation.world = getStateValue(StateKey_LastWorld);
++ _nextLocation.room = getStateValue(StateKey_LastRoom);
++ _nextLocation.node = getStateValue(StateKey_LastNode);
++ _nextLocation.view = getStateValue(StateKey_LastView);
++ _nextLocation.offset = getStateValue(StateKey_LastViewPos);
++ } else {
++ _nextLocation.world = getStateValue(StateKey_Menu_LastWorld);
++ _nextLocation.room = getStateValue(StateKey_Menu_LastRoom);
++ _nextLocation.node = getStateValue(StateKey_Menu_LastNode);
++ _nextLocation.view = getStateValue(StateKey_Menu_LastView);
++ _nextLocation.offset = getStateValue(StateKey_Menu_LastViewPos);
++ }
++ }
++}
++
++void ScriptManager::do_changeLocation() {
++ assert(_nextLocation.world != 0);
++ debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
++
++ _engine->setRenderDelay(2);
++
++ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
++ if (_nextLocation.world != 'g' || _nextLocation.room != 'j') {
++ setStateValue(StateKey_LastWorld, getStateValue(StateKey_World));
++ setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room));
++ setStateValue(StateKey_LastNode, getStateValue(StateKey_Node));
++ setStateValue(StateKey_LastView, getStateValue(StateKey_View));
++ setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos));
++ } else {
++ setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World));
++ setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room));
++ setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node));
++ setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View));
++ setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos));
++ }
++ }
+
+ // Auto save
- _engine->getSaveManager()->autoSave();
++ //_engine->getSaveManager()->autoSave();
++
++ setStateValue(StateKey_World, _nextLocation.world);
++ setStateValue(StateKey_Room, _nextLocation.room);
++ setStateValue(StateKey_Node, _nextLocation.node);
++ setStateValue(StateKey_View, _nextLocation.view);
++ setStateValue(StateKey_ViewPos, _nextLocation.offset);
+
- // Clear all the containers
+ _referenceTable.clear();
- _puzzlesToCheck.clear();
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
- }
- _activePuzzles.clear();
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
- }
- _activeControls.clear();
++ addPuzzlesToReferenceTable(universe);
+
- // Revert to the idle cursor
- _engine->getCursorManager()->revertToIdle();
++ if (_nextLocation.world != _currentLocation.world) {
++ cleanScriptScope(nodeview);
++ cleanScriptScope(room);
++ cleanScriptScope(world);
+
- // Reset the background velocity
- _engine->getRenderManager()->setBackgroundVelocity(0);
++ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
++ parseScrFile(fileName, nodeview);
++ addPuzzlesToReferenceTable(nodeview);
+
- // Remove any alphaEntries
- _engine->getRenderManager()->clearAlphaEntries();
++ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
++ parseScrFile(fileName, room);
++ addPuzzlesToReferenceTable(room);
+
- // Clean the global state table
- cleanStateTable();
++ fileName = Common::String::format("%c.scr", _nextLocation.world);
++ parseScrFile(fileName, world);
++ addPuzzlesToReferenceTable(world);
++ } else if (_nextLocation.room != _currentLocation.room) {
++ cleanScriptScope(nodeview);
++ cleanScriptScope(room);
+
- // Parse into puzzles and controls
- Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
- parseScrFile(fileName);
++ addPuzzlesToReferenceTable(world);
+
- // Change the background position
- _engine->getRenderManager()->setBackgroundPosition(offset);
++ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
++ parseScrFile(fileName, nodeview);
++ addPuzzlesToReferenceTable(nodeview);
+
- // Enable all the controls
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->enable();
- }
++ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
++ parseScrFile(fileName, room);
++ addPuzzlesToReferenceTable(room);
+
- // Add all the local puzzles to the queue to be checked
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- // Reset any Puzzles that have the flag ONCE_PER_INST
- if ((getStateFlags((*iter)->key) & ONCE_PER_INST) == ONCE_PER_INST) {
- setStateValue((*iter)->key, 0);
- }
++ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
++ cleanScriptScope(nodeview);
++
++ addPuzzlesToReferenceTable(room);
++ addPuzzlesToReferenceTable(world);
+
- _puzzlesToCheck.push((*iter));
++ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
++ parseScrFile(fileName, nodeview);
++ addPuzzlesToReferenceTable(nodeview);
+ }
+
- // Add all the global puzzles to the queue to be checked
- for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- // Reset any Puzzles that have the flag ONCE_PER_INST
- if ((getStateFlags((*iter)->key) & ONCE_PER_INST) == ONCE_PER_INST) {
- setStateValue((*iter)->key, 0);
- }
++ _activeControls = &nodeview._controls;
++
++ // Revert to the idle cursor
++ _engine->getCursorManager()->changeCursor(CursorIndex_Idle);
+
- _puzzlesToCheck.push((*iter));
++ // Change the background position
++ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
++
++ if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) {
++ _currentLocation = _nextLocation;
++ execScope(world);
++ execScope(room);
++ execScope(nodeview);
++ } else if (_nextLocation.world != _currentLocation.world) {
++ _currentLocation = _nextLocation;
++ execScope(room);
++ execScope(nodeview);
++ } else if (_nextLocation.room != _currentLocation.room) {
++ _currentLocation = _nextLocation;
++ execScope(room);
++ execScope(nodeview);
++ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
++ _currentLocation = _nextLocation;
++ execScope(nodeview);
+ }
++}
+
- // Create the puzzle reference table
- createReferenceTable();
++void ScriptManager::serialize(Common::WriteStream *stream) {
++ stream->writeUint32BE(MKTAG('Z', 'N', 'S', 'G'));
++ stream->writeUint32LE(4);
++ stream->writeUint32LE(0);
++ stream->writeUint32BE(MKTAG('L', 'O', 'C', ' '));
++ stream->writeUint32LE(8);
++ stream->writeByte(getStateValue(StateKey_World));
++ stream->writeByte(getStateValue(StateKey_Room));
++ stream->writeByte(getStateValue(StateKey_Node));
++ stream->writeByte(getStateValue(StateKey_View));
++ stream->writeUint32LE(getStateValue(StateKey_ViewPos));
++
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter)
++ (*iter)->serialize(stream);
+
- // Update _currentLocation
- _currentLocation.world = world;
- _currentLocation.room = room;
- _currentLocation.node = node;
- _currentLocation.view = view;
- _currentLocation.offset = offset;
-}
++ stream->writeUint32BE(MKTAG('F', 'L', 'A', 'G'));
+
-void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
- // Write the number of state value entries
- stream->writeUint32LE(_globalState.size());
++ int32 slots = 20000;
++ if (_engine->getGameId() == GID_NEMESIS)
++ slots = 30000;
+
- for (StateMap::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) {
- // Write out the key/value pair
- stream->writeUint32LE(iter->_key);
- stream->writeUint32LE(iter->_value);
- }
++ stream->writeUint32LE(slots * 2);
++
++ for (int32 i = 0; i < slots; i++)
++ stream->writeUint16LE(getStateFlag(i));
++
++ stream->writeUint32BE(MKTAG('P', 'U', 'Z', 'Z'));
++
++ stream->writeUint32LE(slots * 2);
++
++ for (int32 i = 0; i < slots; i++)
++ stream->writeSint16LE(getStateValue(i));
+ }
+
-void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
++void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
+ // Clear out the current table values
+ _globalState.clear();
++ _globalStateFlags.clear();
+
- // Read the number of key/value pairs
- uint32 numberOfPairs = stream->readUint32LE();
++ cleanScriptScope(nodeview);
++ cleanScriptScope(room);
++ cleanScriptScope(world);
+
- 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
- _globalState[key] = value;
- }
-}
++ _currentLocation.node = 0;
++ _currentLocation.world = 0;
++ _currentLocation.room = 0;
++ _currentLocation.view = 0;
+
-void ScriptManager::serializeControls(Common::WriteStream *stream) {
- // Count how many controls need to save their data
- // Because WriteStream isn't seekable
- uint32 numberOfControlsNeedingSerialization = 0;
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->needsSerialization()) {
- numberOfControlsNeedingSerialization++;
- }
- }
- stream->writeUint32LE(numberOfControlsNeedingSerialization);
++ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++)
++ delete(*iter);
+
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->serialize(stream);
++ _activeSideFx.clear();
++
++ _referenceTable.clear();
++
++ if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) {
++ changeLocation('g', 'a', 'r', 'y', 0);
++ return;
+ }
-}
+
-void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {
- uint32 numberOfControls = stream->readUint32LE();
++ stream->seek(4, SEEK_CUR);
+
- for (uint32 i = 0; i < numberOfControls; ++i) {
- uint32 key = stream->readUint32LE();
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- (*iter)->deserialize(stream);
- break;
- }
++ if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) {
++ changeLocation('g', 'a', 'r', 'y', 0);
++ return;
++ }
++
++ Location next_loc;
++
++ next_loc.world = stream->readByte();
++ next_loc.room = stream->readByte();
++ next_loc.node = stream->readByte();
++ next_loc.view = stream->readByte();
++ next_loc.offset = stream->readUint32LE() & 0x0000FFFF;
++
++ // What the fck, eos is not 'return pos >= size'
++ // while (!stream->eos()) {*/
++ while (stream->pos() < stream->size()) {
++ uint32 tag = stream->readUint32BE();
++ uint32 tag_size = stream->readUint32LE();
++ switch (tag) {
++ case MKTAG('T', 'I', 'M', 'R'): {
++ uint32 key = stream->readUint32LE();
++ uint32 time = stream->readUint32LE();
++ if (_engine->getGameId() == GID_GRANDINQUISITOR)
++ time /= 100;
++ else if (_engine->getGameId() == GID_NEMESIS)
++ time /= 1000;
++ addSideFX(new TimerNode(_engine, key, time));
++ }
++ break;
++ case MKTAG('F', 'L', 'A', 'G'):
++ for (uint32 i = 0; i < tag_size / 2; i++)
++ setStateFlagSilent(i, stream->readUint16LE());
++ break;
++ case MKTAG('P', 'U', 'Z', 'Z'):
++ for (uint32 i = 0; i < tag_size / 2; i++)
++ setStateValueSilent(i, stream->readUint16LE());
++ break;
++ default:
++ stream->seek(tag_size, SEEK_CUR);
+ }
+ }
++
++ _nextLocation = next_loc;
++
++ do_changeLocation();
++ // Place for read prefs
++ _engine->setRenderDelay(10);
++ setStateValue(StateKey_RestoreFlag, 1);
+ }
+
+ Location ScriptManager::getCurrentLocation() const {
+ Location location = _currentLocation;
+ location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset();
+
+ return location;
+ }
+
++ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val):
++ _sc_man(sc_man) {
++ value = 0;
++ slot = false;
++ const char *is_slot = strstr(slot_val, "[");
++ if (is_slot) {
++ slot = true;
++ value = atoi(is_slot + 1);
++ } else {
++ slot = false;
++ value = atoi(slot_val);
++ }
++}
++int16 ValueSlot::getValue() {
++ if (slot) {
++ if (value >= 0)
++ return _sc_man->getStateValue(value);
++ else
++ return 0;
++ } else
++ return value;
++}
++
+ } // End of namespace ZVision
diff --cc engines/zvision/scripting/script_manager.h
index 0000000,4d1b1f3..6adade5
mode 000000,100644..100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@@ -1,0 -1,225 +1,333 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * 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 "zvision/scripting/puzzle.h"
-#include "zvision/scripting/control.h"
++#include "zvision/puzzle.h"
++#include "zvision/control.h"
++#include "zvision/sidefx.h"
+
+ #include "common/hashmap.h"
+ #include "common/queue.h"
+
+
+ namespace Common {
+ class String;
+ class SeekableReadStream;
+ }
+
+ namespace ZVision {
+
+ class ZVision;
+
++enum StateKey {
++ StateKey_World = 3,
++ StateKey_Room = 4,
++ StateKey_Node = 5,
++ StateKey_View = 6,
++ StateKey_ViewPos = 7,
++ StateKey_KeyPress = 8,
++ StateKey_InventoryItem = 9,
++ StateKey_LMouse = 10,
++ StateKey_NotSet = 11, // This key doesn't set
++ StateKey_Rounds = 12,
++ StateKey_Venus = 13,
++ StateKey_RMouse = 18,
++ StateKey_MenuState = 19,
++ StateKey_RestoreFlag = 20,
++ StateKey_Quitting = 39,
++ StateKey_LastWorld = 40,
++ StateKey_LastRoom = 41,
++ StateKey_LastNode = 42,
++ StateKey_LastView = 43,
++ StateKey_LastViewPos = 44,
++ StateKey_Menu_LastWorld = 45,
++ StateKey_Menu_LastRoom = 46,
++ StateKey_Menu_LastNode = 47,
++ StateKey_Menu_LastView = 48,
++ StateKey_Menu_LastViewPos = 49,
++ StateKey_KbdRotateSpeed = 50,
++ StateKey_Subtitles = 51,
++ StateKey_StreamSkipKey = 52,
++ StateKey_RotateSpeed = 53,
++ StateKey_Volume = 56,
++ StateKey_Qsound = 57,
++ StateKey_VenusEnable = 58,
++ StateKey_HighQuality = 59,
++ StateKey_VideoLineSkip = 65,
++ StateKey_Platform = 66,
++ StateKey_InstallLevel = 67,
++ StateKey_CountryCode = 68,
++ StateKey_CPU = 69,
++ StateKey_MovieCursor = 70,
++ StateKey_NoTurnAnim = 71,
++ StateKey_WIN958 = 72,
++ StateKey_ShowErrorDlg = 73,
++ StateKey_DebugCheats = 74,
++ StateKey_JapanFonts = 75,
++ StateKey_Brightness = 77,
++ StateKey_EF9_B = 91,
++ StateKey_EF9_G = 92,
++ StateKey_EF9_R = 93,
++ StateKey_EF9_Speed = 94,
++ StateKey_Inv_Cnt_Slot = 100,
++ StateKey_Inv_1_Slot = 101,
++ StateKey_Inv_49_Slot = 149,
++ StateKey_Inv_TotalSlots = 150
++};
++
+ struct Location {
+ Location() : world('g'), room('a'), node('r'), view('y'), offset(0) {}
+
+ char world;
+ char room;
+ char node;
+ char view;
+ 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;
-typedef Common::HashMap<uint32, uint32> StateMap;
-typedef Common::HashMap<uint32, uint> StateFlagMap;
++typedef Common::HashMap<uint32, int32> StateMap;
++typedef Common::List<SideFX *> SideFXList;
+
+ class ScriptManager {
+ public:
+ ScriptManager(ZVision *engine);
+ ~ScriptManager();
+
-public:
- enum StateFlags {
- ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
- DISABLED = 0x04
- };
-
+ private:
+ ZVision *_engine;
++
++ struct script_scope {
++ uint32 proc_count;
++
++ PuzzleList *scope_queue; // For adding puzzles to queue
++ PuzzleList *exec_queue; // Switch to it when execute
++ PuzzleList _priv_queue_one;
++ PuzzleList _priv_queue_two;
++
++ PuzzleList _puzzles;
++ ControlList _controls;
++ };
++
++ struct puzzle_ref {
++ Puzzle *puz;
++ script_scope *scope;
++ };
++
++ typedef Common::HashMap<uint32, Common::Array<puzzle_ref> > PuzzleMap;
++
+ /**
+ * 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.
+ */
+ StateMap _globalState;
- /**
- * Holds the flags for the global states. This is used to enable/disable puzzles and/or
- * controls as well as which puzzles should are allowed to be re-executed
- */
- StateFlagMap _globalStateFlags;
++ /** Holds execute flags */
++ StateMap _globalStateFlags;
+ /** References _globalState keys to Puzzles */
+ PuzzleMap _referenceTable;
- /** Holds the Puzzles that should be checked this frame */
- PuzzleQueue _puzzlesToCheck;
- /** Holds the currently active puzzles */
- PuzzleList _activePuzzles;
- /** Holds the global puzzles */
- PuzzleList _globalPuzzles;
+ /** Holds the currently active controls */
- ControlList _activeControls;
++ ControlList *_activeControls;
++
++ script_scope universe;
++ script_scope world;
++ script_scope room;
++ script_scope nodeview;
++
++ /** Holds the currently active timers, musics, other */
++ SideFXList _activeSideFx;
+
+ Location _currentLocation;
++ Location _nextLocation;
+
+ uint32 _currentlyFocusedControl;
+
+ public:
+ void initialize();
+ void update(uint deltaTimeMillis);
++ void queuePuzzles(uint32 key);
+
- uint getStateValue(uint32 key);
- void setStateValue(uint32 key, uint value);
- void addToStateValue(uint32 key, uint valueToAdd);
++ int getStateValue(uint32 key);
++ void setStateValue(uint32 key, int value);
+
- uint getStateFlags(uint32 key);
- void setStateFlags(uint32 key, uint flags);
++ uint getStateFlag(uint32 key);
++ void setStateFlag(uint32 key, uint value);
++ void unsetStateFlag(uint32 key, uint value);
+
+ void addControl(Control *control);
+ Control *getControl(uint32 key);
+
++ void enableControl(uint32 key);
++ void disableControl(uint32 key);
++
+ void focusControl(uint32 key);
+
++ void addSideFX(SideFX *fx);
++ SideFX *getSideFX(uint32 key);
++ void deleteSideFx(uint32 key);
++ void stopSideFx(uint32 key);
++ void killSideFx(uint32 key);
++ void killSideFxType(SideFX::SideFXType type);
++
+ /**
+ * 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);
+ /**
+ * 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);
+
++ /** Mark next location */
+ void changeLocation(char world, char room, char node, char view, uint32 offset);
+
- void serializeStateTable(Common::WriteStream *stream);
- void deserializeStateTable(Common::SeekableReadStream *stream);
- void serializeControls(Common::WriteStream *stream);
- void deserializeControls(Common::SeekableReadStream *stream);
++ void serialize(Common::WriteStream *stream);
++ void deserialize(Common::SeekableReadStream *stream);
+
+ Location getCurrentLocation() const;
+
+ private:
- void createReferenceTable();
++ void referenceTableAddPuzzle(uint32 key, puzzle_ref ref);
++ void addPuzzlesToReferenceTable(script_scope &scope);
+ void updateNodes(uint deltaTimeMillis);
- void checkPuzzleCriteria();
++ void updateControls(uint deltaTimeMillis);
++ void checkPuzzleCriteria(Puzzle *puzzle, uint counter);
+ void cleanStateTable();
++ void cleanScriptScope(script_scope &scope);
++ void execScope(script_scope &scope);
++
++ /** Perform change location */
++ void do_changeLocation();
++
++ int8 invertory_getCount();
++ void invertory_setCount(int8 cnt);
++ int16 invertory_getItem(int8 id);
++ void invertory_setItem(int8 id, int16 item);
++
++ void setStateFlagSilent(uint32 key, uint value);
++ void setStateValueSilent(uint32 key, int value);
+
-// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
+ public:
++ void invertory_add(int16 item);
++ void invertory_drop(int16 item);
++ void invertory_cycle();
++
++ // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
+ /**
+ * Parses a script file into triggers and events
+ *
+ * @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, bool isGlobal = false);
++ void parseScrFile(const Common::String &fileName, script_scope &scope);
+
+ private:
+ /**
+ * 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 criteria Pointer to the Criteria object to fill
+ * @param stream Scr file stream
+ * @return Whether any criteria were read
+ */
+ bool parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const;
+
+ /**
+ * Parses the stream into a ResultAction objects
+ * Helper method for parsePuzzle.
+ *
+ * @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;
+
+ /**
+ * 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
+ */
+ uint parseFlags(Common::SeekableReadStream &stream) const;
+
+ /**
+ * Helper method for parseScrFile. Parses the stream into a Control object
+ *
+ * @param line The line initially read
+ * @param stream Scr file stream
+ */
- void parseControl(Common::String &line, Common::SeekableReadStream &stream);
++ Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
++};
++
++class ValueSlot {
++public:
++ ValueSlot(ScriptManager *sc_man, const char *slot_val);
++ int16 getValue();
++private:
++ int16 value;
++ bool slot;
++ ScriptManager *_sc_man;
+ };
+
+
+ } // End of namespace ZVision
+
+ #endif
diff --cc engines/zvision/sound/zork_raw.cpp
index 0000000,edee1fd..a4d091f
mode 000000,100644..100644
--- a/engines/zvision/sound/zork_raw.cpp
+++ b/engines/zvision/sound/zork_raw.cpp
@@@ -1,0 -1,217 +1,289 @@@
+ /* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
- *
++
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
- *
++
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ #include "common/scummsys.h"
+
-#include "zvision/sound/zork_raw.h"
++#include "zvision/zork_raw.h"
+
+ #include "zvision/zvision.h"
+ #include "zvision/detection.h"
-#include "zvision/utility/utility.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"
Commit: ace0e5e88f63f34dad94962c95f57f3ec42258ae
https://github.com/scummvm/scummvm/commit/ace0e5e88f63f34dad94962c95f57f3ec42258ae
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-06-14T15:18:24+07:00
Commit Message:
ZVISION: Fix compilation errors with latest scummvm
Changed paths:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation_node.cpp
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/core/menu.h
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/fonts/truetype_font.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/inventory_manager.cpp
engines/zvision/menu.cpp
engines/zvision/meta_animation.cpp
engines/zvision/module.mk
engines/zvision/music_node.cpp
engines/zvision/music_node.h
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/timer_node.cpp
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/search_manager.cpp
engines/zvision/sidefx.cpp
engines/zvision/slot_control.cpp
engines/zvision/slot_control.h
engines/zvision/sound/zork_raw.cpp
engines/zvision/subtitles.cpp
engines/zvision/syncsound_node.cpp
engines/zvision/syncsound_node.h
engines/zvision/text.cpp
engines/zvision/text.h
engines/zvision/ttytext_node.cpp
engines/zvision/ttytext_node.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp
index 5784df0..2bb0271 100644
--- a/engines/zvision/animation/rlf_animation.cpp
+++ b/engines/zvision/animation/rlf_animation.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#include "zvision/rlf_animation.h"
+#include "zvision/animation/rlf_animation.h"
#include "common/str.h"
#include "common/file.h"
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
index 365ff74..49ef22b 100644
--- a/engines/zvision/animation_node.cpp
+++ b/engines/zvision/animation_node.cpp
@@ -25,8 +25,8 @@
#include "zvision/animation_node.h"
#include "zvision/zvision.h"
-#include "zvision/render_manager.h"
-#include "zvision/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
#include "zvision/meta_animation.h"
#include "graphics/surface.h"
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index 252a4b7..ef088f7 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -22,16 +22,16 @@
#include "common/scummsys.h"
-#include "zvision/console.h"
+#include "zvision/core/console.h"
#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"
-#include "zvision/cursor.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/strings/string_manager.h"
+#include "zvision/video/zork_avi_decoder.h"
+#include "zvision/sound/zork_raw.h"
+#include "zvision/utility/utility.h"
+#include "zvision/cursors/cursor.h"
#include "common/system.h"
#include "common/file.h"
@@ -45,18 +45,18 @@
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));
- 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));
- 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));
+ registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage));
+ registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
+ registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound));
+ registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
+ registerCmd("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState));
+ registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
+ registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
+ registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
+ registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
+ registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
+ registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
+ registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText));
}
bool Console::cmdLoadImage(int argc, const char **argv) {
@@ -72,7 +72,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\n");
+ debugPrintf("Use loadvideo <fileName> to load a video to the screen\n");
return true;
}
@@ -86,7 +86,7 @@ bool Console::cmdLoadVideo(int argc, const char **argv) {
bool Console::cmdLoadSound(int argc, const char **argv) {
if (!Common::File::exists(argv[1])) {
- DebugPrintf("File does not exist\n");
+ debugPrintf("File does not exist\n");
return true;
}
@@ -105,7 +105,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
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");
+ debugPrintf("Use loadsound <fileName> [<rate> <isStereo: 1 or 0>] to load a sound\n");
return true;
}
@@ -114,7 +114,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
bool Console::cmdRawToWav(int argc, const char **argv) {
if (argc != 3) {
- DebugPrintf("Use raw2wav <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n");
+ debugPrintf("Use raw2wav <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n");
return true;
}
@@ -124,7 +124,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) {
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");
+ debugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
return true;
}
@@ -137,7 +137,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) {
else if (renderState.matchString("flat", true))
_engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
else
- DebugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+ debugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
return true;
}
@@ -150,7 +150,7 @@ 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");
+ debugPrintf("Use setpanoramafov <fieldOfView> to change the current panorama field of view\n");
return true;
}
@@ -161,7 +161,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Use setpanoramascale <scale> to change the current panorama scale\n");
+ debugPrintf("Use setpanoramascale <scale> to change the current panorama scale\n");
return true;
}
@@ -172,7 +172,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\n");
+ debugPrintf("Use changelocation <char: world> <char: room> <char:node> <char:view> <int: x position> to change your location\n");
return true;
}
@@ -183,7 +183,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\n");
+ debugPrintf("Use dumpfile <fileName> to dump a file\n");
return true;
}
@@ -204,7 +204,7 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
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");
+ debugPrintf("Use rendertext <text> <fontNumber> <destX> <destY> <maxWidth> <1 or 0: wrap> to render text\n");
return true;
}
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 189bf00..943f8ff 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -24,12 +24,12 @@
#include "zvision/zvision.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 "zvision/menu.h"
+#include "zvision/core/console.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/animation/rlf_animation.h"
+#include "zvision/core/menu.h"
#include "common/events.h"
#include "common/system.h"
diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h
index 7be03f6..cc802ee 100644
--- a/engines/zvision/core/menu.h
+++ b/engines/zvision/core/menu.h
@@ -27,7 +27,7 @@
#include "common/rect.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
+#include "zvision/scripting/script_manager.h"
namespace ZVision {
diff --git a/engines/zvision/cursors/cursor.cpp b/engines/zvision/cursors/cursor.cpp
index e2e3d7e..8c6027a 100644
--- a/engines/zvision/cursors/cursor.cpp
+++ b/engines/zvision/cursors/cursor.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#include "zvision/cursor.h"
+#include "zvision/cursors/cursor.h"
#include "common/str.h"
#include "common/file.h"
diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp
index c66fa65..cfb4baf 100644
--- a/engines/zvision/cursors/cursor_manager.cpp
+++ b/engines/zvision/cursors/cursor_manager.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#include "zvision/cursor_manager.h"
+#include "zvision/cursors/cursor_manager.h"
#include "zvision/zvision.h"
diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h
index 0521a17..5392fd5 100644
--- a/engines/zvision/cursors/cursor_manager.h
+++ b/engines/zvision/cursors/cursor_manager.h
@@ -23,7 +23,7 @@
#ifndef ZVISION_CURSOR_MANAGER_H
#define ZVISION_CURSOR_MANAGER_H
-#include "zvision/cursor.h"
+#include "zvision/cursors/cursor.h"
#include "common/str.h"
diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp
index e3eea40..224603c 100644
--- a/engines/zvision/fonts/truetype_font.cpp
+++ b/engines/zvision/fonts/truetype_font.cpp
@@ -22,10 +22,10 @@
#include "common/scummsys.h"
-#include "zvision/truetype_font.h"
+#include "zvision/fonts/truetype_font.h"
#include "zvision/zvision.h"
-#include "zvision/render_manager.h"
+#include "zvision/graphics/render_manager.h"
#include "common/config-manager.h"
#include "common/debug.h"
@@ -212,7 +212,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
if (themeArchive->hasFile("FreeSans.ttf")) {
Common::SeekableReadStream *stream = nullptr;
stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
- Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
@@ -225,7 +225,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
themeArchive = nullptr;
}
} else {
- Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
+ Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h
index bed1d55..0fed3cc 100644
--- a/engines/zvision/fonts/truetype_font.h
+++ b/engines/zvision/fonts/truetype_font.h
@@ -43,12 +43,12 @@ public:
~TruetypeFont();
private:
-// ZVision *_engine;
+ ZVision *_engine;
Graphics::Font *_font;
int _lineHeight;
-// size_t _maxCharWidth;
-// size_t _maxCharHeight;
+ size_t _maxCharWidth;
+ size_t _maxCharHeight;
public:
int32 _fontHeight;
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 071afff..c9dc5d3 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -23,10 +23,10 @@
#include "common/scummsys.h"
#include "zvision/zvision.h"
-#include "zvision/render_manager.h"
+#include "zvision/graphics/render_manager.h"
#include "zvision/text.h"
-#include "zvision/lzss_read_stream.h"
+#include "zvision/utility/lzss_read_stream.h"
#include "common/file.h"
#include "common/system.h"
@@ -34,7 +34,7 @@
#include "engines/util.h"
-#include "graphics/decoders/tga.h"
+#include "image/tga.h"
namespace ZVision {
@@ -127,7 +127,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
uint32 imageWidth;
uint32 imageHeight;
- Graphics::TGADecoder tga;
+ Image::TGADecoder tga;
uint16 *buffer;
bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
// All ZVision images are in RGB 555
@@ -221,7 +221,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
uint32 imageWidth;
uint32 imageHeight;
- Graphics::TGADecoder tga;
+ Image::TGADecoder tga;
uint16 *buffer;
// All ZVision images are in RGB 555
Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index 668c8ac..ca2e715 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -23,8 +23,8 @@
#ifndef ZVISION_RENDER_MANAGER_H
#define ZVISION_RENDER_MANAGER_H
-#include "zvision/render_table.h"
-#include "zvision/truetype_font.h"
+#include "zvision/graphics/render_table.h"
+#include "zvision/fonts/truetype_font.h"
#include "common/rect.h"
#include "common/hashmap.h"
diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp
index 3924c6b..f8b2297 100644
--- a/engines/zvision/inventory_manager.cpp
+++ b/engines/zvision/inventory_manager.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#include "zvision/script_manager.h"
+#include "zvision/scripting/script_manager.h"
namespace ZVision {
diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp
index bf422b3..bf311c4 100644
--- a/engines/zvision/menu.cpp
+++ b/engines/zvision/menu.cpp
@@ -22,9 +22,9 @@
#include "common/scummsys.h"
-#include "zvision/menu.h"
+#include "zvision/core/menu.h"
-#include "zvision/render_manager.h"
+#include "zvision/graphics/render_manager.h"
namespace ZVision {
diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp
index 33ae92a..dddc238 100644
--- a/engines/zvision/meta_animation.cpp
+++ b/engines/zvision/meta_animation.cpp
@@ -25,10 +25,10 @@
#include "zvision/meta_animation.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 "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/animation/rlf_animation.h"
+#include "zvision/video/zork_avi_decoder.h"
#include "video/video_decoder.h"
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index d6d0dd7..a386f6f 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,35 +1,35 @@
MODULE := engines/zvision
MODULE_OBJS := \
- actions.o \
+ scripting/actions.o \
animation_node.o \
- clock.o \
- console.o \
- control.o \
- cursor.o \
- cursor_manager.o \
+ utility/clock.o \
+ core/console.o \
+ scripting/control.o \
+ cursors/cursor.o \
+ cursors/cursor_manager.o \
detection.o \
- events.o \
- input_control.o \
- lever_control.o \
- lzss_read_stream.o \
- push_toggle_control.o \
- render_manager.o \
- render_table.o \
- rlf_animation.o \
- save_manager.o \
- scr_file_handling.o \
- script_manager.o \
- single_value_container.o \
- string_manager.o \
- timer_node.o \
- truetype_font.o \
- utility.o \
- video.o \
+ core/events.o \
+ scripting/controls/input_control.o \
+ scripting/controls/lever_control.o \
+ utility/lzss_read_stream.o \
+ scripting/controls/push_toggle_control.o \
+ graphics/render_manager.o \
+ graphics/render_table.o \
+ animation/rlf_animation.o \
+ core/save_manager.o \
+ scripting/scr_file_handling.o \
+ scripting/script_manager.o \
+ utility/single_value_container.o \
+ strings/string_manager.o \
+ scripting/controls/timer_node.o \
+ fonts/truetype_font.o \
+ utility/utility.o \
+ video/video.o \
zvision.o \
- zfs_archive.o \
- zork_avi_decoder.o \
- zork_raw.o \
+ archives/zfs_archive.o \
+ video/zork_avi_decoder.o \
+ sound/zork_raw.o \
sidefx.o \
music_node.o \
inventory_manager.o \
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
index b716b3e..f8fd08b 100644
--- a/engines/zvision/music_node.cpp
+++ b/engines/zvision/music_node.cpp
@@ -25,9 +25,9 @@
#include "zvision/music_node.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
-#include "zvision/zork_raw.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
#include "common/stream.h"
#include "common/file.h"
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
index d24496f..0dad226 100644
--- a/engines/zvision/music_node.h
+++ b/engines/zvision/music_node.h
@@ -25,7 +25,7 @@
#include "audio/mixer.h"
#include "zvision/sidefx.h"
-#include "zvision/subtitles.h"
+#include "zvision/subtitles/subtitles.h"
namespace Common {
class String;
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index f60a697..3c341fb 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -22,14 +22,14 @@
#include "common/scummsys.h"
-#include "zvision/actions.h"
+#include "zvision/scripting/actions.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
-#include "zvision/zork_raw.h"
-#include "zvision/zork_avi_decoder.h"
-#include "zvision/timer_node.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
+#include "zvision/video/zork_avi_decoder.h"
+#include "zvision/scripting/controls/timer_node.h"
#include "zvision/music_node.h"
#include "zvision/syncsound_node.h"
#include "zvision/animation_node.h"
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index a366e06..ca707b5 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -22,13 +22,13 @@
#include "common/scummsys.h"
-#include "zvision/input_control.h"
+#include "zvision/scripting/controls/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 "zvision/scripting/script_manager.h"
+#include "zvision/strings/string_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
#include "common/str.h"
#include "common/stream.h"
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index f68f256..121fab9 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -22,14 +22,14 @@
#include "common/scummsys.h"
-#include "zvision/lever_control.h"
+#include "zvision/scripting/controls/lever_control.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
-#include "zvision/cursor_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
#include "zvision/meta_animation.h"
-#include "zvision/utility.h"
+#include "zvision/utility/utility.h"
#include "common/stream.h"
#include "common/file.h"
diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/controls/timer_node.cpp
index a94f6db..e68610f 100644
--- a/engines/zvision/scripting/controls/timer_node.cpp
+++ b/engines/zvision/scripting/controls/timer_node.cpp
@@ -22,10 +22,10 @@
#include "common/scummsys.h"
-#include "zvision/timer_node.h"
+#include "zvision/scripting/controls/timer_node.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
+#include "zvision/scripting/script_manager.h"
#include "common/stream.h"
diff --git a/engines/zvision/scripting/puzzle.h b/engines/zvision/scripting/puzzle.h
index 4d50756..ab38c5f 100644
--- a/engines/zvision/scripting/puzzle.h
+++ b/engines/zvision/scripting/puzzle.h
@@ -23,7 +23,7 @@
#ifndef ZVISION_PUZZLE_H
#define ZVISION_PUZZLE_H
-#include "zvision/actions.h"
+#include "zvision/scripting/actions.h"
#include "common/list.h"
#include "common/ptr.h"
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 9d1d0bf..fff187d 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -23,13 +23,13 @@
#include "common/scummsys.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
+#include "zvision/scripting/script_manager.h"
-#include "zvision/utility.h"
-#include "zvision/puzzle.h"
-#include "zvision/actions.h"
-#include "zvision/push_toggle_control.h"
-#include "zvision/lever_control.h"
+#include "zvision/utility/utility.h"
+#include "zvision/scripting/puzzle.h"
+#include "zvision/scripting/actions.h"
+#include "zvision/scripting/controls/push_toggle_control.h"
+#include "zvision/scripting/controls/lever_control.h"
#include "zvision/slot_control.h"
#include "common/textconsole.h"
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 1a56739..9713a34 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -22,15 +22,15 @@
#include "common/scummsys.h"
-#include "zvision/script_manager.h"
+#include "zvision/scripting/script_manager.h"
#include "zvision/zvision.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 "zvision/timer_node.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/core/save_manager.h"
+#include "zvision/scripting/actions.h"
+#include "zvision/utility/utility.h"
+#include "zvision/scripting/controls/timer_node.h"
#include "common/algorithm.h"
#include "common/hashmap.h"
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 6adade5..a835c13 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -23,8 +23,8 @@
#ifndef ZVISION_SCRIPT_MANAGER_H
#define ZVISION_SCRIPT_MANAGER_H
-#include "zvision/puzzle.h"
-#include "zvision/control.h"
+#include "zvision/scripting/puzzle.h"
+#include "zvision/scripting/control.h"
#include "zvision/sidefx.h"
#include "common/hashmap.h"
diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp
index 124a499..db120f2 100644
--- a/engines/zvision/search_manager.cpp
+++ b/engines/zvision/search_manager.cpp
@@ -22,7 +22,7 @@
#include "common/debug.h"
#include "zvision/search_manager.h"
-#include "zvision/zfs_archive.h"
+#include "zvision/archives/zfs_archive.h"
#include "common/fs.h"
#include "common/stream.h"
diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp
index 3874c86..7ba1959 100644
--- a/engines/zvision/sidefx.cpp
+++ b/engines/zvision/sidefx.cpp
@@ -25,8 +25,8 @@
#include "zvision/sidefx.h"
#include "zvision/zvision.h"
-#include "zvision/render_manager.h"
-#include "zvision/utility.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
#include "common/stream.h"
diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp
index 111a7c6..d3d9c2e 100644
--- a/engines/zvision/slot_control.cpp
+++ b/engines/zvision/slot_control.cpp
@@ -25,10 +25,10 @@
#include "zvision/slot_control.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/cursor_manager.h"
-#include "zvision/render_manager.h"
-#include "zvision/utility.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
#include "common/stream.h"
diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h
index eec2d04..0ac8ec9 100644
--- a/engines/zvision/slot_control.h
+++ b/engines/zvision/slot_control.h
@@ -23,7 +23,7 @@
#ifndef ZVISION_SLOT_CONTROL_H
#define ZVISION_SLOT_CONTROL_H
-#include "zvision/control.h"
+#include "zvision/scripting/control.h"
#include "graphics/surface.h"
diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp
index a4d091f..a0f660f 100644
--- a/engines/zvision/sound/zork_raw.cpp
+++ b/engines/zvision/sound/zork_raw.cpp
@@ -22,11 +22,11 @@
#include "common/scummsys.h"
-#include "zvision/zork_raw.h"
+#include "zvision/sound/zork_raw.h"
#include "zvision/zvision.h"
#include "zvision/detection.h"
-#include "zvision/utility.h"
+#include "zvision/utility/utility.h"
#include "common/file.h"
#include "common/str.h"
diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp
index 1942e3c..da9b0fc 100644
--- a/engines/zvision/subtitles.cpp
+++ b/engines/zvision/subtitles.cpp
@@ -20,8 +20,8 @@
*
*/
-#include "zvision/subtitles.h"
-#include "zvision/render_manager.h"
+#include "zvision/subtitles/subtitles.h"
+#include "zvision/graphics/render_manager.h"
#include "zvision/search_manager.h"
#include "zvision/text.h"
diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp
index 5d04c1f..7bd520d4 100644
--- a/engines/zvision/syncsound_node.cpp
+++ b/engines/zvision/syncsound_node.cpp
@@ -25,9 +25,9 @@
#include "zvision/syncsound_node.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
-#include "zvision/zork_raw.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
#include "common/stream.h"
#include "common/file.h"
diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h
index 7d875f2..1f63ec4 100644
--- a/engines/zvision/syncsound_node.h
+++ b/engines/zvision/syncsound_node.h
@@ -25,7 +25,7 @@
#include "audio/mixer.h"
#include "zvision/sidefx.h"
-#include "zvision/subtitles.h"
+#include "zvision/subtitles/subtitles.h"
namespace Common {
class String;
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp
index 2fdfafc..6b0ff07 100644
--- a/engines/zvision/text.cpp
+++ b/engines/zvision/text.cpp
@@ -24,7 +24,7 @@
#include "zvision/text.h"
-#include "zvision/truetype_font.h"
+#include "zvision/fonts/truetype_font.h"
#include "common/file.h"
#include "common/tokenizer.h"
@@ -37,8 +37,8 @@
#include "graphics/font.h"
#include "graphics/fonts/ttf.h"
-#include "zvision/render_manager.h"
-#include "zvision/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
namespace ZVision {
diff --git a/engines/zvision/text.h b/engines/zvision/text.h
index c1dc0c1..4b318fd 100644
--- a/engines/zvision/text.h
+++ b/engines/zvision/text.h
@@ -25,7 +25,7 @@
#define ZVISION_TEXT_H
#include "zvision/detection.h"
-#include "zvision/truetype_font.h"
+#include "zvision/fonts/truetype_font.h"
#include "zvision/zvision.h"
diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp
index 4f64800..6741d28 100644
--- a/engines/zvision/ttytext_node.cpp
+++ b/engines/zvision/ttytext_node.cpp
@@ -25,8 +25,8 @@
#include "zvision/ttytext_node.h"
#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
#include "zvision/text.h"
#include "common/stream.h"
diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h
index 6c3e6f4..e25fdb0 100644
--- a/engines/zvision/ttytext_node.h
+++ b/engines/zvision/ttytext_node.h
@@ -28,7 +28,7 @@
#include "zvision/sidefx.h"
#include "zvision/text.h"
-#include "zvision/truetype_font.h"
+#include "zvision/fonts/truetype_font.h"
namespace Common {
class String;
diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp
index 0ad9000..7a120df 100644
--- a/engines/zvision/video/video.cpp
+++ b/engines/zvision/video/video.cpp
@@ -24,9 +24,9 @@
#include "zvision/zvision.h"
-#include "zvision/clock.h"
-#include "zvision/render_manager.h"
-#include "zvision/subtitles.h"
+#include "zvision/utility/clock.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/subtitles/subtitles.h"
#include "common/system.h"
diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h
index d8937ac..db1ad31 100644
--- a/engines/zvision/video/zork_avi_decoder.h
+++ b/engines/zvision/video/zork_avi_decoder.h
@@ -25,7 +25,7 @@
#define ZORK_AVI_DECODER_H
#include "video/avi_decoder.h"
-#include "zork_raw.h"
+#include "zvision/sound/zork_raw.h"
namespace ZVision {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b1615aa..580f8c4 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -24,18 +24,18 @@
#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/core/console.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/core/save_manager.h"
+#include "zvision/strings/string_manager.h"
+#include "zvision/archives/zfs_archive.h"
#include "zvision/detection.h"
-#include "zvision/menu.h"
+#include "zvision/core/menu.h"
#include "zvision/search_manager.h"
#include "zvision/text.h"
-#include "zvision/truetype_font.h"
+#include "zvision/fonts/truetype_font.h"
#include "common/config-manager.h"
#include "common/str.h"
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 982d3fd..2674df2 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -25,7 +25,7 @@
#define ZVISION_ZVISION_H
#include "zvision/detection.h"
-#include "zvision/clock.h"
+#include "zvision/utility/clock.h"
#include "zvision/search_manager.h"
#include "common/random.h"
Commit: 23c1b508611d5fa4e7dfc47f8f5ec10a7de177e3
https://github.com/scummvm/scummvm/commit/23c1b508611d5fa4e7dfc47f8f5ec10a7de177e3
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-02T19:50:55Z
Commit Message:
ZVISION: Reorgonize source files into directories.
Changed paths:
A engines/zvision/animation/meta_animation.cpp
A engines/zvision/animation/meta_animation.h
A engines/zvision/core/menu.cpp
A engines/zvision/core/search_manager.cpp
A engines/zvision/core/search_manager.h
A engines/zvision/scripting/controls/slot_control.cpp
A engines/zvision/scripting/controls/slot_control.h
A engines/zvision/scripting/inventory.cpp
A engines/zvision/scripting/sidefx.cpp
A engines/zvision/scripting/sidefx.h
A engines/zvision/scripting/sidefx/animation_node.cpp
A engines/zvision/scripting/sidefx/animation_node.h
A engines/zvision/scripting/sidefx/music_node.cpp
A engines/zvision/scripting/sidefx/music_node.h
A engines/zvision/scripting/sidefx/syncsound_node.cpp
A engines/zvision/scripting/sidefx/syncsound_node.h
A engines/zvision/scripting/sidefx/timer_node.cpp
A engines/zvision/scripting/sidefx/timer_node.h
A engines/zvision/scripting/sidefx/ttytext_node.cpp
A engines/zvision/scripting/sidefx/ttytext_node.h
A engines/zvision/subtitles/subtitles.cpp
A engines/zvision/text/string_manager.cpp
A engines/zvision/text/string_manager.h
A engines/zvision/text/text.cpp
A engines/zvision/text/text.h
R engines/zvision/animation_node.cpp
R engines/zvision/animation_node.h
R engines/zvision/inventory_manager.cpp
R engines/zvision/menu.cpp
R engines/zvision/meta_animation.cpp
R engines/zvision/meta_animation.h
R engines/zvision/music_node.cpp
R engines/zvision/music_node.h
R engines/zvision/scripting/controls/timer_node.cpp
R engines/zvision/scripting/controls/timer_node.h
R engines/zvision/search_manager.cpp
R engines/zvision/search_manager.h
R engines/zvision/sidefx.cpp
R engines/zvision/sidefx.h
R engines/zvision/slot_control.cpp
R engines/zvision/slot_control.h
R engines/zvision/strings/string_manager.cpp
R engines/zvision/strings/string_manager.h
R engines/zvision/subtitles.cpp
R engines/zvision/syncsound_node.cpp
R engines/zvision/syncsound_node.h
R engines/zvision/text.cpp
R engines/zvision/text.h
R engines/zvision/ttytext_node.cpp
R engines/zvision/ttytext_node.h
engines/zvision/core/console.cpp
engines/zvision/graphics/render_manager.cpp
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/input_control.h
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp
new file mode 100644
index 0000000..38f5669
--- /dev/null
+++ b/engines/zvision/animation/meta_animation.cpp
@@ -0,0 +1,131 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/animation/meta_animation.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/animation/rlf_animation.h"
+#include "zvision/video/zork_avi_decoder.h"
+
+#include "video/video_decoder.h"
+
+#include "graphics/surface.h"
+
+
+namespace ZVision {
+
+MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
+ : _fileType(RLF),
+ _cur_frame(NULL) {
+ if (fileName.hasSuffix(".rlf")) {
+ _fileType = RLF;
+ Common::File *_file = engine->getSearchManager()->openFile(fileName);
+ _animation.rlf = new RlfAnimation(_file, false);
+ _frmDelay = _animation.rlf->frameTime();
+ } else if (fileName.hasSuffix(".avi")) {
+ _fileType = AVI;
+ Common::File *_file = engine->getSearchManager()->openFile(fileName);
+ _animation.avi = new ZorkAVIDecoder();
+ _animation.avi->loadStream(_file);
+ _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+}
+
+MetaAnimation::~MetaAnimation() {
+ if (_fileType == RLF) {
+ delete _animation.rlf;
+ } else if (_fileType == AVI) {
+ delete _animation.avi;
+ }
+}
+
+uint MetaAnimation::frameCount() {
+ if (_fileType == RLF) {
+ return _animation.rlf->frameCount();
+ } else
+ return _animation.avi->getFrameCount();
+
+}
+
+uint MetaAnimation::width() {
+ if (_fileType == RLF) {
+ return _animation.rlf->width();
+ } else
+ return _animation.avi->getWidth();
+}
+uint MetaAnimation::height() {
+ if (_fileType == RLF) {
+ return _animation.rlf->height();
+ } else
+ return _animation.avi->getHeight();
+}
+uint32 MetaAnimation::frameTime() {
+ return _frmDelay;
+}
+
+void MetaAnimation::seekToFrame(int frameNumber) {
+ if (frameNumber >= (int)frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(frameNumber);
+ } else
+ _animation.avi->seekToFrame(frameNumber);
+}
+
+const Graphics::Surface *MetaAnimation::decodeNextFrame() {
+ if (_fileType == RLF)
+ _cur_frame = _animation.rlf->decodeNextFrame();
+ else
+ _cur_frame = _animation.avi->decodeNextFrame();
+
+ return _cur_frame;
+}
+
+const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
+ if (frameNumber >= frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _cur_frame = _animation.rlf->getFrameData(frameNumber);
+ return _cur_frame;
+ } else {
+ _animation.avi->seekToFrame(frameNumber);
+ _cur_frame = _animation.avi->decodeNextFrame();
+ return _cur_frame;
+ }
+}
+
+bool MetaAnimation::endOfAnimation() {
+ if (_fileType == RLF) {
+ return _animation.rlf->endOfAnimation();
+ } else
+ return _animation.avi->endOfVideo();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h
new file mode 100644
index 0000000..2ea0031
--- /dev/null
+++ b/engines/zvision/animation/meta_animation.h
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_METAANIM_NODE_H
+#define ZVISION_METAANIM_NODE_H
+
+#include "zvision/scripting/sidefx.h"
+#include "zvision/zvision.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace Common {
+class String;
+}
+
+namespace Video {
+class VideoDecoder;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+class RlfAnimation;
+
+class MetaAnimation {
+public:
+ MetaAnimation(const Common::String &fileName, ZVision *engine);
+ ~MetaAnimation();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ Graphics::Surface *_scaled;
+ };
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+private:
+ union {
+ RlfAnimation *rlf;
+ Video::VideoDecoder *avi;
+ } _animation;
+
+ FileType _fileType;
+ int32 _frmDelay;
+
+ const Graphics::Surface *_cur_frame;
+
+public:
+
+ uint frameCount();
+ uint width();
+ uint height();
+ uint32 frameTime();
+
+ void seekToFrame(int frameNumber);
+
+ const Graphics::Surface *decodeNextFrame();
+ const Graphics::Surface *getFrameData(uint frameNumber);
+
+ bool endOfAnimation();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp
deleted file mode 100644
index 49ef22b..0000000
--- a/engines/zvision/animation_node.cpp
+++ /dev/null
@@ -1,211 +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/animation_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/meta_animation.h"
-
-#include "graphics/surface.h"
-
-
-namespace ZVision {
-
-AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
- : SideFX(engine, controlKey, SIDEFX_ANIM),
- _DisposeAfterUse(DisposeAfterUse),
- _mask(mask),
- _animation(NULL) {
-
- if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
- _animation = new MetaAnimation(fileName, engine);
- _frmDelay = _animation->frameTime();
- } else {
- warning("Unrecognized animation file type: %s", fileName.c_str());
- }
-
- if (frate > 0)
- _frmDelay = 1000.0 / frate;
-}
-
-AnimationNode::~AnimationNode() {
- if (_animation)
- delete _animation;
-
- _engine->getScriptManager()->setStateValue(_key, 2);
-
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
-
- if ((*it)._scaled)
- delete(*it)._scaled;
- }
-
- _playList.clear();
-}
-
-bool AnimationNode::process(uint32 deltaTimeInMillis) {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- playnode *nod = &(*it);
-
- nod->_delay -= deltaTimeInMillis;
- if (nod->_delay <= 0) {
- nod->_delay += _frmDelay;
-
- const Graphics::Surface *frame = NULL;
-
- if (nod->_cur_frm == -1) { // Start of new playlist node
- nod->_cur_frm = nod->start;
-
- _animation->seekToFrame(nod->_cur_frm);
- frame = _animation->decodeNextFrame();
-
- nod->_delay = _frmDelay;
- if (nod->slot)
- _engine->getScriptManager()->setStateValue(nod->slot, 1);
- } else {
- nod->_cur_frm++;
-
- if (nod->_cur_frm > nod->stop) {
- nod->loop--;
-
- if (nod->loop == 0) {
- if (nod->slot >= 0)
- _engine->getScriptManager()->setStateValue(nod->slot, 2);
- if (nod->_scaled)
- delete nod->_scaled;
- _playList.erase(it);
- return _DisposeAfterUse;
- }
-
- nod->_cur_frm = nod->start;
- _animation->seekToFrame(nod->_cur_frm);
- }
-
- frame = _animation->decodeNextFrame();
- }
-
- if (frame) {
-
- uint32 dstw;
- uint32 dsth;
- if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
- dstw = nod->pos.height();
- dsth = nod->pos.width();
- } else {
- dstw = nod->pos.width();
- dsth = nod->pos.height();
- }
-
- if (frame->w != dstw || frame->h != dsth) {
- if (nod->_scaled)
- if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
- delete nod->_scaled;
- nod->_scaled = NULL;
- }
-
- if (!nod->_scaled) {
- nod->_scaled = new Graphics::Surface;
- nod->_scaled->create(dstw, dsth, frame->format);
- }
-
- _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
- frame = nod->_scaled;
- }
-
- if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
- Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
- if (_mask > 0)
- _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
- else
- _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top);
- delete transposed;
- } else {
- if (_mask > 0)
- _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
- else
- _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top);
- }
- }
- }
- }
-
- return false;
-}
-
-
-
-void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) {
- playnode nod;
- nod.loop = loops;
- nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
- nod.start = start_frame;
- nod.stop = end_frame;
-
- if (nod.stop >= (int)_animation->frameCount())
- nod.stop = _animation->frameCount() - 1;
-
- nod.slot = slot;
- nod._cur_frm = -1;
- nod._delay = 0;
- nod._scaled = NULL;
- _playList.push_back(nod);
-}
-
-bool AnimationNode::stop() {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
- if ((*it)._scaled)
- delete(*it)._scaled;
- }
-
- _playList.clear();
-
- // We don't need to delete, it's may be reused
- return false;
-}
-
-void AnimationNode::setNewFrameDelay(int32 newDelay) {
- if (newDelay > 0) {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- playnode *nod = &(*it);
- float percent = (float)nod->_delay / (float)_frmDelay;
- nod->_delay = percent * newDelay; // Scale to new max
- }
-
- _frmDelay = newDelay;
- }
-}
-
-int32 AnimationNode::getFrameDelay() {
- return _frmDelay;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h
deleted file mode 100644
index ff7636a..0000000
--- a/engines/zvision/animation_node.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * 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_NODE_H
-#define ZVISION_ANIMATION_NODE_H
-
-#include "zvision/sidefx.h"
-#include "common/rect.h"
-#include "common/list.h"
-
-
-namespace Common {
-class String;
-}
-
-namespace Graphics {
-struct Surface;
-}
-
-namespace ZVision {
-
-class ZVision;
-class MetaAnimation;
-
-class AnimationNode : public SideFX {
-public:
- AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true);
- ~AnimationNode();
-
- struct playnode {
- Common::Rect pos;
- int32 slot;
- int32 start;
- int32 stop;
- int32 loop;
- int32 _cur_frm;
- int32 _delay;
- Graphics::Surface *_scaled;
- };
-
-private:
- typedef Common::List<playnode> PlayNodes;
-
- PlayNodes _playList;
-
- int32 _mask;
- bool _DisposeAfterUse;
-
- MetaAnimation *_animation;
- int32 _frmDelay;
-
-public:
- bool process(uint32 deltaTimeInMillis);
-
- void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1);
-
- bool stop();
-
- void setNewFrameDelay(int32 newDelay);
- int32 getFrameDelay();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index ef088f7..aac4e7b 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -27,7 +27,7 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/video/zork_avi_decoder.h"
#include "zvision/sound/zork_raw.h"
#include "zvision/utility/utility.h"
diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp
new file mode 100644
index 0000000..bf311c4
--- /dev/null
+++ b/engines/zvision/core/menu.cpp
@@ -0,0 +1,765 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/core/menu.h"
+
+#include "zvision/graphics/render_manager.h"
+
+
+namespace ZVision {
+
+enum {
+ SLOT_START_SLOT = 151,
+ SLOT_SPELL_1 = 191,
+ SLOT_USER_CHOSE_THIS_SPELL = 205,
+ SLOT_REVERSED_SPELLBOOK = 206
+};
+
+enum {
+ menu_MAIN_SAVE = 0,
+ menu_MAIN_REST = 1,
+ menu_MAIN_PREF = 2,
+ menu_MAIN_EXIT = 3
+};
+
+menuHandler::menuHandler(ZVision *engine) {
+ _engine = engine;
+ menu_bar_flag = 0xFFFF;
+}
+
+menuZgi::menuZgi(ZVision *engine) :
+ menuHandler(engine) {
+ menu_mousefocus = -1;
+ inmenu = false;
+ scrolled[0] = false;
+ scrolled[1] = false;
+ scrolled[2] = false;
+ scrollPos[0] = 0.0;
+ scrollPos[1] = 0.0;
+ scrollPos[2] = 0.0;
+ mouse_on_item = -1;
+
+ char buf[24];
+ for (int i = 1; i < 4; i++) {
+ sprintf(buf, "gmzau%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false);
+ sprintf(buf, "gmzau%2.2x1.tga", i + 0x10);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false);
+ }
+ for (int i = 0; i < 4; i++) {
+ sprintf(buf, "gmzmu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false);
+ sprintf(buf, "gmznu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false);
+ }
+
+ for (int i = 0; i < 50; i++) {
+ items[i][0] = NULL;
+ items[i][1] = NULL;
+ item_id[i] = 0;
+ }
+
+ for (int i = 0; i < 12; i++) {
+ magic[i][0] = NULL;
+ magic[i][1] = NULL;
+ magic_id[i] = 0;
+ }
+}
+
+menuZgi::~menuZgi() {
+ for (int i = 0; i < 3; i++) {
+ menuback[i][0].free();
+ menuback[i][1].free();
+ }
+ for (int i = 0; i < 4; i++) {
+ menubar[i][0].free();
+ menubar[i][1].free();
+ }
+ for (int i = 0; i < 50; i++) {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ }
+ }
+ for (int i = 0; i < 12; i++) {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ }
+ }
+}
+
+void menuZgi::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items) {
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
+ scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
+ int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (mouse_item >= 0 && mouse_item < 0xE0) {
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i));
+ _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item);
+
+ redraw = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic) {
+ for (int i = 0; i < 12; i++) {
+
+ uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ if (itemnum != 0) {
+ if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ itemnum = 0xEE + i;
+ else
+ itemnum = 0xE0 + i;
+ }
+ if (itemnum)
+ if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0)
+ if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
+ 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos))
+ _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum);
+ }
+
+ }
+ break;
+
+ case menu_MAIN:
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(320 + 135,
+ scrollPos[menu_MAIN],
+ 320 + 135 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ // ifquit();
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(320 ,
+ scrollPos[menu_MAIN],
+ 320 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(320 - 135,
+ scrollPos[menu_MAIN],
+ 320,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[menu_MAIN],
+ 320 - 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ }
+ break;
+ }
+ }
+}
+
+void menuZgi::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ if (!inmenu)
+ redraw = true;
+ inmenu = true;
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items) {
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+ else if (item_count > 50)
+ item_count = 50;
+
+ int last_item = mouse_on_item;
+
+ mouse_on_item = -1;
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
+ scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
+ mouse_on_item = i;
+ break;
+ }
+ }
+
+ if (last_item != mouse_on_item)
+ if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) ||
+ _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item))
+ redraw = true;
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic) {
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+ for (int i = 0; i < 12; i++) {
+ if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
+ 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) {
+ mouse_on_item = i;
+ break;
+ }
+ }
+
+ if (last_item != mouse_on_item)
+ if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) ||
+ _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item))
+ redraw = true;
+
+ }
+ break;
+
+ case menu_MAIN: {
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(320 + 135,
+ scrollPos[menu_MAIN],
+ 320 + 135 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_EXIT;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(320 ,
+ scrollPos[menu_MAIN],
+ 320 + 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_PREF;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(320 - 135,
+ scrollPos[menu_MAIN],
+ 320,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_REST;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[menu_MAIN],
+ 320 - 135,
+ scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_SAVE;
+ }
+
+ if (last_item != mouse_on_item)
+ redraw = true;
+ }
+ break;
+
+ default:
+ int cur_menu = menu_mousefocus;
+ if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main
+ menu_mousefocus = menu_MAIN;
+ scrolled[menu_MAIN] = false;
+ scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+ }
+
+ if (menu_bar_flag & menuBar_Magic)
+ if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
+ menu_mousefocus = menu_MAGIC;
+ scrolled[menu_MAGIC] = false;
+ scrollPos[menu_MAGIC] = 28;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
+ }
+
+ if (menu_bar_flag & menuBar_Items)
+ if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
+ menu_mousefocus = menu_ITEM;
+ scrolled[menu_ITEM] = false;
+ scrollPos[menu_ITEM] = 28 - 600;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
+ }
+
+ if (cur_menu != menu_mousefocus)
+ clean = true;
+
+ break;
+ }
+ } else {
+ if (inmenu)
+ clean = true;
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ menu_mousefocus = -1;
+ }
+}
+
+void menuZgi::process(uint32 deltatime) {
+ if (clean) {
+ _engine->getRenderManager()->clearMenuSurface();
+ clean = false;
+ }
+ switch (menu_mousefocus) {
+ case menu_ITEM:
+ if (menu_bar_flag & menuBar_Items)
+ if (!scrolled[menu_ITEM]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_ITEM] += scrl;
+
+ if (scrollPos[menu_ITEM] >= 0) {
+ scrolled[menu_ITEM] = true;
+ scrollPos [menu_ITEM] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0);
+
+ int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (item_count == 0)
+ item_count = 20;
+ else if (item_count > 50)
+ item_count = 50;
+
+
+ for (int i = 0; i < item_count; i++) {
+ int itemspace = (600 - 28) / item_count;
+
+ bool inrect = false;
+
+ if (mouse_on_item == i)
+ inrect = true;
+
+ uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
+
+ if (cur_item_id != 0) {
+ if (item_id[i] != cur_item_id) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ items[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ items[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ item_id[i] = cur_item_id;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+
+ } else {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ items[i][0] = NULL;
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ items[i][1] = NULL;
+ }
+ item_id[i] = 0;
+ }
+ }
+
+ redraw = false;
+ }
+ break;
+
+ case menu_MAGIC:
+ if (menu_bar_flag & menuBar_Magic)
+ if (!scrolled[menu_MAGIC]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_MAGIC] += scrl;
+
+ if (scrollPos[menu_MAGIC] >= 600) {
+ scrolled[menu_MAGIC] = true;
+ scrollPos [menu_MAGIC] = 600;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0);
+
+ for (int i = 0; i < 12; i++) {
+ bool inrect = false;
+
+ if (mouse_on_item == i)
+ inrect = true;
+
+ uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ if (cur_item_id) {
+ if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ cur_item_id = 0xEE + i;
+ else
+ cur_item_id = 0xE0 + i;
+ }
+
+ if (cur_item_id != 0) {
+ if (item_id[i] != cur_item_id) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ magic[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ magic[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ magic_id[i] = cur_item_id;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+
+ } else {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ magic[i][0] = NULL;
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ magic[i][1] = NULL;
+ }
+ magic_id[i] = 0;
+ }
+ }
+ redraw = false;
+ }
+ break;
+
+ case menu_MAIN:
+ if (!scrolled[menu_MAIN]) {
+ redraw = true;
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [menu_MAIN] += scrl;
+
+ if (scrollPos[menu_MAIN] >= 0) {
+ scrolled[menu_MAIN] = true;
+ scrollPos [menu_MAIN] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
+
+ if (menu_bar_flag & menuBar_Exit) {
+ if (mouse_on_item == menu_MAIN_EXIT)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Settings) {
+ if (mouse_on_item == menu_MAIN_PREF)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Restore) {
+ if (mouse_on_item == menu_MAIN_REST)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
+ }
+ if (menu_bar_flag & menuBar_Save) {
+ if (mouse_on_item == menu_MAIN_SAVE)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ }
+ redraw = false;
+ }
+ break;
+ default:
+ if (redraw) {
+ if (inmenu) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0);
+
+ if (menu_bar_flag & menuBar_Items)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0);
+
+ if (menu_bar_flag & menuBar_Magic)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0);
+ }
+ redraw = false;
+ }
+ break;
+ }
+}
+
+
+menuNem::menuNem(ZVision *engine) :
+ menuHandler(engine) {
+ inmenu = false;
+ scrolled = false;
+ scrollPos = 0.0;
+ mouse_on_item = -1;
+
+ char buf[24];
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++) {
+ sprintf(buf, "butfrm%d%d.tga", i + 1, j);
+ _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false);
+ }
+
+ _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false);
+
+ frm = 0;
+}
+
+menuNem::~menuNem() {
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++)
+ but[i][j].free();
+
+ menubar.free();
+}
+
+static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} };
+
+void menuNem::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ // ifquit();
+ frm = 5;
+ redraw = true;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+ }
+}
+
+void menuNem::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ inmenu = true;
+
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+
+ int last_item = mouse_on_item;
+ mouse_on_item = -1;
+
+ // Exit
+ if (menu_bar_flag & menuBar_Exit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_EXIT;
+ }
+
+ // Settings
+ if (menu_bar_flag & menuBar_Settings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_PREF;
+ }
+
+ // Load
+ if (menu_bar_flag & menuBar_Restore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_REST;
+ }
+
+ // Save
+ if (menu_bar_flag & menuBar_Save)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ mouse_on_item = menu_MAIN_SAVE;
+ }
+
+ if (last_item != mouse_on_item) {
+ redraw = true;
+ frm = 0;
+ delay = 200;
+ }
+ } else {
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ mouse_on_item = -1;
+ }
+}
+
+void menuNem::process(uint32 deltatime) {
+ if (inmenu) {
+ if (!scrolled) {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos += scrl;
+ redraw = true;
+ }
+
+ if (scrollPos >= 0) {
+ scrolled = true;
+ scrollPos = 0;
+ }
+
+ if (mouse_on_item != -1) {
+ delay -= deltatime;
+ if (delay <= 0 && frm < 4) {
+ delay = 200;
+ frm++;
+ redraw = true;
+ }
+ }
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+
+ if (menu_bar_flag & menuBar_Exit)
+ if (mouse_on_item == menu_MAIN_EXIT)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Settings)
+ if (mouse_on_item == menu_MAIN_PREF)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Restore)
+ if (mouse_on_item == menu_MAIN_REST)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
+
+ if (menu_bar_flag & menuBar_Save)
+ if (mouse_on_item == menu_MAIN_SAVE)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
+
+ redraw = false;
+ }
+ } else {
+ scrolled = false;
+ if (scrollPos > -32) {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1);
+ _engine->getRenderManager()->clearMenuSurface(cl);
+
+ scrollPos -= scrl;
+ redraw = true;
+ } else
+ scrollPos = -32;
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+ redraw = false;
+ }
+ }
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp
new file mode 100644
index 0000000..fe99772
--- /dev/null
+++ b/engines/zvision/core/search_manager.cpp
@@ -0,0 +1,274 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+#include "common/debug.h"
+
+#include "zvision/core/search_manager.h"
+#include "zvision/archives/zfs_archive.h"
+#include "common/fs.h"
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+sManager::sManager(const Common::String &root_path, int depth) {
+ _root = root_path;
+ if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/')
+ _root.deleteLastChar();
+
+ Common::FSNode fs_node(_root);
+
+ list_dir_recursive(dir_list, fs_node, depth);
+
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end();)
+ if (it->size() == _root.size())
+ it = dir_list.erase(it);
+ else if (it->size() > _root.size()) {
+ *it = Common::String(it->c_str() + _root.size() + 1);
+ it++;
+ } else
+ it++;
+}
+
+sManager::~sManager() {
+ Common::List<Common::Archive *>::iterator it = archList.begin();
+ while (it != archList.end()) {
+ delete *it;
+ it++;
+ }
+
+ archList.clear();
+}
+
+void sManager::addPatch(const Common::String &src, const Common::String &dst) {
+ Common::String lw_name = dst;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator it = files.find(lw_name);
+
+ if (it != files.end()) {
+ lw_name = src;
+ lw_name.toLowercase();
+ files[lw_name] = it->_value;
+ }
+}
+
+void sManager::addFile(const Common::String &name, Common::Archive *arch) {
+ bool addArch = true;
+ Common::List<Common::Archive *>::iterator it = archList.begin();
+ while (it != archList.end()) {
+ if (*it == arch) {
+ addArch = false;
+ break;
+ }
+ it++;
+ }
+ if (addArch)
+ archList.push_back(arch);
+
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::Node nod;
+ nod.name = lw_name;
+ nod.arch = arch;
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit == files.end()) {
+ files[lw_name] = nod;
+ } else {
+ Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
+ if (stream) {
+ if (stream->size() < 10)
+ fit->_value.arch = arch;
+ delete stream;
+ } else {
+ files[lw_name] = nod;
+ }
+ }
+}
+
+Common::File *sManager::openFile(const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end()) {
+ Common::File *tmp = new Common::File();
+ tmp->open(fit->_value.name, *fit->_value.arch);
+ return tmp;
+ }
+ return NULL;
+}
+
+bool sManager::openFile(Common::File &file, const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end())
+ return file.open(fit->_value.name, *fit->_value.arch);
+ return false;
+}
+
+bool sManager::hasFile(const Common::String &name) {
+ Common::String lw_name = name;
+ lw_name.toLowercase();
+
+ sManager::MatchList::iterator fit = files.find(lw_name);
+
+ if (fit != files.end())
+ return true;
+ return false;
+}
+
+void sManager::loadZix(const Common::String &name) {
+ Common::File file;
+ file.open(name);
+
+ Common::String line;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ if (line.matchString("----------*", true))
+ break;
+ }
+
+ if (file.eos())
+ return;
+
+ Common::Array<Common::Archive *> archives;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ if (line.matchString("----------*", true))
+ break;
+ else if (line.matchString("DIR:*", true)) {
+ Common::String path(line.c_str() + 5);
+ Common::Archive *arc;
+ char n_path[128];
+ strcpy(n_path, path.c_str());
+ for (uint i = 0; i < path.size(); i++)
+ if (n_path[i] == '\\')
+ n_path[i] = '/';
+
+ path = Common::String(n_path);
+ if (path.size() && path[0] == '.')
+ path.deleteChar(0);
+ if (path.size() && path[0] == '/')
+ path.deleteChar(0);
+
+ if (path.matchString("*.zfs", true))
+ arc = new ZfsArchive(path);
+ else {
+ if (path.size()) {
+ if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/')
+ path.deleteLastChar();
+ if (path.size())
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ if (path.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+ }
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ arc = new Common::FSDirectory(path);
+ }
+ archives.push_back(arc);
+ }
+ }
+
+ if (file.eos())
+ return;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ uint dr = 0;
+ char buf[32];
+ if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
+ if (dr <= archives.size() && dr > 0) {
+ addFile(Common::String(buf), archives[dr - 1]);
+ }
+ }
+ }
+}
+
+void sManager::addDir(const Common::String &name) {
+ Common::String path;
+ for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ if (name.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+
+ if (path.size() == 0)
+ return;
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ Common::FSDirectory *dir = new Common::FSDirectory(path);
+
+ Common::ArchiveMemberList list;
+ dir->listMatchingMembers(list, "*.zfs");
+
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+
+ ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str()));
+
+ Common::ArchiveMemberList zfslist;
+ zfs->listMembers(zfslist);
+
+ for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
+ Common::String z_name = (*ziter)->getName();
+ addFile(z_name, zfs);
+ }
+ }
+
+ list.clear();
+ dir->listMembers(list);
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+ addFile(flname, dir);
+ }
+}
+
+void sManager::list_dir_recursive(Common::List<Common::String> &_list, const Common::FSNode &fs_node, int depth) {
+ Common::FSList fs_list;
+ fs_node.getChildren(fs_list);
+
+ _list.push_back(fs_node.getPath());
+
+ if (depth > 1)
+ for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it)
+ list_dir_recursive(_list, *it, depth - 1);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h
new file mode 100644
index 0000000..c768cb8
--- /dev/null
+++ b/engines/zvision/core/search_manager.h
@@ -0,0 +1,51 @@
+#ifndef SEARCH_MANAGER_H_INCLUDED
+#define SEARCH_MANAGER_H_INCLUDED
+
+#include "common/str.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/list.h"
+
+namespace ZVision {
+
+class sManager {
+public:
+ sManager(const Common::String &root_path, int depth);
+ ~sManager();
+
+ void addFile(const Common::String &name, Common::Archive *arch);
+ void addDir(const Common::String &name);
+ void addPatch(const Common::String &src, const Common::String &dst);
+
+ Common::File *openFile(const Common::String &name);
+ bool openFile(Common::File &file, const Common::String &name);
+ bool hasFile(const Common::String &name);
+
+ void loadZix(const Common::String &name);
+
+private:
+
+ void list_dir_recursive(Common::List<Common::String> &dir_list, const Common::FSNode &fs_node, int depth);
+
+ struct Node {
+ Common::String name;
+ Common::Archive *arch;
+ };
+
+ Common::List<Common::String> dir_list;
+
+ typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList;
+
+ Common::List<Common::Archive *> archList;
+ MatchList files;
+
+ Common::String _root;
+
+private:
+};
+
+}
+
+#endif // SEARCH_MANAGER_H_INCLUDED
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index c9dc5d3..f3b01b7 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -24,7 +24,7 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/text.h"
+#include "zvision/text/text.h"
#include "zvision/utility/lzss_read_stream.h"
diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp
deleted file mode 100644
index f8b2297..0000000
--- a/engines/zvision/inventory_manager.cpp
+++ /dev/null
@@ -1,123 +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/scripting/script_manager.h"
-
-
-namespace ZVision {
-
-int8 ScriptManager::invertory_getCount() {
- return getStateValue(StateKey_Inv_Cnt_Slot);
-}
-
-void ScriptManager::invertory_setCount(int8 cnt) {
- setStateValue(StateKey_Inv_Cnt_Slot, cnt);
-}
-
-int16 ScriptManager::invertory_getItem(int8 id) {
- if (id < 49 && id >= 0)
- return getStateValue(StateKey_Inv_1_Slot + id);
- return -1;
-}
-
-void ScriptManager::invertory_setItem(int8 id, int16 item) {
- if (id < 49 && id >= 0)
- setStateValue(StateKey_Inv_1_Slot + id, item);
-}
-
-void ScriptManager::invertory_add(int16 item) {
- int8 cnt = invertory_getCount();
-
- if (cnt < 49) {
- bool not_exist = true;
-
- if (cnt == 0) {
- invertory_setItem(0, 0);
- invertory_setCount(1); // we needed empty item for cycle code
- cnt = 1;
- }
-
- for (int8 cur = 0; cur < cnt; cur++)
- if (invertory_getItem(cur) == item) {
- not_exist = false;
- break;
- }
-
- if (not_exist) {
- for (int8 i = cnt; i > 0; i--)
- invertory_setItem(i, invertory_getItem(i - 1));
-
- invertory_setItem(0, item);
-
- setStateValue(StateKey_InventoryItem, item);
-
- invertory_setCount(cnt + 1);
- }
- }
-}
-
-void ScriptManager::invertory_drop(int16 item) {
- int8 items_cnt = invertory_getCount();
-
- // if items in inventory > 0
- if (items_cnt != 0) {
- int8 index = 0;
-
- // finding needed item
- while (index < items_cnt) {
- if (invertory_getItem(index) == item)
- break;
-
- index++;
- }
-
- // if item in the inventory
- if (items_cnt != index) {
- // shift all items left with rewrite founded item
- for (int8 v = index; v < items_cnt - 1 ; v++)
- invertory_setItem(v, invertory_getItem(v + 1));
-
- // del last item
- invertory_setItem(items_cnt - 1, 0);
- invertory_setCount(invertory_getCount() - 1);
-
- setStateValue(StateKey_InventoryItem, invertory_getItem(0));
- }
- }
-}
-void ScriptManager::invertory_cycle() {
- int8 item_cnt = invertory_getCount();
- int8 cur_item = invertory_getItem(0);
- if (item_cnt > 1) {
- for (int8 i = 0; i < item_cnt - 1; i++)
- invertory_setItem(i, invertory_getItem(i + 1));
-
- invertory_setItem(item_cnt - 1, cur_item);
-
- setStateValue(StateKey_InventoryItem, invertory_getItem(0));
-
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp
deleted file mode 100644
index bf311c4..0000000
--- a/engines/zvision/menu.cpp
+++ /dev/null
@@ -1,765 +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/core/menu.h"
-
-#include "zvision/graphics/render_manager.h"
-
-
-namespace ZVision {
-
-enum {
- SLOT_START_SLOT = 151,
- SLOT_SPELL_1 = 191,
- SLOT_USER_CHOSE_THIS_SPELL = 205,
- SLOT_REVERSED_SPELLBOOK = 206
-};
-
-enum {
- menu_MAIN_SAVE = 0,
- menu_MAIN_REST = 1,
- menu_MAIN_PREF = 2,
- menu_MAIN_EXIT = 3
-};
-
-menuHandler::menuHandler(ZVision *engine) {
- _engine = engine;
- menu_bar_flag = 0xFFFF;
-}
-
-menuZgi::menuZgi(ZVision *engine) :
- menuHandler(engine) {
- menu_mousefocus = -1;
- inmenu = false;
- scrolled[0] = false;
- scrolled[1] = false;
- scrolled[2] = false;
- scrollPos[0] = 0.0;
- scrollPos[1] = 0.0;
- scrollPos[2] = 0.0;
- mouse_on_item = -1;
-
- char buf[24];
- for (int i = 1; i < 4; i++) {
- sprintf(buf, "gmzau%2.2x1.tga", i);
- _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false);
- sprintf(buf, "gmzau%2.2x1.tga", i + 0x10);
- _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false);
- }
- for (int i = 0; i < 4; i++) {
- sprintf(buf, "gmzmu%2.2x1.tga", i);
- _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false);
- sprintf(buf, "gmznu%2.2x1.tga", i);
- _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false);
- }
-
- for (int i = 0; i < 50; i++) {
- items[i][0] = NULL;
- items[i][1] = NULL;
- item_id[i] = 0;
- }
-
- for (int i = 0; i < 12; i++) {
- magic[i][0] = NULL;
- magic[i][1] = NULL;
- magic_id[i] = 0;
- }
-}
-
-menuZgi::~menuZgi() {
- for (int i = 0; i < 3; i++) {
- menuback[i][0].free();
- menuback[i][1].free();
- }
- for (int i = 0; i < 4; i++) {
- menubar[i][0].free();
- menubar[i][1].free();
- }
- for (int i = 0; i < 50; i++) {
- if (items[i][0]) {
- items[i][0]->free();
- delete items[i][0];
- }
- if (items[i][1]) {
- items[i][1]->free();
- delete items[i][1];
- }
- }
- for (int i = 0; i < 12; i++) {
- if (magic[i][0]) {
- magic[i][0]->free();
- delete magic[i][0];
- }
- if (magic[i][1]) {
- magic[i][1]->free();
- delete magic[i][1];
- }
- }
-}
-
-void menuZgi::onMouseUp(const Common::Point &Pos) {
- if (Pos.y < 40) {
- switch (menu_mousefocus) {
- case menu_ITEM:
- if (menu_bar_flag & menuBar_Items) {
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
-
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
-
- if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
- scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
- int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
- if (mouse_item >= 0 && mouse_item < 0xE0) {
- _engine->getScriptManager()->invertory_drop(mouse_item);
- _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i));
- _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item);
-
- redraw = true;
- }
- }
- }
- }
- break;
-
- case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic) {
- for (int i = 0; i < 12; i++) {
-
- uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
- if (itemnum != 0) {
- if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
- itemnum = 0xEE + i;
- else
- itemnum = 0xE0 + i;
- }
- if (itemnum)
- if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0)
- if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
- 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos))
- _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum);
- }
-
- }
- break;
-
- case menu_MAIN:
-
- // Exit
- if (menu_bar_flag & menuBar_Exit)
- if (Common::Rect(320 + 135,
- scrollPos[menu_MAIN],
- 320 + 135 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- // ifquit();
- }
-
- // Settings
- if (menu_bar_flag & menuBar_Settings)
- if (Common::Rect(320 ,
- scrollPos[menu_MAIN],
- 320 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
- }
-
- // Load
- if (menu_bar_flag & menuBar_Restore)
- if (Common::Rect(320 - 135,
- scrollPos[menu_MAIN],
- 320,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
- }
-
- // Save
- if (menu_bar_flag & menuBar_Save)
- if (Common::Rect(320 - 135 * 2,
- scrollPos[menu_MAIN],
- 320 - 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
- }
- break;
- }
- }
-}
-
-void menuZgi::onMouseMove(const Common::Point &Pos) {
- if (Pos.y < 40) {
-
- if (!inmenu)
- redraw = true;
- inmenu = true;
- switch (menu_mousefocus) {
- case menu_ITEM:
- if (menu_bar_flag & menuBar_Items) {
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
- else if (item_count > 50)
- item_count = 50;
-
- int last_item = mouse_on_item;
-
- mouse_on_item = -1;
-
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
-
- if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
- scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
- mouse_on_item = i;
- break;
- }
- }
-
- if (last_item != mouse_on_item)
- if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) ||
- _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item))
- redraw = true;
- }
- break;
-
- case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic) {
- int last_item = mouse_on_item;
- mouse_on_item = -1;
- for (int i = 0; i < 12; i++) {
- if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
- 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) {
- mouse_on_item = i;
- break;
- }
- }
-
- if (last_item != mouse_on_item)
- if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) ||
- _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item))
- redraw = true;
-
- }
- break;
-
- case menu_MAIN: {
- int last_item = mouse_on_item;
- mouse_on_item = -1;
-
- // Exit
- if (menu_bar_flag & menuBar_Exit)
- if (Common::Rect(320 + 135,
- scrollPos[menu_MAIN],
- 320 + 135 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_EXIT;
- }
-
- // Settings
- if (menu_bar_flag & menuBar_Settings)
- if (Common::Rect(320 ,
- scrollPos[menu_MAIN],
- 320 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_PREF;
- }
-
- // Load
- if (menu_bar_flag & menuBar_Restore)
- if (Common::Rect(320 - 135,
- scrollPos[menu_MAIN],
- 320,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_REST;
- }
-
- // Save
- if (menu_bar_flag & menuBar_Save)
- if (Common::Rect(320 - 135 * 2,
- scrollPos[menu_MAIN],
- 320 - 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_SAVE;
- }
-
- if (last_item != mouse_on_item)
- redraw = true;
- }
- break;
-
- default:
- int cur_menu = menu_mousefocus;
- if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main
- menu_mousefocus = menu_MAIN;
- scrolled[menu_MAIN] = false;
- scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h;
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
- }
-
- if (menu_bar_flag & menuBar_Magic)
- if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
- menu_mousefocus = menu_MAGIC;
- scrolled[menu_MAGIC] = false;
- scrollPos[menu_MAGIC] = 28;
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
- }
-
- if (menu_bar_flag & menuBar_Items)
- if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
- menu_mousefocus = menu_ITEM;
- scrolled[menu_ITEM] = false;
- scrollPos[menu_ITEM] = 28 - 600;
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
- }
-
- if (cur_menu != menu_mousefocus)
- clean = true;
-
- break;
- }
- } else {
- if (inmenu)
- clean = true;
- inmenu = false;
- if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
- menu_mousefocus = -1;
- }
-}
-
-void menuZgi::process(uint32 deltatime) {
- if (clean) {
- _engine->getRenderManager()->clearMenuSurface();
- clean = false;
- }
- switch (menu_mousefocus) {
- case menu_ITEM:
- if (menu_bar_flag & menuBar_Items)
- if (!scrolled[menu_ITEM]) {
- redraw = true;
- float scrl = 600.0 * (deltatime / 1000.0);
-
- if (scrl == 0)
- scrl = 1.0;
-
- scrollPos [menu_ITEM] += scrl;
-
- if (scrollPos[menu_ITEM] >= 0) {
- scrolled[menu_ITEM] = true;
- scrollPos [menu_ITEM] = 0;
- }
- }
- if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0);
-
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
- else if (item_count > 50)
- item_count = 50;
-
-
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
-
- bool inrect = false;
-
- if (mouse_on_item == i)
- inrect = true;
-
- uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
-
- if (cur_item_id != 0) {
- if (item_id[i] != cur_item_id) {
- char buf[16];
- sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
- items[i][0] = _engine->getRenderManager()->loadImage(buf, false);
- sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
- items[i][1] = _engine->getRenderManager()->loadImage(buf, false);
- item_id[i] = cur_item_id;
- }
-
- if (inrect)
- _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
-
- } else {
- if (items[i][0]) {
- items[i][0]->free();
- delete items[i][0];
- items[i][0] = NULL;
- }
- if (items[i][1]) {
- items[i][1]->free();
- delete items[i][1];
- items[i][1] = NULL;
- }
- item_id[i] = 0;
- }
- }
-
- redraw = false;
- }
- break;
-
- case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic)
- if (!scrolled[menu_MAGIC]) {
- redraw = true;
- float scrl = 600.0 * (deltatime / 1000.0);
-
- if (scrl == 0)
- scrl = 1.0;
-
- scrollPos [menu_MAGIC] += scrl;
-
- if (scrollPos[menu_MAGIC] >= 600) {
- scrolled[menu_MAGIC] = true;
- scrollPos [menu_MAGIC] = 600;
- }
- }
- if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0);
-
- for (int i = 0; i < 12; i++) {
- bool inrect = false;
-
- if (mouse_on_item == i)
- inrect = true;
-
- uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
- if (cur_item_id) {
- if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
- cur_item_id = 0xEE + i;
- else
- cur_item_id = 0xE0 + i;
- }
-
- if (cur_item_id != 0) {
- if (item_id[i] != cur_item_id) {
- char buf[16];
- sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
- magic[i][0] = _engine->getRenderManager()->loadImage(buf, false);
- sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
- magic[i][1] = _engine->getRenderManager()->loadImage(buf, false);
- magic_id[i] = cur_item_id;
- }
-
- if (inrect)
- _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
-
- } else {
- if (magic[i][0]) {
- magic[i][0]->free();
- delete magic[i][0];
- magic[i][0] = NULL;
- }
- if (magic[i][1]) {
- magic[i][1]->free();
- delete magic[i][1];
- magic[i][1] = NULL;
- }
- magic_id[i] = 0;
- }
- }
- redraw = false;
- }
- break;
-
- case menu_MAIN:
- if (!scrolled[menu_MAIN]) {
- redraw = true;
- float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
-
- if (scrl == 0)
- scrl = 1.0;
-
- scrollPos [menu_MAIN] += scrl;
-
- if (scrollPos[menu_MAIN] >= 0) {
- scrolled[menu_MAIN] = true;
- scrollPos [menu_MAIN] = 0;
- }
- }
- if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
-
- if (menu_bar_flag & menuBar_Exit) {
- if (mouse_on_item == menu_MAIN_EXIT)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
- }
- if (menu_bar_flag & menuBar_Settings) {
- if (mouse_on_item == menu_MAIN_PREF)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
- }
- if (menu_bar_flag & menuBar_Restore) {
- if (mouse_on_item == menu_MAIN_REST)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
- }
- if (menu_bar_flag & menuBar_Save) {
- if (mouse_on_item == menu_MAIN_SAVE)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
- else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]);
- }
- redraw = false;
- }
- break;
- default:
- if (redraw) {
- if (inmenu) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0);
-
- if (menu_bar_flag & menuBar_Items)
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0);
-
- if (menu_bar_flag & menuBar_Magic)
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0);
- }
- redraw = false;
- }
- break;
- }
-}
-
-
-menuNem::menuNem(ZVision *engine) :
- menuHandler(engine) {
- inmenu = false;
- scrolled = false;
- scrollPos = 0.0;
- mouse_on_item = -1;
-
- char buf[24];
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 6; j++) {
- sprintf(buf, "butfrm%d%d.tga", i + 1, j);
- _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false);
- }
-
- _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false);
-
- frm = 0;
-}
-
-menuNem::~menuNem() {
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 6; j++)
- but[i][j].free();
-
- menubar.free();
-}
-
-static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} };
-
-void menuNem::onMouseUp(const Common::Point &Pos) {
- if (Pos.y < 40) {
- // Exit
- if (menu_bar_flag & menuBar_Exit)
- if (Common::Rect(buts[3][1],
- scrollPos,
- buts[3][0] + buts[3][1],
- scrollPos + 32).contains(Pos)) {
- // ifquit();
- frm = 5;
- redraw = true;
- }
-
- // Settings
- if (menu_bar_flag & menuBar_Settings)
- if (Common::Rect(buts[2][1],
- scrollPos,
- buts[2][0] + buts[2][1],
- scrollPos + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
- frm = 5;
- redraw = true;
- }
-
- // Load
- if (menu_bar_flag & menuBar_Restore)
- if (Common::Rect(buts[1][1],
- scrollPos,
- buts[1][0] + buts[1][1],
- scrollPos + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
- frm = 5;
- redraw = true;
- }
-
- // Save
- if (menu_bar_flag & menuBar_Save)
- if (Common::Rect(buts[0][1],
- scrollPos,
- buts[0][0] + buts[0][1],
- scrollPos + 32).contains(Pos)) {
- _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
- frm = 5;
- redraw = true;
- }
- }
-}
-
-void menuNem::onMouseMove(const Common::Point &Pos) {
- if (Pos.y < 40) {
-
- inmenu = true;
-
- if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2)
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
-
- int last_item = mouse_on_item;
- mouse_on_item = -1;
-
- // Exit
- if (menu_bar_flag & menuBar_Exit)
- if (Common::Rect(buts[3][1],
- scrollPos,
- buts[3][0] + buts[3][1],
- scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_EXIT;
- }
-
- // Settings
- if (menu_bar_flag & menuBar_Settings)
- if (Common::Rect(buts[2][1],
- scrollPos,
- buts[2][0] + buts[2][1],
- scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_PREF;
- }
-
- // Load
- if (menu_bar_flag & menuBar_Restore)
- if (Common::Rect(buts[1][1],
- scrollPos,
- buts[1][0] + buts[1][1],
- scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_REST;
- }
-
- // Save
- if (menu_bar_flag & menuBar_Save)
- if (Common::Rect(buts[0][1],
- scrollPos,
- buts[0][0] + buts[0][1],
- scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_SAVE;
- }
-
- if (last_item != mouse_on_item) {
- redraw = true;
- frm = 0;
- delay = 200;
- }
- } else {
- inmenu = false;
- if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
- _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
- mouse_on_item = -1;
- }
-}
-
-void menuNem::process(uint32 deltatime) {
- if (inmenu) {
- if (!scrolled) {
- float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
-
- if (scrl == 0)
- scrl = 1.0;
-
- scrollPos += scrl;
- redraw = true;
- }
-
- if (scrollPos >= 0) {
- scrolled = true;
- scrollPos = 0;
- }
-
- if (mouse_on_item != -1) {
- delay -= deltatime;
- if (delay <= 0 && frm < 4) {
- delay = 200;
- frm++;
- redraw = true;
- }
- }
-
- if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
-
- if (menu_bar_flag & menuBar_Exit)
- if (mouse_on_item == menu_MAIN_EXIT)
- _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
-
- if (menu_bar_flag & menuBar_Settings)
- if (mouse_on_item == menu_MAIN_PREF)
- _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
-
- if (menu_bar_flag & menuBar_Restore)
- if (mouse_on_item == menu_MAIN_REST)
- _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
-
- if (menu_bar_flag & menuBar_Save)
- if (mouse_on_item == menu_MAIN_SAVE)
- _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
-
- redraw = false;
- }
- } else {
- scrolled = false;
- if (scrollPos > -32) {
- float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
-
- if (scrl == 0)
- scrl = 1.0;
-
- Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1);
- _engine->getRenderManager()->clearMenuSurface(cl);
-
- scrollPos -= scrl;
- redraw = true;
- } else
- scrollPos = -32;
-
- if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
- redraw = false;
- }
- }
-}
-
-
-} // End of namespace ZVision
diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp
deleted file mode 100644
index dddc238..0000000
--- a/engines/zvision/meta_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 "zvision/meta_animation.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/animation/rlf_animation.h"
-#include "zvision/video/zork_avi_decoder.h"
-
-#include "video/video_decoder.h"
-
-#include "graphics/surface.h"
-
-
-namespace ZVision {
-
-MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
- : _fileType(RLF),
- _cur_frame(NULL) {
- if (fileName.hasSuffix(".rlf")) {
- _fileType = RLF;
- Common::File *_file = engine->getSearchManager()->openFile(fileName);
- _animation.rlf = new RlfAnimation(_file, false);
- _frmDelay = _animation.rlf->frameTime();
- } else if (fileName.hasSuffix(".avi")) {
- _fileType = AVI;
- Common::File *_file = engine->getSearchManager()->openFile(fileName);
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadStream(_file);
- _frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
- } else {
- warning("Unrecognized animation file type: %s", fileName.c_str());
- }
-}
-
-MetaAnimation::~MetaAnimation() {
- if (_fileType == RLF) {
- delete _animation.rlf;
- } else if (_fileType == AVI) {
- delete _animation.avi;
- }
-}
-
-uint MetaAnimation::frameCount() {
- if (_fileType == RLF) {
- return _animation.rlf->frameCount();
- } else
- return _animation.avi->getFrameCount();
-
-}
-
-uint MetaAnimation::width() {
- if (_fileType == RLF) {
- return _animation.rlf->width();
- } else
- return _animation.avi->getWidth();
-}
-uint MetaAnimation::height() {
- if (_fileType == RLF) {
- return _animation.rlf->height();
- } else
- return _animation.avi->getHeight();
-}
-uint32 MetaAnimation::frameTime() {
- return _frmDelay;
-}
-
-void MetaAnimation::seekToFrame(int frameNumber) {
- if (frameNumber >= (int)frameCount())
- frameNumber = frameCount() - 1;
-
- if (_fileType == RLF) {
- _animation.rlf->seekToFrame(frameNumber);
- } else
- _animation.avi->seekToFrame(frameNumber);
-}
-
-const Graphics::Surface *MetaAnimation::decodeNextFrame() {
- if (_fileType == RLF)
- _cur_frame = _animation.rlf->decodeNextFrame();
- else
- _cur_frame = _animation.avi->decodeNextFrame();
-
- return _cur_frame;
-}
-
-const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
- if (frameNumber >= frameCount())
- frameNumber = frameCount() - 1;
-
- if (_fileType == RLF) {
- _cur_frame = _animation.rlf->getFrameData(frameNumber);
- return _cur_frame;
- } else {
- _animation.avi->seekToFrame(frameNumber);
- _cur_frame = _animation.avi->decodeNextFrame();
- return _cur_frame;
- }
-}
-
-bool MetaAnimation::endOfAnimation() {
- if (_fileType == RLF) {
- return _animation.rlf->endOfAnimation();
- } else
- return _animation.avi->endOfVideo();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h
deleted file mode 100644
index 3754aae..0000000
--- a/engines/zvision/meta_animation.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * 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_METAANIM_NODE_H
-#define ZVISION_METAANIM_NODE_H
-
-#include "zvision/sidefx.h"
-#include "zvision/zvision.h"
-#include "common/rect.h"
-#include "common/list.h"
-
-
-namespace Common {
-class String;
-}
-
-namespace Video {
-class VideoDecoder;
-}
-
-namespace Graphics {
-struct Surface;
-}
-
-namespace ZVision {
-
-class ZVision;
-class RlfAnimation;
-
-class MetaAnimation {
-public:
- MetaAnimation(const Common::String &fileName, ZVision *engine);
- ~MetaAnimation();
-
- struct playnode {
- Common::Rect pos;
- int32 slot;
- int32 start;
- int32 stop;
- int32 loop;
- int32 _cur_frm;
- int32 _delay;
- Graphics::Surface *_scaled;
- };
-
-private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
-
-private:
- union {
- RlfAnimation *rlf;
- Video::VideoDecoder *avi;
- } _animation;
-
- FileType _fileType;
- int32 _frmDelay;
-
- const Graphics::Surface *_cur_frame;
-
-public:
-
- uint frameCount();
- uint width();
- uint height();
- uint32 frameTime();
-
- void seekToFrame(int frameNumber);
-
- const Graphics::Surface *decodeNextFrame();
- const Graphics::Surface *getFrameData(uint frameNumber);
-
- bool endOfAnimation();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index a386f6f..9d5072a 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,46 +1,46 @@
MODULE := engines/zvision
MODULE_OBJS := \
- scripting/actions.o \
- animation_node.o \
- utility/clock.o \
+ animation/meta_animation.o \
+ animation/rlf_animation.o \
+ archives/zfs_archive.o \
core/console.o \
- scripting/control.o \
- cursors/cursor.o \
+ core/events.o \
+ core/menu.o \
+ core/save_manager.o \
+ core/search_manager.o \
cursors/cursor_manager.o \
+ cursors/cursor.o \
detection.o \
- core/events.o \
+ fonts/truetype_font.o \
+ graphics/render_manager.o \
+ graphics/render_table.o \
+ scripting/actions.o \
+ scripting/control.o \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
- utility/lzss_read_stream.o \
scripting/controls/push_toggle_control.o \
- graphics/render_manager.o \
- graphics/render_table.o \
- animation/rlf_animation.o \
- core/save_manager.o \
+ scripting/controls/slot_control.o \
+ scripting/inventory.o \
scripting/scr_file_handling.o \
scripting/script_manager.o \
+ scripting/sidefx.o \
+ scripting/sidefx/animation_node.o \
+ scripting/sidefx/music_node.o \
+ scripting/sidefx/syncsound_node.o \
+ scripting/sidefx/timer_node.o \
+ scripting/sidefx/ttytext_node.o \
+ sound/zork_raw.o \
+ subtitles/subtitles.o \
+ text/string_manager.o \
+ text/text.o \
+ utility/clock.o \
+ utility/lzss_read_stream.o \
utility/single_value_container.o \
- strings/string_manager.o \
- scripting/controls/timer_node.o \
- fonts/truetype_font.o \
utility/utility.o \
video/video.o \
- zvision.o \
- archives/zfs_archive.o \
video/zork_avi_decoder.o \
- sound/zork_raw.o \
- sidefx.o \
- music_node.o \
- inventory_manager.o \
- slot_control.o \
- menu.o \
- meta_animation.o \
- search_manager.o \
- text.o \
- subtitles.o \
- syncsound_node.o \
- ttytext_node.o
+ zvision.o
MODULE_DIRS += \
engines/zvision
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp
deleted file mode 100644
index f8fd08b..0000000
--- a/engines/zvision/music_node.cpp
+++ /dev/null
@@ -1,190 +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/music_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-#include "audio/decoders/wave.h"
-
-
-namespace ZVision {
-
-MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
- : SideFX(engine, key, SIDEFX_AUDIO) {
- _loop = loop;
- _volume = volume;
- _crossfade = false;
- _crossfade_target = 0;
- _crossfade_time = 0;
- _attenuate = 0;
- _pantrack = false;
- _pantrack_X = 0;
- _sub = NULL;
-
- Audio::RewindableAudioStream *audioStream;
-
- if (filename.contains(".wav")) {
- Common::File *file = new Common::File();
- if (_engine->getSearchManager()->openFile(*file, filename)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- }
- } else {
- audioStream = makeRawZorkStream(filename, _engine);
- }
-
- _stereo = audioStream->isStereo();
-
- if (_loop) {
- Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
- } else {
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
- }
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-
- Common::String subname = filename;
- subname.setChar('s', subname.size() - 3);
- subname.setChar('u', subname.size() - 2);
- subname.setChar('b', subname.size() - 1);
-
- if (_engine->getSearchManager()->hasFile(subname))
- _sub = new Subtitle(_engine, subname);
-}
-
-MusicNode::~MusicNode() {
- _engine->_mixer->stopHandle(_handle);
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- if (_sub)
- delete _sub;
- debug(1, "MusicNode: %d destroyed\n", _key);
-}
-
-void MusicNode::setPanTrack(int16 pos) {
- if (!_stereo) {
- _pantrack = true;
- _pantrack_X = pos;
- setVolume(_volume);
- }
-}
-
-void MusicNode::unsetPanTrack() {
- _pantrack = false;
- setVolume(_volume);
-}
-
-void MusicNode::setFade(int32 time, uint8 target) {
- _crossfade_target = target;
- _crossfade_time = time;
- _crossfade = true;
-}
-
-bool MusicNode::process(uint32 deltaTimeInMillis) {
- if (! _engine->_mixer->isSoundHandleActive(_handle))
- return stop();
- else {
- uint8 _newvol = _volume;
-
- if (_crossfade) {
- if (_crossfade_time > 0) {
- if ((int32)deltaTimeInMillis > _crossfade_time)
- deltaTimeInMillis = _crossfade_time;
- _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis;
- _crossfade_time -= deltaTimeInMillis;
- } else {
- _crossfade = false;
- _newvol = _crossfade_target;
- }
- }
-
- if (_pantrack || _volume != _newvol)
- setVolume(_newvol);
-
- if (_sub)
- _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
- }
- return false;
-}
-
-void MusicNode::setVolume(uint8 new_volume) {
- if (_pantrack) {
- int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
- cur_x -= _pantrack_X;
- int32 _width = _engine->getRenderManager()->getBkgSize().x;
- if (cur_x < (-_width) / 2)
- cur_x += _width;
- else if (cur_x >= _width / 2)
- cur_x -= _width;
-
- float norm = (float)cur_x / ((float)_width / 2.0);
- float lvl = fabs(norm);
- if (lvl > 0.5)
- lvl = (lvl - 0.5) * 1.7;
- else
- lvl = 1.0;
-
- float bal = sin(-norm * 3.1415926) * 127.0;
-
- if (_engine->_mixer->isSoundHandleActive(_handle)) {
- _engine->_mixer->setChannelBalance(_handle, bal);
- _engine->_mixer->setChannelVolume(_handle, new_volume * lvl);
- }
- } else {
- if (_engine->_mixer->isSoundHandleActive(_handle)) {
- _engine->_mixer->setChannelBalance(_handle, 0);
- _engine->_mixer->setChannelVolume(_handle, new_volume);
- }
- }
-
- _volume = new_volume;
-}
-
-PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
- : SideFX(engine, key, SIDEFX_PANTRACK) {
- _slot = slot;
-
- SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
- if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode *mus = (MusicNode *)fx;
- mus->setPanTrack(pos);
- }
-}
-
-PanTrackNode::~PanTrackNode() {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
- if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode *mus = (MusicNode *)fx;
- mus->unsetPanTrack();
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h
deleted file mode 100644
index 0dad226..0000000
--- a/engines/zvision/music_node.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_MUSIC_NODE_H
-#define ZVISION_MUSIC_NODE_H
-
-#include "audio/mixer.h"
-#include "zvision/sidefx.h"
-#include "zvision/subtitles/subtitles.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-class MusicNode : public SideFX {
-public:
- MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
- ~MusicNode();
-
- /**
- * 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);
-
- void setVolume(uint8 volume);
-
- void setPanTrack(int16 pos);
- void unsetPanTrack();
-
- void setFade(int32 time, uint8 target);
-
-private:
- int32 _timeLeft;
- bool _pantrack;
- int32 _pantrack_X;
- int32 _attenuate;
- uint8 _volume;
- bool _loop;
- bool _crossfade;
- uint8 _crossfade_target;
- int32 _crossfade_time;
- bool _stereo;
- Audio::SoundHandle _handle;
- Subtitle *_sub;
-};
-
-class PanTrackNode : public SideFX {
-public:
- PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
- ~PanTrackNode();
-
-private:
- uint32 _slot;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 3c341fb..22fbd4f 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -29,11 +29,11 @@
#include "zvision/graphics/render_manager.h"
#include "zvision/sound/zork_raw.h"
#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/scripting/controls/timer_node.h"
-#include "zvision/music_node.h"
-#include "zvision/syncsound_node.h"
-#include "zvision/animation_node.h"
-#include "zvision/ttytext_node.h"
+#include "zvision/scripting/sidefx/timer_node.h"
+#include "zvision/scripting/sidefx/music_node.h"
+#include "zvision/scripting/sidefx/syncsound_node.h"
+#include "zvision/scripting/sidefx/animation_node.h"
+#include "zvision/scripting/sidefx/ttytext_node.h"
#include "common/file.h"
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index ca707b5..ba1b634 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -26,7 +26,7 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/utility/utility.h"
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 4a63f22..6fcdb2c 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -24,7 +24,7 @@
#define ZVISION_INPUT_CONTROL_H
#include "zvision/scripting/control.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "common/rect.h"
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 121fab9..7e3ee77 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -28,7 +28,7 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
-#include "zvision/meta_animation.h"
+#include "zvision/animation/meta_animation.h"
#include "zvision/utility/utility.h"
#include "common/stream.h"
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
new file mode 100644
index 0000000..c85b02b
--- /dev/null
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -0,0 +1,219 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/slot_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key) {
+
+ _rendered_item = 0;
+ _bkg = NULL;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("hotspot", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _hotspot = Common::Rect(x, y, width, height);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("distance_id", true)) {
+ sscanf(values.c_str(), "%c", &_distance_id);
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ } else if (param.matchString("eligible_objects", true)) {
+ char buf[256];
+ memset(buf, 0, 256);
+ strcpy(buf, values.c_str());
+
+ char *curpos = buf;
+ char *strend = buf + strlen(buf);
+ while (true) {
+ char *st = curpos;
+
+ if (st >= strend)
+ break;
+
+ while (*curpos != ' ' && curpos < strend)
+ curpos++;
+
+ *curpos = 0;
+ curpos++;
+
+ int obj = atoi(st);
+
+ _eligible_objects.push_back(obj);
+ }
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_hotspot.isEmpty() || _rectangle.isEmpty()) {
+ warning("Slot %u was parsed incorrectly", key);
+ }
+}
+
+SlotControl::~SlotControl() {
+ // Clear the state value back to 0
+ //_engine->getScriptManager()->setStateValue(_key, 0);
+
+ if (_bkg)
+ delete _bkg;
+}
+
+bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ //ctrl_setvenus(ct);
+
+ int item = _engine->getScriptManager()->getStateValue(_key);
+ int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (item != 0) {
+ if (mouse_item != 0) {
+ if (eligeblity(mouse_item)) {
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ _engine->getScriptManager()->invertory_add(item);
+ _engine->getScriptManager()->setStateValue(_key, mouse_item);
+ }
+ } else {
+ _engine->getScriptManager()->invertory_add(item);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (mouse_item == 0) {
+ if (eligeblity(0)) {
+ _engine->getScriptManager()->invertory_drop(0);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (eligeblity(mouse_item)) {
+ _engine->getScriptManager()->setStateValue(_key, mouse_item);
+ _engine->getScriptManager()->invertory_drop(mouse_item);
+ }
+ }
+ return false;
+}
+
+bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+ return true;
+ }
+
+ return false;
+}
+
+bool SlotControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_engine->canRender()) {
+ int cur_item = _engine->getScriptManager()->getStateValue(_key);
+ if (cur_item != _rendered_item) {
+ if (_rendered_item != 0 && cur_item == 0) {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ _rendered_item = cur_item;
+ } else {
+ if (_rendered_item == 0) {
+ if (_bkg)
+ delete _bkg;
+
+ _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
+ } else {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ }
+
+ char buf[16];
+ if (_engine->getGameId() == GID_NEMESIS)
+ sprintf(buf, "%d%cobj.tga", cur_item, _distance_id);
+ else
+ sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item);
+
+ Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);
+
+ int16 drawx = _rectangle.left;
+ int16 drawy = _rectangle.top;
+
+ if (_rectangle.width() > srf->w)
+ drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2;
+
+ if (_rectangle.height() > srf->h)
+ drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2;
+
+ _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0);
+
+ delete srf;
+
+ _rendered_item = cur_item;
+ }
+ }
+ }
+ return false;
+}
+
+bool SlotControl::eligeblity(int item_id) {
+ for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
+ if (*it == item_id)
+ return true;
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h
new file mode 100644
index 0000000..0ac8ec9
--- /dev/null
+++ b/engines/zvision/scripting/controls/slot_control.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SLOT_CONTROL_H
+#define ZVISION_SLOT_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace ZVision {
+
+class SlotControl : public Control {
+public:
+ SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~SlotControl();
+
+ /**
+ * 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
+ */
+ bool 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);
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _rectangle;
+ Common::Rect _hotspot;
+
+ int _cursor;
+ char _distance_id;
+ int _venus_id;
+
+ int _rendered_item;
+
+ Common::List<int> _eligible_objects;
+
+ bool eligeblity(int item_id);
+
+ Graphics::Surface *_bkg;
+
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/controls/timer_node.cpp
deleted file mode 100644
index e68610f..0000000
--- a/engines/zvision/scripting/controls/timer_node.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 "zvision/scripting/controls/timer_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-
-#include "common/stream.h"
-
-
-namespace ZVision {
-
-TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : SideFX(engine, key, SIDEFX_TIMER) {
- if (_engine->getGameId() == GID_NEMESIS)
- _timeLeft = timeInSeconds * 1000;
- else if (_engine->getGameId() == GID_GRANDINQUISITOR)
- _timeLeft = timeInSeconds * 100;
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-TimerNode::~TimerNode() {
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
- if (timeLeft > 0)
- _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
-}
-
-bool TimerNode::process(uint32 deltaTimeInMillis) {
- _timeLeft -= deltaTimeInMillis;
-
- if (_timeLeft <= 0)
- return stop();
-
- return false;
-}
-
-bool TimerNode::stop() {
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- return true;
-}
-
-void TimerNode::serialize(Common::WriteStream *stream) {
- stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
- stream->writeUint32LE(8); // size
- stream->writeUint32LE(_key);
- stream->writeUint32LE(_timeLeft);
-}
-
-void TimerNode::deserialize(Common::SeekableReadStream *stream) {
- _timeLeft = stream->readUint32LE();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/timer_node.h b/engines/zvision/scripting/controls/timer_node.h
deleted file mode 100644
index f6584be..0000000
--- a/engines/zvision/scripting/controls/timer_node.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_TIMER_NODE_H
-#define ZVISION_TIMER_NODE_H
-
-#include "zvision/sidefx.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class TimerNode : public SideFX {
-public:
- TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
- ~TimerNode();
-
- /**
- * 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);
- void serialize(Common::WriteStream *stream);
- void deserialize(Common::SeekableReadStream *stream);
- inline bool needsSerialization() {
- return true;
- }
-
- bool stop();
-
-private:
- int32 _timeLeft;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp
new file mode 100644
index 0000000..f8b2297
--- /dev/null
+++ b/engines/zvision/scripting/inventory.cpp
@@ -0,0 +1,123 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* 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/scripting/script_manager.h"
+
+
+namespace ZVision {
+
+int8 ScriptManager::invertory_getCount() {
+ return getStateValue(StateKey_Inv_Cnt_Slot);
+}
+
+void ScriptManager::invertory_setCount(int8 cnt) {
+ setStateValue(StateKey_Inv_Cnt_Slot, cnt);
+}
+
+int16 ScriptManager::invertory_getItem(int8 id) {
+ if (id < 49 && id >= 0)
+ return getStateValue(StateKey_Inv_1_Slot + id);
+ return -1;
+}
+
+void ScriptManager::invertory_setItem(int8 id, int16 item) {
+ if (id < 49 && id >= 0)
+ setStateValue(StateKey_Inv_1_Slot + id, item);
+}
+
+void ScriptManager::invertory_add(int16 item) {
+ int8 cnt = invertory_getCount();
+
+ if (cnt < 49) {
+ bool not_exist = true;
+
+ if (cnt == 0) {
+ invertory_setItem(0, 0);
+ invertory_setCount(1); // we needed empty item for cycle code
+ cnt = 1;
+ }
+
+ for (int8 cur = 0; cur < cnt; cur++)
+ if (invertory_getItem(cur) == item) {
+ not_exist = false;
+ break;
+ }
+
+ if (not_exist) {
+ for (int8 i = cnt; i > 0; i--)
+ invertory_setItem(i, invertory_getItem(i - 1));
+
+ invertory_setItem(0, item);
+
+ setStateValue(StateKey_InventoryItem, item);
+
+ invertory_setCount(cnt + 1);
+ }
+ }
+}
+
+void ScriptManager::invertory_drop(int16 item) {
+ int8 items_cnt = invertory_getCount();
+
+ // if items in inventory > 0
+ if (items_cnt != 0) {
+ int8 index = 0;
+
+ // finding needed item
+ while (index < items_cnt) {
+ if (invertory_getItem(index) == item)
+ break;
+
+ index++;
+ }
+
+ // if item in the inventory
+ if (items_cnt != index) {
+ // shift all items left with rewrite founded item
+ for (int8 v = index; v < items_cnt - 1 ; v++)
+ invertory_setItem(v, invertory_getItem(v + 1));
+
+ // del last item
+ invertory_setItem(items_cnt - 1, 0);
+ invertory_setCount(invertory_getCount() - 1);
+
+ setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+ }
+ }
+}
+void ScriptManager::invertory_cycle() {
+ int8 item_cnt = invertory_getCount();
+ int8 cur_item = invertory_getItem(0);
+ if (item_cnt > 1) {
+ for (int8 i = 0; i < item_cnt - 1; i++)
+ invertory_setItem(i, invertory_getItem(i + 1));
+
+ invertory_setItem(item_cnt - 1, cur_item);
+
+ setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index fff187d..5d697bd 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -30,7 +30,7 @@
#include "zvision/scripting/actions.h"
#include "zvision/scripting/controls/push_toggle_control.h"
#include "zvision/scripting/controls/lever_control.h"
-#include "zvision/slot_control.h"
+#include "zvision/scripting/controls/slot_control.h"
#include "common/textconsole.h"
#include "common/file.h"
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 9713a34..a27ae4d 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -30,7 +30,7 @@
#include "zvision/core/save_manager.h"
#include "zvision/scripting/actions.h"
#include "zvision/utility/utility.h"
-#include "zvision/scripting/controls/timer_node.h"
+#include "zvision/scripting/sidefx/timer_node.h"
#include "common/algorithm.h"
#include "common/hashmap.h"
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index a835c13..8ec364b 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -25,7 +25,7 @@
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/control.h"
-#include "zvision/sidefx.h"
+#include "zvision/scripting/sidefx.h"
#include "common/hashmap.h"
#include "common/queue.h"
diff --git a/engines/zvision/scripting/sidefx.cpp b/engines/zvision/scripting/sidefx.cpp
new file mode 100644
index 0000000..c0b8a4d
--- /dev/null
+++ b/engines/zvision/scripting/sidefx.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/sidefx.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h
new file mode 100644
index 0000000..2c53467
--- /dev/null
+++ b/engines/zvision/scripting/sidefx.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SIDEFX_H_INCLUDED
+#define SIDEFX_H_INCLUDED
+
+namespace Common {
+class SeekableReadStream;
+struct Point;
+class WriteStream;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class SideFX {
+public:
+
+ enum SideFXType {
+ SIDEFX_ANIM = 1,
+ SIDEFX_AUDIO = 2,
+ SIDEFX_DISTORT = 4,
+ SIDEFX_PANTRACK = 8,
+ SIDEFX_REGION = 16,
+ SIDEFX_TIMER = 32,
+ SIDEFX_TTYTXT = 64,
+ SIDEFX_UNK = 128,
+ SIDEFX_ALL = 255
+ };
+
+ SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
+ SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {}
+ virtual ~SideFX() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+ SideFXType getType() {
+ return _type;
+ }
+
+ virtual bool process(uint32 deltaTimeInMillis) {
+ return false;
+ }
+ /**
+ * Serialize a SideFX for save game use. This should only be used if a SideFX 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
+ * SideFX 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 SideFX overrides serialize() and deserialize(), this should return true
+ *
+ * @return Does the SideFX need save game serialization?
+ */
+ virtual inline bool needsSerialization() {
+ return false;
+ }
+
+ virtual bool stop() {
+ return true;
+ }
+ virtual void kill() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ SideFXType _type;
+
+// Static member functions
+public:
+
+};
+
+// TODO: Implement InputControl
+// TODO: Implement SaveControl
+// TODO: Implement SlotControl
+// TODO: Implement SafeControl
+// TODO: Implement FistControl
+// TODO: Implement HotMovieControl
+// TODO: Implement PaintControl
+// TODO: Implement TilterControl
+
+} // End of namespace ZVision
+
+#endif // SIDEFX_H_INCLUDED
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
new file mode 100644
index 0000000..4a606ad
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/animation_node.cpp
@@ -0,0 +1,211 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/sidefx/animation_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/animation/meta_animation.h"
+
+#include "graphics/surface.h"
+
+
+namespace ZVision {
+
+AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse)
+ : SideFX(engine, controlKey, SIDEFX_ANIM),
+ _DisposeAfterUse(DisposeAfterUse),
+ _mask(mask),
+ _animation(NULL) {
+
+ if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
+ _animation = new MetaAnimation(fileName, engine);
+ _frmDelay = _animation->frameTime();
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+
+ if (frate > 0)
+ _frmDelay = 1000.0 / frate;
+}
+
+AnimationNode::~AnimationNode() {
+ if (_animation)
+ delete _animation;
+
+ _engine->getScriptManager()->setStateValue(_key, 2);
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ if ((*it)._scaled)
+ delete(*it)._scaled;
+ }
+
+ _playList.clear();
+}
+
+bool AnimationNode::process(uint32 deltaTimeInMillis) {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+
+ nod->_delay -= deltaTimeInMillis;
+ if (nod->_delay <= 0) {
+ nod->_delay += _frmDelay;
+
+ const Graphics::Surface *frame = NULL;
+
+ if (nod->_cur_frm == -1) { // Start of new playlist node
+ nod->_cur_frm = nod->start;
+
+ _animation->seekToFrame(nod->_cur_frm);
+ frame = _animation->decodeNextFrame();
+
+ nod->_delay = _frmDelay;
+ if (nod->slot)
+ _engine->getScriptManager()->setStateValue(nod->slot, 1);
+ } else {
+ nod->_cur_frm++;
+
+ if (nod->_cur_frm > nod->stop) {
+ nod->loop--;
+
+ if (nod->loop == 0) {
+ if (nod->slot >= 0)
+ _engine->getScriptManager()->setStateValue(nod->slot, 2);
+ if (nod->_scaled)
+ delete nod->_scaled;
+ _playList.erase(it);
+ return _DisposeAfterUse;
+ }
+
+ nod->_cur_frm = nod->start;
+ _animation->seekToFrame(nod->_cur_frm);
+ }
+
+ frame = _animation->decodeNextFrame();
+ }
+
+ if (frame) {
+
+ uint32 dstw;
+ uint32 dsth;
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
+ dstw = nod->pos.height();
+ dsth = nod->pos.width();
+ } else {
+ dstw = nod->pos.width();
+ dsth = nod->pos.height();
+ }
+
+ if (frame->w != dstw || frame->h != dsth) {
+ if (nod->_scaled)
+ if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
+ delete nod->_scaled;
+ nod->_scaled = NULL;
+ }
+
+ if (!nod->_scaled) {
+ nod->_scaled = new Graphics::Surface;
+ nod->_scaled->create(dstw, dsth, frame->format);
+ }
+
+ _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
+ frame = nod->_scaled;
+ }
+
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) {
+ Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
+ if (_mask > 0)
+ _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top);
+ delete transposed;
+ } else {
+ if (_mask > 0)
+ _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
+ else
+ _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
+
+void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) {
+ playnode nod;
+ nod.loop = loops;
+ nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
+ nod.start = start_frame;
+ nod.stop = end_frame;
+
+ if (nod.stop >= (int)_animation->frameCount())
+ nod.stop = _animation->frameCount() - 1;
+
+ nod.slot = slot;
+ nod._cur_frm = -1;
+ nod._delay = 0;
+ nod._scaled = NULL;
+ _playList.push_back(nod);
+}
+
+bool AnimationNode::stop() {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+ if ((*it)._scaled)
+ delete(*it)._scaled;
+ }
+
+ _playList.clear();
+
+ // We don't need to delete, it's may be reused
+ return false;
+}
+
+void AnimationNode::setNewFrameDelay(int32 newDelay) {
+ if (newDelay > 0) {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+ float percent = (float)nod->_delay / (float)_frmDelay;
+ nod->_delay = percent * newDelay; // Scale to new max
+ }
+
+ _frmDelay = newDelay;
+ }
+}
+
+int32 AnimationNode::getFrameDelay() {
+ return _frmDelay;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h
new file mode 100644
index 0000000..4d1c74b
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/animation_node.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_ANIMATION_NODE_H
+#define ZVISION_ANIMATION_NODE_H
+
+#include "zvision/scripting/sidefx.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace Common {
+class String;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+class MetaAnimation;
+
+class AnimationNode : public SideFX {
+public:
+ AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true);
+ ~AnimationNode();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ Graphics::Surface *_scaled;
+ };
+
+private:
+ typedef Common::List<playnode> PlayNodes;
+
+ PlayNodes _playList;
+
+ int32 _mask;
+ bool _DisposeAfterUse;
+
+ MetaAnimation *_animation;
+ int32 _frmDelay;
+
+public:
+ bool process(uint32 deltaTimeInMillis);
+
+ void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1);
+
+ bool stop();
+
+ void setNewFrameDelay(int32 newDelay);
+ int32 getFrameDelay();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp
new file mode 100644
index 0000000..0351867
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/music_node.cpp
@@ -0,0 +1,190 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/sidefx/music_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+
+namespace ZVision {
+
+MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
+ : SideFX(engine, key, SIDEFX_AUDIO) {
+ _loop = loop;
+ _volume = volume;
+ _crossfade = false;
+ _crossfade_target = 0;
+ _crossfade_time = 0;
+ _attenuate = 0;
+ _pantrack = false;
+ _pantrack_X = 0;
+ _sub = NULL;
+
+ Audio::RewindableAudioStream *audioStream;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _stereo = audioStream->isStereo();
+
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
+ } else {
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+}
+
+MusicNode::~MusicNode() {
+ _engine->_mixer->stopHandle(_handle);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ if (_sub)
+ delete _sub;
+ debug(1, "MusicNode: %d destroyed\n", _key);
+}
+
+void MusicNode::setPanTrack(int16 pos) {
+ if (!_stereo) {
+ _pantrack = true;
+ _pantrack_X = pos;
+ setVolume(_volume);
+ }
+}
+
+void MusicNode::unsetPanTrack() {
+ _pantrack = false;
+ setVolume(_volume);
+}
+
+void MusicNode::setFade(int32 time, uint8 target) {
+ _crossfade_target = target;
+ _crossfade_time = time;
+ _crossfade = true;
+}
+
+bool MusicNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+ uint8 _newvol = _volume;
+
+ if (_crossfade) {
+ if (_crossfade_time > 0) {
+ if ((int32)deltaTimeInMillis > _crossfade_time)
+ deltaTimeInMillis = _crossfade_time;
+ _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis;
+ _crossfade_time -= deltaTimeInMillis;
+ } else {
+ _crossfade = false;
+ _newvol = _crossfade_target;
+ }
+ }
+
+ if (_pantrack || _volume != _newvol)
+ setVolume(_newvol);
+
+ if (_sub)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+void MusicNode::setVolume(uint8 new_volume) {
+ if (_pantrack) {
+ int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+ cur_x -= _pantrack_X;
+ int32 _width = _engine->getRenderManager()->getBkgSize().x;
+ if (cur_x < (-_width) / 2)
+ cur_x += _width;
+ else if (cur_x >= _width / 2)
+ cur_x -= _width;
+
+ float norm = (float)cur_x / ((float)_width / 2.0);
+ float lvl = fabs(norm);
+ if (lvl > 0.5)
+ lvl = (lvl - 0.5) * 1.7;
+ else
+ lvl = 1.0;
+
+ float bal = sin(-norm * 3.1415926) * 127.0;
+
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, bal);
+ _engine->_mixer->setChannelVolume(_handle, new_volume * lvl);
+ }
+ } else {
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, 0);
+ _engine->_mixer->setChannelVolume(_handle, new_volume);
+ }
+ }
+
+ _volume = new_volume;
+}
+
+PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
+ : SideFX(engine, key, SIDEFX_PANTRACK) {
+ _slot = slot;
+
+ SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
+ if (fx && fx->getType() == SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->setPanTrack(pos);
+ }
+}
+
+PanTrackNode::~PanTrackNode() {
+ SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
+ if (fx && fx->getType() == SIDEFX_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->unsetPanTrack();
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
new file mode 100644
index 0000000..066b8f8
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -0,0 +1,82 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_MUSIC_NODE_H
+#define ZVISION_MUSIC_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/sidefx.h"
+#include "zvision/subtitles/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class MusicNode : public SideFX {
+public:
+ MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
+ ~MusicNode();
+
+ /**
+ * 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);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ int32 _timeLeft;
+ bool _pantrack;
+ int32 _pantrack_X;
+ int32 _attenuate;
+ uint8 _volume;
+ bool _loop;
+ bool _crossfade;
+ uint8 _crossfade_target;
+ int32 _crossfade_time;
+ bool _stereo;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+};
+
+class PanTrackNode : public SideFX {
+public:
+ PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
+ ~PanTrackNode();
+
+private:
+ uint32 _slot;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp
new file mode 100644
index 0000000..2bfdc34
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/syncsound_node.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/sidefx/syncsound_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+
+namespace ZVision {
+
+SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
+ : SideFX(engine, key, SIDEFX_AUDIO) {
+ _syncto = syncto;
+ _sub = NULL;
+
+ Audio::RewindableAudioStream *audioStream;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+}
+
+SyncSoundNode::~SyncSoundNode() {
+ _engine->_mixer->stopHandle(_handle);
+ if (_sub)
+ delete _sub;
+}
+
+bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+
+ if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
+ return stop();
+
+ if (_sub)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h
new file mode 100644
index 0000000..c16ffeb
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/syncsound_node.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SYNCSOUND_NODE_H
+#define ZVISION_SYNCSOUND_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/sidefx.h"
+#include "zvision/subtitles/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class SyncSoundNode : public SideFX {
+public:
+ SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
+ ~SyncSoundNode();
+
+ /**
+ * 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:
+ int32 _syncto;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp
new file mode 100644
index 0000000..6e71101
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/timer_node.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/sidefx/timer_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : SideFX(engine, key, SIDEFX_TIMER) {
+ if (_engine->getGameId() == GID_NEMESIS)
+ _timeLeft = timeInSeconds * 1000;
+ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ _timeLeft = timeInSeconds * 100;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+TimerNode::~TimerNode() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
+ if (timeLeft > 0)
+ _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
+}
+
+bool TimerNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
+ if (_timeLeft <= 0)
+ return stop();
+
+ return false;
+}
+
+bool TimerNode::stop() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ return true;
+}
+
+void TimerNode::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
+ stream->writeUint32LE(8); // size
+ stream->writeUint32LE(_key);
+ stream->writeUint32LE(_timeLeft);
+}
+
+void TimerNode::deserialize(Common::SeekableReadStream *stream) {
+ _timeLeft = stream->readUint32LE();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/timer_node.h b/engines/zvision/scripting/sidefx/timer_node.h
new file mode 100644
index 0000000..7a26aff
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/timer_node.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 ZVISION_TIMER_NODE_H
+#define ZVISION_TIMER_NODE_H
+
+#include "zvision/scripting/sidefx.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class TimerNode : public SideFX {
+public:
+ TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
+ ~TimerNode();
+
+ /**
+ * 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);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
+ inline bool needsSerialization() {
+ return true;
+ }
+
+ bool stop();
+
+private:
+ int32 _timeLeft;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp
new file mode 100644
index 0000000..68636eb
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp
@@ -0,0 +1,175 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/sidefx/ttytext_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/text.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+
+
+namespace ZVision {
+
+ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
+ SideFX(engine, key, SIDEFX_TTYTXT),
+ _fnt(engine) {
+ _delay = delay;
+ _r = r;
+ _txtpos = 0;
+ _nexttime = 0;
+ _dx = 0;
+ _dy = 0;
+
+ Common::File *infile = _engine->getSearchManager()->openFile(file);
+ if (infile) {
+ while (!infile->eos()) {
+ Common::String asciiLine = readWideLine(*infile);
+ if (asciiLine.empty()) {
+ continue;
+ }
+ _txtbuf += asciiLine;
+ }
+
+ delete infile;
+ }
+ _img.create(_r.width(), _r.height(), _engine->_pixelFormat);
+ _style.sharp = true;
+ _style.readAllStyle(_txtbuf);
+ _style.setFont(_fnt);
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+ttyTextNode::~ttyTextNode() {
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ _img.free();
+}
+
+bool ttyTextNode::process(uint32 deltaTimeInMillis) {
+ _nexttime -= deltaTimeInMillis;
+
+ if (_nexttime < 0) {
+ if (_txtpos < _txtbuf.size()) {
+ if (_txtbuf[_txtpos] == '<') {
+ int32 strt = _txtpos;
+ int32 endt = 0;
+ int16 ret = 0;
+ while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
+ _txtpos++;
+ endt = _txtpos;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (ret & TXT_RET_FNTCHG)
+ _style.setFont(_fnt);
+ if (ret & TXT_RET_FNTSTL)
+ _style.setFontStyle(_fnt);
+
+ if (ret & TXT_RET_NEWLN)
+ newline();
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf;
+ buf.format("%d", _style.statebox);
+
+ for (uint8 j = 0; j < buf.size(); j++)
+ outchar(buf[j]);
+ }
+
+ _txtpos++;
+ } else {
+ int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
+
+ uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ if (chr == ' ') {
+ uint32 i = _txtpos + charsz;
+ uint16 width = _fnt.getCharWidth(chr);
+
+ while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
+
+ int8 chsz = getUtf8CharSize(_txtbuf[i]);
+ uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ width += _fnt.getCharWidth(uchr);
+
+ i += chsz;
+ }
+
+ if (_dx + width > _r.width())
+ newline();
+ else
+ outchar(chr);
+ } else
+ outchar(chr);
+
+ _txtpos += charsz;
+ }
+ _nexttime = _delay;
+ _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
+ } else
+ return stop();
+ }
+
+ return false;
+}
+
+void ttyTextNode::scroll() {
+ int32 scrl = 0;
+ while (_dy - scrl > _r.height() - _fnt.getFontHeight())
+ scrl += _fnt.getFontHeight();
+ int8 *pixels = (int8 *)_img.getPixels();
+ for (uint16 h = scrl; h < _img.h; h++)
+ memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
+
+ _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
+ _dy -= scrl;
+}
+
+void ttyTextNode::newline() {
+ _dy += _fnt.getFontHeight();
+ _dx = 0;
+}
+
+void ttyTextNode::outchar(uint16 chr) {
+ uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue);
+
+ if (_dx + _fnt.getCharWidth(chr) > _r.width())
+ newline();
+
+ if (_dy + _fnt.getFontHeight() >= _r.height())
+ scroll();
+
+ _fnt.drawChar(&_img, chr, _dx, _dy, clr);
+
+ _dx += _fnt.getCharWidth(chr);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h
new file mode 100644
index 0000000..a6326c7
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/ttytext_node.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_TTYTEXT_NODE_H
+#define ZVISION_TTYTEXT_NODE_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "zvision/scripting/sidefx.h"
+#include "zvision/text/text.h"
+#include "zvision/fonts/truetype_font.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class ttyTextNode : public SideFX {
+public:
+ ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
+ ~ttyTextNode();
+
+ /**
+ * 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:
+ Common::Rect _r;
+ //int16 x;
+ //int16 y;
+ //uint16 w;
+ //uint16 h;
+ cTxtStyle _style;
+ sTTFont _fnt;
+ Common::String _txtbuf;
+ uint32 _txtpos;
+ //int32 txtsize;
+ int32 _delay;
+ int32 _nexttime;
+ Graphics::Surface _img;
+ int16 _dx;
+ int16 _dy;
+private:
+
+ void newline();
+ void scroll();
+ void outchar(uint16 chr);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp
deleted file mode 100644
index db120f2..0000000
--- a/engines/zvision/search_manager.cpp
+++ /dev/null
@@ -1,274 +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/debug.h"
-
-#include "zvision/search_manager.h"
-#include "zvision/archives/zfs_archive.h"
-#include "common/fs.h"
-#include "common/stream.h"
-
-
-namespace ZVision {
-
-sManager::sManager(const Common::String &root_path, int depth) {
- _root = root_path;
- if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/')
- _root.deleteLastChar();
-
- Common::FSNode fs_node(_root);
-
- list_dir_recursive(dir_list, fs_node, depth);
-
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end();)
- if (it->size() == _root.size())
- it = dir_list.erase(it);
- else if (it->size() > _root.size()) {
- *it = Common::String(it->c_str() + _root.size() + 1);
- it++;
- } else
- it++;
-}
-
-sManager::~sManager() {
- Common::List<Common::Archive *>::iterator it = archList.begin();
- while (it != archList.end()) {
- delete *it;
- it++;
- }
-
- archList.clear();
-}
-
-void sManager::addPatch(const Common::String &src, const Common::String &dst) {
- Common::String lw_name = dst;
- lw_name.toLowercase();
-
- sManager::MatchList::iterator it = files.find(lw_name);
-
- if (it != files.end()) {
- lw_name = src;
- lw_name.toLowercase();
- files[lw_name] = it->_value;
- }
-}
-
-void sManager::addFile(const Common::String &name, Common::Archive *arch) {
- bool addArch = true;
- Common::List<Common::Archive *>::iterator it = archList.begin();
- while (it != archList.end()) {
- if (*it == arch) {
- addArch = false;
- break;
- }
- it++;
- }
- if (addArch)
- archList.push_back(arch);
-
- Common::String lw_name = name;
- lw_name.toLowercase();
-
- sManager::Node nod;
- nod.name = lw_name;
- nod.arch = arch;
-
- sManager::MatchList::iterator fit = files.find(lw_name);
-
- if (fit == files.end()) {
- files[lw_name] = nod;
- } else {
- Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
- if (stream) {
- if (stream->size() < 10)
- fit->_value.arch = arch;
- delete stream;
- } else {
- files[lw_name] = nod;
- }
- }
-}
-
-Common::File *sManager::openFile(const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
-
- sManager::MatchList::iterator fit = files.find(lw_name);
-
- if (fit != files.end()) {
- Common::File *tmp = new Common::File();
- tmp->open(fit->_value.name, *fit->_value.arch);
- return tmp;
- }
- return NULL;
-}
-
-bool sManager::openFile(Common::File &file, const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
-
- sManager::MatchList::iterator fit = files.find(lw_name);
-
- if (fit != files.end())
- return file.open(fit->_value.name, *fit->_value.arch);
- return false;
-}
-
-bool sManager::hasFile(const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
-
- sManager::MatchList::iterator fit = files.find(lw_name);
-
- if (fit != files.end())
- return true;
- return false;
-}
-
-void sManager::loadZix(const Common::String &name) {
- Common::File file;
- file.open(name);
-
- Common::String line;
-
- while (!file.eos()) {
- line = file.readLine();
- if (line.matchString("----------*", true))
- break;
- }
-
- if (file.eos())
- return;
-
- Common::Array<Common::Archive *> archives;
-
- while (!file.eos()) {
- line = file.readLine();
- line.trim();
- if (line.matchString("----------*", true))
- break;
- else if (line.matchString("DIR:*", true)) {
- Common::String path(line.c_str() + 5);
- Common::Archive *arc;
- char n_path[128];
- strcpy(n_path, path.c_str());
- for (uint i = 0; i < path.size(); i++)
- if (n_path[i] == '\\')
- n_path[i] = '/';
-
- path = Common::String(n_path);
- if (path.size() && path[0] == '.')
- path.deleteChar(0);
- if (path.size() && path[0] == '/')
- path.deleteChar(0);
-
- if (path.matchString("*.zfs", true))
- arc = new ZfsArchive(path);
- else {
- if (path.size()) {
- if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/')
- path.deleteLastChar();
- if (path.size())
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
- if (path.equalsIgnoreCase(*it)) {
- path = *it;
- break;
- }
- }
-
- path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
-
- arc = new Common::FSDirectory(path);
- }
- archives.push_back(arc);
- }
- }
-
- if (file.eos())
- return;
-
- while (!file.eos()) {
- line = file.readLine();
- line.trim();
- uint dr = 0;
- char buf[32];
- if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
- if (dr <= archives.size() && dr > 0) {
- addFile(Common::String(buf), archives[dr - 1]);
- }
- }
- }
-}
-
-void sManager::addDir(const Common::String &name) {
- Common::String path;
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
- if (name.equalsIgnoreCase(*it)) {
- path = *it;
- break;
- }
-
- if (path.size() == 0)
- return;
-
- path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
-
- Common::FSDirectory *dir = new Common::FSDirectory(path);
-
- Common::ArchiveMemberList list;
- dir->listMatchingMembers(list, "*.zfs");
-
-
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::String flname = (*iter)->getName();
-
- ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str()));
-
- Common::ArchiveMemberList zfslist;
- zfs->listMembers(zfslist);
-
- for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
- Common::String z_name = (*ziter)->getName();
- addFile(z_name, zfs);
- }
- }
-
- list.clear();
- dir->listMembers(list);
-
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::String flname = (*iter)->getName();
- addFile(flname, dir);
- }
-}
-
-void sManager::list_dir_recursive(Common::List<Common::String> &_list, const Common::FSNode &fs_node, int depth) {
- Common::FSList fs_list;
- fs_node.getChildren(fs_list);
-
- _list.push_back(fs_node.getPath());
-
- if (depth > 1)
- for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it)
- list_dir_recursive(_list, *it, depth - 1);
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/search_manager.h b/engines/zvision/search_manager.h
deleted file mode 100644
index c768cb8..0000000
--- a/engines/zvision/search_manager.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef SEARCH_MANAGER_H_INCLUDED
-#define SEARCH_MANAGER_H_INCLUDED
-
-#include "common/str.h"
-#include "common/hash-str.h"
-#include "common/hashmap.h"
-#include "common/archive.h"
-#include "common/file.h"
-#include "common/list.h"
-
-namespace ZVision {
-
-class sManager {
-public:
- sManager(const Common::String &root_path, int depth);
- ~sManager();
-
- void addFile(const Common::String &name, Common::Archive *arch);
- void addDir(const Common::String &name);
- void addPatch(const Common::String &src, const Common::String &dst);
-
- Common::File *openFile(const Common::String &name);
- bool openFile(Common::File &file, const Common::String &name);
- bool hasFile(const Common::String &name);
-
- void loadZix(const Common::String &name);
-
-private:
-
- void list_dir_recursive(Common::List<Common::String> &dir_list, const Common::FSNode &fs_node, int depth);
-
- struct Node {
- Common::String name;
- Common::Archive *arch;
- };
-
- Common::List<Common::String> dir_list;
-
- typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList;
-
- Common::List<Common::Archive *> archList;
- MatchList files;
-
- Common::String _root;
-
-private:
-};
-
-}
-
-#endif // SEARCH_MANAGER_H_INCLUDED
diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp
deleted file mode 100644
index 7ba1959..0000000
--- a/engines/zvision/sidefx.cpp
+++ /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.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/sidefx.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/utility/utility.h"
-
-#include "common/stream.h"
-
-namespace ZVision {
-
-
-} // End of namespace ZVision
diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h
deleted file mode 100644
index 2c53467..0000000
--- a/engines/zvision/sidefx.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef SIDEFX_H_INCLUDED
-#define SIDEFX_H_INCLUDED
-
-namespace Common {
-class SeekableReadStream;
-struct Point;
-class WriteStream;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-class SideFX {
-public:
-
- enum SideFXType {
- SIDEFX_ANIM = 1,
- SIDEFX_AUDIO = 2,
- SIDEFX_DISTORT = 4,
- SIDEFX_PANTRACK = 8,
- SIDEFX_REGION = 16,
- SIDEFX_TIMER = 32,
- SIDEFX_TTYTXT = 64,
- SIDEFX_UNK = 128,
- SIDEFX_ALL = 255
- };
-
- SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
- SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {}
- virtual ~SideFX() {}
-
- uint32 getKey() {
- return _key;
- }
- SideFXType getType() {
- return _type;
- }
-
- virtual bool process(uint32 deltaTimeInMillis) {
- return false;
- }
- /**
- * Serialize a SideFX for save game use. This should only be used if a SideFX 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
- * SideFX 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 SideFX overrides serialize() and deserialize(), this should return true
- *
- * @return Does the SideFX need save game serialization?
- */
- virtual inline bool needsSerialization() {
- return false;
- }
-
- virtual bool stop() {
- return true;
- }
- virtual void kill() {}
-
-protected:
- ZVision *_engine;
- uint32 _key;
- SideFXType _type;
-
-// Static member functions
-public:
-
-};
-
-// TODO: Implement InputControl
-// TODO: Implement SaveControl
-// TODO: Implement SlotControl
-// TODO: Implement SafeControl
-// TODO: Implement FistControl
-// TODO: Implement HotMovieControl
-// TODO: Implement PaintControl
-// TODO: Implement TilterControl
-
-} // End of namespace ZVision
-
-#endif // SIDEFX_H_INCLUDED
diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp
deleted file mode 100644
index d3d9c2e..0000000
--- a/engines/zvision/slot_control.cpp
+++ /dev/null
@@ -1,219 +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/slot_control.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/utility/utility.h"
-
-#include "common/stream.h"
-
-
-namespace ZVision {
-
-SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
-
- _rendered_item = 0;
- _bkg = NULL;
-
- // Loop until we find the closing brace
- Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
- Common::String param;
- Common::String values;
- getParams(line, param, values);
-
- while (!stream.eos() && !line.contains('}')) {
- if (param.matchString("hotspot", true)) {
- int x;
- int y;
- int width;
- int height;
-
- sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
-
- _hotspot = Common::Rect(x, y, width, height);
- } else if (param.matchString("rectangle", true)) {
- int x;
- int y;
- int width;
- int height;
-
- sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
-
- _rectangle = Common::Rect(x, y, width, height);
- } else if (param.matchString("cursor", true)) {
- _cursor = _engine->getCursorManager()->getCursorId(values);
- } else if (param.matchString("distance_id", true)) {
- sscanf(values.c_str(), "%c", &_distance_id);
- } else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
- } else if (param.matchString("eligible_objects", true)) {
- char buf[256];
- memset(buf, 0, 256);
- strcpy(buf, values.c_str());
-
- char *curpos = buf;
- char *strend = buf + strlen(buf);
- while (true) {
- char *st = curpos;
-
- if (st >= strend)
- break;
-
- while (*curpos != ' ' && curpos < strend)
- curpos++;
-
- *curpos = 0;
- curpos++;
-
- int obj = atoi(st);
-
- _eligible_objects.push_back(obj);
- }
- }
-
- line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
- getParams(line, param, values);
- }
-
- if (_hotspot.isEmpty() || _rectangle.isEmpty()) {
- warning("Slot %u was parsed incorrectly", key);
- }
-}
-
-SlotControl::~SlotControl() {
- // Clear the state value back to 0
- //_engine->getScriptManager()->setStateValue(_key, 0);
-
- if (_bkg)
- delete _bkg;
-}
-
-bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return false;
-
- if (_hotspot.contains(backgroundImageSpacePos)) {
- //ctrl_setvenus(ct);
-
- int item = _engine->getScriptManager()->getStateValue(_key);
- int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
- if (item != 0) {
- if (mouse_item != 0) {
- if (eligeblity(mouse_item)) {
- _engine->getScriptManager()->invertory_drop(mouse_item);
- _engine->getScriptManager()->invertory_add(item);
- _engine->getScriptManager()->setStateValue(_key, mouse_item);
- }
- } else {
- _engine->getScriptManager()->invertory_add(item);
- _engine->getScriptManager()->setStateValue(_key, 0);
- }
- } else if (mouse_item == 0) {
- if (eligeblity(0)) {
- _engine->getScriptManager()->invertory_drop(0);
- _engine->getScriptManager()->setStateValue(_key, 0);
- }
- } else if (eligeblity(mouse_item)) {
- _engine->getScriptManager()->setStateValue(_key, mouse_item);
- _engine->getScriptManager()->invertory_drop(mouse_item);
- }
- }
- return false;
-}
-
-bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return false;
-
- if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_cursor);
- return true;
- }
-
- return false;
-}
-
-bool SlotControl::process(uint32 deltaTimeInMillis) {
- if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
- return false;
-
- if (_engine->canRender()) {
- int cur_item = _engine->getScriptManager()->getStateValue(_key);
- if (cur_item != _rendered_item) {
- if (_rendered_item != 0 && cur_item == 0) {
- _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
- _rendered_item = cur_item;
- } else {
- if (_rendered_item == 0) {
- if (_bkg)
- delete _bkg;
-
- _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
- } else {
- _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
- }
-
- char buf[16];
- if (_engine->getGameId() == GID_NEMESIS)
- sprintf(buf, "%d%cobj.tga", cur_item, _distance_id);
- else
- sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item);
-
- Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);
-
- int16 drawx = _rectangle.left;
- int16 drawy = _rectangle.top;
-
- if (_rectangle.width() > srf->w)
- drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2;
-
- if (_rectangle.height() > srf->h)
- drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2;
-
- _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0);
-
- delete srf;
-
- _rendered_item = cur_item;
- }
- }
- }
- return false;
-}
-
-bool SlotControl::eligeblity(int item_id) {
- for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
- if (*it == item_id)
- return true;
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h
deleted file mode 100644
index 0ac8ec9..0000000
--- a/engines/zvision/slot_control.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_SLOT_CONTROL_H
-#define ZVISION_SLOT_CONTROL_H
-
-#include "zvision/scripting/control.h"
-
-#include "graphics/surface.h"
-
-#include "common/rect.h"
-#include "common/list.h"
-
-
-namespace ZVision {
-
-class SlotControl : public Control {
-public:
- SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
- ~SlotControl();
-
- /**
- * 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
- */
- bool 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);
-
- bool process(uint32 deltaTimeInMillis);
-
-private:
- /**
- * The area that will trigger the event
- * This is in image space coordinates, NOT screen space
- */
- Common::Rect _rectangle;
- Common::Rect _hotspot;
-
- int _cursor;
- char _distance_id;
- int _venus_id;
-
- int _rendered_item;
-
- Common::List<int> _eligible_objects;
-
- bool eligeblity(int item_id);
-
- Graphics::Surface *_bkg;
-
- /** The cursor to use when hovering over _hotspot */
- Common::String _hoverCursor;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/strings/string_manager.cpp b/engines/zvision/strings/string_manager.cpp
deleted file mode 100644
index 22331d8..0000000
--- a/engines/zvision/strings/string_manager.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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/strings/string_manager.h"
-
-#include "zvision/fonts/truetype_font.h"
-
-#include "common/file.h"
-#include "common/tokenizer.h"
-#include "common/debug.h"
-
-#include "graphics/fontman.h"
-#include "graphics/colormasks.h"
-
-
-namespace ZVision {
-
-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 == GID_NEMESIS) {
- // TODO: Check this hardcoded filename against all versions of Nemesis
- parseStrFile("nemesis.str");
- } else if (gameId == GID_GRANDINQUISITOR) {
- // 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;
- }
-
- uint lineNumber = 0;
- while (!file.eos()) {
- _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;
- char textString[150];
- uint textStringCursor = 0;
- bool inTag = false;
-
- for (uint i = 0; i < asciiLine.size(); ++i) {
- 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), lineNumber);
- tagStringCursor = 0;
- break;
- default:
- if (inTag) {
- tagString[tagStringCursor] = asciiLine[i];
- tagStringCursor++;
- } else {
- textString[textStringCursor] = asciiLine[i];
- textStringCursor++;
- }
- break;
- }
- }
-
- if (textStringCursor > 0) {
- _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
- }
-
- lineNumber++;
- assert(lineNumber <= NUM_TEXT_LINES);
- }
-}
-
-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 = _lastStyle.align;
- int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 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();
- }
-
- TextFragment fragment;
-
- 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 {
- debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
- if (bold) {
- newFontName = "zorknorm.ttf";
- } else {
- newFontName = "arial.ttf";
- }
- }
-
- 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);
- _fonts[fontKey] = fragment.style.font;
- }
- }
-
- fragment.style.align = align;
- fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565> >(0, red, green, blue);
- _inGameText[lineNumber].fragments.push_back(fragment);
-
- _lastStyle = fragment.style;
-}
-
-Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
- 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();
- 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 = '?';
- }
- char charValue = (char)value;
-
- asciiString += charValue;
-
- value = stream.readUint16LE();
- }
-
- if (charOverflowWarning) {
- warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'");
- }
-
- return asciiString;
-}
-
-StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
- return _inGameText[stringNumber].fragments.front().style;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/strings/string_manager.h b/engines/zvision/strings/string_manager.h
deleted file mode 100644
index af8324b..0000000
--- a/engines/zvision/strings/string_manager.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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 "zvision/detection.h"
-#include "zvision/fonts/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;
- };
-
- 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;
- InGameText _inGameText[NUM_TEXT_LINES];
- Common::HashMap<Common::String, TruetypeFont *> _fonts;
-
- 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, uint lineNumber);
-
- static Common::String readWideLine(Common::SeekableReadStream &stream);
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp
deleted file mode 100644
index da9b0fc..0000000
--- a/engines/zvision/subtitles.cpp
+++ /dev/null
@@ -1,108 +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 "zvision/subtitles/subtitles.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/search_manager.h"
-#include "zvision/text.h"
-
-namespace ZVision {
-
-Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
- _engine(engine),
- _areaId(-1),
- _subId(-1) {
- Common::File file;
- if (_engine->getSearchManager()->openFile(file, subname)) {
- while (!file.eos()) {
- Common::String str = file.readLine();
- if (str.lastChar() == '~')
- str.deleteLastChar();
-
- if (str.matchString("*Initialization*", true)) {
- // Not used
- } else if (str.matchString("*Rectangle*", true)) {
- int32 x1, y1, x2, y2;
- sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
- Common::Rect rct = Common::Rect(x1, y1, x2, y2);
- _areaId = _engine->getRenderManager()->createSubArea(rct);
- } else if (str.matchString("*TextFile*", true)) {
- char filename[64];
- sscanf(str.c_str(), "%*[^:]:%s", filename);
- Common::File txt;
- if (_engine->getSearchManager()->openFile(txt, filename)) {
- while (!txt.eos()) {
- Common::String txtline = readWideLine(txt);
- sub cur_sub;
- cur_sub.start = -1;
- cur_sub.stop = -1;
- cur_sub.sub = txtline;
-
- _subs.push_back(cur_sub);
- }
- txt.close();
- }
- } else {
- int32 st;
- int32 en;
- int32 sb;
- if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
- if (sb <= (int32)_subs.size()) {
- _subs[sb].start = st;
- _subs[sb].stop = en;
- }
- }
- }
- }
- }
-}
-
-Subtitle::~Subtitle() {
- if (_areaId != -1)
- _engine->getRenderManager()->deleteSubArea(_areaId);
-
- _subs.clear();
-}
-
-void Subtitle::process(int32 time) {
- int16 j = -1;
- for (uint16 i = 0; i < _subs.size(); i++)
- if (time >= _subs[i].start && time <= _subs[i].stop) {
- j = i;
- break;
- }
-
- if (j == -1 && _subId != -1) {
- if (_areaId != -1)
- _engine->getRenderManager()->updateSubArea(_areaId, "");
- _subId = -1;
- }
-
- if (j != -1 && j != _subId) {
- if (_subs[j].sub.size())
- if (_areaId != -1)
- _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub);
- _subId = j;
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp
new file mode 100644
index 0000000..4ca48f7
--- /dev/null
+++ b/engines/zvision/subtitles/subtitles.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "zvision/subtitles/subtitles.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/core/search_manager.h"
+#include "zvision/text/text.h"
+
+namespace ZVision {
+
+Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
+ _engine(engine),
+ _areaId(-1),
+ _subId(-1) {
+ Common::File file;
+ if (_engine->getSearchManager()->openFile(file, subname)) {
+ while (!file.eos()) {
+ Common::String str = file.readLine();
+ if (str.lastChar() == '~')
+ str.deleteLastChar();
+
+ if (str.matchString("*Initialization*", true)) {
+ // Not used
+ } else if (str.matchString("*Rectangle*", true)) {
+ int32 x1, y1, x2, y2;
+ sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
+ Common::Rect rct = Common::Rect(x1, y1, x2, y2);
+ _areaId = _engine->getRenderManager()->createSubArea(rct);
+ } else if (str.matchString("*TextFile*", true)) {
+ char filename[64];
+ sscanf(str.c_str(), "%*[^:]:%s", filename);
+ Common::File txt;
+ if (_engine->getSearchManager()->openFile(txt, filename)) {
+ while (!txt.eos()) {
+ Common::String txtline = readWideLine(txt);
+ sub cur_sub;
+ cur_sub.start = -1;
+ cur_sub.stop = -1;
+ cur_sub.sub = txtline;
+
+ _subs.push_back(cur_sub);
+ }
+ txt.close();
+ }
+ } else {
+ int32 st;
+ int32 en;
+ int32 sb;
+ if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
+ if (sb <= (int32)_subs.size()) {
+ _subs[sb].start = st;
+ _subs[sb].stop = en;
+ }
+ }
+ }
+ }
+ }
+}
+
+Subtitle::~Subtitle() {
+ if (_areaId != -1)
+ _engine->getRenderManager()->deleteSubArea(_areaId);
+
+ _subs.clear();
+}
+
+void Subtitle::process(int32 time) {
+ int16 j = -1;
+ for (uint16 i = 0; i < _subs.size(); i++)
+ if (time >= _subs[i].start && time <= _subs[i].stop) {
+ j = i;
+ break;
+ }
+
+ if (j == -1 && _subId != -1) {
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, "");
+ _subId = -1;
+ }
+
+ if (j != -1 && j != _subId) {
+ if (_subs[j].sub.size())
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub);
+ _subId = j;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp
deleted file mode 100644
index 7bd520d4..0000000
--- a/engines/zvision/syncsound_node.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-
-#include "zvision/syncsound_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-#include "audio/decoders/wave.h"
-
-
-namespace ZVision {
-
-SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
- : SideFX(engine, key, SIDEFX_AUDIO) {
- _syncto = syncto;
- _sub = NULL;
-
- Audio::RewindableAudioStream *audioStream;
-
- if (filename.contains(".wav")) {
- Common::File *file = new Common::File();
- if (_engine->getSearchManager()->openFile(*file, filename)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- }
- } else {
- audioStream = makeRawZorkStream(filename, _engine);
- }
-
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
-
- Common::String subname = filename;
- subname.setChar('s', subname.size() - 3);
- subname.setChar('u', subname.size() - 2);
- subname.setChar('b', subname.size() - 1);
-
- if (_engine->getSearchManager()->hasFile(subname))
- _sub = new Subtitle(_engine, subname);
-}
-
-SyncSoundNode::~SyncSoundNode() {
- _engine->_mixer->stopHandle(_handle);
- if (_sub)
- delete _sub;
-}
-
-bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
- if (! _engine->_mixer->isSoundHandleActive(_handle))
- return stop();
- else {
-
- if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
- return stop();
-
- if (_sub)
- _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
- }
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h
deleted file mode 100644
index 1f63ec4..0000000
--- a/engines/zvision/syncsound_node.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_SYNCSOUND_NODE_H
-#define ZVISION_SYNCSOUND_NODE_H
-
-#include "audio/mixer.h"
-#include "zvision/sidefx.h"
-#include "zvision/subtitles/subtitles.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-class SyncSoundNode : public SideFX {
-public:
- SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
- ~SyncSoundNode();
-
- /**
- * 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:
- int32 _syncto;
- Audio::SoundHandle _handle;
- Subtitle *_sub;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp
deleted file mode 100644
index 6b0ff07..0000000
--- a/engines/zvision/text.cpp
+++ /dev/null
@@ -1,549 +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/text.h"
-
-#include "zvision/fonts/truetype_font.h"
-
-#include "common/file.h"
-#include "common/tokenizer.h"
-#include "common/debug.h"
-#include "common/rect.h"
-
-#include "graphics/fontman.h"
-#include "graphics/colormasks.h"
-#include "graphics/surface.h"
-#include "graphics/font.h"
-#include "graphics/fonts/ttf.h"
-
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-
-
-namespace ZVision {
-
-cTxtStyle::cTxtStyle() {
- fontname = "Arial";
- blue = 255;
- green = 255;
- red = 255;
- bold = false;
- escapement = 0;
- italic = false;
- justify = TXT_JUSTIFY_LEFT;
- newline = false;
- size = 12;
- skipcolor = false;
- strikeout = false;
- underline = false;
- statebox = 0;
- sharp = false;
-}
-
-txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
- Common::String buf = Common::String(strin.c_str(), ln);
-
- int8 retval = TXT_RET_NOTHING;
-
- Common::StringTokenizer tokenizer(buf, " ");
- Common::String token;
-
- while (!tokenizer.empty()) {
- token = tokenizer.nextToken();
-
- if (token.matchString("font", true)) {
- token = tokenizer.nextToken();
- if (token[0] == '"') {
- Common::String _tmp = Common::String(token.c_str() + 1);
-
- while (token.lastChar() != '"' && !tokenizer.empty()) {
- token = tokenizer.nextToken();
- _tmp += " " + token;
- }
-
- if (_tmp.lastChar() == '"')
- _tmp.deleteLastChar();
-
- fontname = _tmp;
- } else {
- if (!tokenizer.empty())
- fontname = token;
- }
- retval |= TXT_RET_FNTCHG;
-
- } else if (token.matchString("blue", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- int32 tmp = atoi(token.c_str());
- if (blue != tmp) {
- blue = tmp;
- retval |= TXT_RET_FNTSTL;
- }
- }
- } else if (token.matchString("red", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- int32 tmp = atoi(token.c_str());
- if (red != tmp) {
- red = tmp;
- retval |= TXT_RET_FNTSTL;
- }
- }
- } else if (token.matchString("green", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- int32 tmp = atoi(token.c_str());
- if (green != tmp) {
- green = tmp;
- retval |= TXT_RET_FNTSTL;
- }
- }
- } else if (token.matchString("newline", true)) {
- if ((retval & TXT_RET_NEWLN) == 0)
- newline = 0;
-
- newline++;
- retval |= TXT_RET_NEWLN;
- } else if (token.matchString("point", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- int32 tmp = atoi(token.c_str());
- if (size != tmp) {
- size = tmp;
- retval |= TXT_RET_FNTCHG;
- }
- }
- } else if (token.matchString("escapement", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- int32 tmp = atoi(token.c_str());
- escapement = tmp;
- }
- } else if (token.matchString("italic", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("on", true)) {
- if (italic != true) {
- italic = true;
- retval |= TXT_RET_FNTSTL;
- }
- } else if (token.matchString("off", true)) {
- if (italic != false) {
- italic = false;
- retval |= TXT_RET_FNTSTL;
- }
- }
- }
- } else if (token.matchString("underline", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("on", true)) {
- if (underline != true) {
- underline = true;
- retval |= TXT_RET_FNTSTL;
- }
- } else if (token.matchString("off", true)) {
- if (underline != false) {
- underline = false;
- retval |= TXT_RET_FNTSTL;
- }
- }
- }
- } else if (token.matchString("strikeout", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("on", true)) {
- if (strikeout != true) {
- strikeout = true;
- retval |= TXT_RET_FNTSTL;
- }
- } else if (token.matchString("off", true)) {
- if (strikeout != false) {
- strikeout = false;
- retval |= TXT_RET_FNTSTL;
- }
- }
- }
- } else if (token.matchString("bold", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("on", true)) {
- if (bold != true) {
- bold = true;
- retval |= TXT_RET_FNTSTL;
- }
- } else if (token.matchString("off", true)) {
- if (bold != false) {
- bold = false;
- retval |= TXT_RET_FNTSTL;
- }
- }
- }
- } else if (token.matchString("skipcolor", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("on", true)) {
- skipcolor = true;
- } else if (token.matchString("off", true)) {
- skipcolor = false;
- }
- }
- } else if (token.matchString("image", true)) {
- // Not used
- } else if (token.matchString("statebox", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- statebox = atoi(token.c_str());
- retval |= TXT_RET_HASSTBOX;
- }
- } else if (token.matchString("justify", true)) {
- if (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- if (token.matchString("center", true))
- justify = TXT_JUSTIFY_CENTER;
- else if (token.matchString("left", true))
- justify = TXT_JUSTIFY_LEFT;
- else if (token.matchString("right", true))
- justify = TXT_JUSTIFY_RIGHT;
- }
- }
- }
- return (txtReturn)retval;
-}
-
-void cTxtStyle::readAllStyle(const Common::String &txt) {
- int16 strt = -1;
- int16 endt = -1;
-
- for (uint16 i = 0; i < txt.size(); i++) {
- if (txt[i] == '<')
- strt = i;
- else if (txt[i] == '>') {
- endt = i;
- if (strt != -1)
- if ((endt - strt - 1) > 0)
- parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1);
- }
-
- }
-}
-
-void cTxtStyle::setFontStyle(sTTFont &font) {
- uint temp_stl = 0;
-
- if (bold)
- temp_stl |= sTTFont::STTF_BOLD;
-
- if (italic)
- temp_stl |= sTTFont::STTF_ITALIC;
-
- if (underline)
- temp_stl |= sTTFont::STTF_UNDERLINE;
-
- if (strikeout)
- temp_stl |= sTTFont::STTF_STRIKEOUT;
-
- if (sharp)
- temp_stl |= sTTFont::STTF_SHARP;
-
- font.setStyle(temp_stl);
-}
-
-void cTxtStyle::setFont(sTTFont &font) {
- uint temp_stl = 0;
-
- if (bold)
- temp_stl |= sTTFont::STTF_BOLD;
-
- if (italic)
- temp_stl |= sTTFont::STTF_ITALIC;
-
- if (underline)
- temp_stl |= sTTFont::STTF_UNDERLINE;
-
- if (strikeout)
- temp_stl |= sTTFont::STTF_STRIKEOUT;
-
- if (sharp)
- temp_stl |= sTTFont::STTF_SHARP;
-
- font.loadFont(fontname, size, temp_stl);
-}
-
-Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
- style.setFontStyle(fnt);
- uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue);
- return fnt.renderSolidText(txt, clr);
-}
-
-void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
- if (justify == TXT_JUSTIFY_LEFT)
- fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft);
- else if (justify == TXT_JUSTIFY_CENTER)
- fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter);
- else if (justify == TXT_JUSTIFY_RIGHT)
- fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight);
-}
-
-int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) {
- sTTFont font(_engine);
- fnt_stl.setFont(font);
-
- dst.fillRect(Common::Rect(dst.w, dst.h), 0);
-
- uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue);
-
- int16 w;
-
- w = font.getStringWidth(txt);
-
- drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify);
-
- return w;
-}
-
-void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
- const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it
- const int TXT_CFG_TEXTURES_PER_LINE = 6;
- cTxtStyle style, style2;
- int16 strt = -1;
- int16 endt = -1;
- int16 i = 0;
- int16 dx = 0, dy = 0;
- int16 txt_w;
- int16 txtpos = 0;
- Common::String buf;
- Common::String buf2;
-
- Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE];
- int16 currentline = 0, currentlineitm = 0;
-
- int TxtJustify[TXT_CFG_TEXTURES_LINES];
- int TxtPoint[TXT_CFG_TEXTURES_LINES];
-
- for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) {
- TxtPoint[k] = 0;
- for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
- TxtSurfaces[k][j] = NULL;
- }
-
- int16 stringlen = text.size();
-
- sTTFont font(_engine);
-
- style.setFont(font);
-
- int16 prevbufspace = 0, prevtxtspace = 0;
-
- while (i < stringlen) {
- TxtJustify[currentline] = style.justify;
- if (text[i] == '<') {
- int16 ret = 0;
-
- strt = i;
- while (i < stringlen && text[i] != '>')
- i++;
- endt = i;
- if (strt != -1)
- if ((endt - strt - 1) > 0) {
- style2 = style;
- ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1);
- }
-
- if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
- if (buf.size() > 0) {
- txt_w = font.getStringWidth(buf);
-
- TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2);
- TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
-
- currentlineitm++;
-
- buf.clear();
- prevbufspace = 0;
- txtpos = 0;
- dx += txt_w;
-
- }
- if (ret & TXT_RET_FNTCHG) {
- style.setFont(font);
- }
- if (ret & TXT_RET_FNTSTL)
- style.setFontStyle(font);
-
- if (ret & TXT_RET_NEWLN) {
- currentline++;
- currentlineitm = 0;
- dx = 0;
- }
- }
-
- if (ret & TXT_RET_HASSTBOX) {
- Common::String buf3;
- buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox));
- buf += buf3;
- txtpos += buf3.size();
- }
-
- } else {
-
- buf += text[i];
- txtpos++;
-
- if (text[i] == ' ') {
- prevbufspace = txtpos - 1;
- prevtxtspace = i;
- }
-
- if (font.isLoaded()) {
- txt_w = font.getStringWidth(buf);
- if (txt_w + dx > dst.w) {
- if (prevbufspace == 0) {
- prevtxtspace = i;
- prevbufspace = txtpos - 1;
- }
- buf2 = Common::String(buf.c_str(), prevbufspace + 1);
-
- if (buf2.size() > 0) {
- TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style);
- TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
- }
-
- buf.clear();
- i = prevtxtspace;
- prevbufspace = 0;
- txtpos = 0;
- currentline++;
- currentlineitm = 0;
- dx = 0;
- }
- }
- }
- i++;
- }
-
- if (buf.size() > 0) {
- TxtSurfaces[currentline][currentlineitm] = render(font, buf, style);
- TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
- }
-
- dy = 0;
- for (i = 0; i <= currentline; i++) {
- int16 j = 0;
- int16 width = 0;
- while (TxtSurfaces[i][j] != NULL) {
- width += TxtSurfaces[i][j]->w;
- j++;
- }
- dx = 0;
- for (int32_t jj = 0; jj < j; jj++) {
- if (TxtJustify[i] == TXT_JUSTIFY_LEFT)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
-
- else if (TxtJustify[i] == TXT_JUSTIFY_CENTER)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
-
- else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
-
- dx += TxtSurfaces[i][jj]->w;
- }
-
- dy += TxtPoint[i];
- }
-
- for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++)
- for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
- if (TxtSurfaces[i][j] != NULL) {
- TxtSurfaces[i][j]->free();
- delete TxtSurfaces[i][j];
- }
-}
-
-Common::String readWideLine(Common::SeekableReadStream &stream) {
- Common::String asciiString;
-
- while (!stream.eos()) {
- uint32 value = stream.readUint16LE();
- // 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 < 0x80) {
- asciiString += (char)(value & 0x7F);
- } else if (value >= 0x80 && value < 0x800) {
- asciiString += (char)(0xC0 | ((value >> 6) & 0x1F));
- asciiString += (char)(0x80 | (value & 0x3F));
- } else if (value >= 0x800 && value < 0x10000) {
- asciiString += (char)(0xE0 | ((value >> 12) & 0xF));
- asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
- asciiString += (char)(0x80 | (value & 0x3F));
- } else if (value >= 0x10000 && value < 0x200000) {
- asciiString += (char)(0xF0);
- asciiString += (char)(0x80 | ((value >> 12) & 0x3F));
- asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
- asciiString += (char)(0x80 | (value & 0x3F));
- }
- }
-
- return asciiString;
-}
-
-int8 getUtf8CharSize(char chr) {
- if ((chr & 0x80) == 0)
- return 1;
- else if ((chr & 0xE0) == 0xC0)
- return 2;
- else if ((chr & 0xF0) == 0xE0)
- return 3;
- else if ((chr & 0xF8) == 0xF0)
- return 4;
- else if ((chr & 0xFC) == 0xF8)
- return 5;
- else if ((chr & 0xFE) == 0xFC)
- return 6;
-
- return 1;
-}
-
-uint16 readUtf8Char(const char *chr) {
- uint16 result = 0;
- if ((chr[0] & 0x80) == 0)
- result = chr[0];
- else if ((chr[0] & 0xE0) == 0xC0)
- result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F);
- else if ((chr[0] & 0xF0) == 0xE0)
- result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F);
- else
- result = chr[0];
-
- return result;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/text.h b/engines/zvision/text.h
deleted file mode 100644
index 4b318fd..0000000
--- a/engines/zvision/text.h
+++ /dev/null
@@ -1,100 +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_TEXT_H
-#define ZVISION_TEXT_H
-
-#include "zvision/detection.h"
-#include "zvision/fonts/truetype_font.h"
-#include "zvision/zvision.h"
-
-
-namespace Graphics {
-class FontManager;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-enum txtJustify {
- TXT_JUSTIFY_CENTER = 0,
- TXT_JUSTIFY_LEFT = 1,
- TXT_JUSTIFY_RIGHT = 2
-};
-
-enum txtReturn {
- TXT_RET_NOTHING = 0x0,
- TXT_RET_FNTCHG = 0x1,
- TXT_RET_FNTSTL = 0x2,
- TXT_RET_NEWLN = 0x4,
- TXT_RET_HASSTBOX = 0x8
-};
-
-class cTxtStyle {
-public:
- cTxtStyle();
- txtReturn parseStyle(const Common::String &strin, int16 len);
- void readAllStyle(const Common::String &txt);
- void setFontStyle(sTTFont &font);
- void setFont(sTTFont &font);
-
-public:
- Common::String fontname;
- txtJustify justify; // 0 - center, 1-left, 2-right
- int16 size;
- uint8 red; // 0-255
- uint8 green; // 0-255
- uint8 blue; // 0-255
- int8 newline;
- int8 escapement;
- bool italic;
- bool bold;
- bool underline;
- bool strikeout;
- bool skipcolor;
- int32 statebox;
- bool sharp;
- // char image ??
-};
-
-class textRenderer {
-public:
- textRenderer(ZVision *engine): _engine(engine) {};
-
- void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
- int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst);
- Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style);
- void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst);
-
-private:
- ZVision *_engine;
-};
-
-Common::String readWideLine(Common::SeekableReadStream &stream);
-int8 getUtf8CharSize(char chr);
-uint16 readUtf8Char(const char *chr);
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp
new file mode 100644
index 0000000..cadfbf1
--- /dev/null
+++ b/engines/zvision/text/string_manager.cpp
@@ -0,0 +1,255 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/text/string_manager.h"
+
+#include "zvision/fonts/truetype_font.h"
+
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/debug.h"
+
+#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
+
+
+namespace ZVision {
+
+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 == GID_NEMESIS) {
+ // TODO: Check this hardcoded filename against all versions of Nemesis
+ parseStrFile("nemesis.str");
+ } else if (gameId == GID_GRANDINQUISITOR) {
+ // 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;
+ }
+
+ uint lineNumber = 0;
+ while (!file.eos()) {
+ _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;
+ char textString[150];
+ uint textStringCursor = 0;
+ bool inTag = false;
+
+ for (uint i = 0; i < asciiLine.size(); ++i) {
+ 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), lineNumber);
+ tagStringCursor = 0;
+ break;
+ default:
+ if (inTag) {
+ tagString[tagStringCursor] = asciiLine[i];
+ tagStringCursor++;
+ } else {
+ textString[textStringCursor] = asciiLine[i];
+ textStringCursor++;
+ }
+ break;
+ }
+ }
+
+ if (textStringCursor > 0) {
+ _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
+ }
+
+ lineNumber++;
+ assert(lineNumber <= NUM_TEXT_LINES);
+ }
+}
+
+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 = _lastStyle.align;
+ int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 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();
+ }
+
+ TextFragment fragment;
+
+ 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 {
+ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
+ if (bold) {
+ newFontName = "zorknorm.ttf";
+ } else {
+ newFontName = "arial.ttf";
+ }
+ }
+
+ 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);
+ _fonts[fontKey] = fragment.style.font;
+ }
+ }
+
+ fragment.style.align = align;
+ fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565> >(0, red, green, blue);
+ _inGameText[lineNumber].fragments.push_back(fragment);
+
+ _lastStyle = fragment.style;
+}
+
+Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
+ 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();
+ 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 = '?';
+ }
+ char charValue = (char)value;
+
+ asciiString += charValue;
+
+ value = stream.readUint16LE();
+ }
+
+ if (charOverflowWarning) {
+ warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'");
+ }
+
+ return asciiString;
+}
+
+StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
+ return _inGameText[stringNumber].fragments.front().style;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h
new file mode 100644
index 0000000..af8324b
--- /dev/null
+++ b/engines/zvision/text/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 "zvision/detection.h"
+#include "zvision/fonts/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;
+ };
+
+ 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;
+ InGameText _inGameText[NUM_TEXT_LINES];
+ Common::HashMap<Common::String, TruetypeFont *> _fonts;
+
+ 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, uint lineNumber);
+
+ static Common::String readWideLine(Common::SeekableReadStream &stream);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp
new file mode 100644
index 0000000..cad2723
--- /dev/null
+++ b/engines/zvision/text/text.cpp
@@ -0,0 +1,549 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/text/text.h"
+
+#include "zvision/fonts/truetype_font.h"
+
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/debug.h"
+#include "common/rect.h"
+
+#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
+
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+
+
+namespace ZVision {
+
+cTxtStyle::cTxtStyle() {
+ fontname = "Arial";
+ blue = 255;
+ green = 255;
+ red = 255;
+ bold = false;
+ escapement = 0;
+ italic = false;
+ justify = TXT_JUSTIFY_LEFT;
+ newline = false;
+ size = 12;
+ skipcolor = false;
+ strikeout = false;
+ underline = false;
+ statebox = 0;
+ sharp = false;
+}
+
+txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
+ Common::String buf = Common::String(strin.c_str(), ln);
+
+ int8 retval = TXT_RET_NOTHING;
+
+ Common::StringTokenizer tokenizer(buf, " ");
+ Common::String token;
+
+ while (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+
+ if (token.matchString("font", true)) {
+ token = tokenizer.nextToken();
+ if (token[0] == '"') {
+ Common::String _tmp = Common::String(token.c_str() + 1);
+
+ while (token.lastChar() != '"' && !tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ _tmp += " " + token;
+ }
+
+ if (_tmp.lastChar() == '"')
+ _tmp.deleteLastChar();
+
+ fontname = _tmp;
+ } else {
+ if (!tokenizer.empty())
+ fontname = token;
+ }
+ retval |= TXT_RET_FNTCHG;
+
+ } else if (token.matchString("blue", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (blue != tmp) {
+ blue = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("red", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (red != tmp) {
+ red = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("green", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (green != tmp) {
+ green = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("newline", true)) {
+ if ((retval & TXT_RET_NEWLN) == 0)
+ newline = 0;
+
+ newline++;
+ retval |= TXT_RET_NEWLN;
+ } else if (token.matchString("point", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (size != tmp) {
+ size = tmp;
+ retval |= TXT_RET_FNTCHG;
+ }
+ }
+ } else if (token.matchString("escapement", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ escapement = tmp;
+ }
+ } else if (token.matchString("italic", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (italic != true) {
+ italic = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (italic != false) {
+ italic = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("underline", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (underline != true) {
+ underline = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (underline != false) {
+ underline = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("strikeout", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (strikeout != true) {
+ strikeout = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (strikeout != false) {
+ strikeout = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("bold", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (bold != true) {
+ bold = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (bold != false) {
+ bold = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("skipcolor", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ skipcolor = true;
+ } else if (token.matchString("off", true)) {
+ skipcolor = false;
+ }
+ }
+ } else if (token.matchString("image", true)) {
+ // Not used
+ } else if (token.matchString("statebox", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ statebox = atoi(token.c_str());
+ retval |= TXT_RET_HASSTBOX;
+ }
+ } else if (token.matchString("justify", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("center", true))
+ justify = TXT_JUSTIFY_CENTER;
+ else if (token.matchString("left", true))
+ justify = TXT_JUSTIFY_LEFT;
+ else if (token.matchString("right", true))
+ justify = TXT_JUSTIFY_RIGHT;
+ }
+ }
+ }
+ return (txtReturn)retval;
+}
+
+void cTxtStyle::readAllStyle(const Common::String &txt) {
+ int16 strt = -1;
+ int16 endt = -1;
+
+ for (uint16 i = 0; i < txt.size(); i++) {
+ if (txt[i] == '<')
+ strt = i;
+ else if (txt[i] == '>') {
+ endt = i;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1);
+ }
+
+ }
+}
+
+void cTxtStyle::setFontStyle(sTTFont &font) {
+ uint temp_stl = 0;
+
+ if (bold)
+ temp_stl |= sTTFont::STTF_BOLD;
+
+ if (italic)
+ temp_stl |= sTTFont::STTF_ITALIC;
+
+ if (underline)
+ temp_stl |= sTTFont::STTF_UNDERLINE;
+
+ if (strikeout)
+ temp_stl |= sTTFont::STTF_STRIKEOUT;
+
+ if (sharp)
+ temp_stl |= sTTFont::STTF_SHARP;
+
+ font.setStyle(temp_stl);
+}
+
+void cTxtStyle::setFont(sTTFont &font) {
+ uint temp_stl = 0;
+
+ if (bold)
+ temp_stl |= sTTFont::STTF_BOLD;
+
+ if (italic)
+ temp_stl |= sTTFont::STTF_ITALIC;
+
+ if (underline)
+ temp_stl |= sTTFont::STTF_UNDERLINE;
+
+ if (strikeout)
+ temp_stl |= sTTFont::STTF_STRIKEOUT;
+
+ if (sharp)
+ temp_stl |= sTTFont::STTF_SHARP;
+
+ font.loadFont(fontname, size, temp_stl);
+}
+
+Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
+ style.setFontStyle(fnt);
+ uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue);
+ return fnt.renderSolidText(txt, clr);
+}
+
+void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
+ if (justify == TXT_JUSTIFY_LEFT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft);
+ else if (justify == TXT_JUSTIFY_CENTER)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter);
+ else if (justify == TXT_JUSTIFY_RIGHT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight);
+}
+
+int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) {
+ sTTFont font(_engine);
+ fnt_stl.setFont(font);
+
+ dst.fillRect(Common::Rect(dst.w, dst.h), 0);
+
+ uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue);
+
+ int16 w;
+
+ w = font.getStringWidth(txt);
+
+ drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify);
+
+ return w;
+}
+
+void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
+ const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it
+ const int TXT_CFG_TEXTURES_PER_LINE = 6;
+ cTxtStyle style, style2;
+ int16 strt = -1;
+ int16 endt = -1;
+ int16 i = 0;
+ int16 dx = 0, dy = 0;
+ int16 txt_w;
+ int16 txtpos = 0;
+ Common::String buf;
+ Common::String buf2;
+
+ Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE];
+ int16 currentline = 0, currentlineitm = 0;
+
+ int TxtJustify[TXT_CFG_TEXTURES_LINES];
+ int TxtPoint[TXT_CFG_TEXTURES_LINES];
+
+ for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) {
+ TxtPoint[k] = 0;
+ for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ TxtSurfaces[k][j] = NULL;
+ }
+
+ int16 stringlen = text.size();
+
+ sTTFont font(_engine);
+
+ style.setFont(font);
+
+ int16 prevbufspace = 0, prevtxtspace = 0;
+
+ while (i < stringlen) {
+ TxtJustify[currentline] = style.justify;
+ if (text[i] == '<') {
+ int16 ret = 0;
+
+ strt = i;
+ while (i < stringlen && text[i] != '>')
+ i++;
+ endt = i;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0) {
+ style2 = style;
+ ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1);
+ }
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (buf.size() > 0) {
+ txt_w = font.getStringWidth(buf);
+
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+
+ currentlineitm++;
+
+ buf.clear();
+ prevbufspace = 0;
+ txtpos = 0;
+ dx += txt_w;
+
+ }
+ if (ret & TXT_RET_FNTCHG) {
+ style.setFont(font);
+ }
+ if (ret & TXT_RET_FNTSTL)
+ style.setFontStyle(font);
+
+ if (ret & TXT_RET_NEWLN) {
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf3;
+ buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox));
+ buf += buf3;
+ txtpos += buf3.size();
+ }
+
+ } else {
+
+ buf += text[i];
+ txtpos++;
+
+ if (text[i] == ' ') {
+ prevbufspace = txtpos - 1;
+ prevtxtspace = i;
+ }
+
+ if (font.isLoaded()) {
+ txt_w = font.getStringWidth(buf);
+ if (txt_w + dx > dst.w) {
+ if (prevbufspace == 0) {
+ prevtxtspace = i;
+ prevbufspace = txtpos - 1;
+ }
+ buf2 = Common::String(buf.c_str(), prevbufspace + 1);
+
+ if (buf2.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ buf.clear();
+ i = prevtxtspace;
+ prevbufspace = 0;
+ txtpos = 0;
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+ }
+ i++;
+ }
+
+ if (buf.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ dy = 0;
+ for (i = 0; i <= currentline; i++) {
+ int16 j = 0;
+ int16 width = 0;
+ while (TxtSurfaces[i][j] != NULL) {
+ width += TxtSurfaces[i][j]->w;
+ j++;
+ }
+ dx = 0;
+ for (int32_t jj = 0; jj < j; jj++) {
+ if (TxtJustify[i] == TXT_JUSTIFY_LEFT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_CENTER)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ dx += TxtSurfaces[i][jj]->w;
+ }
+
+ dy += TxtPoint[i];
+ }
+
+ for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++)
+ for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ if (TxtSurfaces[i][j] != NULL) {
+ TxtSurfaces[i][j]->free();
+ delete TxtSurfaces[i][j];
+ }
+}
+
+Common::String readWideLine(Common::SeekableReadStream &stream) {
+ Common::String asciiString;
+
+ while (!stream.eos()) {
+ uint32 value = stream.readUint16LE();
+ // 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 < 0x80) {
+ asciiString += (char)(value & 0x7F);
+ } else if (value >= 0x80 && value < 0x800) {
+ asciiString += (char)(0xC0 | ((value >> 6) & 0x1F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value >= 0x800 && value < 0x10000) {
+ asciiString += (char)(0xE0 | ((value >> 12) & 0xF));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value >= 0x10000 && value < 0x200000) {
+ asciiString += (char)(0xF0);
+ asciiString += (char)(0x80 | ((value >> 12) & 0x3F));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ }
+ }
+
+ return asciiString;
+}
+
+int8 getUtf8CharSize(char chr) {
+ if ((chr & 0x80) == 0)
+ return 1;
+ else if ((chr & 0xE0) == 0xC0)
+ return 2;
+ else if ((chr & 0xF0) == 0xE0)
+ return 3;
+ else if ((chr & 0xF8) == 0xF0)
+ return 4;
+ else if ((chr & 0xFC) == 0xF8)
+ return 5;
+ else if ((chr & 0xFE) == 0xFC)
+ return 6;
+
+ return 1;
+}
+
+uint16 readUtf8Char(const char *chr) {
+ uint16 result = 0;
+ if ((chr[0] & 0x80) == 0)
+ result = chr[0];
+ else if ((chr[0] & 0xE0) == 0xC0)
+ result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F);
+ else if ((chr[0] & 0xF0) == 0xE0)
+ result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F);
+ else
+ result = chr[0];
+
+ return result;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h
new file mode 100644
index 0000000..4b318fd
--- /dev/null
+++ b/engines/zvision/text/text.h
@@ -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.
+ *
+ *
+ */
+
+#ifndef ZVISION_TEXT_H
+#define ZVISION_TEXT_H
+
+#include "zvision/detection.h"
+#include "zvision/fonts/truetype_font.h"
+#include "zvision/zvision.h"
+
+
+namespace Graphics {
+class FontManager;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+enum txtJustify {
+ TXT_JUSTIFY_CENTER = 0,
+ TXT_JUSTIFY_LEFT = 1,
+ TXT_JUSTIFY_RIGHT = 2
+};
+
+enum txtReturn {
+ TXT_RET_NOTHING = 0x0,
+ TXT_RET_FNTCHG = 0x1,
+ TXT_RET_FNTSTL = 0x2,
+ TXT_RET_NEWLN = 0x4,
+ TXT_RET_HASSTBOX = 0x8
+};
+
+class cTxtStyle {
+public:
+ cTxtStyle();
+ txtReturn parseStyle(const Common::String &strin, int16 len);
+ void readAllStyle(const Common::String &txt);
+ void setFontStyle(sTTFont &font);
+ void setFont(sTTFont &font);
+
+public:
+ Common::String fontname;
+ txtJustify justify; // 0 - center, 1-left, 2-right
+ int16 size;
+ uint8 red; // 0-255
+ uint8 green; // 0-255
+ uint8 blue; // 0-255
+ int8 newline;
+ int8 escapement;
+ bool italic;
+ bool bold;
+ bool underline;
+ bool strikeout;
+ bool skipcolor;
+ int32 statebox;
+ bool sharp;
+ // char image ??
+};
+
+class textRenderer {
+public:
+ textRenderer(ZVision *engine): _engine(engine) {};
+
+ void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
+ int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst);
+ Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style);
+ void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst);
+
+private:
+ ZVision *_engine;
+};
+
+Common::String readWideLine(Common::SeekableReadStream &stream);
+int8 getUtf8CharSize(char chr);
+uint16 readUtf8Char(const char *chr);
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp
deleted file mode 100644
index 6741d28..0000000
--- a/engines/zvision/ttytext_node.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * 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/ttytext_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/text.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-
-
-namespace ZVision {
-
-ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
- SideFX(engine, key, SIDEFX_TTYTXT),
- _fnt(engine) {
- _delay = delay;
- _r = r;
- _txtpos = 0;
- _nexttime = 0;
- _dx = 0;
- _dy = 0;
-
- Common::File *infile = _engine->getSearchManager()->openFile(file);
- if (infile) {
- while (!infile->eos()) {
- Common::String asciiLine = readWideLine(*infile);
- if (asciiLine.empty()) {
- continue;
- }
- _txtbuf += asciiLine;
- }
-
- delete infile;
- }
- _img.create(_r.width(), _r.height(), _engine->_pixelFormat);
- _style.sharp = true;
- _style.readAllStyle(_txtbuf);
- _style.setFont(_fnt);
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-ttyTextNode::~ttyTextNode() {
- _engine->getScriptManager()->setStateValue(_key, 2);
- _img.free();
-}
-
-bool ttyTextNode::process(uint32 deltaTimeInMillis) {
- _nexttime -= deltaTimeInMillis;
-
- if (_nexttime < 0) {
- if (_txtpos < _txtbuf.size()) {
- if (_txtbuf[_txtpos] == '<') {
- int32 strt = _txtpos;
- int32 endt = 0;
- int16 ret = 0;
- while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
- _txtpos++;
- endt = _txtpos;
- if (strt != -1)
- if ((endt - strt - 1) > 0)
- ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
-
- if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
- if (ret & TXT_RET_FNTCHG)
- _style.setFont(_fnt);
- if (ret & TXT_RET_FNTSTL)
- _style.setFontStyle(_fnt);
-
- if (ret & TXT_RET_NEWLN)
- newline();
- }
-
- if (ret & TXT_RET_HASSTBOX) {
- Common::String buf;
- buf.format("%d", _style.statebox);
-
- for (uint8 j = 0; j < buf.size(); j++)
- outchar(buf[j]);
- }
-
- _txtpos++;
- } else {
- int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
-
- uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
-
- if (chr == ' ') {
- uint32 i = _txtpos + charsz;
- uint16 width = _fnt.getCharWidth(chr);
-
- while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
-
- int8 chsz = getUtf8CharSize(_txtbuf[i]);
- uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
-
- width += _fnt.getCharWidth(uchr);
-
- i += chsz;
- }
-
- if (_dx + width > _r.width())
- newline();
- else
- outchar(chr);
- } else
- outchar(chr);
-
- _txtpos += charsz;
- }
- _nexttime = _delay;
- _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
- } else
- return stop();
- }
-
- return false;
-}
-
-void ttyTextNode::scroll() {
- int32 scrl = 0;
- while (_dy - scrl > _r.height() - _fnt.getFontHeight())
- scrl += _fnt.getFontHeight();
- int8 *pixels = (int8 *)_img.getPixels();
- for (uint16 h = scrl; h < _img.h; h++)
- memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
-
- _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
- _dy -= scrl;
-}
-
-void ttyTextNode::newline() {
- _dy += _fnt.getFontHeight();
- _dx = 0;
-}
-
-void ttyTextNode::outchar(uint16 chr) {
- uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue);
-
- if (_dx + _fnt.getCharWidth(chr) > _r.width())
- newline();
-
- if (_dy + _fnt.getFontHeight() >= _r.height())
- scroll();
-
- _fnt.drawChar(&_img, chr, _dx, _dy, clr);
-
- _dx += _fnt.getCharWidth(chr);
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h
deleted file mode 100644
index e25fdb0..0000000
--- a/engines/zvision/ttytext_node.h
+++ /dev/null
@@ -1,76 +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_TTYTEXT_NODE_H
-#define ZVISION_TTYTEXT_NODE_H
-
-#include "common/rect.h"
-#include "graphics/surface.h"
-
-#include "zvision/sidefx.h"
-#include "zvision/text.h"
-#include "zvision/fonts/truetype_font.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-class ttyTextNode : public SideFX {
-public:
- ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
- ~ttyTextNode();
-
- /**
- * 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:
- Common::Rect _r;
- //int16 x;
- //int16 y;
- //uint16 w;
- //uint16 h;
- cTxtStyle _style;
- sTTFont _fnt;
- Common::String _txtbuf;
- uint32 _txtpos;
- //int32 txtsize;
- int32 _delay;
- int32 _nexttime;
- Graphics::Surface _img;
- int16 _dx;
- int16 _dy;
-private:
-
- void newline();
- void scroll();
- void outchar(uint16 chr);
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 580f8c4..0eb1425 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -29,12 +29,12 @@
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
#include "zvision/core/save_manager.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/archives/zfs_archive.h"
#include "zvision/detection.h"
#include "zvision/core/menu.h"
-#include "zvision/search_manager.h"
-#include "zvision/text.h"
+#include "zvision/core/search_manager.h"
+#include "zvision/text/text.h"
#include "zvision/fonts/truetype_font.h"
#include "common/config-manager.h"
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 2674df2..db2c646 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -26,7 +26,7 @@
#include "zvision/detection.h"
#include "zvision/utility/clock.h"
-#include "zvision/search_manager.h"
+#include "zvision/core/search_manager.h"
#include "common/random.h"
#include "common/events.h"
Commit: 628d6cb4ee92aa15dbdf5029b8675cb09d18f3e9
https://github.com/scummvm/scummvm/commit/628d6cb4ee92aa15dbdf5029b8675cb09d18f3e9
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-05T17:15:04Z
Commit Message:
ZVISION: Fix puzzle disable condition check
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index a27ae4d..fc765f0 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -158,8 +158,7 @@ void ScriptManager::updateControls(uint deltaTimeMillis) {
void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
// Check if the puzzle is already finished
// Also check that the puzzle isn't disabled
- if (getStateValue(puzzle->key) == 1 &&
- (getStateFlag(puzzle->key) & Puzzle::DISABLED) == 0) {
+ if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) {
return;
}
Commit: bbaebdf680179dca103b0ed635e791aa602d610d
https://github.com/scummvm/scummvm/commit/bbaebdf680179dca103b0ed635e791aa602d610d
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-05T17:27:08Z
Commit Message:
ZVISION: Process events for controls similar to original engine, fix some errors.
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/zvision.h
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 943f8ff..c977125 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -46,13 +46,15 @@ void ZVision::processEvents() {
case Common::EVENT_LBUTTONDOWN:
_cursorManager->cursorDown(true);
_scriptManager->setStateValue(StateKey_LMouse, 1);
- onMouseDown(_event.mouse);
+ _menu->onMouseDown(_event.mouse);
+ _scriptManager->addEvent(_event);
break;
case Common::EVENT_LBUTTONUP:
_cursorManager->cursorDown(false);
_scriptManager->setStateValue(StateKey_LMouse, 0);
- onMouseUp(_event.mouse);
+ _menu->onMouseUp(_event.mouse);
+ _scriptManager->addEvent(_event);
break;
case Common::EVENT_RBUTTONDOWN:
@@ -87,10 +89,10 @@ void ZVision::processEvents() {
break;
}
- _scriptManager->onKeyDown(_event.kbd);
+ _scriptManager->addEvent(_event);
break;
case Common::EVENT_KEYUP:
- _scriptManager->onKeyUp(_event.kbd);
+ _scriptManager->addEvent(_event);
break;
default:
break;
@@ -98,20 +100,6 @@ void ZVision::processEvents() {
}
}
-void ZVision::onMouseDown(const Common::Point &pos) {
- _menu->onMouseDown(pos);
-
- Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- _scriptManager->onMouseDown(pos, imageCoord);
-}
-
-void ZVision::onMouseUp(const Common::Point &pos) {
- _menu->onMouseUp(pos);
-
- Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- _scriptManager->onMouseUp(pos, imageCoord);
-}
-
void ZVision::onMouseMove(const Common::Point &pos) {
_menu->onMouseMove(pos);
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index fc765f0..7c124b6 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -51,6 +51,7 @@ ScriptManager::~ScriptManager() {
cleanScriptScope(world);
cleanScriptScope(room);
cleanScriptScope(nodeview);
+ _controlEvents.clear();
}
void ScriptManager::initialize() {
@@ -66,6 +67,8 @@ void ScriptManager::initialize() {
parseScrFile("universe.scr", universe);
changeLocation('g', 'a', 'r', 'y', 0);
+
+ _controlEvents.clear();
}
void ScriptManager::update(uint deltaTimeMillis) {
@@ -151,6 +154,32 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) {
void ScriptManager::updateControls(uint deltaTimeMillis) {
if (!_activeControls)
return;
+
+ // Process only one event
+ if (!_controlEvents.empty()) {
+ Common::Event _event = _controlEvents.front();
+ Common::Point imageCoord;
+ switch (_event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseDown(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseUp(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_KEYDOWN:
+ onKeyDown(_event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ onKeyUp(_event.kbd);
+ break;
+ default:
+ break;
+ }
+ _controlEvents.pop_front();
+ }
+
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
(*iter)->process(deltaTimeMillis);
}
@@ -693,6 +722,10 @@ Location ScriptManager::getCurrentLocation() const {
return location;
}
+void ScriptManager::addEvent(Common::Event event) {
+ _controlEvents.push_back(event);
+}
+
ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val):
_sc_man(sc_man) {
value = 0;
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 8ec364b..316b50a 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -29,6 +29,7 @@
#include "common/hashmap.h"
#include "common/queue.h"
+#include "common/events.h"
namespace Common {
@@ -111,6 +112,7 @@ typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;
typedef Common::HashMap<uint32, int32> StateMap;
typedef Common::List<SideFX *> SideFXList;
+typedef Common::List<Common::Event> EventList;
class ScriptManager {
public:
@@ -152,6 +154,8 @@ private:
/** Holds the currently active controls */
ControlList *_activeControls;
+ EventList _controlEvents;
+
script_scope universe;
script_scope world;
script_scope room;
@@ -192,6 +196,8 @@ public:
void killSideFx(uint32 key);
void killSideFxType(SideFX::SideFXType type);
+ void addEvent(Common::Event);
+
/**
* Called when LeftMouse is pushed.
*
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index db2c646..57e7339 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -179,8 +179,6 @@ private:
/** 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);
void updateRotation();
};
Commit: b9103b8d19a5da396d217e8d9bcc5c1502b89837
https://github.com/scummvm/scummvm/commit/b9103b8d19a5da396d217e8d9bcc5c1502b89837
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T19:09:08Z
Commit Message:
ZVISION: Implement functions for system messaging.
Changed paths:
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index f3b01b7..c89444d 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -729,6 +729,21 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) {
return _subid;
}
+uint16 RenderManager::createSubArea() {
+ _subid++;
+
+ oneSub sub;
+ sub.redraw = false;
+ sub.timer = -1;
+ sub.todelete = false;
+ sub._r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom);
+ sub._r.translate(-_workingWindow.left, -_workingWindow.top);
+
+ _subsList[_subid] = sub;
+
+ return _subid;
+}
+
void RenderManager::deleteSubArea(uint16 id) {
if (_subsList.contains(id))
_subsList[id].todelete = true;
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index ca2e715..b4c6c76 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -233,6 +233,7 @@ public:
void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey);
uint16 createSubArea(const Common::Rect &area);
+ uint16 createSubArea();
void deleteSubArea(uint16 id);
void deleteSubArea(uint16 id, int16 delay);
void updateSubArea(uint16 id, const Common::String &txt);
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0eb1425..24e15e0 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -212,6 +212,71 @@ Common::Error ZVision::run() {
return Common::kNoError;
}
+bool ZVision::askQuestion(const Common::String &str) {
+ uint16 msgid = _renderManager->createSubArea();
+ _renderManager->updateSubArea(msgid, str);
+ _renderManager->processSubs(0);
+ _renderManager->renderBackbufferToScreen();
+ _clock.stop();
+
+ int result = 0;
+
+ while (result == 0) {
+ Common::Event evnt;
+ while (_eventMan->pollEvent(evnt)) {
+ if (evnt.type == Common::EVENT_KEYDOWN) {
+ switch (evnt.kbd.keycode) {
+ case Common::KEYCODE_y:
+ result = 2;
+ break;
+ case Common::KEYCODE_n:
+ result = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ _system->updateScreen();
+ _system->delayMillis(66);
+ }
+ _renderManager->deleteSubArea(msgid);
+ _clock.start();
+ return result == 2;
+}
+
+void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) {
+ uint16 msgid = _renderManager->createSubArea();
+ _renderManager->updateSubArea(msgid, str);
+ _renderManager->processSubs(0);
+ _renderManager->renderBackbufferToScreen();
+ _clock.stop();
+
+ uint32 stop_time = _system->getMillis() + milsecs;
+ while (_system->getMillis() < stop_time) {
+ Common::Event evnt;
+ while (_eventMan->pollEvent(evnt)) {
+ if (evnt.type == Common::EVENT_KEYDOWN &&
+ (evnt.kbd.keycode == Common::KEYCODE_SPACE ||
+ evnt.kbd.keycode == Common::KEYCODE_RETURN ||
+ evnt.kbd.keycode == Common::KEYCODE_ESCAPE))
+ break;
+ }
+ _system->updateScreen();
+ _system->delayMillis(66);
+ }
+ _renderManager->deleteSubArea(msgid);
+ _clock.start();
+}
+
+void ZVision::timedMessage(const Common::String &str, uint16 milsecs) {
+ uint16 msgid = _renderManager->createSubArea();
+ _renderManager->updateSubArea(msgid, str);
+ _renderManager->processSubs(0);
+ _renderManager->renderBackbufferToScreen();
+ _renderManager->deleteSubArea(msgid, milsecs);
+}
+
void ZVision::pauseEngineIntern(bool pause) {
_mixer->pauseAll(pause);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 57e7339..e5d32bf 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -167,6 +167,10 @@ public:
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
+ bool askQuestion(const Common::String &str);
+ void delayedMessage(const Common::String &str, uint16 milsecs);
+ void timedMessage(const Common::String &str, uint16 milsecs);
+
void setRenderDelay(uint);
bool canRender();
Commit: 57857a1d768fc9b226326efe2294f73e847c816e
https://github.com/scummvm/scummvm/commit/57857a1d768fc9b226326efe2294f73e847c816e
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:35:50Z
Commit Message:
ZVISION: Controls now can return type of control.
Changed paths:
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/slot_control.cpp
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 93ad5f5..6ec47c6 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -39,14 +39,33 @@ class ZVision;
class Control {
public:
+
+ enum ControlType {
+ CONTROL_UNKNOW,
+ CONTROL_INPUT,
+ CONTROL_PUSHTGL,
+ CONTROL_SLOT,
+ CONTROL_LEVER,
+ CONTROL_SAVE,
+ CONTROL_SAFE,
+ CONTROL_FIST,
+ CONTROL_TITLER,
+ CONTROL_HOTMOV,
+ CONTROL_PAINT
+ };
+
Control() : _engine(0), _key(0) {}
- Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
+ Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type) {}
virtual ~Control() {}
uint32 getKey() {
return _key;
}
+ ControlType getType() {
+ return _type;
+ }
+
virtual void focus() {}
virtual void unfocus() {}
/**
@@ -109,6 +128,8 @@ public:
static void parseFlatControl(ZVision *engine);
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
+private:
+ ControlType _type;
};
// TODO: Implement InputControl
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index ba1b634..0bca01b 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -38,7 +38,7 @@
namespace ZVision {
InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
+ : Control(engine, key, CONTROL_INPUT),
_nextTabstop(0),
_focused(false),
_textChanged(false),
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 7e3ee77..87fbb43 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -42,7 +42,7 @@
namespace ZVision {
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
+ : Control(engine, key, CONTROL_LEVER),
_frameInfo(0),
_frameCount(0),
_startFrame(0),
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 16cd971..2f4af0d 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -35,7 +35,7 @@
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
+ : Control(engine, key, CONTROL_PUSHTGL),
_countTo(2),
_event(Common::EVENT_LBUTTONUP) {
// Loop until we find the closing brace
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
index c85b02b..f78061a 100644
--- a/engines/zvision/scripting/controls/slot_control.cpp
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -36,7 +36,7 @@
namespace ZVision {
SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
+ : Control(engine, key, CONTROL_SLOT) {
_rendered_item = 0;
_bkg = NULL;
Commit: 9dd9bfce808cacb90bdea1ee7cc371e698c1eca9
https://github.com/scummvm/scummvm/commit/9dd9bfce808cacb90bdea1ee7cc371e698c1eca9
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:38:11Z
Commit Message:
ZVISION: String manager only load text lines without parsing text styles.
Changed paths:
engines/zvision/text/string_manager.cpp
engines/zvision/text/string_manager.h
diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp
index cadfbf1..114f298 100644
--- a/engines/zvision/text/string_manager.cpp
+++ b/engines/zvision/text/string_manager.cpp
@@ -22,6 +22,8 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
+#include "zvision/core/search_manager.h"
#include "zvision/text/string_manager.h"
#include "zvision/fonts/truetype_font.h"
@@ -49,10 +51,25 @@ StringManager::~StringManager() {
void StringManager::initialize(ZVisionGameId gameId) {
if (gameId == GID_NEMESIS) {
// TODO: Check this hardcoded filename against all versions of Nemesis
- parseStrFile("nemesis.str");
+ loadStrFile("nemesis.str");
} else if (gameId == GID_GRANDINQUISITOR) {
// TODO: Check this hardcoded filename against all versions of Grand Inquisitor
- parseStrFile("inquis.str");
+ loadStrFile("inquis.str");
+ }
+}
+
+void StringManager::loadStrFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("%s does not exist. String parsing failed", fileName.c_str());
+ return;
+ }
+ uint lineNumber = 0;
+ while (!file.eos()) {
+ _lines[lineNumber] = readWideLine(file);
+
+ lineNumber++;
+ assert(lineNumber <= NUM_TEXT_LINES);
}
}
@@ -252,4 +269,8 @@ StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
return _inGameText[stringNumber].fragments.front().style;
}
+const Common::String StringManager::getTextLine(uint stringNumber) {
+ return _lines[stringNumber];
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h
index af8324b..e226fbe 100644
--- a/engines/zvision/text/string_manager.h
+++ b/engines/zvision/text/string_manager.h
@@ -63,6 +63,8 @@ private:
private:
ZVision *_engine;
+ Common::String _lines[NUM_TEXT_LINES];
+
InGameText _inGameText[NUM_TEXT_LINES];
Common::HashMap<Common::String, TruetypeFont *> _fonts;
@@ -71,8 +73,10 @@ private:
public:
void initialize(ZVisionGameId gameId);
StringManager::TextStyle getTextStyle(uint stringNumber);
+ const Common::String getTextLine(uint stringNumber);
private:
+ void loadStrFile(const Common::String &fileName);
void parseStrFile(const Common::String &fileName);
void parseTag(const Common::String &tagString, uint lineNumber);
Commit: bc4b0b5bf6145be02071410e044c9f27040c856b
https://github.com/scummvm/scummvm/commit/bc4b0b5bf6145be02071410e044c9f27040c856b
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:39:02Z
Commit Message:
ZVISION: Implement code for getControl
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 7c124b6..25fa138 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -351,7 +351,9 @@ void ScriptManager::unsetStateFlag(uint32 key, uint value) {
}
Control *ScriptManager::getControl(uint32 key) {
-
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter)
+ if ((*iter)->getKey() == key)
+ return *iter;
return nullptr;
}
Commit: ce248644b813d7a722f2c6250f723331fd119e55
https://github.com/scummvm/scummvm/commit/ce248644b813d7a722f2c6250f723331fd119e55
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:41:49Z
Commit Message:
ZVISION: Fix drawTxt y-position.
Changed paths:
engines/zvision/text/text.cpp
diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp
index cad2723..efb0fb4 100644
--- a/engines/zvision/text/text.cpp
+++ b/engines/zvision/text/text.cpp
@@ -318,7 +318,7 @@ int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graph
w = font.getStringWidth(txt);
- drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify);
+ drawTxtWithJustify(txt, font, clr, dst, 0, fnt_stl.justify);
return w;
}
Commit: 7f2d4d9a6c72b4f0e88c86d5fe04eb059ec107a8
https://github.com/scummvm/scummvm/commit/7f2d4d9a6c72b4f0e88c86d5fe04eb059ec107a8
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:44:10Z
Commit Message:
ZVISION: Implement fuctionality for change focus without of calling focus/unfocus
Changed paths:
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 25fa138..ada06a5 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -373,6 +373,10 @@ void ScriptManager::focusControl(uint32 key) {
_currentlyFocusedControl = key;
}
+void ScriptManager::setFocusControlKey(uint32 key) {
+ _currentlyFocusedControl = key;
+}
+
void ScriptManager::addSideFX(SideFX *fx) {
_activeSideFx.push_back(fx);
}
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 316b50a..6cc9578 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -188,6 +188,8 @@ public:
void disableControl(uint32 key);
void focusControl(uint32 key);
+ // Only change focus control without call focus/unfocus.
+ void setFocusControlKey(uint32 key);
void addSideFX(SideFX *fx);
SideFX *getSideFX(uint32 key);
Commit: 5a870100bd62ce3913bb4a3adb6bd12ce97f1675
https://github.com/scummvm/scummvm/commit/5a870100bd62ce3913bb4a3adb6bd12ce97f1675
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-07-12T21:52:56Z
Commit Message:
ZVISION: Bool results for keyUp and keyDown events for controls.
Changed paths:
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/input_control.h
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 6ec47c6..ac24505 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -101,13 +101,13 @@ public:
*
* @param keycode The key that was pressed
*/
- virtual void onKeyDown(Common::KeyState keyState) {}
+ virtual bool onKeyDown(Common::KeyState keyState) {return false;}
/**
* Called when a key is released. Default is NOP.
*
* @param keycode The key that was pressed
*/
- virtual void onKeyUp(Common::KeyState keyState) {}
+ virtual bool onKeyUp(Common::KeyState keyState) {return false;}
/**
* Processes the node given the deltaTime since last frame. Default is NOP.
*
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index 0bca01b..bebf3fa 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -98,9 +98,9 @@ bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
return false;
}
-void InputControl::onKeyDown(Common::KeyState keyState) {
+bool InputControl::onKeyDown(Common::KeyState keyState) {
if (!_focused) {
- return;
+ return false;
}
if (keyState.keycode == Common::KEYCODE_BACKSPACE) {
@@ -119,6 +119,7 @@ void InputControl::onKeyDown(Common::KeyState keyState) {
_textChanged = true;
}
}
+ return false;
}
bool InputControl::process(uint32 deltaTimeInMillis) {
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 6fcdb2c..91fcd36 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -55,7 +55,7 @@ public:
_focused = false;
}
bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- void onKeyDown(Common::KeyState keyState);
+ bool onKeyDown(Common::KeyState keyState);
bool process(uint32 deltaTimeInMillis);
};
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index ada06a5..53fa583 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -471,7 +471,8 @@ void ScriptManager::onKeyDown(Common::KeyState keyState) {
if (!_activeControls)
return;
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
- (*iter)->onKeyDown(keyState);
+ if ((*iter)->onKeyDown(keyState))
+ return;
}
}
@@ -479,7 +480,8 @@ void ScriptManager::onKeyUp(Common::KeyState keyState) {
if (!_activeControls)
return;
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
- (*iter)->onKeyUp(keyState);
+ if ((*iter)->onKeyUp(keyState))
+ return;
}
}
Commit: fb62b9477b5a9d887eb3484d82a7ef67efb6bfa5
https://github.com/scummvm/scummvm/commit/fb62b9477b5a9d887eb3484d82a7ef67efb6bfa5
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:29:58+07:00
Commit Message:
ZVISION: Make controls processing breakeable.
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 53fa583..4dd5181 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -181,7 +181,8 @@ void ScriptManager::updateControls(uint deltaTimeMillis) {
}
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
- (*iter)->process(deltaTimeMillis);
+ if ( (*iter)->process(deltaTimeMillis) )
+ break;
}
void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
Commit: d7d058cd60aae2c898f285b183416d1393c4a7ad
https://github.com/scummvm/scummvm/commit/d7d058cd60aae2c898f285b183416d1393c4a7ad
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:32:48+07:00
Commit Message:
ZVISION: New scriptManager location methods
Changed paths:
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 4dd5181..6a9398d 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -486,6 +486,10 @@ void ScriptManager::onKeyUp(Common::KeyState keyState) {
}
}
+void ScriptManager::changeLocation(const Location &_newLocation) {
+ changeLocation(_newLocation.world, _newLocation.room, _newLocation.node, _newLocation.view, _newLocation.offset);
+}
+
void ScriptManager::changeLocation(char _world, char _room, char _node, char _view, uint32 offset) {
_nextLocation.world = _world;
_nextLocation.room = _room;
@@ -731,6 +735,28 @@ Location ScriptManager::getCurrentLocation() const {
return location;
}
+Location ScriptManager::getLastLocation() {
+ Location location;
+ location.world = getStateValue(StateKey_LastWorld);
+ location.room = getStateValue(StateKey_LastRoom);
+ location.node = getStateValue(StateKey_LastNode);
+ location.view = getStateValue(StateKey_LastView);
+ location.offset = getStateValue(StateKey_LastViewPos);
+
+ return location;
+}
+
+Location ScriptManager::getLastMenuLocation() {
+ Location location;
+ location.world = getStateValue(StateKey_Menu_LastWorld);
+ location.room = getStateValue(StateKey_Menu_LastRoom);
+ location.node = getStateValue(StateKey_Menu_LastNode);
+ location.view = getStateValue(StateKey_Menu_LastView);
+ location.offset = getStateValue(StateKey_Menu_LastViewPos);
+
+ return location;
+}
+
void ScriptManager::addEvent(Common::Event event) {
_controlEvents.push_back(event);
}
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 6cc9578..4d82f36 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -237,11 +237,14 @@ public:
/** Mark next location */
void changeLocation(char world, char room, char node, char view, uint32 offset);
+ void changeLocation(const Location &_newLocation);
void serialize(Common::WriteStream *stream);
void deserialize(Common::SeekableReadStream *stream);
Location getCurrentLocation() const;
+ Location getLastLocation();
+ Location getLastMenuLocation();
private:
void referenceTableAddPuzzle(uint32 key, puzzle_ref ref);
Commit: 73d26bc2337e8afd03bfd73e6ccc0c0fb44a5950
https://github.com/scummvm/scummvm/commit/73d26bc2337e8afd03bfd73e6ccc0c0fb44a5950
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:33:36+07:00
Commit Message:
ZVISION: Don't focus on already focused control
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 6a9398d..3801414 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -361,6 +361,8 @@ Control *ScriptManager::getControl(uint32 key) {
void ScriptManager::focusControl(uint32 key) {
if (!_activeControls)
return;
+ if (_currentlyFocusedControl == key)
+ return;
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
Commit: 550c4dbc359ece732684e0733e1925283f31c257
https://github.com/scummvm/scummvm/commit/550c4dbc359ece732684e0733e1925283f31c257
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:35:54+07:00
Commit Message:
ZVISION: Implement full code for input control
Changed paths:
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/input_control.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index bebf3fa..e35b300 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "zvision/scripting/controls/input_control.h"
+#include "zvision/cursors/cursor_manager.h"
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
@@ -42,7 +43,11 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_nextTabstop(0),
_focused(false),
_textChanged(false),
- _cursorOffset(0) {
+ _cursorOffset(0),
+ _enterPressed(false),
+ _readOnly(false),
+ _txtWidth(0),
+ _animation(NULL) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -71,21 +76,30 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
- _textStyle = _engine->getStringManager()->getTextStyle(fontFormatNumber);
+ _string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
+ } else if (line.matchString("*chooser_init_string*", true)) {
+ uint fontFormatNumber;
+
+ sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
+
+ _string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
} else if (line.matchString("*next_tabstop*", true)) {
sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop);
+ } 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("*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
+ _animation = new MetaAnimation(fileName, _engine);
+ _frame = -1;
+ _frameDelay = 0;
} else if (line.matchString("*focus*", true)) {
_focused = true;
+ _engine->getScriptManager()->setFocusControlKey(_key);
}
line = stream.readLine();
@@ -94,51 +108,140 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- _engine->getScriptManager()->focusControl(_key);
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_textRectangle.contains(backgroundImageSpacePos)) {
+ if (!_readOnly) {
+ // Save
+ _engine->getScriptManager()->focusControl(_key);
+ } else {
+ // Restore
+ if (_currentInputText.size())
+ _enterPressed = true;
+ }
+ }
+ return false;
+}
+
+bool InputControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_textRectangle.contains(backgroundImageSpacePos)) {
+ if (!_readOnly) {
+ // Save
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ } else {
+ // Restore
+ if (_currentInputText.size()) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ _engine->getScriptManager()->focusControl(_key);
+ return true;
+ }
+ }
+ }
return false;
}
bool InputControl::onKeyDown(Common::KeyState keyState) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
if (!_focused) {
return false;
}
if (keyState.keycode == Common::KEYCODE_BACKSPACE) {
- _currentInputText.deleteLastChar();
+ if (!_readOnly) {
+ _currentInputText.deleteLastChar();
+ _textChanged = true;
+ }
+ } else if (keyState.keycode == Common::KEYCODE_RETURN) {
+ _enterPressed = true;
} else if (keyState.keycode == Common::KEYCODE_TAB) {
- _focused = false;
+ unfocus();
// Focus the next input control
_engine->getScriptManager()->focusControl(_nextTabstop);
+ // Don't process this event for other controls
+ return true;
} 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;
+ if (!_readOnly) {
+ // 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;
+ }
}
}
return false;
}
bool InputControl::process(uint32 deltaTimeInMillis) {
- if (!_focused) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
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;
+ Graphics::Surface txt;
+ txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat);
+
+ if (!_readOnly || !_focused)
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_init, txt);
+ else
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_chooser_init, txt);
+
+ _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top);
+
+ txt.free();
+ }
+
+ if (_animation && !_readOnly && _focused) {
+ bool need_draw = true;// = _textChanged;
+ _frameDelay -= deltaTimeInMillis;
+ if (_frameDelay <= 0) {
+ _frame = (_frame + 1) % _animation->frameCount();
+ _frameDelay = _animation->frameTime();
+ need_draw = true;
+ }
+
+ if (need_draw) {
+ const Graphics::Surface *srf = _animation->getFrameData(_frame);
+ uint32 xx = _textRectangle.left + _txtWidth;
+ if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width()))
+ xx = _textRectangle.left + _textRectangle.width() - _animation->width();
+ _engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top);
+ }
}
- // Render the next frame of the animation
- // TODO: Implement animation handling
+ _textChanged = false;
+ return false;
+}
+bool InputControl::enterPress() {
+ if (_enterPressed) {
+ _enterPressed = false;
+ return true;
+ }
return false;
}
+void InputControl::setText(const Common::String &_str) {
+ _currentInputText = _str;
+ _textChanged = true;
+}
+
+const Common::String InputControl::getText() {
+ return _currentInputText;
+}
+
+void InputControl::setReadOnly(bool readonly) {
+ _readOnly = readonly;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 91fcd36..5e2190f 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -24,6 +24,8 @@
#define ZVISION_INPUT_CONTROL_H
#include "zvision/scripting/control.h"
+#include "zvision/animation/meta_animation.h"
+#include "zvision/text/text.h"
#include "zvision/text/string_manager.h"
#include "common/rect.h"
@@ -38,25 +40,39 @@ public:
private:
Common::Rect _textRectangle;
Common::Rect _headerRectangle;
- StringManager::TextStyle _textStyle;
+ cTxtStyle _string_init;
+ cTxtStyle _string_chooser_init;
uint32 _nextTabstop;
- Common::String _cursorAnimationFileName;
bool _focused;
Common::String _currentInputText;
bool _textChanged;
uint _cursorOffset;
+ bool _enterPressed;
+ bool _readOnly;
+
+ int16 _txtWidth;
+ MetaAnimation *_animation;
+ int32 _frameDelay;
+ int16 _frame;
public:
void focus() {
_focused = true;
+ _textChanged = true;
}
void unfocus() {
_focused = false;
+ _textChanged = true;
}
bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool onKeyDown(Common::KeyState keyState);
bool process(uint32 deltaTimeInMillis);
+ void setText(const Common::String &_str);
+ const Common::String getText();
+ bool enterPress();
+ void setReadOnly(bool);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 5d697bd..d1d6e28 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -31,6 +31,7 @@
#include "zvision/scripting/controls/push_toggle_control.h"
#include "zvision/scripting/controls/lever_control.h"
#include "zvision/scripting/controls/slot_control.h"
+#include "zvision/scripting/controls/input_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -346,6 +347,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new LeverControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("slot")) {
return new SlotControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("input")) {
+ return new InputControl(_engine, key, stream);
}
return NULL;
}
Commit: 5a5a32c84a67ce4c8466b069b6bb1c844d014577
https://github.com/scummvm/scummvm/commit/5a5a32c84a67ce4c8466b069b6bb1c844d014577
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:39:14+07:00
Commit Message:
ZVISION: New SaveManager methods for pre-buffering save data
Changed paths:
engines/zvision/core/save_manager.cpp
engines/zvision/core/save_manager.h
diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp
index 8ec4f4d..6e8b6b5 100644
--- a/engines/zvision/core/save_manager.cpp
+++ b/engines/zvision/core/save_manager.cpp
@@ -67,6 +67,13 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me
delete file;
}
+void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) {
+ if (_tempSave) {
+ saveGame(slot, saveName, _tempSave);
+ flushSaveBuffer();
+ }
+}
+
void SaveManager::autoSave() {
Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());
@@ -231,4 +238,20 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
return saveFile;
}
+void SaveManager::prepareSaveBuffer() {
+ if (_tempSave)
+ delete _tempSave;
+
+ _tempSave = new Common::MemoryWriteStreamDynamic;
+
+ _engine->getScriptManager()->serialize(_tempSave);
+}
+
+void SaveManager::flushSaveBuffer() {
+ if (_tempSave)
+ delete _tempSave;
+
+ _tempSave = NULL;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h
index 8ed64a3..c7c1297 100644
--- a/engines/zvision/core/save_manager.h
+++ b/engines/zvision/core/save_manager.h
@@ -48,7 +48,8 @@ struct SaveGameHeader {
class SaveManager {
public:
- SaveManager(ZVision *engine) : _engine(engine) {}
+ SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {}
+ ~SaveManager() { flushSaveBuffer(); }
private:
ZVision *_engine;
@@ -59,6 +60,8 @@ private:
SAVE_VERSION = 1
};
+ Common::MemoryWriteStreamDynamic *_tempSave;
+
public:
/**
* Called every room change. Saves the state of the room just before
@@ -76,6 +79,7 @@ public:
*/
void saveGame(uint slot, const Common::String &saveName);
void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream);
+ void saveGameBuffered(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.
@@ -87,6 +91,9 @@ public:
Common::SeekableReadStream *getSlotFile(uint slot);
bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header);
+
+ void prepareSaveBuffer();
+ void flushSaveBuffer();
private:
void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName);
};
Commit: 49fc9eb5e665ad77512c3ea466ec34330022b776
https://github.com/scummvm/scummvm/commit/49fc9eb5e665ad77512c3ea466ec34330022b776
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:41:08+07:00
Commit Message:
ZVISION: Define ID's for system strings
Changed paths:
engines/zvision/text/string_manager.h
diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h
index e226fbe..5420e1f 100644
--- a/engines/zvision/text/string_manager.h
+++ b/engines/zvision/text/string_manager.h
@@ -52,6 +52,13 @@ public:
Common::String text;
};
+ enum {
+ ZVISION_STR_SAVEEXIST = 23,
+ ZVISION_STR_SAVED = 4,
+ ZVISION_STR_SAVEEMPTY = 21,
+ ZVISION_STR_EXITPROMT = 6
+ };
+
private:
struct InGameText {
Common::List<TextFragment> fragments;
Commit: e9676f5d7aa0a77b649ee99f4222f571894f96c2
https://github.com/scummvm/scummvm/commit/e9676f5d7aa0a77b649ee99f4222f571894f96c2
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:42:16+07:00
Commit Message:
ZVISION: Implementation of save control
Changed paths:
A engines/zvision/scripting/controls/save_control.cpp
A engines/zvision/scripting/controls/save_control.h
engines/zvision/module.mk
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 9d5072a..ee4a233 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS := \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
scripting/controls/push_toggle_control.o \
+ scripting/controls/save_control.o \
scripting/controls/slot_control.o \
scripting/inventory.o \
scripting/scr_file_handling.o \
diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp
new file mode 100644
index 0000000..fda8a70
--- /dev/null
+++ b/engines/zvision/scripting/controls/save_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 "zvision/scripting/controls/input_control.h"
+#include "zvision/scripting/controls/save_control.h"
+#include "zvision/utility/utility.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/text/string_manager.h"
+
+#include "zvision/core/save_manager.h"
+
+#include "common/str.h"
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_SAVE),
+ _saveControl(false) {
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (line.matchString("*savebox*", true)) {
+ int save_id;
+ int input_id;
+
+ sscanf(line.c_str(), "%*[^(](%d %d)", &save_id, &input_id);
+ save_elmnt elmnt;
+ elmnt.input_key = input_id;
+ elmnt.save_id = save_id;
+ elmnt.exist = false;
+ _inputs.push_back(elmnt);
+ } else if (line.matchString("*control_type*", true)) {
+ char buf[32];
+
+ sscanf(line.c_str(), "%*[^(](%s)", buf);
+ if (Common::String(buf).contains("save"))
+ _saveControl = true;
+ else
+ _saveControl = false;
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ }
+
+ for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key);
+ if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
+ InputControl *inp = (InputControl *)ctrl;
+ inp->setReadOnly(!_saveControl);
+ Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->save_id);
+ if (save) {
+ SaveGameHeader header;
+ _engine->getSaveManager()->readSaveGameHeader(save, header);
+ delete save;
+ inp->setText(header.saveName);
+ iter->exist = true;
+ }
+ }
+ }
+}
+
+bool SaveControl::process(uint32 deltaTimeInMillis) {
+ for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key);
+ if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
+ InputControl *inp = (InputControl *)ctrl;
+ if (inp->enterPress()) {
+ if (_saveControl) {
+ if (inp->getText().size() > 0) {
+ bool toSave = true;
+ if (iter->exist)
+ if (!_engine->askQuestion(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEXIST)))
+ toSave = false;
+
+ if (toSave) {
+ _engine->getSaveManager()->saveGameBuffered(iter->save_id, inp->getText());
+ _engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000);
+ _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation());
+ }
+ } else {
+ _engine->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000);
+ }
+ } else {
+ _engine->getSaveManager()->loadGame(iter->save_id);
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h
new file mode 100644
index 0000000..942b9c9
--- /dev/null
+++ b/engines/zvision/scripting/controls/save_control.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SAVE_CONTROL_H
+#define ZVISION_SAVE_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/list.h"
+
+
+namespace ZVision {
+
+class SaveControl : public Control {
+public:
+ SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+
+private:
+ struct save_elmnt {
+ int save_id;
+ int input_key;
+ bool exist;
+ };
+ typedef Common::List<save_elmnt> saveElmntList;
+ saveElmntList _inputs;
+
+ bool _saveControl;
+
+public:
+
+ bool process(uint32 deltaTimeInMillis);
+
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index d1d6e28..cacde9b 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -31,6 +31,7 @@
#include "zvision/scripting/controls/push_toggle_control.h"
#include "zvision/scripting/controls/lever_control.h"
#include "zvision/scripting/controls/slot_control.h"
+#include "zvision/scripting/controls/save_control.h"
#include "zvision/scripting/controls/input_control.h"
#include "common/textconsole.h"
@@ -349,6 +350,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new SlotControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("input")) {
return new InputControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("save")) {
+ return new SaveControl(_engine, key, stream);
}
return NULL;
}
Commit: 1696e0dd9675f087608fdfabb7b5c93d7d2820df
https://github.com/scummvm/scummvm/commit/1696e0dd9675f087608fdfabb7b5c93d7d2820df
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-04T16:43:15+07:00
Commit Message:
ZVISION: Prepare save data while changing location
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 3801414..7a2854d 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -538,8 +538,18 @@ void ScriptManager::do_changeLocation() {
}
}
- // Auto save
- //_engine->getSaveManager()->autoSave();
+ if (_nextLocation.world == 'g' && _nextLocation.room == 'j') {
+ if (_nextLocation.node == 's' && _nextLocation.view == 'e' &&
+ _currentLocation.world != 'g' && _currentLocation.room != 'j')
+ _engine->getSaveManager()->prepareSaveBuffer();
+ } else {
+ if (_currentLocation.world == 'g' && _currentLocation.room == 'j')
+ _engine->getSaveManager()->flushSaveBuffer();
+ else {
+ // Auto save
+ //_engine->getSaveManager()->autoSave();
+ }
+ }
setStateValue(StateKey_World, _nextLocation.world);
setStateValue(StateKey_Room, _nextLocation.room);
Commit: 7378443e38e2d9ad037cb3c96e28625939c1b7a9
https://github.com/scummvm/scummvm/commit/7378443e38e2d9ad037cb3c96e28625939c1b7a9
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-07T15:52:43+07:00
Commit Message:
ZVISION: Implement safe control
Changed paths:
A engines/zvision/scripting/controls/safe_control.cpp
A engines/zvision/scripting/controls/safe_control.h
engines/zvision/module.mk
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index ee4a233..457444c 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS := \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
scripting/controls/push_toggle_control.o \
+ scripting/controls/safe_control.o \
scripting/controls/save_control.o \
scripting/controls/slot_control.o \
scripting/inventory.o \
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
new file mode 100644
index 0000000..a6be20b
--- /dev/null
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -0,0 +1,208 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/safe_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/animation/meta_animation.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
+
+namespace ZVision {
+
+SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_SAFE) {
+ _num_states = 0;
+ _cur_state = 0;
+ _animation = NULL;
+ _radius_inner = 0;
+ _radius_inner_sq = 0;
+ _radius_outer = 0;
+ _radius_outer_sq = 0;
+ _zero_pointer = 0;
+ _start_pointer = 0;
+ _cur_frame = -1;
+ _to_frame = 0;
+ _frame_time = 0;
+ _lastRenderedFrame = -1;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("animation", true)) {
+ if (values.hasSuffix(".avi") || values.hasSuffix(".rlf"))
+ _animation = new MetaAnimation(values, _engine);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("num_states", true)) {
+ _num_states = atoi(values.c_str());
+ } else if (param.matchString("center", true)) {
+ int x;
+ int y;
+
+ sscanf(values.c_str(), "%d %d", &x, &y);
+ _center = Common::Point(x,y);
+ } else if (param.matchString("dial_inner_radius", true)) {
+ _radius_inner = atoi(values.c_str());
+ _radius_inner_sq = _radius_inner * _radius_inner;
+ } else if (param.matchString("radius", true)) {
+ _radius_outer = atoi(values.c_str());
+ _radius_outer_sq = _radius_outer * _radius_outer;
+ } else if (param.matchString("zero_radians_offset", true)) {
+ _zero_pointer = atoi(values.c_str());
+ } else if (param.matchString("pointer_offset", true)) {
+ _start_pointer = atoi(values.c_str());
+ _cur_state = _start_pointer;
+ } else if (param.matchString("cursor", true)) {
+ // Not used
+ } else if (param.matchString("mirrored", true)) {
+ // Not used
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+ renderFrame(_cur_state);
+}
+
+SafeControl::~SafeControl() {
+ if (_animation)
+ delete _animation;
+
+}
+
+void SafeControl::renderFrame(uint frameNumber) {
+ if (frameNumber == 0) {
+ _lastRenderedFrame = frameNumber;
+ } else if ((int16)frameNumber < _lastRenderedFrame) {
+ _lastRenderedFrame = frameNumber;
+ frameNumber = (_num_states * 2) - frameNumber;
+ } else {
+ _lastRenderedFrame = frameNumber;
+ }
+
+ const Graphics::Surface *frameData;
+ int x = _rectangle.left;
+ int y = _rectangle.top;
+
+ frameData = _animation->getFrameData(frameNumber);
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
+}
+
+bool SafeControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_cur_frame != _to_frame) {
+ _frame_time -= deltaTimeInMillis;
+
+ if (_frame_time <= 0) {
+ if (_cur_frame < _to_frame) {
+ _cur_frame++;
+ renderFrame(_cur_frame);
+ } else if (_cur_frame > _to_frame) {
+ _cur_frame--;
+ renderFrame(_cur_frame);
+ }
+ _frame_time = _animation->frameTime();
+ }
+ }
+
+ return false;
+}
+
+bool SafeControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int32 mR = backgroundImageSpacePos.sqrDist(_center);
+ if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int32 mR = backgroundImageSpacePos.sqrDist(_center);
+ if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) {
+
+ Common::Point tmp = backgroundImageSpacePos - _center;
+
+ float dd = atan2(tmp.x, tmp.y) * 57.29578;
+
+ int16 dp_state = 360 / _num_states;
+
+ int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states;
+
+ int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1 ) % _num_states;
+
+ _cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states;
+
+ _cur_state = (_num_states * 2 + tmp2) % _num_states;
+
+ _to_frame = (_cur_state + _num_states - _start_pointer) % _num_states;
+
+ _engine->getScriptManager()->setStateValue(_key, _cur_state);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h
new file mode 100644
index 0000000..2477d8c
--- /dev/null
+++ b/engines/zvision/scripting/controls/safe_control.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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_SAFE_CONTROL_H
+#define ZVISION_SAFE_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/list.h"
+#include "common/rect.h"
+
+
+namespace ZVision {
+
+class ZorkAVIDecoder;
+class MetaAnimation;
+
+class SafeControl : public Control {
+public:
+ SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~SafeControl();
+
+private:
+ int16 _num_states;
+ int16 _cur_state;
+ MetaAnimation *_animation;
+ Common::Point _center;
+ Common::Rect _rectangle;
+ int16 _radius_inner;
+ int32 _radius_inner_sq;
+ int16 _radius_outer;
+ int32 _radius_outer_sq;
+ int16 _zero_pointer;
+ int16 _start_pointer;
+ int16 _cur_frame;
+ int16 _to_frame;
+ int32 _frame_time;
+
+ int16 _lastRenderedFrame;
+
+public:
+ bool 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 renderFrame(uint frameNumber);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index cacde9b..b8046c0 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -33,6 +33,7 @@
#include "zvision/scripting/controls/slot_control.h"
#include "zvision/scripting/controls/save_control.h"
#include "zvision/scripting/controls/input_control.h"
+#include "zvision/scripting/controls/safe_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -352,6 +353,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new InputControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("save")) {
return new SaveControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("safe")) {
+ return new SafeControl(_engine, key, stream);
}
return NULL;
}
Commit: 2cfef440d7a9d3f50ebddd3e662175c0e0bd4e94
https://github.com/scummvm/scummvm/commit/2cfef440d7a9d3f50ebddd3e662175c0e0bd4e94
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-07T15:58:27+07:00
Commit Message:
ZVISION: venus_id now in base control class
Changed paths:
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/slot_control.h
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index ac24505..7c8a273 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -121,6 +121,7 @@ public:
protected:
ZVision *_engine;
uint32 _key;
+ int32 _venus_id;
void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values);
// Static member functions
diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h
index 0ac8ec9..7799785 100644
--- a/engines/zvision/scripting/controls/slot_control.h
+++ b/engines/zvision/scripting/controls/slot_control.h
@@ -67,7 +67,6 @@ private:
int _cursor;
char _distance_id;
- int _venus_id;
int _rendered_item;
Commit: 21d6fddab43ff4adbd8c8b3d10b110576c197108
https://github.com/scummvm/scummvm/commit/21d6fddab43ff4adbd8c8b3d10b110576c197108
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-27T14:57:35+07:00
Commit Message:
ZVISION: Added scaled blitter to bkg
Changed paths:
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index c89444d..5aa0d75 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -565,6 +565,32 @@ void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y,
_bkgDirtyRect.extend(dirty);
}
+void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect) {
+ if (src.w == _dstRect.width() && src.h == _dstRect.height())
+ blitSurfaceToBkg(src, _dstRect.left, _dstRect.top);
+ else {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ tmp->create(_dstRect.width(), _dstRect.height(), src.format);
+ scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height());
+ blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top);
+ tmp->free();
+ delete tmp;
+ }
+}
+
+void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey) {
+ if (src.w == _dstRect.width() && src.h == _dstRect.height())
+ blitSurfaceToBkg(src, _dstRect.left, _dstRect.top, colorkey);
+ else {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ tmp->create(_dstRect.width(), _dstRect.height(), src.format);
+ scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height());
+ blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top, colorkey);
+ tmp->free();
+ delete tmp;
+ }
+}
+
void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) {
Common::Rect empt;
blitSurfaceToSurface(src, empt, _menuWnd, x, y);
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index b4c6c76..24234e2 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -229,6 +229,8 @@ public:
void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y);
void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey);
+ void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect);
+ void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey);
void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y);
void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey);
Commit: 2b6d65f83bdc26b3d07cfc3061a27882d87df67c
https://github.com/scummvm/scummvm/commit/2b6d65f83bdc26b3d07cfc3061a27882d87df67c
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-08-27T14:59:18+07:00
Commit Message:
ZVISION: Implemented hotmovie control
Changed paths:
A engines/zvision/scripting/controls/hotmov_control.cpp
A engines/zvision/scripting/controls/hotmov_control.h
engines/zvision/module.mk
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 457444c..0e6f1ce 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
graphics/render_table.o \
scripting/actions.o \
scripting/control.o \
+ scripting/controls/hotmov_control.o \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
scripting/controls/push_toggle_control.o \
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
new file mode 100644
index 0000000..1e1886e
--- /dev/null
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -0,0 +1,201 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/hotmov_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/animation/meta_animation.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
+
+namespace ZVision {
+
+HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_HOTMOV) {
+ _animation = NULL;
+ _cycle = 0;
+ _cur_frame = -1;
+ _lastRenderedFrame = -1;
+ _frames.clear();
+ _frame_time = 0;
+ _num_cycles = 0;
+ _num_frames = 0;
+
+ _engine->getScriptManager()->setStateFlag(_key, 0);
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("hs_frame_list", true)) {
+ readHsFile(values);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("num_frames", true)) {
+ _num_frames = atoi(values.c_str());
+ } else if (param.matchString("num_cycles", true)) {
+ _num_cycles = atoi(values.c_str());
+ } else if (param.matchString("animation", true)) {
+ char filename[64];
+ sscanf(values.c_str(), "%s", filename);
+ values = Common::String(filename);
+ if (values.hasSuffix(".avi") || values.hasSuffix(".rlf"))
+ _animation = new MetaAnimation(values, _engine);
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+}
+
+HotMovControl::~HotMovControl() {
+ if (_animation)
+ delete _animation;
+
+ _frames.clear();
+}
+
+void HotMovControl::renderFrame(uint frameNumber) {
+ if ((int)frameNumber == _lastRenderedFrame)
+ return;
+
+ _lastRenderedFrame = frameNumber;
+
+ const Graphics::Surface *frameData;
+
+ if (_animation) {
+ frameData = _animation->getFrameData(frameNumber);
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle);
+ }
+}
+
+bool HotMovControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_cycle < _num_cycles) {
+ _frame_time -= deltaTimeInMillis;
+
+ if (_frame_time <= 0) {
+ _cur_frame++;
+ if (_cur_frame >= _num_frames) {
+ _cur_frame = 0;
+ _cycle++;
+ }
+ if (_cycle != _num_cycles)
+ renderFrame(_cur_frame);
+ else
+ _engine->getScriptManager()->setStateFlag(_key, 2);
+
+ _frame_time = _animation->frameTime();
+ }
+ }
+
+ return false;
+}
+
+bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_cycle < _num_cycles) {
+ if (_frames[_cur_frame].contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_cycle < _num_cycles) {
+ if (_frames[_cur_frame].contains(backgroundImageSpacePos)) {
+ _engine->getScriptManager()->setStateValue(_key, 1);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void HotMovControl::readHsFile(const Common::String &fileName) {
+ if (_num_frames == 0)
+ return;
+
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("HS file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line;
+
+ _frames.resize(_num_frames);
+
+ while (!file.eos()) {
+ line = file.readLine();
+
+ int frame;
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(line.c_str(), "%d:%d %d %d %d~", &frame, &x, &y, &width, &height);
+
+ if (frame >= 0 && frame < _num_frames)
+ _frames[frame] = Common::Rect(x, y, width, height);
+ }
+ file.close();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h
new file mode 100644
index 0000000..ea12bab
--- /dev/null
+++ b/engines/zvision/scripting/controls/hotmov_control.h
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_HOTMOV_CONTROL_H
+#define ZVISION_HOTMOV_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+
+namespace ZVision {
+
+class MetaAnimation;
+
+class HotMovControl : public Control {
+public:
+ HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~HotMovControl();
+
+private:
+ int32 _num_frames;
+ int32 _frame_time;
+ int32 _cur_frame;
+ int32 _lastRenderedFrame;
+ int32 _cycle;
+ int32 _num_cycles;
+ MetaAnimation *_animation;
+ Common::Rect _rectangle;
+ Common::Array<Common::Rect> _frames;
+public:
+ bool 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 renderFrame(uint frameNumber);
+ void readHsFile(const Common::String &fileName);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index b8046c0..d6c5aa0 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -34,6 +34,7 @@
#include "zvision/scripting/controls/save_control.h"
#include "zvision/scripting/controls/input_control.h"
#include "zvision/scripting/controls/safe_control.h"
+#include "zvision/scripting/controls/hotmov_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -355,6 +356,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new SaveControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("safe")) {
return new SafeControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("hotmovie")) {
+ return new HotMovControl(_engine, key, stream);
}
return NULL;
}
Commit: 78552afdae3b7b27845d7ea4d2c2638fa3182333
https://github.com/scummvm/scummvm/commit/78552afdae3b7b27845d7ea4d2c2638fa3182333
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-09-09T12:31:11+07:00
Commit Message:
ZVISION: Check .avi and .rlf suffix only in MetaAnimation.
Changed paths:
engines/zvision/animation/meta_animation.cpp
engines/zvision/scripting/controls/hotmov_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/safe_control.cpp
engines/zvision/scripting/sidefx/animation_node.cpp
diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp
index 38f5669..1ea6df6 100644
--- a/engines/zvision/animation/meta_animation.cpp
+++ b/engines/zvision/animation/meta_animation.cpp
@@ -40,14 +40,16 @@ namespace ZVision {
MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
: _fileType(RLF),
_cur_frame(NULL) {
- if (fileName.hasSuffix(".rlf")) {
+ Common::String tmpFileName = fileName;
+ tmpFileName.toLowercase();
+ if (tmpFileName.hasSuffix(".rlf")) {
_fileType = RLF;
- Common::File *_file = engine->getSearchManager()->openFile(fileName);
+ Common::File *_file = engine->getSearchManager()->openFile(tmpFileName);
_animation.rlf = new RlfAnimation(_file, false);
_frmDelay = _animation.rlf->frameTime();
- } else if (fileName.hasSuffix(".avi")) {
+ } else if (tmpFileName.hasSuffix(".avi")) {
_fileType = AVI;
- Common::File *_file = engine->getSearchManager()->openFile(fileName);
+ Common::File *_file = engine->getSearchManager()->openFile(tmpFileName);
_animation.avi = new ZorkAVIDecoder();
_animation.avi->loadStream(_file);
_frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index 1e1886e..8ffc339 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -80,8 +80,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
char filename[64];
sscanf(values.c_str(), "%s", filename);
values = Common::String(filename);
- if (values.hasSuffix(".avi") || values.hasSuffix(".rlf"))
- _animation = new MetaAnimation(values, _engine);
+ _animation = new MetaAnimation(values, _engine);
} else if (param.matchString("venus_id", true)) {
_venus_id = atoi(values.c_str());
}
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 87fbb43..8072079 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -104,8 +104,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
Common::String animationFileName(fileNameBuffer);
- if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf"))
- _animation = new MetaAnimation(animationFileName, _engine);
+ _animation = new MetaAnimation(animationFileName, _engine);
} else if (line.matchString("*skipcolor*", true)) {
// Not used
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index a6be20b..d5eff09 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -66,8 +66,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
while (!stream.eos() && !line.contains('}')) {
if (param.matchString("animation", true)) {
- if (values.hasSuffix(".avi") || values.hasSuffix(".rlf"))
- _animation = new MetaAnimation(values, _engine);
+ _animation = new MetaAnimation(values, _engine);
} else if (param.matchString("rectangle", true)) {
int x;
int y;
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
index 4a606ad..bd9c543 100644
--- a/engines/zvision/scripting/sidefx/animation_node.cpp
+++ b/engines/zvision/scripting/sidefx/animation_node.cpp
@@ -40,12 +40,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
_mask(mask),
_animation(NULL) {
- if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
- _animation = new MetaAnimation(fileName, engine);
- _frmDelay = _animation->frameTime();
- } else {
- warning("Unrecognized animation file type: %s", fileName.c_str());
- }
+ _animation = new MetaAnimation(fileName, engine);
+ _frmDelay = _animation->frameTime();
if (frate > 0)
_frmDelay = 1000.0 / frate;
Commit: bcb1aea0ff3fa45528ebf1dea8c9855cccf1e736
https://github.com/scummvm/scummvm/commit/bcb1aea0ff3fa45528ebf1dea8c9855cccf1e736
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-09-09T12:34:20+07:00
Commit Message:
ZVISION: FistControl implementation.
Changed paths:
A engines/zvision/scripting/controls/fist_control.cpp
A engines/zvision/scripting/controls/fist_control.h
engines/zvision/module.mk
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 0e6f1ce..4cfb8f3 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
graphics/render_table.o \
scripting/actions.o \
scripting/control.o \
+ scripting/controls/fist_control.o \
scripting/controls/hotmov_control.o \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
new file mode 100644
index 0000000..46b87dd
--- /dev/null
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -0,0 +1,294 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/fist_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/animation/meta_animation.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
+
+namespace ZVision {
+
+FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_FIST) {
+ _cursor = CursorIndex_Idle;
+ _animation = NULL;
+ _soundKey = 0;
+ _fiststatus = 0;
+ _order = 0;
+ _fistnum = 0;
+
+ _frameCur = -1;
+ _frameEnd = -1;
+ _frameTime = 0;
+ _lastRenderedFrame = -1;
+ _animationId = 0;
+
+ clearFistArray(_fistsUp);
+ clearFistArray(_fistsDwn);
+
+ _numEntries = 0;
+ _entries.clear();
+
+ _anmRect = Common::Rect();
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("sound_key", true)) {
+ _soundKey = atoi(values.c_str());
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("descfile", true)) {
+ readDescFile(values);
+ } else if (param.matchString("animation_id", true)) {
+ _animationId = atoi(values.c_str());
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+}
+
+FistControl::~FistControl() {
+ if (_animation)
+ delete _animation;
+
+ clearFistArray(_fistsUp);
+ clearFistArray(_fistsDwn);
+ _entries.clear();
+}
+
+void FistControl::renderFrame(uint frameNumber) {
+ if ((int32)frameNumber == _lastRenderedFrame)
+ return;
+
+ _lastRenderedFrame = frameNumber;
+
+ const Graphics::Surface *frameData;
+
+ if (_animation) {
+ frameData = _animation->getFrameData(frameNumber);
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect);
+ }
+}
+
+bool FistControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_frameCur >= 0 && _frameEnd >= 0)
+ if (_frameCur <= _frameEnd) {
+ _frameTime -= deltaTimeInMillis;
+
+ if (_frameTime <= 0) {
+ _frameTime = _animation->frameTime();
+
+ renderFrame(_frameCur);
+
+ _frameCur++;
+
+ if (_frameCur > _frameEnd)
+ _engine->getScriptManager()->setStateValue(_animationId, 2);
+ }
+ }
+
+ return false;
+}
+
+bool FistControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (mouseIn(screenSpacePos, backgroundImageSpacePos) >= 0) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+ return true;
+ }
+
+ return false;
+}
+
+bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos);
+
+ if (n_fist >= 0) {
+ //ctrl_setvenus(ct);
+
+ uint32 oldStatus = _fiststatus;
+ _fiststatus ^= (1 << n_fist);
+
+ for(int i = 0; i < _numEntries; i++)
+ if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) {
+ _frameCur = _entries[i]._anmStrt;
+ _frameEnd = _entries[i]._anmEnd;
+ _frameTime = 0;
+
+ _engine->getScriptManager()->setStateValue(_animationId, 1);
+ _engine->getScriptManager()->setStateValue(_soundKey, _entries[i]._sound);
+ break;
+ }
+
+ _engine->getScriptManager()->setStateValue(_key, _fiststatus);
+
+ //_engine->getScriptManager()->FlushMouseBtn(SDL_BUTTON_LEFT);
+ }
+
+ return false;
+}
+
+void FistControl::readDescFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("Desc file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line;
+
+ while (!file.eos()) {
+ line = file.readLine();
+
+ for (int i = line.size() - 1; i >= 0; i--)
+ if (line[i] == '~')
+ line.deleteChar(i);
+
+ if (line.matchString("*animation_id*", true)) {
+ // Not used
+ } else if (line.matchString("*animation*", true)) {
+ char filename[64];
+ sscanf(line.c_str(), "animation:%s", filename);
+ _animation = new MetaAnimation(Common::String(filename), _engine);
+ } else if (line.matchString("*anim_rect*", true)) {
+ int left, top, right, bottom;
+ sscanf(line.c_str(), "anim_rect:%d %d %d %d", &left, &top, &right, &bottom);
+ _anmRect = Common::Rect(left, top, right, bottom);
+ } else if (line.matchString("*num_fingers*", true)) {
+ sscanf(line.c_str(), "num_fingers:%d", &_fistnum);
+ _fistsUp.resize(_fistnum);
+ _fistsDwn.resize(_fistnum);
+ } else if (line.matchString("*entries*", true)) {
+ sscanf(line.c_str(), "entries:%d", &_numEntries);
+ _entries.resize(_numEntries);
+ } else if (line.matchString("*eval_order_ascending*", true)) {
+ sscanf(line.c_str(), "eval_order_ascending:%d", &_order);
+ } else if (line.matchString("*up_hs_num_*", true)) {
+ int fist, num;
+ sscanf(line.c_str(), "up_hs_num_%d:%d", &fist, &num);
+ _fistsUp[fist].resize(num);
+ } else if (line.matchString("*up_hs_*", true)) {
+ int16 fist, box, x1, y1, x2, y2;
+ sscanf(line.c_str(), "up_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2);
+ (_fistsUp[fist])[box] = Common::Rect(x1, y1, x2, y2);
+ } else if (line.matchString("*down_hs_num_*", true)) {
+ int fist, num;
+ sscanf(line.c_str(), "down_hs_num_%d:%d", &fist, &num);
+ _fistsDwn[fist].resize(num);
+ } else if (line.matchString("*down_hs_*", true)) {
+ int16 fist, box, x1, y1, x2, y2;
+ sscanf(line.c_str(), "down_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2);
+ (_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2);
+ } else {
+ int entry, start, end, sound;
+ char bits_start[33];
+ char bits_end[33];
+ if (sscanf(line.c_str(), "%d:%s %s %d %d (%d)", &entry, bits_start, bits_end, &start, &end, &sound) == 6) {
+ _entries[entry]._bitsStrt = readBits(bits_start);
+ _entries[entry]._bitsEnd = readBits(bits_end);
+ _entries[entry]._anmStrt = start;
+ _entries[entry]._anmEnd = end;
+ _entries[entry]._sound = sound;
+ }
+ }
+ }
+ file.close();
+}
+
+void FistControl::clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr) {
+ for (uint i = 0; i < arr.size(); i++)
+ arr[i].clear();
+
+ arr.clear();
+}
+
+uint32 FistControl::readBits(const char *str) {
+ uint32 bfield = 0;
+ int len = strlen(str);
+ for (int i = 0; i < len; i++)
+ if (str[i] != '0')
+ bfield |= (1 << i);
+ return bfield;
+}
+
+int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_order) {
+ for(int i = 0; i < _fistnum; i++) {
+ if (((_fiststatus >> i) & 1) == 1) {
+ for(uint j = 0; j < _fistsDwn[i].size(); j++)
+ if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ } else {
+ for(uint j = 0; j < _fistsUp[i].size(); j++)
+ if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ }
+ }
+ } else {
+ for(int i = _fistnum - 1; i >= 0; i--) {
+ if (((_fiststatus >> i) & 1) == 1) {
+ for(uint j = 0; j < _fistsDwn[i].size(); j++)
+ if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ } else {
+ for(uint j = 0; j < _fistsUp[i].size(); j++)
+ if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h
new file mode 100644
index 0000000..940bc96
--- /dev/null
+++ b/engines/zvision/scripting/controls/fist_control.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_FIST_CONTROL_H
+#define ZVISION_FIST_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+
+namespace ZVision {
+
+class MetaAnimation;
+
+class FistControl : public Control {
+public:
+ FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~FistControl();
+
+private:
+ uint32 _fiststatus;
+ int _fistnum;
+ int16 _cursor;
+ int _order;
+
+ Common::Array< Common::Array<Common::Rect> > _fistsUp;
+ Common::Array< Common::Array<Common::Rect> > _fistsDwn;
+
+ int32 _numEntries;
+
+ struct entries {
+ uint32 _bitsStrt;
+ uint32 _bitsEnd;
+ int32 _anmStrt;
+ int32 _anmEnd;
+ int32 _sound;
+ };
+
+ Common::Array<entries> _entries;
+
+ MetaAnimation *_animation;
+ Common::Rect _anmRect;
+ int32 _soundKey;
+ int32 _frameCur;
+ int32 _frameEnd;
+ int32 _frameTime;
+ int32 _lastRenderedFrame;
+ int32 _animationId;
+
+public:
+ bool 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 renderFrame(uint frameNumber);
+ void readDescFile(const Common::String &fileName);
+ void clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr);
+ uint32 readBits(const char *str);
+ int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index d6c5aa0..5afa5b2 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -35,6 +35,7 @@
#include "zvision/scripting/controls/input_control.h"
#include "zvision/scripting/controls/safe_control.h"
#include "zvision/scripting/controls/hotmov_control.h"
+#include "zvision/scripting/controls/fist_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -358,6 +359,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new SafeControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("hotmovie")) {
return new HotMovControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("fist")) {
+ return new FistControl(_engine, key, stream);
}
return NULL;
}
Commit: 6ae414fbde8421cc66a58a08ac3c8b9ca85f6c73
https://github.com/scummvm/scummvm/commit/6ae414fbde8421cc66a58a08ac3c8b9ca85f6c73
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-09-10T11:42:26+07:00
Commit Message:
ZVISION: PaintControl implemented
Changed paths:
A engines/zvision/scripting/controls/paint_control.cpp
A engines/zvision/scripting/controls/paint_control.h
engines/zvision/module.mk
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 4cfb8f3..a7a9523 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS := \
scripting/controls/hotmov_control.o \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
+ scripting/controls/paint_control.o \
scripting/controls/push_toggle_control.o \
scripting/controls/safe_control.o \
scripting/controls/save_control.o \
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
new file mode 100644
index 0000000..a350e9b
--- /dev/null
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -0,0 +1,215 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/paint_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
+
+namespace ZVision {
+
+PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_PAINT) {
+
+ _cursor = CursorIndex_Active;
+ _paint = NULL;
+ _bkg = NULL;
+ _brush = NULL;
+ _colorKey = 0;
+ _mouseDown = false;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width + x, height + y);
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("brush_file", true)) {
+ _brush = _engine->getRenderManager()->loadImage(values, false);
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
+ } else if (param.matchString("paint_file", true)) {
+ _paint = _engine->getRenderManager()->loadImage(values, false);
+ } else if (param.matchString("eligible_objects", true)) {
+ char buf[256];
+ memset(buf, 0, 256);
+ strcpy(buf, values.c_str());
+
+ char *curpos = buf;
+ char *strend = buf + strlen(buf);
+ while (true) {
+ char *st = curpos;
+
+ if (st >= strend)
+ break;
+
+ while (*curpos != ' ' && curpos < strend)
+ curpos++;
+
+ *curpos = 0;
+ curpos++;
+
+ int obj = atoi(st);
+
+ _eligible_objects.push_back(obj);
+ }
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_paint) {
+ _colorKey = _paint->format.RGBToColor(255,0,255);
+ _bkg = new Graphics::Surface;
+ _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format);
+ _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey);
+
+ Graphics::Surface *tmp = new Graphics::Surface;
+ tmp->create(_rectangle.width(), _rectangle.height(), _paint->format);
+ _engine->getRenderManager()->blitSurfaceToSurface(*_paint, _rectangle, *tmp, 0, 0);
+ _paint->free();
+ delete _paint;
+ _paint = tmp;
+ }
+
+
+}
+
+PaintControl::~PaintControl() {
+ // Clear the state value back to 0
+ //_engine->getScriptManager()->setStateValue(_key, 0);
+ if (_paint)
+ delete _paint;
+ if (_brush)
+ delete _brush;
+ if (_bkg)
+ delete _bkg;
+}
+
+bool PaintControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ _mouseDown = false;
+
+ return false;
+}
+
+bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+
+ if (eligeblity(mouse_item)) {
+ _mouseDown = true;
+ }
+ }
+
+ return false;
+}
+
+bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+
+ if (eligeblity(mouse_item)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+
+ if (_mouseDown) {
+ Common::Rect bkgRect = paint(backgroundImageSpacePos);
+ if (!bkgRect.isEmpty()) {
+ Common::Rect imgRect = bkgRect;
+ imgRect.translate(-_rectangle.left, -_rectangle.top);
+
+ Graphics::Surface imgUpdate = _bkg->getSubArea(imgRect);
+
+ _engine->getRenderManager()->blitSurfaceToBkg(imgUpdate, bkgRect.left, bkgRect.top, _colorKey);
+ }
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool PaintControl::eligeblity(int item_id) {
+ for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
+ if (*it == item_id)
+ return true;
+ return false;
+}
+
+Common::Rect PaintControl::paint(const Common::Point &point) {
+ Common::Rect paint_rect = Common::Rect(_brush->w, _brush->h);
+ paint_rect.moveTo(point);
+ paint_rect.clip(_rectangle);
+
+ if (!paint_rect.isEmpty()) {
+ Common::Rect brush_rect = paint_rect;
+ brush_rect.translate(-point.x, -point.y);
+
+ Common::Rect bkg_rect = paint_rect;
+ bkg_rect.translate( -_rectangle.left, -_rectangle.top );
+
+ for (int yy = 0; yy < brush_rect.height(); yy++) {
+ uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy);
+ uint16 *from = (uint16 *)_paint->getBasePtr(bkg_rect.left, bkg_rect.top + yy);
+ uint16 *to = (uint16 *)_bkg->getBasePtr(bkg_rect.left, bkg_rect.top + yy);
+ for (int xx = 0; xx < brush_rect.width(); xx++) {
+ if (*mask != 0)
+ *(to + xx) = *(from + xx);
+
+ mask++;
+ }
+ }
+
+ }
+ return paint_rect;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h
new file mode 100644
index 0000000..c74431e
--- /dev/null
+++ b/engines/zvision/scripting/controls/paint_control.h
@@ -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.
+ *
+ */
+
+#ifndef ZVISION_PAINT_CONTROL_H
+#define ZVISION_PAINT_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace ZVision {
+
+class PaintControl : public Control {
+public:
+ PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~PaintControl();
+
+ /**
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+
+ /**
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseDown(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);
+
+ bool process(uint32 deltaTimeInMillis) { return false; };
+
+private:
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+
+ uint32 _colorKey;
+
+ Graphics::Surface *_paint;
+ Graphics::Surface *_bkg;
+ Graphics::Surface *_brush;
+
+ Common::List<int> _eligible_objects;
+
+ int _cursor;
+ Common::Rect _rectangle;
+
+ bool _mouseDown;
+
+ bool eligeblity(int item_id);
+ Common::Rect paint(const Common::Point &point);
+
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 5afa5b2..0e53eec 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -36,6 +36,7 @@
#include "zvision/scripting/controls/safe_control.h"
#include "zvision/scripting/controls/hotmov_control.h"
#include "zvision/scripting/controls/fist_control.h"
+#include "zvision/scripting/controls/paint_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -361,6 +362,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new HotMovControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("fist")) {
return new FistControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("paint")) {
+ return new PaintControl(_engine, key, stream);
}
return NULL;
}
Commit: 39c3a26bfa50aae3b189773a75fe77cbebd17064
https://github.com/scummvm/scummvm/commit/39c3a26bfa50aae3b189773a75fe77cbebd17064
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-09-10T16:17:30+07:00
Commit Message:
ZVISION: Fix setStateFlag->setStateValue in HotMov control
Changed paths:
engines/zvision/scripting/controls/hotmov_control.cpp
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index 8ffc339..b39292f 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -51,7 +51,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
_num_cycles = 0;
_num_frames = 0;
- _engine->getScriptManager()->setStateFlag(_key, 0);
+ _engine->getScriptManager()->setStateValue(_key, 0);
// Loop until we find the closing brace
Common::String line = stream.readLine();
@@ -129,7 +129,7 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) {
if (_cycle != _num_cycles)
renderFrame(_cur_frame);
else
- _engine->getScriptManager()->setStateFlag(_key, 2);
+ _engine->getScriptManager()->setStateValue(_key, 2);
_frame_time = _animation->frameTime();
}
Commit: 2a6c2fdf4532e6f5ba3a2a6f8a0e78db4dcdc635
https://github.com/scummvm/scummvm/commit/2a6c2fdf4532e6f5ba3a2a6f8a0e78db4dcdc635
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-09-10T16:20:50+07:00
Commit Message:
ZVISION: Titler control and DisplayMessage action implemented
Changed paths:
A engines/zvision/scripting/controls/titler_control.cpp
A engines/zvision/scripting/controls/titler_control.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index a7a9523..6734fde 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS := \
scripting/controls/safe_control.o \
scripting/controls/save_control.o \
scripting/controls/slot_control.o \
+ scripting/controls/titler_control.o \
scripting/inventory.o \
scripting/scr_file_handling.o \
scripting/script_manager.o \
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 22fbd4f..399a81d 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -34,6 +34,7 @@
#include "zvision/scripting/sidefx/syncsound_node.h"
#include "zvision/scripting/sidefx/animation_node.h"
#include "zvision/scripting/sidefx/ttytext_node.h"
+#include "zvision/scripting/controls/titler_control.h"
#include "common/file.h"
@@ -167,6 +168,23 @@ bool ActionDisableControl::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionDisplayMessage
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%hd %hd", &_control, &_msgid);
+}
+
+bool ActionDisplayMessage::execute() {
+ Control *ctrl = _engine->getScriptManager()->getControl(_control);
+ if (ctrl && ctrl->getType() == Control::CONTROL_TITLER) {
+ TitlerControl *titler = (TitlerControl *)ctrl;
+ titler->setString(_msgid);
+ }
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionEnableControl
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index c60aedc..de303a7 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -189,6 +189,8 @@ public:
bool execute();
private:
+ int16 _control;
+ int16 _msgid;
};
class ActionDissolve : public ResultAction {
diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp
new file mode 100644
index 0000000..b803501
--- /dev/null
+++ b/engines/zvision/scripting/controls/titler_control.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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/scripting/controls/titler_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/text/text.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/utility/utility.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_TITLER) {
+
+ _surface = NULL;
+ _curString = -1;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("string_resource_file", true)) {
+ readStringsFile(values);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int x2;
+ int y2;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &x2, &y2);
+
+ _rectangle = Common::Rect(x, y, x2, y2);
+ }
+
+ line = stream.readLine();
+ trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (!_rectangle.isEmpty()) {
+ _surface = new Graphics::Surface;
+ _surface->create(_rectangle.width(), _rectangle.height(), _engine->_pixelFormat);
+ _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
+ }
+}
+
+TitlerControl::~TitlerControl() {
+ if (_surface)
+ delete _surface;
+}
+
+void TitlerControl::setString(int strLine) {
+ if (strLine != _curString && strLine >= 0 && strLine < (int)_strings.size()) {
+ _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
+ _engine->getTextRenderer()->drawTxtInOneLine(_strings[strLine], *_surface);
+ _engine->getRenderManager()->blitSurfaceToBkg(*_surface, _rectangle.left, _rectangle.top);
+ _curString = strLine;
+ }
+}
+
+void TitlerControl::readStringsFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("String_resource_file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ _strings.clear();
+
+ while (!file.eos()) {
+
+ Common::String line = readWideLine(file);
+ _strings.push_back(line);
+ }
+ file.close();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h
new file mode 100644
index 0000000..ee230af
--- /dev/null
+++ b/engines/zvision/scripting/controls/titler_control.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_TITLER_CONTROL_H
+#define ZVISION_TITLER_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/array.h"
+
+
+namespace ZVision {
+
+class TitlerControl : public Control {
+public:
+ TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~TitlerControl();
+
+ void setString(int strLine);
+
+private:
+
+ Common::Array< Common::String > _strings;
+ Common::Rect _rectangle;
+ int16 _curString;
+ Graphics::Surface *_surface;
+
+ void readStringsFile(const Common::String &fileName);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 0e53eec..04378f8 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -37,6 +37,7 @@
#include "zvision/scripting/controls/hotmov_control.h"
#include "zvision/scripting/controls/fist_control.h"
#include "zvision/scripting/controls/paint_control.h"
+#include "zvision/scripting/controls/titler_control.h"
#include "common/textconsole.h"
#include "common/file.h"
@@ -237,7 +238,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("disable_venus", true)) {
// TODO: Implement ActionDisableVenus
} else if (act.matchString("display_message", true)) {
- // TODO: Implement ActionDisplayMessage
+ actionList.push_back(new ActionDisplayMessage(_engine, slot, args));
} else if (act.matchString("dissolve", true)) {
// TODO: Implement ActionDissolve
} else if (act.matchString("distort", true)) {
@@ -364,6 +365,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS
return new FistControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("paint")) {
return new PaintControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("titler")) {
+ return new TitlerControl(_engine, key, stream);
}
return NULL;
}
Commit: cf63da941cf7b7162551f6d660f5dbbda3150239
https://github.com/scummvm/scummvm/commit/cf63da941cf7b7162551f6d660f5dbbda3150239
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-10T16:40:46+07:00
Commit Message:
ZVISION: Action:region and visual effects implemented.
Changed paths:
A engines/zvision/graphics/effect.h
A engines/zvision/graphics/effects/fog.cpp
A engines/zvision/graphics/effects/fog.h
A engines/zvision/graphics/effects/light.cpp
A engines/zvision/graphics/effects/light.h
A engines/zvision/graphics/effects/wave.cpp
A engines/zvision/graphics/effects/wave.h
A engines/zvision/scripting/sidefx/region_node.cpp
A engines/zvision/scripting/sidefx/region_node.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/graphics/effect.h b/engines/zvision/graphics/effect.h
new file mode 100644
index 0000000..c6653c6
--- /dev/null
+++ b/engines/zvision/graphics/effect.h
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef EFFECT_H_INCLUDED
+#define EFFECT_H_INCLUDED
+
+#include "common/rect.h"
+#include "common/list.h"
+#include "graphics/surface.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class Effect {
+public:
+
+ Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
+ _surface.create(_region.width(), _region.height(), _engine->_pixelFormat);
+ }
+ virtual ~Effect() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+
+ Common::Rect getRegion() {
+ return _region;
+ }
+
+ bool isPort() {
+ return _ported;
+ }
+
+ virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) {
+ return &_surface;
+ }
+
+ virtual void update() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ Common::Rect _region;
+ bool _ported;
+ Graphics::Surface _surface;
+
+// Static member functions
+public:
+
+};
+
+struct EffectMapUnit {
+ uint32 count;
+ bool inEffect;
+};
+
+typedef Common::List<EffectMapUnit> EffectMap;
+
+} // End of namespace ZVision
+
+#endif // EFFECT_H_INCLUDED
diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp
new file mode 100644
index 0000000..b6c5e7b
--- /dev/null
+++ b/engines/zvision/graphics/effects/fog.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/graphics/effects/fog.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+
+
+namespace ZVision {
+
+FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds):
+ Effect(engine, key, region, ported) {
+
+ _map = Map;
+
+ _r = 0;
+ _g = 0;
+ _b = 0;
+
+ _pos = 0;
+
+ if (_engine->getSearchManager()->hasFile(clouds))
+ _engine->getRenderManager()->readImageToSurface(clouds, _fog);
+ else
+ _engine->getRenderManager()->readImageToSurface("cloud.tga", _fog);
+
+ _mp.resize(_fog.h);
+ for (int16 i = 0; i < _fog.h; i++) {
+ _mp[i].resize(_fog.w);
+ for (int16 j = 0; j < _fog.w; j++)
+ _mp[i][j] = true;
+ }
+
+ for (uint8 i = 0; i < 32; i++)
+ _colorMap[i] = 0;
+}
+
+FogFx::~FogFx() {
+ if (_map)
+ delete _map;
+
+ for (uint16 i = 0; i < _mp.size(); i++)
+ _mp[i].clear();
+ _mp.clear();
+}
+
+const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) {
+ _surface.copyFrom(srcSubRect);
+ EffectMap::iterator it = _map->begin();
+
+ uint32 cnt = 0;
+
+ for (uint16 j = 0; j < _surface.h; j++) {
+ uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _surface.w; i++) {
+ if (it->inEffect) {
+ // Not 100% equivalent, but looks nice and not buggy
+ uint8 sr, sg, sb;
+ _engine->_pixelFormat.colorToRGB(lineBuf[i], sr, sg, sb);
+ uint16 fogColor = *(uint16 *)_fog.getBasePtr((i + _pos) % _fog.w, j);
+ uint8 dr, dg, db;
+ _engine->_pixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db);
+ uint16 fr = dr + sr;
+ if (fr > 255)
+ fr = 255;
+ uint16 fg = dg + sg;
+ if (fg > 255)
+ fg = 255;
+ uint16 fb = db + sb;
+ if (fb > 255)
+ fb = 255;
+ lineBuf[i] = _engine->_pixelFormat.RGBToColor(fr, fg, fb);
+ }
+ cnt++;
+ if (cnt >= it->count) {
+ it++;
+ cnt = 0;
+ }
+ if (it == _map->end())
+ break;
+ }
+ if (it == _map->end())
+ break;
+ }
+
+ return &_surface;
+}
+
+void FogFx::update() {
+ _pos += _engine->getScriptManager()->getStateValue(StateKey_EF9_Speed);
+ _pos %= _fog.w;
+
+ uint8 dr = _engine->getScriptManager()->getStateValue(StateKey_EF9_R);
+ uint8 dg = _engine->getScriptManager()->getStateValue(StateKey_EF9_G);
+ uint8 db = _engine->getScriptManager()->getStateValue(StateKey_EF9_B);
+ dr = CLIP((int)dr, 0, 31);
+ dg = CLIP((int)dg, 0, 31);
+ db = CLIP((int)db, 0, 31);
+
+ if (dr != _r || dg != _g || db != _b) {
+ if (_r > dr)
+ _r--;
+ else if (_r < dr)
+ _r++;
+
+ if (_g > dg)
+ _g--;
+ else if (_g < dg)
+ _g++;
+
+ if (_b > db)
+ _b--;
+ else if (_b < db)
+ _b++;
+
+ // Not 100% equivalent, but looks nice and not buggy
+
+ _colorMap[31] = _engine->_pixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3);
+
+ for (uint8 i = 0; i < 31; i++) {
+ float perc = (float)i / 31.0;
+ uint8 cr = (float)_r * perc;
+ uint8 cg = (float)_g * perc;
+ uint8 cb = (float)_b * perc;
+ _colorMap[i] = _engine->_pixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3);
+ }
+ }
+
+ for (uint16 j = 0; j < _fog.h; j++) {
+ uint16 *pix = (uint16 *)_fog.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _fog.w; i++) {
+ if (_mp[j][i]) {
+ if ((pix[i] & 0x1F) == 0x1F) {
+ pix[i]--;
+ _mp[j][i] = false;
+ } else
+ pix[i]++;
+ } else {
+ if ((pix[i] & 0x1F) == 0) {
+ pix[i]++;
+ _mp[j][i] = true;
+ } else
+ pix[i]--;
+ }
+ }
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h
new file mode 100644
index 0000000..62dd1f9
--- /dev/null
+++ b/engines/zvision/graphics/effects/fog.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef FOGFX_H_INCLUDED
+#define FOGFX_H_INCLUDED
+
+#include "zvision/graphics/effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class FogFx : public Effect {
+public:
+
+ FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds);
+ ~FogFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ EffectMap *_map;
+ Graphics::Surface _fog;
+ uint8 _r, _g, _b;
+ int32 _pos;
+ Common::Array< Common::Array< bool > > _mp;
+ uint16 _colorMap[32];
+};
+} // End of namespace ZVision
+
+#endif // FOGFX_H_INCLUDED
diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp
new file mode 100644
index 0000000..9bff077
--- /dev/null
+++ b/engines/zvision/graphics/effects/light.cpp
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/graphics/effects/light.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+
+
+namespace ZVision {
+
+LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD):
+ Effect(engine, key, region, ported) {
+ _map = Map;
+ _delta = delta;
+ _up = true;
+ _pos = 0;
+
+ _minD = minD;
+ if (_minD < -delta)
+ _minD = -delta;
+
+ _maxD = maxD;
+ if (_maxD > delta)
+ _maxD = delta;
+}
+
+LightFx::~LightFx() {
+ if (_map)
+ delete _map;
+}
+
+const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) {
+ _surface.copyFrom(srcSubRect);
+ EffectMap::iterator it = _map->begin();
+ uint32 cnt = 0;
+
+ uint32 dcolor = 0;
+
+ if (_pos < 0) {
+ uint8 cc = ((-_pos) & 0x1F) << 3;
+ dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc);
+ } else {
+ uint8 cc = (_pos & 0x1F) << 3;
+ dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc);
+ }
+
+ for (uint16 j = 0; j < _surface.h; j++) {
+ uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _surface.w; i++) {
+ if (it->inEffect) {
+ if (_pos < 0) {
+ lineBuf[i] -= dcolor;
+ } else {
+ lineBuf[i] += dcolor;
+ }
+ }
+ cnt++;
+ if (cnt >= it->count) {
+ it++;
+ cnt = 0;
+ }
+ if (it == _map->end())
+ break;
+ }
+ if (it == _map->end())
+ break;
+ }
+
+ return &_surface;
+}
+
+void LightFx::update() {
+ if (_up)
+ _pos++;
+ else
+ _pos--;
+
+ if (_pos <= _minD) {
+ _up = !_up;
+ _pos = _minD;
+ } else if (_pos >= _maxD) {
+ _up = !_up;
+ _pos = _maxD;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/light.h b/engines/zvision/graphics/effects/light.h
new file mode 100644
index 0000000..ae87d66
--- /dev/null
+++ b/engines/zvision/graphics/effects/light.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 LIGHTFX_H_INCLUDED
+#define LIGHTFX_H_INCLUDED
+
+#include "zvision/graphics/effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class LightFx : public Effect {
+public:
+
+ LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127);
+ ~LightFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ EffectMap *_map;
+ int32 _delta;
+ bool _up;
+ int32 _pos;
+
+ int8 _minD;
+ int8 _maxD;
+};
+} // End of namespace ZVision
+
+#endif // LIGHTFX_H_INCLUDED
diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp
new file mode 100644
index 0000000..88239f3
--- /dev/null
+++ b/engines/zvision/graphics/effects/wave.cpp
@@ -0,0 +1,146 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/graphics/effects/wave.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+
+
+namespace ZVision {
+
+WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd):
+ Effect(engine, key, region, ported) {
+
+ _frame = 0;
+ _frame_cnt = frames;
+
+ _ampls.resize(_frame_cnt);
+ _hw = _region.width() / 2;
+ _hh = _region.height() / 2;
+
+ int32 frmsize = _hw * _hh;
+
+ float phase = 0;
+
+ int16 w_4 = _hw / 2;
+ int16 h_4 = _hh / 2;
+
+ for (int16 i = 0; i < _frame_cnt; i++) {
+ _ampls[i].resize(frmsize);
+
+ for (int16 y = 0; y < _hh; y++)
+ for (int16 x = 0; x < _hw; x++) {
+ int16 dx = (x - w_4);
+ int16 dy = (y - h_4);
+
+ _ampls[i][x + y * _hw] = ampl * sin(sqrt(dx * dx / (float)s_x + dy * dy / (float)s_y) / (-waveln * 3.1415926) + phase);
+ }
+ phase += spd;
+ }
+}
+
+WaveFx::~WaveFx() {
+ for (uint16 i = 0; i < _ampls.size(); i++)
+ _ampls[i].clear();
+ _ampls.clear();
+}
+
+const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) {
+ for (int16 y = 0; y < _hh; y++) {
+ uint16 *abc = (uint16 *)_surface.getBasePtr(0, y);
+ uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _hh + y);
+ uint16 *abc3 = (uint16 *)_surface.getBasePtr(_hw, y);
+ uint16 *abc4 = (uint16 *)_surface.getBasePtr(_hw, _hh + y);
+
+ for (int16 x = 0; x < _hw; x++) {
+ int8 amnt = _ampls[_frame][x + _hw * y];
+
+ int16 n_x = x + amnt;
+ int16 n_y = y + amnt;
+
+ if (n_x < 0)
+ n_x = 0;
+ if (n_x >= _region.width())
+ n_x = _region.width() - 1;
+ if (n_y < 0)
+ n_y = 0;
+ if (n_y >= _region.height())
+ n_y = _region.height() - 1;
+ *abc = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
+
+ n_x = x + amnt + _hw;
+ n_y = y + amnt;
+
+ if (n_x < 0)
+ n_x = 0;
+ if (n_x >= _region.width())
+ n_x = _region.width() - 1;
+ if (n_y < 0)
+ n_y = 0;
+ if (n_y >= _region.height())
+ n_y = _region.height() - 1;
+ *abc3 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
+
+ n_x = x + amnt;
+ n_y = y + amnt + _hh;
+
+ if (n_x < 0)
+ n_x = 0;
+ if (n_x >= _region.width())
+ n_x = _region.width() - 1;
+ if (n_y < 0)
+ n_y = 0;
+ if (n_y >= _region.height())
+ n_y = _region.height() - 1;
+ *abc2 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
+
+ n_x = x + amnt + _hw;
+ n_y = y + amnt + _hh;
+
+ if (n_x < 0)
+ n_x = 0;
+ if (n_x >= _region.width())
+ n_x = _region.width() - 1;
+ if (n_y < 0)
+ n_y = 0;
+ if (n_y >= _region.height())
+ n_y = _region.height() - 1;
+ *abc4 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
+
+ abc++;
+ abc2++;
+ abc3++;
+ abc4++;
+ }
+ }
+
+ return &_surface;
+}
+
+void WaveFx::update() {
+ _frame = (_frame + 1) % _frame_cnt;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h
new file mode 100644
index 0000000..0046dfc
--- /dev/null
+++ b/engines/zvision/graphics/effects/wave.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WAVEFX_H_INCLUDED
+#define WAVEFX_H_INCLUDED
+
+#include "common/array.h"
+#include "zvision/graphics/effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class WaveFx : public Effect {
+public:
+
+ WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd);
+ ~WaveFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ int16 _frame;
+ int16 _frame_cnt;
+ int16 _hw, _hh;
+ Common::Array< Common::Array< int8 > > _ampls;
+};
+} // End of namespace ZVision
+
+#endif // WAVEFX_H_INCLUDED
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 5aa0d75..0aa0622 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -54,6 +54,7 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH
_renderTable(_wrkWidth, _wrkHeight) {
_wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
+ _effectWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
_outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat);
_menuWnd.create(windowWidth, workingWindow.top, _pixelFormat);
_subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat);
@@ -67,21 +68,55 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH
RenderManager::~RenderManager() {
_curBkg.free();
_wrkWnd.free();
+ _effectWnd.free();
_outWnd.free();
+ _menuWnd.free();
+ _subWnd.free();
}
void RenderManager::renderBackbufferToScreen() {
Graphics::Surface *out = &_outWnd;
+ Graphics::Surface *in = &_wrkWnd;
+
+ if (!_effects.empty()) {
+ bool copied = false;
+ Common::Rect windRect(_wrkWidth, _wrkHeight);
+ for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) {
+ Common::Rect rect = (*it)->getRegion();
+ Common::Rect scrPlace = rect;
+ if ((*it)->isPort())
+ scrPlace = bkgRectToScreen(scrPlace);
+ if (windRect.intersects(scrPlace)) {
+ if (!copied) {
+ copied = true;
+ _effectWnd.copyFrom(_wrkWnd);
+ in = &_effectWnd;
+ }
+ const Graphics::Surface *post;
+ if ((*it)->isPort())
+ post = (*it)->draw(_curBkg.getSubArea(rect));
+ else
+ post = (*it)->draw(_effectWnd.getSubArea(rect));
+ blitSurfaceToSurface(*post, _effectWnd, scrPlace.left, scrPlace.top);
+ scrPlace.clip(windRect);
+ if (_wrkWndDirtyRect .isEmpty()) {
+ _wrkWndDirtyRect = scrPlace;
+ } else {
+ _wrkWndDirtyRect.extend(scrPlace);
+ }
+ }
+ }
+ }
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
if (!_wrkWndDirtyRect.isEmpty()) {
- _renderTable.mutateImage(&_outWnd, &_wrkWnd);
+ _renderTable.mutateImage(&_outWnd, in);
out = &_outWnd;
_outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight);
}
} else {
- out = &_wrkWnd;
+ out = in;
_outWndDirtyRect = _wrkWndDirtyRect;
}
@@ -832,4 +867,183 @@ Common::Point RenderManager::getBkgSize() {
return Common::Point(_bkgWidth, _bkgHeight);
}
+void RenderManager::addEffect(Effect *_effect) {
+ _effects.push_back(_effect);
+}
+
+void RenderManager::deleteEffect(uint32 ID) {
+ for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) {
+ if ((*it)->getKey() == ID) {
+ delete *it;
+ it = _effects.erase(it);
+ }
+ }
+}
+
+Common::Rect RenderManager::bkgRectToScreen(const Common::Rect &src) {
+ Common::Rect tmp = src;
+ RenderTable::RenderState state = _renderTable.getRenderState();
+
+ if (state == RenderTable::PANORAMA) {
+ if (_bkgOff < _screenCenterX) {
+ Common::Rect rScreen(_screenCenterX + _bkgOff, _wrkHeight);
+ Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight);
+ lScreen.translate(_bkgWidth - lScreen.width(), 0);
+ lScreen.clip(src);
+ rScreen.clip(src);
+ if (rScreen.width() < lScreen.width()) {
+ tmp.translate(_screenCenterX - _bkgOff - _bkgWidth, 0);
+ } else {
+ tmp.translate(_screenCenterX - _bkgOff, 0);
+ }
+ } else if (_bkgWidth - _bkgOff < _screenCenterX) {
+ Common::Rect rScreen(_screenCenterX - (_bkgWidth - _bkgOff), _wrkHeight);
+ Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight);
+ lScreen.translate(_bkgWidth - lScreen.width(), 0);
+ lScreen.clip(src);
+ rScreen.clip(src);
+ if (lScreen.width() < rScreen.width()) {
+ tmp.translate(_screenCenterX + (_bkgWidth - _bkgOff), 0);
+ } else {
+ tmp.translate(_screenCenterX - _bkgOff, 0);
+ }
+ } else {
+ tmp.translate(_screenCenterX - _bkgOff, 0);
+ }
+ } else if (state == RenderTable::TILT) {
+ tmp.translate(0, (_screenCenterY - _bkgOff));
+ }
+
+ return tmp;
+}
+
+EffectMap *RenderManager::makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *_minComp, int8 *_maxComp) {
+ Common::Rect bkgRect(_bkgWidth, _bkgHeight);
+ if (!bkgRect.contains(xy))
+ return NULL;
+
+ if (!bkgRect.intersects(rect))
+ return NULL;
+
+ uint16 color = *(uint16 *)_curBkg.getBasePtr(xy.x, xy.y);
+ uint8 stC1, stC2, stC3;
+ _curBkg.format.colorToRGB(color, stC1, stC2, stC3);
+ EffectMap *newMap = new EffectMap;
+
+ EffectMapUnit unit;
+ unit.count = 0;
+ unit.inEffect = false;
+
+ int16 w = rect.width();
+ int16 h = rect.height();
+
+ bool first = true;
+
+ uint8 minComp = MIN(MIN(stC1, stC2), stC3);
+ uint8 maxComp = MAX(MAX(stC1, stC2), stC3);
+
+ uint8 depth8 = depth << 3;
+
+ for (int16 j = 0; j < h; j++) {
+ uint16 *pix = (uint16 *)_curBkg.getBasePtr(rect.left, rect.top + j);
+ for (int16 i = 0; i < w; i++) {
+ uint16 curClr = pix[i];
+ uint8 cC1, cC2, cC3;
+ _curBkg.format.colorToRGB(curClr, cC1, cC2, cC3);
+
+ bool use = false;
+
+ if (curClr == color)
+ use = true;
+ else if (curClr > color) {
+ if ((cC1 - stC1 < depth8) &&
+ (cC2 - stC2 < depth8) &&
+ (cC3 - stC3 < depth8))
+ use = true;
+ } else { /* if (curClr < color) */
+ if ((stC1 - cC1 < depth8) &&
+ (stC2 - cC2 < depth8) &&
+ (stC3 - cC3 < depth8))
+ use = true;
+ }
+
+ if (first) {
+ unit.inEffect = use;
+ first = false;
+ }
+
+ if (use) {
+ uint8 cMinComp = MIN(MIN(cC1, cC2), cC3);
+ uint8 cMaxComp = MAX(MAX(cC1, cC2), cC3);
+ if (cMinComp < minComp)
+ minComp = cMinComp;
+ if (cMaxComp > maxComp)
+ maxComp = cMaxComp;
+ }
+
+ if (unit.inEffect == use)
+ unit.count++;
+ else {
+ newMap->push_back(unit);
+ unit.count = 1;
+ unit.inEffect = use;
+ }
+ }
+ }
+ newMap->push_back(unit);
+
+ if (_minComp) {
+ if (minComp - depth8 < 0)
+ *_minComp = -(minComp >> 3);
+ else
+ *_minComp = -depth;
+ }
+ if (_maxComp) {
+ if ((int16)maxComp + (int16)depth8 > 255)
+ *_maxComp = (255 - maxComp) >> 3;
+ else
+ *_maxComp = depth;
+ }
+
+ return newMap;
+}
+
+EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 transp) {
+ EffectMapUnit unit;
+ unit.count = 0;
+ unit.inEffect = false;
+
+ int16 w = surf.w;
+ int16 h = surf.h;
+
+ EffectMap *newMap = new EffectMap;
+
+ bool first = true;
+
+ for (int16 j = 0; j < h; j++) {
+ const uint16 *pix = (const uint16 *)surf.getBasePtr(0, j);
+ for (int16 i = 0; i < w; i++) {
+ bool use = false;
+ if (pix[i] != transp)
+ use = true;
+
+ if (first) {
+ unit.inEffect = use;
+ first = false;
+ }
+
+ if (unit.inEffect == use)
+ unit.count++;
+ else {
+ newMap->push_back(unit);
+ unit.count = 1;
+ unit.inEffect = use;
+ }
+ }
+ }
+ newMap->push_back(unit);
+
+ return newMap;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index 24234e2..665a27b 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -31,6 +31,8 @@
#include "graphics/surface.h"
+#include "effect.h"
+
class OSystem;
@@ -68,6 +70,7 @@ private:
// };
//
typedef Common::HashMap<uint16, oneSub> subMap;
+ typedef Common::List<Effect *> effectsList;
private:
ZVision *_engine;
@@ -93,6 +96,8 @@ private:
Common::Rect _menuWndDirtyRect;
+ Graphics::Surface _effectWnd;
+
// A buffer the exact same size as the workingWindow
// This buffer stores everything un-warped, then does a warp at the end of the frame
@@ -151,6 +156,8 @@ private:
/** Holds any 'leftover' milliseconds between frames */
//uint _accumulatedVelocityMilliseconds;
+ effectsList _effects;
+
public:
void initialize();
@@ -267,6 +274,13 @@ public:
*/
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
+
+ void addEffect(Effect *_effect);
+ void deleteEffect(uint32 ID);
+ EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD);
+ EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
+
+ Common::Rect bkgRectToScreen(const Common::Rect &src);
};
} // End of namespace ZVision
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 6734fde..872b48f 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -13,6 +13,9 @@ MODULE_OBJS := \
cursors/cursor.o \
detection.o \
fonts/truetype_font.o \
+ graphics/effects/fog.o \
+ graphics/effects/light.o \
+ graphics/effects/wave.o \
graphics/render_manager.o \
graphics/render_table.o \
scripting/actions.o \
@@ -33,6 +36,7 @@ MODULE_OBJS := \
scripting/sidefx.o \
scripting/sidefx/animation_node.o \
scripting/sidefx/music_node.o \
+ scripting/sidefx/region_node.o \
scripting/sidefx/syncsound_node.o \
scripting/sidefx/timer_node.o \
scripting/sidefx/ttytext_node.o \
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 399a81d..839eb1f 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -34,7 +34,13 @@
#include "zvision/scripting/sidefx/syncsound_node.h"
#include "zvision/scripting/sidefx/animation_node.h"
#include "zvision/scripting/sidefx/ttytext_node.h"
+#include "zvision/scripting/sidefx/region_node.h"
#include "zvision/scripting/controls/titler_control.h"
+#include "zvision/graphics/render_table.h"
+#include "zvision/graphics/effect.h"
+#include "zvision/graphics/effects/fog.h"
+#include "zvision/graphics/effects/light.h"
+#include "zvision/graphics/effects/wave.h"
#include "common/file.h"
@@ -476,6 +482,80 @@ bool ActionQuit::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRegion
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+
+ char art[64];
+ char custom[64];
+
+ int32 x1, x2, y1, y2;
+
+ sscanf(line.c_str(), "%s %d %d %d %d %hu %hu %hu %hu %s", art, &x1, &y1, &x2, &y2, &_delay, &_type, &_unk1, &_unk2, custom);
+ _art = Common::String(art);
+ _custom = Common::String(custom);
+ _rect = Common::Rect(x1, y1, x2 + 1, y2 + 1);
+}
+
+ActionRegion::~ActionRegion() {
+ _engine->getScriptManager()->killSideFx(_slotkey);
+}
+
+bool ActionRegion::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
+ return true;
+
+ Effect *effct = NULL;
+ switch (_type) {
+ case 0: {
+ uint16 s_x, s_y, frames;
+ double amplitude, waveln, speed;
+ sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &s_x, &s_y, &frames, &litude, &waveln, &speed);
+ effct = new WaveFx(_engine, _slotkey, _rect, _unk1, frames, s_x, s_y, amplitude, waveln, speed);
+ }
+ break;
+ case 1: {
+ uint16 aX, aY, aD;
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aY, &aX, &aD);
+ else
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aX, &aY, &aD);
+ int8 minD;
+ int8 maxD;
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD);
+ effct = new LightFx(_engine, _slotkey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD);
+ }
+ break;
+ case 9: {
+ int16 dum1;
+ int32 dum2;
+ char buf[64];
+ sscanf(_custom.c_str(), "%hd,%d,%s", &dum1, &dum2, buf);
+ Graphics::Surface tempMask;
+ _engine->getRenderManager()->readImageToSurface(_art, tempMask);
+ if (_rect.width() != tempMask.w)
+ _rect.setWidth(tempMask.w);
+ if (_rect.height() != tempMask.h)
+ _rect.setHeight(tempMask.h);
+
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0);
+ effct = new FogFx(_engine, _slotkey, _rect, _unk1, _map, Common::String(buf));
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (effct) {
+ _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotkey, effct, _delay));
+ _engine->getRenderManager()->addEffect(effct);
+ }
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionRandom
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index de303a7..5e34f6e 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -317,6 +317,22 @@ public:
bool execute();
};
+class ActionRegion : public ResultAction {
+public:
+ ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionRegion();
+ bool execute();
+
+private:
+ Common::String _art;
+ Common::String _custom;
+ Common::Rect _rect;
+ uint16 _delay;
+ uint16 _type;
+ uint16 _unk1;
+ uint16 _unk2;
+};
+
// TODO: See if this exists in ZGI. It doesn't in ZNem
class ActionUnloadAnimation : public ResultAction {
public:
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 04378f8..8140d09 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -266,7 +266,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("random", true)) {
actionList.push_back(new ActionRandom(_engine, slot, args));
} else if (act.matchString("region", true)) {
- // TODO: Implement ActionRegion
+ actionList.push_back(new ActionRegion(_engine, slot, args));
} else if (act.matchString("restore_game", true)) {
// TODO: Implement ActionRestoreGame
} else if (act.matchString("rotate_to", true)) {
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 4d82f36..219cff9 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -87,9 +87,9 @@ enum StateKey {
StateKey_DebugCheats = 74,
StateKey_JapanFonts = 75,
StateKey_Brightness = 77,
- StateKey_EF9_B = 91,
+ StateKey_EF9_R = 91,
StateKey_EF9_G = 92,
- StateKey_EF9_R = 93,
+ StateKey_EF9_B = 93,
StateKey_EF9_Speed = 94,
StateKey_Inv_Cnt_Slot = 100,
StateKey_Inv_1_Slot = 101,
diff --git a/engines/zvision/scripting/sidefx/region_node.cpp b/engines/zvision/scripting/sidefx/region_node.cpp
new file mode 100644
index 0000000..de613d8
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/region_node.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/sidefx/region_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+RegionNode::RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay)
+ : SideFX(engine, key, SIDEFX_REGION) {
+ _effect = effect;
+ _delay = delay;
+ _timeLeft = 0;
+}
+
+RegionNode::~RegionNode() {
+ _engine->getRenderManager()->deleteEffect(_key);
+}
+
+bool RegionNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
+ if (_timeLeft <= 0) {
+ _timeLeft = _delay;
+ if (_effect)
+ _effect->update();
+ }
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/region_node.h b/engines/zvision/scripting/sidefx/region_node.h
new file mode 100644
index 0000000..ec716b6
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/region_node.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_REGION_NODE_H
+#define ZVISION_REGION_NODE_H
+
+#include "graphics/surface.h"
+
+#include "zvision/scripting/sidefx.h"
+#include "zvision/graphics/effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class RegionNode : public SideFX {
+public:
+ RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay);
+ ~RegionNode();
+
+ /**
+ * 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:
+ int32 _timeLeft;
+ uint32 _delay;
+ Effect *_effect;
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 002b8e692a9488ac91e043df2fe7dce34d52a771
https://github.com/scummvm/scummvm/commit/002b8e692a9488ac91e043df2fe7dce34d52a771
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-10T16:46:48+07:00
Commit Message:
ZVISION: Fix default Tilt linScale
Changed paths:
engines/zvision/graphics/render_table.cpp
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index 942420c..2fc21b7 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -55,7 +55,7 @@ void RenderTable::setRenderState(RenderState newState) {
break;
case TILT:
_tiltOptions.fieldOfView = 27.0f;
- _tiltOptions.linearScale = 0.55f;
+ _tiltOptions.linearScale = 0.65f;
_tiltOptions.reverse = false;
break;
case FLAT:
Commit: 7c9d8f22de461528ac5e3fbe9c1c69dcdaa1a908
https://github.com/scummvm/scummvm/commit/7c9d8f22de461528ac5e3fbe9c1c69dcdaa1a908
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-10T16:48:28+07:00
Commit Message:
ZVISION: Implement dynamic tilt up/down border
Changed paths:
engines/zvision/graphics/render_table.cpp
engines/zvision/graphics/render_table.h
engines/zvision/zvision.cpp
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index 2fc21b7..9bf40d3 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -199,6 +199,7 @@ void RenderTable::generateTiltLookupTable() {
float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f);
float cylinderRadius = halfWidth / tan(fovInRadians);
+ _tiltOptions.gap = cylinderRadius * atan2(halfHeight / cylinderRadius, 1.0) * _tiltOptions.linearScale;
for (uint y = 0; y < _numRows; ++y) {
@@ -259,4 +260,8 @@ void RenderTable::setTiltReverse(bool reverse) {
_tiltOptions.reverse = reverse;
}
+float RenderTable::getTiltGap() {
+ return _tiltOptions.gap;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index 0b4d6e3..a268ee6 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -57,6 +57,7 @@ private:
float fieldOfView;
float linearScale;
bool reverse;
+ float gap;
} _tiltOptions;
public:
@@ -79,6 +80,8 @@ public:
void setTiltScale(float scale);
void setTiltReverse(bool reverse);
+ float getTiltGap();
+
private:
void generatePanoramaLookupTable();
void generateTiltLookupTable();
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 24e15e0..a534e49 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -332,7 +332,7 @@ void ZVision::updateRotation() {
int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
int16 scr_height = _renderManager->getBkgSize().y;
- int16 tilt_gap = _workingWindow.height() / 2;
+ int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();
if (new_pos >= (scr_height - tilt_gap))
new_pos = scr_height - tilt_gap;
Commit: ac74070af1d09cb9eb319b50716d2c3ee272c2a9
https://github.com/scummvm/scummvm/commit/ac74070af1d09cb9eb319b50716d2c3ee272c2a9
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-10T16:49:38+07:00
Commit Message:
ZVISION: Lever blitter must scale image to rect
Changed paths:
engines/zvision/scripting/controls/lever_control.cpp
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 8072079..84cd6fa 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -370,12 +370,10 @@ void LeverControl::renderFrame(uint frameNumber) {
}
const Graphics::Surface *frameData;
- int x = _animationCoords.left;
- int y = _animationCoords.top;
frameData = _animation->getFrameData(frameNumber);
if (frameData)
- _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
}
} // End of namespace ZVision
Commit: a65ec38f8ddfb2a856619880d005ccd1a766623a
https://github.com/scummvm/scummvm/commit/a65ec38f8ddfb2a856619880d005ccd1a766623a
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-10T16:50:59+07:00
Commit Message:
ZVISION: Fix code style
Changed paths:
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/fist_control.cpp
engines/zvision/scripting/controls/paint_control.cpp
engines/zvision/scripting/controls/paint_control.h
engines/zvision/scripting/controls/safe_control.cpp
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 7c8a273..8708f03 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -40,7 +40,7 @@ class ZVision;
class Control {
public:
- enum ControlType {
+ enum ControlType {
CONTROL_UNKNOW,
CONTROL_INPUT,
CONTROL_PUSHTGL,
@@ -63,7 +63,7 @@ public:
}
ControlType getType() {
- return _type;
+ return _type;
}
virtual void focus() {}
@@ -101,13 +101,17 @@ public:
*
* @param keycode The key that was pressed
*/
- virtual bool onKeyDown(Common::KeyState keyState) {return false;}
+ virtual bool onKeyDown(Common::KeyState keyState) {
+ return false;
+ }
/**
* Called when a key is released. Default is NOP.
*
* @param keycode The key that was pressed
*/
- virtual bool onKeyUp(Common::KeyState keyState) {return false;}
+ virtual bool onKeyUp(Common::KeyState keyState) {
+ return false;
+ }
/**
* Processes the node given the deltaTime since last frame. Default is NOP.
*
@@ -130,7 +134,7 @@ public:
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
private:
- ControlType _type;
+ ControlType _type;
};
// TODO: Implement InputControl
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index 46b87dd..89aeb53 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -121,17 +121,17 @@ bool FistControl::process(uint32 deltaTimeInMillis) {
if (_frameCur <= _frameEnd) {
_frameTime -= deltaTimeInMillis;
- if (_frameTime <= 0) {
- _frameTime = _animation->frameTime();
+ if (_frameTime <= 0) {
+ _frameTime = _animation->frameTime();
- renderFrame(_frameCur);
+ renderFrame(_frameCur);
- _frameCur++;
+ _frameCur++;
- if (_frameCur > _frameEnd)
- _engine->getScriptManager()->setStateValue(_animationId, 2);
+ if (_frameCur > _frameEnd)
+ _engine->getScriptManager()->setStateValue(_animationId, 2);
+ }
}
- }
return false;
}
@@ -142,7 +142,7 @@ bool FistControl::onMouseMove(const Common::Point &screenSpacePos, const Common:
if (mouseIn(screenSpacePos, backgroundImageSpacePos) >= 0) {
_engine->getCursorManager()->changeCursor(_cursor);
- return true;
+ return true;
}
return false;
@@ -160,7 +160,7 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
uint32 oldStatus = _fiststatus;
_fiststatus ^= (1 << n_fist);
- for(int i = 0; i < _numEntries; i++)
+ for (int i = 0; i < _numEntries; i++)
if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) {
_frameCur = _entries[i]._anmStrt;
_frameEnd = _entries[i]._anmEnd;
@@ -264,25 +264,25 @@ uint32 FistControl::readBits(const char *str) {
int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (_order) {
- for(int i = 0; i < _fistnum; i++) {
+ for (int i = 0; i < _fistnum; i++) {
if (((_fiststatus >> i) & 1) == 1) {
- for(uint j = 0; j < _fistsDwn[i].size(); j++)
+ for (uint j = 0; j < _fistsDwn[i].size(); j++)
if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
return i;
} else {
- for(uint j = 0; j < _fistsUp[i].size(); j++)
+ for (uint j = 0; j < _fistsUp[i].size(); j++)
if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
return i;
}
}
} else {
- for(int i = _fistnum - 1; i >= 0; i--) {
+ for (int i = _fistnum - 1; i >= 0; i--) {
if (((_fiststatus >> i) & 1) == 1) {
- for(uint j = 0; j < _fistsDwn[i].size(); j++)
+ for (uint j = 0; j < _fistsDwn[i].size(); j++)
if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
return i;
} else {
- for(uint j = 0; j < _fistsUp[i].size(); j++)
+ for (uint j = 0; j < _fistsUp[i].size(); j++)
if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
return i;
}
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
index a350e9b..2891f1b 100644
--- a/engines/zvision/scripting/controls/paint_control.cpp
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -98,7 +98,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
if (_paint) {
- _colorKey = _paint->format.RGBToColor(255,0,255);
+ _colorKey = _paint->format.RGBToColor(255, 0, 255);
_bkg = new Graphics::Surface;
_bkg->create(_rectangle.width(), _rectangle.height(), _paint->format);
_bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey);
@@ -194,7 +194,7 @@ Common::Rect PaintControl::paint(const Common::Point &point) {
brush_rect.translate(-point.x, -point.y);
Common::Rect bkg_rect = paint_rect;
- bkg_rect.translate( -_rectangle.left, -_rectangle.top );
+ bkg_rect.translate(-_rectangle.left, -_rectangle.top);
for (int yy = 0; yy < brush_rect.height(); yy++) {
uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy);
diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h
index c74431e..54b96e8 100644
--- a/engines/zvision/scripting/controls/paint_control.h
+++ b/engines/zvision/scripting/controls/paint_control.h
@@ -59,7 +59,9 @@ public:
*/
bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- bool process(uint32 deltaTimeInMillis) { return false; };
+ bool process(uint32 deltaTimeInMillis) {
+ return false;
+ };
private:
/**
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index d5eff09..ba80914 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -83,7 +83,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
int y;
sscanf(values.c_str(), "%d %d", &x, &y);
- _center = Common::Point(x,y);
+ _center = Common::Point(x, y);
} else if (param.matchString("dial_inner_radius", true)) {
_radius_inner = atoi(values.c_str());
_radius_inner_sq = _radius_inner * _radius_inner;
@@ -188,7 +188,7 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states;
- int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1 ) % _num_states;
+ int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1) % _num_states;
_cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states;
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 7a2854d..fea3c2e 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -160,28 +160,28 @@ void ScriptManager::updateControls(uint deltaTimeMillis) {
Common::Event _event = _controlEvents.front();
Common::Point imageCoord;
switch (_event.type) {
- case Common::EVENT_LBUTTONDOWN:
- imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
- onMouseDown(_event.mouse, imageCoord);
- break;
- case Common::EVENT_LBUTTONUP:
- imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
- onMouseUp(_event.mouse, imageCoord);
- break;
- case Common::EVENT_KEYDOWN:
- onKeyDown(_event.kbd);
- break;
- case Common::EVENT_KEYUP:
- onKeyUp(_event.kbd);
- break;
- default:
- break;
+ case Common::EVENT_LBUTTONDOWN:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseDown(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseUp(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_KEYDOWN:
+ onKeyDown(_event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ onKeyUp(_event.kbd);
+ break;
+ default:
+ break;
}
_controlEvents.pop_front();
}
for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
- if ( (*iter)->process(deltaTimeMillis) )
+ if ((*iter)->process(deltaTimeMillis))
break;
}
@@ -540,7 +540,7 @@ void ScriptManager::do_changeLocation() {
if (_nextLocation.world == 'g' && _nextLocation.room == 'j') {
if (_nextLocation.node == 's' && _nextLocation.view == 'e' &&
- _currentLocation.world != 'g' && _currentLocation.room != 'j')
+ _currentLocation.world != 'g' && _currentLocation.room != 'j')
_engine->getSaveManager()->prepareSaveBuffer();
} else {
if (_currentLocation.world == 'g' && _currentLocation.room == 'j')
Commit: 0b3a20f645324696e08745a9e8a3fc75e1700cac
https://github.com/scummvm/scummvm/commit/0b3a20f645324696e08745a9e8a3fc75e1700cac
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-22T11:43:24+07:00
Commit Message:
ZVISION: Some push toggles may contain few hotspot zones
Changed paths:
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/push_toggle_control.h
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 2f4af0d..bf74a22 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -42,6 +42,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
line.toLowercase();
+ _hotspots.clear();
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("*_hotspot*", true)) {
@@ -52,7 +53,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
- _hotspot = Common::Rect(x, y, x + width, y + height);
+ _hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1));
} else if (line.matchString("cursor*", true)) {
char nameBuffer[25];
@@ -86,12 +87,13 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
trimCommentsAndWhiteSpace(&line);
}
- if (_hotspot.isEmpty() || _hoverCursor.empty()) {
- warning("Push_toggle cursor %u was parsed incorrectly", key);
+ if (_hotspots.size() == 0 || _hoverCursor.empty()) {
+ warning("Push_toggle %u was parsed incorrectly", key);
}
}
PushToggleControl::~PushToggleControl() {
+ _hotspots.clear();
}
bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
@@ -101,7 +103,7 @@ bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com
if (_event != Common::EVENT_LBUTTONUP)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
@@ -117,7 +119,7 @@ bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const C
if (_event != Common::EVENT_LBUTTONDOWN)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
@@ -130,7 +132,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor));
return true;
}
@@ -138,4 +140,11 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
return false;
}
+bool PushToggleControl::contain(const Common::Point &point) {
+ for (uint i = 0; i < _hotspots.size(); i++)
+ if (_hotspots[i].contains(point))
+ return true;
+ return false;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h
index 6ba1bd7..7b45fb4 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.h
+++ b/engines/zvision/scripting/controls/push_toggle_control.h
@@ -27,6 +27,7 @@
#include "common/rect.h"
#include "common/events.h"
+#include "common/array.h"
namespace ZVision {
@@ -65,13 +66,15 @@ private:
* The area that will trigger the event
* This is in image space coordinates, NOT screen space
*/
- Common::Rect _hotspot;
+ Common::Array<Common::Rect> _hotspots;
/** The cursor to use when hovering over _hotspot */
Common::String _hoverCursor;
/** Button maximal values count */
uint _countTo;
Common::EventType _event;
+
+ bool contain(const Common::Point &point);
};
} // End of namespace ZVision
Commit: 4bc319441069101a902ed22f48bec40b7e6c9284
https://github.com/scummvm/scummvm/commit/4bc319441069101a902ed22f48bec40b7e6c9284
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-22T11:44:49+07:00
Commit Message:
ZVISION: Implement simple midi support
Changed paths:
A engines/zvision/core/midi.cpp
A engines/zvision/core/midi.h
engines/zvision/module.mk
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp
new file mode 100644
index 0000000..5cc8cd0
--- /dev/null
+++ b/engines/zvision/core/midi.cpp
@@ -0,0 +1,89 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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/core/midi.h"
+
+namespace ZVision {
+
+midiManager::midiManager() {
+ MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB);
+ _driver = MidiDriver::createMidi(dev);
+ _driver->open();
+}
+
+midiManager::~midiManager() {
+ stop();
+ _driver->close();
+ delete _driver;
+}
+
+void midiManager::stop() {
+ for (int8 i = 0; i < 16; i++)
+ if (_playChannels[i].playing)
+ noteOff(i);
+}
+
+void midiManager::noteOn(int8 channel, int8 note, int8 velocity) {
+ assert(channel <= 15);
+
+ _playChannels[channel].playing = true;
+ _playChannels[channel].note = note;
+ _driver->send(channel | (velocity << 16) | (note << 8) | 0x90);
+}
+
+void midiManager::noteOff(int8 channel) {
+ assert(channel <= 15);
+
+ if (_playChannels[channel].playing) {
+ _playChannels[channel].playing = false;
+ _driver->send(channel | (_playChannels[channel].note << 8) | 0x80);
+ }
+}
+
+int8 midiManager::getFreeChannel() {
+ for (int8 i = 0; i < 16; i++)
+ if (!_playChannels[i].playing)
+ return i;
+ return -1;
+}
+
+void midiManager::setPan(int8 channel, int8 pan) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (pan << 16) | 0xAB0);
+}
+
+void midiManager::setVolume(int8 channel, int8 volume) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (volume << 16) | 0x7B0);
+}
+
+void midiManager::setProgram(int8 channel, int8 prog) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (prog << 8) | 0xC0);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h
new file mode 100644
index 0000000..79f8ea3
--- /dev/null
+++ b/engines/zvision/core/midi.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 ZVISION_MIDI_H
+#define ZVISION_MIDI_H
+
+#include "audio/mididrv.h"
+
+namespace ZVision {
+
+class midiManager {
+public:
+ midiManager();
+ ~midiManager();
+
+ void stop();
+ void noteOn(int8 channel, int8 noteNumber, int8 velocity);
+ void noteOff(int8 channel);
+ void setPan(int8 channel, int8 pan);
+ void setVolume(int8 channel, int8 volume);
+ void setProgram(int8 channel, int8 prog);
+
+ int8 getFreeChannel();
+
+protected:
+
+ struct chan {
+ bool playing;
+ int8 note;
+
+ chan() : playing(false), note(0) {};
+ };
+
+ MidiDriver *_driver;
+ chan _playChannels[16];
+};
+
+}
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 872b48f..3f00d67 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
core/console.o \
core/events.o \
core/menu.o \
+ core/midi.o \
core/save_manager.o \
core/search_manager.o \
cursors/cursor_manager.o \
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index a534e49..a78d68d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -36,6 +36,7 @@
#include "zvision/core/search_manager.h"
#include "zvision/text/text.h"
#include "zvision/fonts/truetype_font.h"
+#include "zvision/core/midi.h"
#include "common/config-manager.h"
#include "common/str.h"
@@ -67,6 +68,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_saveManager(nullptr),
_stringManager(nullptr),
_cursorManager(nullptr),
+ _midiManager(nullptr),
_aud_id(0),
_rendDelay(2),
_velocity(0) {
@@ -85,6 +87,7 @@ ZVision::~ZVision() {
delete _renderManager;
delete _scriptManager;
delete _rnd;
+ delete _midiManager;
// Remove all of our debug levels
DebugMan.clearAllDebugChannels();
@@ -156,6 +159,7 @@ void ZVision::initialize() {
_stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
_textRenderer = new textRenderer(this);
+ _midiManager = new midiManager();
if (_gameDescription->gameId == GID_GRANDINQUISITOR)
_menu = new menuZgi(this);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index e5d32bf..cbd10da 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -55,6 +55,7 @@ class RlfAnimation;
class menuHandler;
class textRenderer;
class Subtitle;
+class midiManager;
class ZVision : public Engine {
public:
@@ -104,6 +105,7 @@ private:
menuHandler *_menu;
sManager *_searchManager;
textRenderer *_textRenderer;
+ midiManager *_midiManager;
// Clock
Clock _clock;
@@ -146,6 +148,9 @@ public:
textRenderer *getTextRenderer() const {
return _textRenderer;
}
+ midiManager *getMidiManager() const {
+ return _midiManager;
+ }
Common::RandomSource *getRandomSource() const {
return _rnd;
}
Commit: 8e9d201cc3496f79fa30d1e05c7372998895c0e6
https://github.com/scummvm/scummvm/commit/8e9d201cc3496f79fa30d1e05c7372998895c0e6
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-22T11:49:24+07:00
Commit Message:
ZVISION: Music actions and sidefx now handle midi sounds.
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/sidefx/music_node.cpp
engines/zvision/scripting/sidefx/music_node.h
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 839eb1f..2464f54 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -313,21 +313,26 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l
// 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;
+ _midi = true;
+ int note;
+ int prog;
+ sscanf(line.c_str(), "%u %d %d %u", &type, &prog, ¬e, &volume);
+ _volume = volume;
+ _note = note;
+ _prog = prog;
} 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;
+ _midi = false;
_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;
+ // 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;
+ }
}
+
+
}
ActionMusic::~ActionMusic() {
@@ -339,10 +344,14 @@ bool ActionMusic::execute() {
if (_engine->getScriptManager()->getSideFX(_slotkey))
return true;
- if (!_engine->getSearchManager()->hasFile(_fileName))
- return true;
+ if (_midi) {
+ _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotkey, _prog, _note, _volume));
+ } else {
+ if (!_engine->getSearchManager()->hasFile(_fileName))
+ return true;
- _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
+ }
return true;
}
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index 5e34f6e..b3c46d1 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -243,11 +243,13 @@ public:
private:
uint32 _key;
- Audio::Mixer::SoundType _soundType;
Common::String _fileName;
bool _loop;
byte _volume;
bool _universe;
+ bool _midi;
+ int8 _note;
+ int8 _prog;
};
class ActionPanTrack : public ResultAction {
diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp
index 0351867..4420da3 100644
--- a/engines/zvision/scripting/sidefx/music_node.cpp
+++ b/engines/zvision/scripting/sidefx/music_node.cpp
@@ -25,6 +25,7 @@
#include "zvision/scripting/sidefx/music_node.h"
#include "zvision/zvision.h"
+#include "zvision/core/midi.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/sound/zork_raw.h"
@@ -37,7 +38,7 @@
namespace ZVision {
MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
- : SideFX(engine, key, SIDEFX_AUDIO) {
+ : MusicNode_BASE(engine, key, SIDEFX_AUDIO) {
_loop = loop;
_volume = volume;
_crossfade = false;
@@ -174,7 +175,7 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode *mus = (MusicNode *)fx;
+ MusicNode_BASE *mus = (MusicNode_BASE *)fx;
mus->setPanTrack(pos);
}
}
@@ -182,9 +183,58 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
PanTrackNode::~PanTrackNode() {
SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode *mus = (MusicNode *)fx;
+ MusicNode_BASE *mus = (MusicNode_BASE *)fx;
mus->unsetPanTrack();
}
}
+
+MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
+ : MusicNode_BASE(engine, key, SIDEFX_AUDIO) {
+ _volume = volume;
+ _prog = program;
+ _noteNumber = note;
+ _pan = 0;
+
+ _chan = _engine->getMidiManager()->getFreeChannel();
+
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, _volume);
+ _engine->getMidiManager()->setPan(_chan, _pan);
+ _engine->getMidiManager()->setProgram(_chan, _prog);
+ _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+MusicMidiNode::~MusicMidiNode() {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->noteOff(_chan);
+ }
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+}
+
+void MusicMidiNode::setPanTrack(int16 pos) {
+}
+
+void MusicMidiNode::unsetPanTrack() {
+}
+
+void MusicMidiNode::setFade(int32 time, uint8 target) {
+}
+
+bool MusicMidiNode::process(uint32 deltaTimeInMillis) {
+ return false;
+}
+
+void MusicMidiNode::setVolume(uint8 new_volume) {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, new_volume);
+ }
+ _volume = new_volume;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
index 066b8f8..262b130 100644
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -32,7 +32,30 @@ class String;
}
namespace ZVision {
-class MusicNode : public SideFX {
+
+class MusicNode_BASE : public SideFX {
+public:
+ MusicNode_BASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {}
+ ~MusicNode_BASE() {}
+
+ /**
+ * 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
+ */
+ virtual bool process(uint32 deltaTimeInMillis) = 0;
+
+ virtual void setVolume(uint8 volume) = 0;
+
+ virtual void setPanTrack(int16 pos) = 0;
+ virtual void unsetPanTrack() = 0;
+
+ virtual void setFade(int32 time, uint8 target) = 0;
+};
+
+class MusicNode : public MusicNode_BASE {
public:
MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
~MusicNode();
@@ -68,6 +91,36 @@ private:
Subtitle *_sub;
};
+class MusicMidiNode : public MusicNode_BASE {
+public:
+ MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
+ ~MusicMidiNode();
+
+ /**
+ * 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);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ int8 _chan;
+ int8 _noteNumber;
+ int8 _velocity;
+ int8 _pan;
+ int8 _volume;
+ int8 _prog;
+};
+
class PanTrackNode : public SideFX {
public:
PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
Commit: 678f47f043fc5498daae5d4331e02d23a2186528
https://github.com/scummvm/scummvm/commit/678f47f043fc5498daae5d4331e02d23a2186528
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-23T17:09:58+07:00
Commit Message:
ZVISION: Implement action:distort and distort sidefx node
Changed paths:
A engines/zvision/scripting/sidefx/distort_node.cpp
A engines/zvision/scripting/sidefx/distort_node.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/graphics/render_table.cpp
engines/zvision/graphics/render_table.h
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 0aa0622..ce1962a 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -1046,4 +1046,8 @@ EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 tr
return newMap;
}
+void RenderManager::markDirty() {
+ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index 665a27b..e0fc5c2 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -281,6 +281,8 @@ public:
EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
Common::Rect bkgRectToScreen(const Common::Rect &src);
+
+ void markDirty();
};
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index 9bf40d3..aeba729 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -264,4 +264,22 @@ float RenderTable::getTiltGap() {
return _tiltOptions.gap;
}
+float RenderTable::getAngle() {
+ if (_renderState == TILT)
+ return _tiltOptions.fieldOfView;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.fieldOfView;
+ else
+ return 1.0;
+}
+
+float RenderTable::getLinscale() {
+ if (_renderState == TILT)
+ return _tiltOptions.linearScale;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.linearScale;
+ else
+ return 1.0;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index a268ee6..7153738 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -81,6 +81,8 @@ public:
void setTiltReverse(bool reverse);
float getTiltGap();
+ float getAngle();
+ float getLinscale();
private:
void generatePanoramaLookupTable();
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 2464f54..9733c5c 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -33,6 +33,7 @@
#include "zvision/scripting/sidefx/music_node.h"
#include "zvision/scripting/sidefx/syncsound_node.h"
#include "zvision/scripting/sidefx/animation_node.h"
+#include "zvision/scripting/sidefx/distort_node.h"
#include "zvision/scripting/sidefx/ttytext_node.h"
#include "zvision/scripting/sidefx/region_node.h"
#include "zvision/scripting/controls/titler_control.h"
@@ -193,6 +194,28 @@ bool ActionDisplayMessage::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionDistort
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_st_angl, &_en_angl, &_st_lin, &_en_lin);
+}
+
+ActionDistort::~ActionDistort() {
+ _engine->getScriptManager()->killSideFx(_distSlot);
+}
+
+bool ActionDistort::execute() {
+ if (_engine->getScriptManager()->getSideFX(_distSlot))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _st_angl, _en_angl, _st_lin, _en_lin));
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index b3c46d1..f51847e 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -202,9 +202,16 @@ public:
class ActionDistort : public ResultAction {
public:
ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionDistort();
bool execute();
private:
+ int16 _distSlot;
+ int16 _speed;
+ float _st_angl;
+ float _en_angl;
+ float _st_lin;
+ float _en_lin;
};
class ActionEnableControl : public ResultAction {
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 8140d09..df60b0b 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -242,7 +242,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("dissolve", true)) {
// TODO: Implement ActionDissolve
} else if (act.matchString("distort", true)) {
- // TODO: Implement ActionDistort
+ actionList.push_back(new ActionDistort(_engine, slot, args));
} else if (act.matchString("enable_control", true)) {
actionList.push_back(new ActionEnableControl(_engine, slot, args));
} else if (act.matchString("flush_mouse_events", true)) {
diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp
new file mode 100644
index 0000000..576a1f8
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/distort_node.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/sidefx/distort_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/render_table.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin)
+ : SideFX(engine, key, SIDEFX_DISTORT) {
+
+ _angle = _engine->getRenderManager()->getRenderTable()->getAngle();
+ _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale();
+
+ _speed = speed;
+ _incr = true;
+ _st_angl = st_angl;
+ _en_angl = en_angl;
+ _st_lin = st_lin;
+ _en_lin = en_lin;
+
+ _curFrame = 1.0;
+
+ _diff_angl = en_angl - st_angl;
+ _diff_lin = en_lin - st_lin;
+
+ _frmSpeed = (float)speed / 15.0;
+ _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
+ if (_frames <= 0)
+ _frames = 1;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+DistortNode::~DistortNode() {
+ setParams(_angle, _linScale);
+}
+
+bool DistortNode::process(uint32 deltaTimeInMillis) {
+
+ float updTime = deltaTimeInMillis / (1000.0 / 60.0);
+
+ if (_incr)
+ _curFrame += updTime;
+ else
+ _curFrame -= updTime;
+
+ if (_curFrame < 1.0) {
+ _curFrame = 1.0;
+ _incr = true;
+ } else if (_curFrame > _frames) {
+ _curFrame = _frames;
+ _incr = false;
+ }
+
+ float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
+
+
+ setParams(_st_angl + diff * _diff_angl, _st_lin + diff * _diff_lin);
+
+ return false;
+}
+
+void DistortNode::setParams(float angl, float linScale) {
+ RenderTable *table = _engine->getRenderManager()->getRenderTable();
+ if (table->getRenderState() == RenderTable::PANORAMA) {
+ table->setPanoramaFoV(angl);
+ table->setPanoramaScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ } else if (table->getRenderState() == RenderTable::TILT) {
+ table->setTiltFoV(angl);
+ table->setTiltScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ }
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h
new file mode 100644
index 0000000..cba9c5e
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/distort_node.h
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_DISTORT_NODE_H
+#define ZVISION_DISTORT_NODE_H
+
+#include "zvision/scripting/sidefx.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class DistortNode : public SideFX {
+public:
+ DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin);
+ ~DistortNode();
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int16 _speed;
+ float _st_angl;
+ float _en_angl;
+ float _st_lin;
+ float _en_lin;
+
+ float _frmSpeed;
+ float _diff_angl;
+ float _diff_lin;
+ bool _incr;
+ int16 _frames;
+
+ float _curFrame;
+
+ float _angle;
+ float _linScale;
+
+private:
+ void setParams(float angl, float linScale);
+};
+
+} // End of namespace ZVision
+
+#endif
Commit: 19b2e9123db86193ad297bf867f7768dfdb389e9
https://github.com/scummvm/scummvm/commit/19b2e9123db86193ad297bf867f7768dfdb389e9
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-23T17:12:25+07:00
Commit Message:
ZVISION: Add distort_node to module.mk for success build
Changed paths:
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 3f00d67..1730bbc 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -36,6 +36,7 @@ MODULE_OBJS := \
scripting/script_manager.o \
scripting/sidefx.o \
scripting/sidefx/animation_node.o \
+ scripting/sidefx/distort_node.o \
scripting/sidefx/music_node.o \
scripting/sidefx/region_node.o \
scripting/sidefx/syncsound_node.o \
Commit: 8b18ba64ae544e762ca29449e7be29f6a430201e
https://github.com/scummvm/scummvm/commit/8b18ba64ae544e762ca29449e7be29f6a430201e
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-10-23T17:13:56+07:00
Commit Message:
ZVISION: Add support for doubleFPS feature
Changed paths:
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 5ad2e7d..1492ade 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -106,6 +106,13 @@ static const ExtraGuiOption ZVisionExtraGuiOption = {
false
};
+static const ExtraGuiOption ZVisionExtraGuiOption2 = {
+ _s("Double FPS"),
+ _s("Halve the update delay"),
+ "doublefps",
+ false
+};
+
class ZVisionMetaEngine : public AdvancedMetaEngine {
public:
ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
@@ -162,6 +169,7 @@ bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG
const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
ExtraGuiOptions options;
options.push_back(ZVisionExtraGuiOption);
+ options.push_back(ZVisionExtraGuiOption2);
return options;
}
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index a78d68d..0bc5fef 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -173,6 +173,7 @@ void ZVision::initialize() {
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
+ _halveDelay = ConfMan.getBool("doublefps");
}
Common::Error ZVision::run() {
@@ -210,6 +211,8 @@ Common::Error ZVision::run() {
int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
// Ensure non-negative
delay = delay < 0 ? 0 : delay;
+ if (_halveDelay)
+ delay >>= 1;
_system->delayMillis(delay);
}
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index cbd10da..8a305f5 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -121,6 +121,7 @@ private:
int _rendDelay;
int16 _velocity;
+ bool _halveDelay;
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
Commit: 3f21de4694080f07f7927afdc11c4093e523dd6f
https://github.com/scummvm/scummvm/commit/3f21de4694080f07f7927afdc11c4093e523dd6f
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-04T10:08:07+06:00
Commit Message:
ZVISION: Make ZorkAVIAudioTrack resetable
Changed paths:
engines/zvision/video/zork_avi_decoder.cpp
engines/zvision/video/zork_avi_decoder.h
diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp
index e762434..a9dc776 100644
--- a/engines/zvision/video/zork_avi_decoder.cpp
+++ b/engines/zvision/video/zork_avi_decoder.cpp
@@ -55,4 +55,8 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s
}
}
+void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() {
+ decoder->init();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h
index db1ad31..89c0d1e 100644
--- a/engines/zvision/video/zork_avi_decoder.h
+++ b/engines/zvision/video/zork_avi_decoder.h
@@ -52,6 +52,7 @@ private:
}
void queueSound(Common::SeekableReadStream *stream);
+ void resetStream();
private:
RawChunkStream *decoder;
};
Commit: d40caba5b748be38f2b6fe4c70af7eeccedd0ab8
https://github.com/scummvm/scummvm/commit/d40caba5b748be38f2b6fe4c70af7eeccedd0ab8
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-04T10:09:27+06:00
Commit Message:
ZVISION: If ZorkAVIAudioTrack got another format call AVIAudioTrack::queueSound
Changed paths:
engines/zvision/video/zork_avi_decoder.cpp
diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp
index a9dc776..415a20d 100644
--- a/engines/zvision/video/zork_avi_decoder.cpp
+++ b/engines/zvision/video/zork_avi_decoder.cpp
@@ -48,10 +48,9 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s
if (chunk.data)
_audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO);
+ } else {
+ AVIAudioTrack::queueSound(stream);
}
- } else {
- warning("Got %d wave format in AVI\n", _wvInfo.tag);
- delete stream;
}
}
Commit: be8cf9767470cc8ca9d35539b768817cf74b89c6
https://github.com/scummvm/scummvm/commit/be8cf9767470cc8ca9d35539b768817cf74b89c6
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-04T10:12:13+06:00
Commit Message:
ZVISION: Implement settings functions
Changed paths:
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/zvision.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index fea3c2e..d216573 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -96,7 +96,7 @@ void ScriptManager::execScope(script_scope &scope) {
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
(*PuzzleIter)->addedBySetState = 0;
- if (scope.proc_count < 2 || getStateValue(76)) {
+ if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) {
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
} else {
@@ -738,6 +738,8 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
// Place for read prefs
_engine->setRenderDelay(10);
setStateValue(StateKey_RestoreFlag, 1);
+
+ _engine->loadSettings();
}
Location ScriptManager::getCurrentLocation() const {
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 219cff9..3fcbad5 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -86,6 +86,7 @@ enum StateKey {
StateKey_ShowErrorDlg = 73,
StateKey_DebugCheats = 74,
StateKey_JapanFonts = 75,
+ StateKey_ExecScopeStyle = 76,
StateKey_Brightness = 77,
StateKey_EF9_R = 91,
StateKey_EF9_G = 92,
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0bc5fef..77c47d9 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -54,6 +54,32 @@
namespace ZVision {
+#define ZVISION_SETTINGS_KEYS_COUNT 17
+
+struct zvisionIniSettings {
+ const char *name;
+ int16 slot;
+ int16 deflt;
+} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = {
+ {"ZVision_KeyboardTurnSpeed", StateKey_KbdRotateSpeed, 5},
+ {"ZVision_PanaRotateSpeed", StateKey_RotateSpeed, 540},
+ {"ZVision_QSoundEnabled", StateKey_Qsound, 1},
+ {"ZVision_VenusEnabled", StateKey_VenusEnable, 1},
+ {"ZVision_HighQuality", StateKey_HighQuality, 1},
+ {"ZVision_Platform", StateKey_Platform, 0},
+ {"ZVision_InstallLevel", StateKey_InstallLevel, 0},
+ {"ZVision_CountryCode", StateKey_CountryCode, 0},
+ {"ZVision_CPU", StateKey_CPU, 1},
+ {"ZVision_MovieCursor", StateKey_MovieCursor, 1},
+ {"ZVision_NoAnimWhileTurning", StateKey_NoTurnAnim, 0},
+ {"ZVision_Win958", StateKey_WIN958, 0},
+ {"ZVision_ShowErrorDialogs", StateKey_ShowErrorDlg, 0},
+ {"ZVision_ShowSubtitles", StateKey_Subtitles, 1},
+ {"ZVision_DebugCheats", StateKey_DebugCheats, 0},
+ {"ZVision_JapaneseFonts", StateKey_JapanFonts, 0},
+ {"ZVision_Brightness", StateKey_Brightness, 0}
+};
+
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
: Engine(syst),
_gameDescription(gameDesc),
@@ -93,6 +119,28 @@ ZVision::~ZVision() {
DebugMan.clearAllDebugChannels();
}
+void ZVision::registerDefaultSettings() {
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
+ ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].deflt);
+ ConfMan.registerDefault("doublefps", false);
+}
+
+void ZVision::loadSettings() {
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
+ _scriptManager->setStateValue(settingsKeys[i].slot, ConfMan.getInt(settingsKeys[i].name));
+
+ if (getGameId() == GID_NEMESIS)
+ _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1);
+ else
+ _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0);
+}
+
+void ZVision::saveSettings() {
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
+ ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot));
+ ConfMan.flushToDisk();
+}
+
void ZVision::initialize() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -171,6 +219,10 @@ void ZVision::initialize() {
_scriptManager->initialize();
_stringManager->initialize(_gameDescription->gameId);
+ registerDefaultSettings();
+
+ loadSettings();
+
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
_halveDelay = ConfMan.getBool("doublefps");
Commit: 3131e3aa5a3a4911c12223af06ad0d2885f64606
https://github.com/scummvm/scummvm/commit/3131e3aa5a3a4911c12223af06ad0d2885f64606
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-07T10:21:24+06:00
Commit Message:
ZVISION: Add missing methods definition
Changed paths:
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 8a305f5..0bee639 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -180,6 +180,9 @@ public:
void setRenderDelay(uint);
bool canRender();
+ void loadSettings();
+ void saveSettings();
+
private:
void initialize();
void initFonts();
@@ -191,6 +194,8 @@ private:
void onMouseMove(const Common::Point &pos);
void updateRotation();
+
+ void registerDefaultSettings();
};
} // End of namespace ZVision
Commit: 7151240345cc723c0084a4ea5dda9aaaa4dff690
https://github.com/scummvm/scummvm/commit/7151240345cc723c0084a4ea5dda9aaaa4dff690
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-07T10:23:29+06:00
Commit Message:
ZVISION: Now setBackgroundPosition must care about statekey value
Changed paths:
engines/zvision/graphics/render_manager.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index ce1962a..4d5bcf7 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -24,6 +24,7 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
#include "zvision/text/text.h"
#include "zvision/utility/lzss_read_stream.h"
@@ -384,6 +385,8 @@ void RenderManager::setBackgroundPosition(int offset) {
if (_bkgOff != offset)
_bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
_bkgOff = offset;
+
+ _engine->getScriptManager()->setStateValue(StateKey_ViewPos, offset);
}
uint32 RenderManager::getCurrentBackgroundOffset() {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 77c47d9..41d3eea 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -383,7 +383,6 @@ void ZVision::updateRotation() {
if (new_pos < 0)
new_pos += scr_width;
- _scriptManager->setStateValue(StateKey_ViewPos, new_pos);
_renderManager->setBackgroundPosition(new_pos);
} else if (renderState == RenderTable::TILT) {
int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
@@ -398,7 +397,6 @@ void ZVision::updateRotation() {
if (new_pos <= tilt_gap)
new_pos = tilt_gap;
- _scriptManager->setStateValue(StateKey_ViewPos, new_pos);
_renderManager->setBackgroundPosition(new_pos);
}
}
Commit: 0efa1bc5606c9fd984df077d55cf93a7903f5f67
https://github.com/scummvm/scummvm/commit/0efa1bc5606c9fd984df077d55cf93a7903f5f67
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-07T10:25:11+06:00
Commit Message:
ZVISION: Implement action:rotate_to
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 9733c5c..2754a39 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -612,6 +612,21 @@ bool ActionRandom::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRotateTo
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%d, %d", &_toPos, &_time);
+}
+
+bool ActionRotateTo::execute() {
+ _engine->rotateTo(_toPos, _time);
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionSetPartialScreen
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index f51847e..6a20019 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -360,6 +360,16 @@ private:
ValueSlot *_max;
};
+class ActionRotateTo : public ResultAction {
+public:
+ ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ int32 _toPos;
+ int32 _time;
+};
+
class ActionSetPartialScreen : public ResultAction {
public:
ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index df60b0b..b16a2d9 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -270,7 +270,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("restore_game", true)) {
// TODO: Implement ActionRestoreGame
} else if (act.matchString("rotate_to", true)) {
- // TODO: Implement ActionRotateTo
+ actionList.push_back(new ActionRotateTo(_engine, slot, args));
} else if (act.matchString("save_game", true)) {
// TODO: Implement ActionSaveGame
} else if (act.matchString("set_partial_screen", true)) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 41d3eea..79f7d74 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -402,4 +402,56 @@ void ZVision::updateRotation() {
}
}
+void ZVision::rotateTo(int16 _toPos, int16 _time) {
+ if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA)
+ return;
+
+ if (_time == 0)
+ _time = 1;
+
+ int32 maxX = _renderManager->getBkgSize().x;
+ int32 curX = _renderManager->getCurrentBackgroundOffset();
+ int32 dx = 0;
+
+ if (curX == _toPos)
+ return;
+
+ if (curX > _toPos) {
+ if (curX - _toPos > maxX / 2)
+ dx = (_toPos + (maxX - curX)) / _time;
+ else
+ dx = -(curX - _toPos) / _time;
+ } else {
+ if (_toPos - curX > maxX / 2)
+ dx = -((maxX - _toPos) + curX) / _time;
+ else
+ dx = (_toPos - curX) / _time;
+ }
+
+ _clock.stop();
+
+ for (int16 i = 0; i <= _time; i++) {
+ if (i == _time)
+ curX = _toPos;
+ else
+ curX += dx;
+
+ if (curX < 0)
+ curX = maxX - curX;
+ else if (curX >= maxX)
+ curX %= maxX;
+
+ _renderManager->setBackgroundPosition(curX);
+
+ _renderManager->prepareBkg();
+ _renderManager->renderBackbufferToScreen();
+
+ _system->updateScreen();
+
+ _system->delayMillis(500 / _time);
+ }
+
+ _clock.start();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 0bee639..e2bde7b 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -170,6 +170,8 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL);
+ void rotateTo(int16 to, int16 time);
+
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();
Commit: 53002dd2d067c24baaecfbc32071365bef58cfca
https://github.com/scummvm/scummvm/commit/53002dd2d067c24baaecfbc32071365bef58cfca
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T12:21:38+06:00
Commit Message:
ZVISION: Implement action:animunload
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 2754a39..8a3d17f 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -440,6 +440,25 @@ bool ActionPreloadAnimation::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionUnloadAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+
+ sscanf(line.c_str(), "%u", &_key);
+}
+
+bool ActionUnloadAnimation::execute() {
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
+
+ if (nod && nod->getType() == SideFX::SIDEFX_ANIM)
+ _engine->getScriptManager()->deleteSideFx(_key);
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionPlayAnimation
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index 6a20019..731105d 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -347,6 +347,8 @@ class ActionUnloadAnimation : public ResultAction {
public:
ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
bool execute();
+private:
+ uint32 _key;
};
class ActionRandom : public ResultAction {
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index b16a2d9..a2b5311 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("animpreload", true)) {
actionList.push_back(new ActionPreloadAnimation(_engine, slot, args));
} else if (act.matchString("animunload", true)) {
- //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
+ actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
} else if (act.matchString("attenuate", true)) {
actionList.push_back(new ActionAttenuate(_engine, slot, args));
} else if (act.matchString("assign", true)) {
Commit: d0f6b61d7d86598c71c7ff8679f610bbd1341aaa
https://github.com/scummvm/scummvm/commit/d0f6b61d7d86598c71c7ff8679f610bbd1341aaa
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T12:26:04+06:00
Commit Message:
ZVISION: Implement action:delay_render
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 8a3d17f..3763eb6 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -160,6 +160,19 @@ bool ActionCrossfade::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionDelayRender
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%u", &_framesToDelay);
+}
+
+bool ActionDelayRender::execute() {
+ _engine->setRenderDelay(_framesToDelay);
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionDisableControl
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index 731105d..ade57ba 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -162,8 +162,7 @@ public:
bool execute();
private:
- // TODO: Check if this should actually be frames or if it should be milliseconds/seconds
- uint32 framesToDelay;
+ uint32 _framesToDelay;
};
class ActionDisableControl : public ResultAction {
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index a2b5311..68840aa 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -232,7 +232,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("debug", true)) {
// TODO: Implement ActionDebug
} else if (act.matchString("delay_render", true)) {
- // TODO: Implement ActionDelayRender
+ actionList.push_back(new ActionDelayRender(_engine, slot, args));
} else if (act.matchString("disable_control", true)) {
actionList.push_back(new ActionDisableControl(_engine, slot, args));
} else if (act.matchString("disable_venus", true)) {
Commit: 7ddfcfd17ec1e367896c223d5b8dc59b44d4029e
https://github.com/scummvm/scummvm/commit/7ddfcfd17ec1e367896c223d5b8dc59b44d4029e
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T12:44:00+06:00
Commit Message:
ZVISION: Implement action:disable_venus and action:set_venus
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 3763eb6..33add9f 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -189,6 +189,21 @@ bool ActionDisableControl::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionDisableVenus
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDisableVenus::ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%d", &_key);
+}
+
+bool ActionDisableVenus::execute() {
+ _engine->getScriptManager()->setStateValue(_key, 0);
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionDisplayMessage
//////////////////////////////////////////////////////////////////////////////
@@ -715,6 +730,23 @@ bool ActionSetScreen::execute() {
return true;
}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionSetVenus
+//////////////////////////////////////////////////////////////////////////////
+
+ActionSetVenus::ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%d", &_key);
+}
+
+bool ActionSetVenus::execute() {
+ if (_engine->getScriptManager()->getStateValue(_key))
+ _engine->getScriptManager()->setStateValue(StateKey_Venus, _key);
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionStop
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index ade57ba..b80af9a 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -180,6 +180,7 @@ public:
bool execute();
private:
+ int32 _key;
};
class ActionDisplayMessage : public ResultAction {
@@ -392,6 +393,15 @@ private:
Common::String _fileName;
};
+class ActionSetVenus : public ResultAction {
+public:
+ ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ int32 _key;
+};
+
class ActionStop : public ResultAction {
public:
ActionStop(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 68840aa..c7268e6 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -236,7 +236,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("disable_control", true)) {
actionList.push_back(new ActionDisableControl(_engine, slot, args));
} else if (act.matchString("disable_venus", true)) {
- // TODO: Implement ActionDisableVenus
+ actionList.push_back(new ActionDisableVenus(_engine, slot, args));
} else if (act.matchString("display_message", true)) {
actionList.push_back(new ActionDisplayMessage(_engine, slot, args));
} else if (act.matchString("dissolve", true)) {
@@ -278,7 +278,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("set_screen", true)) {
actionList.push_back(new ActionSetScreen(_engine, slot, args));
} else if (act.matchString("set_venus", true)) {
- // TODO: Implement ActionSetVenus
+ actionList.push_back(new ActionSetVenus(_engine, slot, args));
} else if (act.matchString("stop", true)) {
actionList.push_back(new ActionStop(_engine, slot, args));
} else if (act.matchString("streamvideo", true)) {
Commit: b8ef942f692d7354fed3fd889994c499db714ba7
https://github.com/scummvm/scummvm/commit/b8ef942f692d7354fed3fd889994c499db714ba7
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T12:58:11+06:00
Commit Message:
ZVISION: Implement action:dissolve
Changed paths:
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 4d5bcf7..8411f19 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -1053,4 +1053,9 @@ void RenderManager::markDirty() {
_bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
}
+void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) {
+ _curBkg.fillRect(Common::Rect(_curBkg.w, _curBkg.h), _curBkg.format.RGBToColor(r, g, b));
+ markDirty();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index e0fc5c2..ae24ce4 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -283,6 +283,8 @@ public:
Common::Rect bkgRectToScreen(const Common::Rect &src);
void markDirty();
+
+ void bkgFill(uint8 r, uint8 g, uint8 b);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 33add9f..96411e2 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -222,6 +222,20 @@ bool ActionDisplayMessage::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionDissolve
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDissolve::ActionDissolve(ZVision *engine) :
+ ResultAction(engine, 0) {
+}
+
+bool ActionDissolve::execute() {
+ // Cause black screen flick
+ // _engine->getRenderManager()->bkgFill(0, 0, 0);
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionDistort
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index c7268e6..daec4f8 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -240,7 +240,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("display_message", true)) {
actionList.push_back(new ActionDisplayMessage(_engine, slot, args));
} else if (act.matchString("dissolve", true)) {
- // TODO: Implement ActionDissolve
+ actionList.push_back(new ActionDissolve(_engine));
} else if (act.matchString("distort", true)) {
actionList.push_back(new ActionDistort(_engine, slot, args));
} else if (act.matchString("enable_control", true)) {
Commit: 66d2cb46989537d80855952cff2c0be1b5d6c320
https://github.com/scummvm/scummvm/commit/66d2cb46989537d80855952cff2c0be1b5d6c320
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T12:59:58+06:00
Commit Message:
ZVISION: Implement action:flush_mouse_events
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 96411e2..42b71ea 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -272,6 +272,20 @@ bool ActionEnableControl::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionFlushMouseEvents
+//////////////////////////////////////////////////////////////////////////////
+
+ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotkey) :
+ ResultAction(engine, slotkey) {
+}
+
+bool ActionFlushMouseEvents::execute() {
+ _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONUP);
+ _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONDOWN);
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionInventory
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index b80af9a..c032385 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -223,6 +223,12 @@ private:
uint32 _key;
};
+class ActionFlushMouseEvents : public ResultAction {
+public:
+ ActionFlushMouseEvents(ZVision *engine, int32 slotkey);
+ bool execute();
+};
+
class ActionInventory : public ResultAction {
public:
ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index daec4f8..a4d127f 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -246,7 +246,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("enable_control", true)) {
actionList.push_back(new ActionEnableControl(_engine, slot, args));
} else if (act.matchString("flush_mouse_events", true)) {
- // TODO: Implement ActionFlushMouseEvents
+ actionList.push_back(new ActionFlushMouseEvents(_engine, slot));
} else if (act.matchString("inventory", true)) {
actionList.push_back(new ActionInventory(_engine, slot, args));
} else if (act.matchString("kill", true)) {
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index d216573..28958dd 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -775,6 +775,17 @@ void ScriptManager::addEvent(Common::Event event) {
_controlEvents.push_back(event);
}
+void ScriptManager::flushEvent(Common::EventType type) {
+ EventList::iterator it = _controlEvents.begin();
+ while (it != _controlEvents.end()) {
+
+ if ((*it).type == type)
+ it = _controlEvents.erase(it);
+ else
+ it++;
+ }
+}
+
ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val):
_sc_man(sc_man) {
value = 0;
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 3fcbad5..fb17077 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -200,6 +200,7 @@ public:
void killSideFxType(SideFX::SideFXType type);
void addEvent(Common::Event);
+ void flushEvent(Common::EventType type);
/**
* Called when LeftMouse is pushed.
Commit: 44eeb4027250a2989a9e34a303383fa8533a7a84
https://github.com/scummvm/scummvm/commit/44eeb4027250a2989a9e34a303383fa8533a7a84
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T13:02:48+06:00
Commit Message:
ZVISION: Implement action:menu_bar_enable
Changed paths:
engines/zvision/core/menu.h
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h
index cc802ee..7e6acf3 100644
--- a/engines/zvision/core/menu.h
+++ b/engines/zvision/core/menu.h
@@ -48,6 +48,10 @@ public:
virtual void onMouseDown(const Common::Point &Pos) {};
virtual void onMouseUp(const Common::Point &Pos) {};
virtual void process(uint32 deltaTimeInMillis) {};
+
+ void setEnable(uint16 flags) {
+ menu_bar_flag = flags;
+ }
protected:
uint16 menu_bar_flag;
ZVision *_engine;
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 42b71ea..fbf887f 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -374,6 +374,19 @@ bool ActionKill::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionMenuBarEnable
+//////////////////////////////////////////////////////////////////////////////
+
+ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%hu", &_menus);
+}
+
+bool ActionMenuBarEnable::execute() {
+ _engine->menuBarEnable(_menus);
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionMusic
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index c032385..fed6209 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -248,6 +248,14 @@ private:
uint32 _type;
};
+class ActionMenuBarEnable : public ResultAction {
+public:
+ ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+private:
+ uint16 _menus;
+};
+
class ActionMusic : public ResultAction {
public:
ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index a4d127f..ca92890 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -252,7 +252,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("kill", true)) {
actionList.push_back(new ActionKill(_engine, slot, args));
} else if (act.matchString("menu_bar_enable", true)) {
- // TODO: Implement ActionMenuBarEnable
+ actionList.push_back(new ActionMenuBarEnable(_engine, slot, args));
} else if (act.matchString("music", true)) {
actionList.push_back(new ActionMusic(_engine, slot, args, false));
} else if (act.matchString("pan_track", true)) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 79f7d74..4f05eda 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -454,4 +454,9 @@ void ZVision::rotateTo(int16 _toPos, int16 _time) {
_clock.start();
}
+void ZVision::menuBarEnable(uint16 menus) {
+ if (_menu)
+ _menu->setEnable(menus);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index e2bde7b..def9bbb 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -185,6 +185,8 @@ public:
void loadSettings();
void saveSettings();
+ void menuBarEnable(uint16 menus);
+
private:
void initialize();
void initFonts();
Commit: 19e2251a7562defc560a25dd4655ededad4d5369
https://github.com/scummvm/scummvm/commit/19e2251a7562defc560a25dd4655ededad4d5369
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T13:04:27+06:00
Commit Message:
ZVISION: Implement action:preferences
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index fbf887f..1e1b3b2 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -474,6 +474,27 @@ bool ActionPanTrack::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionPreferences
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPreferences::ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ if (line.compareToIgnoreCase("save") == 0)
+ _save = true;
+ else
+ _save = false;
+}
+
+bool ActionPreferences::execute() {
+ if (_save)
+ _engine->saveSettings();
+ else
+ _engine->loadSettings();
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index fed6209..dd771c1 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -334,6 +334,15 @@ private:
int32 _framerate;
};
+class ActionPreferences : public ResultAction {
+public:
+ ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ bool _save;
+};
+
class ActionQuit : public ResultAction {
public:
ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {}
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index ca92890..06354fe 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -260,7 +260,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("playpreload", true)) {
actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args));
} else if (act.matchString("preferences", true)) {
- // TODO: Implement ActionPreferences
+ actionList.push_back(new ActionPreferences(_engine, slot, args));
} else if (act.matchString("quit", true)) {
actionList.push_back(new ActionQuit(_engine, slot));
} else if (act.matchString("random", true)) {
Commit: ea8cc34a66f7b8a853d396daaade9de25efb431f
https://github.com/scummvm/scummvm/commit/ea8cc34a66f7b8a853d396daaade9de25efb431f
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T13:06:48+06:00
Commit Message:
ZVISION: Implement action:restore_game
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 1e1b3b2..04f318b 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -42,6 +42,7 @@
#include "zvision/graphics/effects/fog.h"
#include "zvision/graphics/effects/light.h"
#include "zvision/graphics/effects/wave.h"
+#include "zvision/core/save_manager.h"
#include "common/file.h"
@@ -722,6 +723,22 @@ bool ActionRandom::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionRestoreGame
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char buf[128];
+ sscanf(line.c_str(), "%s", buf);
+ _fileName = Common::String(buf);
+}
+
+bool ActionRestoreGame::execute() {
+ _engine->getSaveManager()->loadGame(_fileName);
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionRotateTo
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index dd771c1..a6b5aa1 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -385,6 +385,15 @@ private:
ValueSlot *_max;
};
+class ActionRestoreGame : public ResultAction {
+public:
+ ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ Common::String _fileName;
+};
+
class ActionRotateTo : public ResultAction {
public:
ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 06354fe..d5f5704 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -268,7 +268,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("region", true)) {
actionList.push_back(new ActionRegion(_engine, slot, args));
} else if (act.matchString("restore_game", true)) {
- // TODO: Implement ActionRestoreGame
+ actionList.push_back(new ActionRestoreGame(_engine, slot, args));
} else if (act.matchString("rotate_to", true)) {
actionList.push_back(new ActionRotateTo(_engine, slot, args));
} else if (act.matchString("save_game", true)) {
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 28958dd..457b491 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -79,14 +79,18 @@ void ScriptManager::update(uint deltaTimeMillis) {
do_changeLocation();
updateNodes(deltaTimeMillis);
- execScope(nodeview);
- execScope(room);
- execScope(world);
- execScope(universe);
+ if (! execScope(nodeview))
+ return;
+ if (! execScope(room))
+ return;
+ if (! execScope(world))
+ return;
+ if (! execScope(universe))
+ return;
updateControls(deltaTimeMillis);
}
-void ScriptManager::execScope(script_scope &scope) {
+bool ScriptManager::execScope(script_scope &scope) {
// Swap queues
PuzzleList *tmp = scope.exec_queue;
scope.exec_queue = scope.scope_queue;
@@ -98,15 +102,18 @@ void ScriptManager::execScope(script_scope &scope) {
if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) {
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
- checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ return false;
} else {
for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter)
- checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ return false;
}
if (scope.proc_count < 2) {
scope.proc_count++;
}
+ return true;
}
void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
@@ -185,16 +192,16 @@ void ScriptManager::updateControls(uint deltaTimeMillis) {
break;
}
-void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
+bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
// Check if the puzzle is already finished
// Also check that the puzzle isn't disabled
if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) {
- return;
+ return true;
}
// Check each Criteria
if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0)
- return;
+ return true;
bool criteriaMet = false;
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) {
@@ -243,18 +250,13 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
// 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) {
- shouldContinue = shouldContinue && (*resultIter)->execute();
- if (!shouldContinue) {
- break;
- }
- }
-
- if (!shouldContinue) {
- return;
+ if (!(*resultIter)->execute())
+ return false;
}
}
+
+ return true;
}
void ScriptManager::cleanStateTable() {
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index fb17077..ddb8c88 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -253,10 +253,10 @@ private:
void addPuzzlesToReferenceTable(script_scope &scope);
void updateNodes(uint deltaTimeMillis);
void updateControls(uint deltaTimeMillis);
- void checkPuzzleCriteria(Puzzle *puzzle, uint counter);
+ bool checkPuzzleCriteria(Puzzle *puzzle, uint counter);
void cleanStateTable();
void cleanScriptScope(script_scope &scope);
- void execScope(script_scope &scope);
+ bool execScope(script_scope &scope);
/** Perform change location */
void do_changeLocation();
Commit: be5860b93af1d17d31e9430fc096ef02683324ee
https://github.com/scummvm/scummvm/commit/be5860b93af1d17d31e9430fc096ef02683324ee
Author: Marisa-Chan (llancelot7 at gmail.com)
Date: 2014-11-08T13:08:40+06:00
Commit Message:
ZVISION: Change comments of not implemented actions
Changed paths:
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index d5f5704..de09218 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -230,7 +230,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("crossfade", true)) {
actionList.push_back(new ActionCrossfade(_engine, slot, args));
} else if (act.matchString("debug", true)) {
- // TODO: Implement ActionDebug
+ // Not used. Purposely left empty
} else if (act.matchString("delay_render", true)) {
actionList.push_back(new ActionDelayRender(_engine, slot, args));
} else if (act.matchString("disable_control", true)) {
@@ -272,7 +272,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("rotate_to", true)) {
actionList.push_back(new ActionRotateTo(_engine, slot, args));
} else if (act.matchString("save_game", true)) {
- // TODO: Implement ActionSaveGame
+ // Not used. Purposely left empty
} else if (act.matchString("set_partial_screen", true)) {
actionList.push_back(new ActionSetPartialScreen(_engine, slot, args));
} else if (act.matchString("set_screen", true)) {
Commit: d0f2e20b62392dc040a61036237cef37e13e6d19
https://github.com/scummvm/scummvm/commit/d0f2e20b62392dc040a61036237cef37e13e6d19
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:25:39+06:00
Commit Message:
ZVISION: Fix rlf backward seek and rename class field
Changed paths:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation/rlf_animation.h
diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp
index 2bb0271..5972bdb 100644
--- a/engines/zvision/animation/rlf_animation.cpp
+++ b/engines/zvision/animation/rlf_animation.cpp
@@ -44,7 +44,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_height(0),
_frameTime(0),
_frames(0),
- _currentFrame(0),
+ _nextFrame(0),
_frameBufferByteSize(0) {
Common::File *_file = new Common::File;
@@ -82,7 +82,7 @@ RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream)
_height(0),
_frameTime(0),
_frames(0),
- _currentFrame(0),
+ _nextFrame(0),
_frameBufferByteSize(0) {
if (!readHeader()) {
@@ -193,23 +193,32 @@ void RlfAnimation::seekToFrame(int frameNumber) {
assert(!_stream);
assert(frameNumber < (int)_frameCount || frameNumber >= -1);
- if (_currentFrame == frameNumber)
+ if (_nextFrame == frameNumber)
return;
if (frameNumber < 0) {
- _currentFrame = 0;
+ _nextFrame = 0;
return;
}
- int closestFrame = _currentFrame;
- int distance = (int)frameNumber - _currentFrame;
- for (uint i = 0; i < _completeFrames.size(); ++i) {
- int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
- if (newDistance < 0)
- break;
- if (newDistance > 0 && newDistance < distance) {
+ int closestFrame = _nextFrame;
+ int distance = (int)frameNumber - _nextFrame;
+
+ if (distance < 0) {
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
+ if ((int)_completeFrames[i] > frameNumber)
+ break;
closestFrame = _completeFrames[i];
- distance = newDistance;
+ }
+ } else {
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
+ int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
+ if (newDistance < 0)
+ break;
+ if (newDistance < distance) {
+ closestFrame = _completeFrames[i];
+ distance = newDistance;
+ }
}
}
@@ -217,7 +226,7 @@ void RlfAnimation::seekToFrame(int frameNumber) {
applyFrameToCurrent(i);
}
- _currentFrame = frameNumber;
+ _nextFrame = frameNumber;
}
const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
@@ -226,9 +235,9 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
// Since this method is so expensive, first check to see if we can use
// decodeNextFrame() it's cheap.
- if ((int)frameNumber == _currentFrame - 1) {
+ if ((int)frameNumber == _nextFrame - 1) {
return &_currentFrameBuffer;
- } else if (_currentFrame == (int)frameNumber) {
+ } else if (_nextFrame == (int)frameNumber) {
return decodeNextFrame();
}
@@ -237,15 +246,15 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
}
const Graphics::Surface *RlfAnimation::decodeNextFrame() {
- assert(_currentFrame < (int)_frameCount);
+ assert(_nextFrame < (int)_frameCount);
if (_stream) {
applyFrameToCurrent(readNextFrame());
} else {
- applyFrameToCurrent(_currentFrame);
+ applyFrameToCurrent(_nextFrame);
}
- _currentFrame++;
+ _nextFrame++;
return &_currentFrameBuffer;
}
diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h
index dfb2a60..00c2e9b 100644
--- a/engines/zvision/animation/rlf_animation.h
+++ b/engines/zvision/animation/rlf_animation.h
@@ -64,7 +64,7 @@ private:
Frame *_frames;
Common::Array<uint> _completeFrames;
- int _currentFrame;
+ int _nextFrame;
Graphics::Surface _currentFrameBuffer;
uint32 _frameBufferByteSize;
@@ -113,7 +113,7 @@ public:
* @return Is the currentFrame is the last frame in the animation?
*/
bool endOfAnimation() {
- return _currentFrame == (int)_frameCount;
+ return _nextFrame == (int)_frameCount;
}
private:
Commit: 51a9ec80df468757902cd85a5ab2a32856148d29
https://github.com/scummvm/scummvm/commit/51a9ec80df468757902cd85a5ab2a32856148d29
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:30:13+06:00
Commit Message:
ZVISION: Implement ZeroPoint for panorama renderer
Changed paths:
engines/zvision/graphics/render_table.cpp
engines/zvision/graphics/render_table.h
engines/zvision/scripting/control.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index aeba729..bb095f0 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -52,6 +52,7 @@ void RenderTable::setRenderState(RenderState newState) {
_panoramaOptions.fieldOfView = 27.0f;
_panoramaOptions.linearScale = 0.55f;
_panoramaOptions.reverse = false;
+ _panoramaOptions.zeroPoint = 0;
break;
case TILT:
_tiltOptions.fieldOfView = 27.0f;
@@ -244,6 +245,14 @@ void RenderTable::setPanoramaReverse(bool reverse) {
_panoramaOptions.reverse = reverse;
}
+void RenderTable::setPanoramaZeroPoint(uint16 point) {
+ _panoramaOptions.zeroPoint = point;
+}
+
+uint16 RenderTable::getPanoramaZeroPoint() {
+ return _panoramaOptions.zeroPoint;
+}
+
void RenderTable::setTiltFoV(float fov) {
assert(fov > 0.0f);
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index 7153738..2e3fd8e 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -50,6 +50,7 @@ private:
float fieldOfView;
float linearScale;
bool reverse;
+ uint16 zeroPoint;
} _panoramaOptions;
// TODO: See if tilt and panorama need to have separate options
@@ -75,6 +76,8 @@ public:
void setPanoramaFoV(float fov);
void setPanoramaScale(float scale);
void setPanoramaReverse(bool reverse);
+ void setPanoramaZeroPoint(uint16 point);
+ uint16 getPanoramaZeroPoint();
void setTiltFoV(float fov);
void setTiltScale(float scale);
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index ae717d6..4567495 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -61,7 +61,9 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
renderTable->setPanoramaReverse(true);
}
} else if (line.matchString("zeropoint*", true)) {
- // TODO: Implement
+ uint point;
+ sscanf(line.c_str(), "zeropoint(%u)", &point);
+ renderTable->setPanoramaZeroPoint(point);
}
line = stream.readLine();
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 4f05eda..606e712 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -370,7 +370,7 @@ void ZVision::updateRotation() {
int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
- int16 zero_point = 0;
+ int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint();
if (st_pos >= zero_point && new_pos < zero_point)
_scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1);
if (st_pos <= zero_point && new_pos > zero_point)
Commit: 54917582eb60c28c093cf84d78f5641a8ea02ea8
https://github.com/scummvm/scummvm/commit/54917582eb60c28c093cf84d78f5641a8ea02ea8
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:31:48+06:00
Commit Message:
ZVISION: Implement missing action - cursor
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/scr_file_handling.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 04f318b..f27427c 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -43,6 +43,7 @@
#include "zvision/graphics/effects/light.h"
#include "zvision/graphics/effects/wave.h"
#include "zvision/core/save_manager.h"
+#include "zvision/cursors/cursor_manager.h"
#include "common/file.h"
@@ -162,6 +163,38 @@ bool ActionCrossfade::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionCursor
+//////////////////////////////////////////////////////////////////////////////
+
+ActionCursor::ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ Common::String up = line;
+ up.toUppercase();
+ _action = 0;
+
+ if (up[0] == 'B')
+ _action = 2;
+ else if (up[0] == 'I')
+ _action = 3;
+ else if (up[0] == 'U')
+ _action = 0;
+ else if (up[0] == 'H')
+ _action = 1;
+}
+
+bool ActionCursor::execute() {
+ switch (_action) {
+ case 1:
+ _engine->getCursorManager()->showMouse(false);
+ break;
+ default:
+ _engine->getCursorManager()->showMouse(true);
+ break;
+ }
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionDelayRender
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index a6b5aa1..5401af0 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -148,6 +148,15 @@ private:
int32 _timeInMillis;
};
+class ActionCursor : public ResultAction {
+public:
+ ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ uint8 _action;
+};
+
class ActionDebug : public ResultAction {
public:
ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index de09218..5e0387f 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -229,6 +229,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
actionList.push_back(new ActionChangeLocation(_engine, slot, args));
} else if (act.matchString("crossfade", true)) {
actionList.push_back(new ActionCrossfade(_engine, slot, args));
+ } else if (act.matchString("cursor", true)) {
+ actionList.push_back(new ActionCursor(_engine, slot, args));
} else if (act.matchString("debug", true)) {
// Not used. Purposely left empty
} else if (act.matchString("delay_render", true)) {
Commit: 6f6d5fc24eb66b893f9871e773b9bd2632ab5ca5
https://github.com/scummvm/scummvm/commit/6f6d5fc24eb66b893f9871e773b9bd2632ab5ca5
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:34:01+06:00
Commit Message:
ZVISION: Hide mouse cursor while streamvideo is working
Changed paths:
engines/zvision/scripting/actions.cpp
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index f27427c..eb6b093 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -899,6 +899,8 @@ bool ActionStreamVideo::execute() {
return true;
}
+ _engine->getCursorManager()->showMouse(false);
+
Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
Common::String subname = _fileName;
@@ -913,6 +915,8 @@ bool ActionStreamVideo::execute() {
_engine->playVideo(decoder, destRect, _skippable, sub);
+ _engine->getCursorManager()->showMouse(true);
+
if (sub)
delete sub;
}
Commit: 7d92b44e09809f559db96ec029a6258d23d84fd0
https://github.com/scummvm/scummvm/commit/7d92b44e09809f559db96ec029a6258d23d84fd0
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:36:30+06:00
Commit Message:
ZVISION: Nemesis and GI has difference in set_partial_screen color mask
Changed paths:
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/scripting/actions.cpp
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 8411f19..3e14693 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -149,6 +149,16 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1
surface.free();
}
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
+
+ uint16 keycolor = *(uint16 *)surface.getBasePtr(keyX, keyY);
+
+ blitSurfaceToBkg(surface, destX, destY, keycolor);
+ surface.free();
+}
+
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
Common::File file;
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index ae24ce4..d34ecf8 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -185,6 +185,8 @@ public:
*/
void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
+ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY);
+
/**
* 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)
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index eb6b093..31f68d7 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -815,10 +815,20 @@ ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, c
bool ActionSetPartialScreen::execute() {
RenderManager *renderManager = _engine->getRenderManager();
- if (_backgroundColor >= 0)
- renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
- else
- renderManager->renderImageToBackground(_fileName, _x, _y);
+
+ if (_engine->getGameId() == GID_NEMESIS) {
+ if (_backgroundColor)
+ renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0);
+ else
+ renderManager->renderImageToBackground(_fileName, _x, _y);
+ } else {
+ if (_backgroundColor >= 0)
+ renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
+ else if (_backgroundColor == -2)
+ renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0);
+ else
+ renderManager->renderImageToBackground(_fileName, _x, _y);
+ }
return true;
}
Commit: 42bc6c5daf132b3656f04759aa1fa615fe7b26f6
https://github.com/scummvm/scummvm/commit/42bc6c5daf132b3656f04759aa1fa615fe7b26f6
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:37:57+06:00
Commit Message:
ZVISION: Fix incorrect usage of Common::String::format
Changed paths:
engines/zvision/core/save_manager.cpp
diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp
index 6e8b6b5..2797b94 100644
--- a/engines/zvision/core/save_manager.cpp
+++ b/engines/zvision/core/save_manager.cpp
@@ -219,9 +219,9 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
// Try to load standart save file
Common::String filename;
if (_engine->getGameId() == GID_GRANDINQUISITOR)
- filename.format("inqsav%u.sav", slot);
+ filename = Common::String::format("inqsav%u.sav", slot);
else if (_engine->getGameId() == GID_NEMESIS)
- filename.format("nemsav%u.sav", slot);
+ filename = Common::String::format("nemsav%u.sav", slot);
saveFile = _engine->getSearchManager()->openFile(filename);
if (saveFile == NULL) {
Commit: f55f4af2937f77c3dc9760b000d2e4806477c1a0
https://github.com/scummvm/scummvm/commit/f55f4af2937f77c3dc9760b000d2e4806477c1a0
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:38:29+06:00
Commit Message:
ZVISION: Fix code style in save_manager.h
Changed paths:
engines/zvision/core/save_manager.h
diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h
index c7c1297..5cd61c7 100644
--- a/engines/zvision/core/save_manager.h
+++ b/engines/zvision/core/save_manager.h
@@ -49,7 +49,9 @@ struct SaveGameHeader {
class SaveManager {
public:
SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {}
- ~SaveManager() { flushSaveBuffer(); }
+ ~SaveManager() {
+ flushSaveBuffer();
+ }
private:
ZVision *_engine;
Commit: 9b88ab15dfff651007f9c6bcad1f5e646a4fa662
https://github.com/scummvm/scummvm/commit/9b88ab15dfff651007f9c6bcad1f5e646a4fa662
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:40:29+06:00
Commit Message:
ZVISION: Make strings const in functions declaration
Changed paths:
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/scripting/control.cpp
engines/zvision/scripting/control.h
diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp
index cfb4baf..564ffd2 100644
--- a/engines/zvision/cursors/cursor_manager.cpp
+++ b/engines/zvision/cursors/cursor_manager.cpp
@@ -140,7 +140,7 @@ void CursorManager::changeCursor(int id) {
}
}
-int CursorManager::getCursorId(Common::String &name) {
+int CursorManager::getCursorId(const Common::String &name) {
for (int i = 0; i < NUM_CURSORS; i++)
if (name.equals(_cursorNames[i]))
return i;
diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h
index 5392fd5..a6f77ce 100644
--- a/engines/zvision/cursors/cursor_manager.h
+++ b/engines/zvision/cursors/cursor_manager.h
@@ -97,7 +97,7 @@ public:
* @return Id of cursor or idle cursor id if not found
*/
- int getCursorId(Common::String &name);
+ int getCursorId(const Common::String &name);
/**
* Load cursor for item by id, and try to change cursor to item cursor if it's not 0
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index 4567495..c746f00 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -105,7 +105,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
-void Control::getParams(Common::String &input_str, Common::String ¶meter, Common::String &values) {
+void Control::getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
const char *chrs = input_str.c_str();
uint lbr;
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 8708f03..28c7348 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -127,7 +127,7 @@ protected:
uint32 _key;
int32 _venus_id;
- void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values);
+ void getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
// Static member functions
public:
static void parseFlatControl(ZVision *engine);
Commit: 9e9b89071f9a07e2784bf52ef976d6560bf56e67
https://github.com/scummvm/scummvm/commit/9e9b89071f9a07e2784bf52ef976d6560bf56e67
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:43:04+06:00
Commit Message:
ZVISION: Implement function for convertion of scummvm KeyCode to win vkKey
Changed paths:
A engines/zvision/utility/win_keys.cpp
A engines/zvision/utility/win_keys.h
engines/zvision/module.mk
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 1730bbc..199f96b 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -50,6 +50,7 @@ MODULE_OBJS := \
utility/lzss_read_stream.o \
utility/single_value_container.o \
utility/utility.o \
+ utility/win_keys.o \
video/video.o \
video/zork_avi_decoder.o \
zvision.o
diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp
new file mode 100644
index 0000000..3441fb8
--- /dev/null
+++ b/engines/zvision/utility/win_keys.cpp
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/keyboard.h"
+
+namespace ZVision {
+
+uint8 VKkey(Common::KeyCode scumm_key) {
+ if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z)
+ return 0x41 + scumm_key - Common::KEYCODE_a;
+ if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9)
+ return 0x30 + scumm_key - Common::KEYCODE_0;
+ if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15)
+ return 0x70 + scumm_key - Common::KEYCODE_F1;
+ if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9)
+ return 0x60 + scumm_key - Common::KEYCODE_KP0;
+
+ switch (scumm_key) {
+ case Common::KEYCODE_BACKSPACE:
+ return 0x8;
+ case Common::KEYCODE_TAB:
+ return 0x9;
+ case Common::KEYCODE_CLEAR:
+ return 0xC;
+ case Common::KEYCODE_RETURN:
+ return 0xD;
+ case Common::KEYCODE_CAPSLOCK:
+ return 0x14;
+ case Common::KEYCODE_ESCAPE:
+ return 0x1B;
+ case Common::KEYCODE_SPACE:
+ return 0x20;
+ case Common::KEYCODE_PAGEUP:
+ return 0x21;
+ case Common::KEYCODE_PAGEDOWN:
+ return 0x22;
+ case Common::KEYCODE_END:
+ return 0x23;
+ case Common::KEYCODE_HOME:
+ return 0x24;
+ case Common::KEYCODE_LEFT:
+ return 0x25;
+ case Common::KEYCODE_UP:
+ return 0x26;
+ case Common::KEYCODE_RIGHT:
+ return 0x27;
+ case Common::KEYCODE_DOWN:
+ return 0x28;
+ case Common::KEYCODE_PRINT:
+ return 0x2A;
+ case Common::KEYCODE_INSERT:
+ return 0x2D;
+ case Common::KEYCODE_DELETE:
+ return 0x2E;
+ case Common::KEYCODE_HELP:
+ return 0x2F;
+ case Common::KEYCODE_KP_MULTIPLY:
+ return 0x6A;
+ case Common::KEYCODE_KP_PLUS:
+ return 0x6B;
+ case Common::KEYCODE_KP_MINUS:
+ return 0x6D;
+ case Common::KEYCODE_KP_PERIOD:
+ return 0x6E;
+ case Common::KEYCODE_KP_DIVIDE:
+ return 0x6F;
+ case Common::KEYCODE_NUMLOCK:
+ return 0x90;
+ case Common::KEYCODE_SCROLLOCK:
+ return 0x91;
+ case Common::KEYCODE_LSHIFT:
+ return 0xA0;
+ case Common::KEYCODE_RSHIFT:
+ return 0xA1;
+ case Common::KEYCODE_LCTRL:
+ return 0xA2;
+ case Common::KEYCODE_RCTRL:
+ return 0xA3;
+ case Common::KEYCODE_MENU:
+ return 0xA5;
+ case Common::KEYCODE_LEFTBRACKET:
+ return 0xDB;
+ case Common::KEYCODE_RIGHTBRACKET:
+ return 0xDD;
+ case Common::KEYCODE_SEMICOLON:
+ return 0xBA;
+ case Common::KEYCODE_BACKSLASH:
+ return 0xDC;
+ case Common::KEYCODE_QUOTE:
+ return 0xDE;
+ case Common::KEYCODE_SLASH:
+ return 0xBF;
+ case Common::KEYCODE_TILDE:
+ return 0xC0;
+ case Common::KEYCODE_COMMA:
+ return 0xBC;
+ case Common::KEYCODE_PERIOD:
+ return 0xBE;
+ case Common::KEYCODE_MINUS:
+ return 0xBD;
+ case Common::KEYCODE_PLUS:
+ return 0xBB;
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+}
diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h
new file mode 100644
index 0000000..a79a03a
--- /dev/null
+++ b/engines/zvision/utility/win_keys.h
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_WINKEY_H
+#define ZVISION_WINKEY_H
+
+#include "common/keyboard.h"
+
+namespace ZVision {
+uint8 VKkey(Common::KeyCode scumm_key);
+} // End of namespace ZVision
+
+#endif
Commit: c79ac80b0c73b86fa665dd439fa30cb3ca709785
https://github.com/scummvm/scummvm/commit/c79ac80b0c73b86fa665dd439fa30cb3ca709785
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:47:12+06:00
Commit Message:
ZVISION: Implement quit function with reminder
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 606e712..b697405 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -459,4 +459,11 @@ void ZVision::menuBarEnable(uint16 menus) {
_menu->setEnable(menus);
}
+bool ZVision::ifQuit() {
+ if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) {
+ quitGame();
+ return true;
+ }
+ return false;
+}
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index def9bbb..e1a94db 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -187,6 +187,8 @@ public:
void menuBarEnable(uint16 menus);
+ bool ifQuit();
+
private:
void initialize();
void initFonts();
Commit: fcbb3d0307d8423399a41cef8f8cbaec062018db
https://github.com/scummvm/scummvm/commit/fcbb3d0307d8423399a41cef8f8cbaec062018db
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T14:48:32+06:00
Commit Message:
ZVISION: Use ifQuit for menu bars
Changed paths:
engines/zvision/core/menu.cpp
diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp
index bf311c4..57a1983 100644
--- a/engines/zvision/core/menu.cpp
+++ b/engines/zvision/core/menu.cpp
@@ -174,7 +174,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
scrollPos[menu_MAIN],
320 + 135 + 135,
scrollPos[menu_MAIN] + 32).contains(Pos)) {
- // ifquit();
+ _engine->ifQuit();
}
// Settings
@@ -591,7 +591,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) {
scrollPos,
buts[3][0] + buts[3][1],
scrollPos + 32).contains(Pos)) {
- // ifquit();
+ _engine->ifQuit();
frm = 5;
redraw = true;
}
Commit: f658a5c8e6a92341efc7ec15ec0f875b1cc7eb93
https://github.com/scummvm/scummvm/commit/f658a5c8e6a92341efc7ec15ec0f875b1cc7eb93
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:34:55+06:00
Commit Message:
ZVISION: Implement methods for get state of menu items
Changed paths:
engines/zvision/core/menu.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h
index 7e6acf3..c2ea822 100644
--- a/engines/zvision/core/menu.h
+++ b/engines/zvision/core/menu.h
@@ -52,6 +52,9 @@ public:
void setEnable(uint16 flags) {
menu_bar_flag = flags;
}
+ uint16 getEnable() {
+ return menu_bar_flag;
+ }
protected:
uint16 menu_bar_flag;
ZVision *_engine;
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b697405..c5d5fdc 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -459,6 +459,12 @@ void ZVision::menuBarEnable(uint16 menus) {
_menu->setEnable(menus);
}
+uint16 ZVision::getMenuBarEnable() {
+ if (_menu)
+ return _menu->getEnable();
+ return 0;
+}
+
bool ZVision::ifQuit() {
if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) {
quitGame();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index e1a94db..8b9b673 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -186,6 +186,7 @@ public:
void saveSettings();
void menuBarEnable(uint16 menus);
+ uint16 getMenuBarEnable();
bool ifQuit();
Commit: db5e2adc5828a4bf888959ebd520bb43e89996fe
https://github.com/scummvm/scummvm/commit/db5e2adc5828a4bf888959ebd520bb43e89996fe
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:40:54+06:00
Commit Message:
ZVISION: Implement method for visual output of some info
Changed paths:
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index c5d5fdc..0b03cc3 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -472,4 +472,10 @@ bool ZVision::ifQuit() {
}
return false;
}
+void ZVision::showDebugMsg(const Common::String &msg, int16 delay) {
+ uint16 msgid = _renderManager->createSubArea();
+ _renderManager->updateSubArea(msgid, msg);
+ _renderManager->deleteSubArea(msgid, delay);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 8b9b673..3c9e26b 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -190,6 +190,8 @@ public:
bool ifQuit();
+ void showDebugMsg(const Common::String &msg, int16 delay = 3000);
+
private:
void initialize();
void initFonts();
Commit: 8e112edb1a7d8d1d579a235bda18b58ffcc18b8c
https://github.com/scummvm/scummvm/commit/8e112edb1a7d8d1d579a235bda18b58ffcc18b8c
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:47:27+06:00
Commit Message:
ZVISION: Implement Easter eggs and debug cheats
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index c977125..97565dd 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -30,6 +30,8 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/animation/rlf_animation.h"
#include "zvision/core/menu.h"
+#include "zvision/utility/win_keys.h"
+#include "zvision/sound/zork_raw.h"
#include "common/events.h"
#include "common/system.h"
@@ -40,6 +42,86 @@
namespace ZVision {
+void ZVision::cheatCodes(uint8 key) {
+ pushKeyToCheatBuf(key);
+
+ if (getGameId() == GID_GRANDINQUISITOR) {
+
+ if (checkCode("IMNOTDEAF")) {
+ // Unknow cheat
+ showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented"));
+ }
+
+ if (checkCode("3100OPB")) {
+ showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("KILLMENOW")) {
+ _scriptManager->changeLocation('g', 'j', 'd', 'e', 0);
+ _scriptManager->setStateValue(2201, 35);
+ }
+
+ if (checkCode("MIKESPANTS")) {
+ _scriptManager->changeLocation('g', 'j', 't', 'm', 0);
+ }
+ } else if (getGameId() == GID_NEMESIS) {
+
+ if (checkCode("CHLOE")) {
+ _scriptManager->changeLocation('t', 'm', '2', 'g', 0);
+ _scriptManager->setStateValue(224, 1);
+ }
+
+ if (checkCode("77MASSAVE")) {
+ showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("IDKFA")) {
+ _scriptManager->changeLocation('t', 'w', '3', 'f', 0);
+ _scriptManager->setStateValue(249, 1);
+ }
+
+ if (checkCode("309NEWDORMA")) {
+ _scriptManager->changeLocation('g', 'j', 'g', 'j', 0);
+ }
+
+ if (checkCode("HELLOSAILOR")) {
+ Location loc = _scriptManager->getCurrentLocation();
+ Audio::AudioStream *soundStream;
+ if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') {
+ soundStream = makeRawZorkStream("v000hpta.raw", this);
+ } else {
+ soundStream = makeRawZorkStream("v000hnta.raw", this);
+ }
+ Audio::SoundHandle handle;
+ _mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream);
+ }
+ }
+
+ if (checkCode("FRAME"))
+ showDebugMsg(Common::String::format("FPS: ???, not implemented"));
+
+ if (checkCode("XYZZY"))
+ _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats));
+
+ if (checkCode("COMPUTERARCH"))
+ showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented"));
+
+ if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1)
+ if (checkCode("GO????"))
+ _scriptManager->changeLocation(getBufferedKey(3),
+ getBufferedKey(2),
+ getBufferedKey(1),
+ getBufferedKey(0), 0);
+}
+
void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
@@ -72,7 +154,7 @@ void ZVision::processEvents() {
onMouseMove(_event.mouse);
break;
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYDOWN: {
switch (_event.kbd.keycode) {
case Common::KEYCODE_d:
if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
@@ -89,8 +171,14 @@ void ZVision::processEvents() {
break;
}
+ uint8 vkKey = VKkey(_event.kbd.keycode);
+
+ _scriptManager->setStateValue(StateKey_KeyPress, vkKey);
+
_scriptManager->addEvent(_event);
- break;
+ cheatCodes(vkKey);
+ }
+ break;
case Common::EVENT_KEYUP:
_scriptManager->addEvent(_event);
break;
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0b03cc3..3518e01 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -100,6 +100,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_velocity(0) {
debug(1, "ZVision::ZVision");
+
+ memset(_cheatBuff, 0, sizeof(_cheatBuff));
}
ZVision::~ZVision() {
@@ -472,6 +474,34 @@ bool ZVision::ifQuit() {
}
return false;
}
+
+void ZVision::pushKeyToCheatBuf(uint8 key) {
+ for (int i = 0; i < KEYBUF_SIZE - 1; i++)
+ _cheatBuff[i] = _cheatBuff[i + 1];
+
+ _cheatBuff[KEYBUF_SIZE - 1] = key;
+}
+
+bool ZVision::checkCode(const char *code) {
+ int codeLen = strlen(code);
+
+ if (codeLen > KEYBUF_SIZE)
+ return false;
+
+ for (int i = 0; i < codeLen; i++)
+ if (code[i] != _cheatBuff[KEYBUF_SIZE - codeLen + i] && code[i] != '?')
+ return false;
+
+ return true;
+}
+
+uint8 ZVision::getBufferedKey(uint8 pos) {
+ if (pos >= KEYBUF_SIZE)
+ return 0;
+ else
+ return _cheatBuff[KEYBUF_SIZE - pos - 1];
+}
+
void ZVision::showDebugMsg(const Common::String &msg, int16 delay) {
uint16 msgid = _renderManager->createSubArea();
_renderManager->updateSubArea(msgid, msg);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 3c9e26b..041a857 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -85,7 +85,9 @@ private:
WORKING_WINDOW_HEIGHT = 344,
ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 400 // Pixels per second
+ MAX_ROTATION_SPEED = 400, // Pixels per second
+
+ KEYBUF_SIZE = 20
};
Console *_console;
@@ -122,6 +124,8 @@ private:
int _rendDelay;
int16 _velocity;
bool _halveDelay;
+
+ uint8 _cheatBuff[KEYBUF_SIZE];
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
@@ -205,6 +209,11 @@ private:
void updateRotation();
void registerDefaultSettings();
+
+ void cheatCodes(uint8 key);
+ void pushKeyToCheatBuf(uint8 key);
+ bool checkCode(const char *code);
+ uint8 getBufferedKey(uint8 pos);
};
} // End of namespace ZVision
Commit: c4911135c152b9f7eb082dee1af79d82932e72c0
https://github.com/scummvm/scummvm/commit/c4911135c152b9f7eb082dee1af79d82932e72c0
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:50:18+06:00
Commit Message:
ZVISION: Implement keyboard hotkeys
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 97565dd..72e3fa6 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -31,6 +31,7 @@
#include "zvision/animation/rlf_animation.h"
#include "zvision/core/menu.h"
#include "zvision/utility/win_keys.h"
+#include "zvision/core/menu.h"
#include "zvision/sound/zork_raw.h"
#include "common/events.h"
@@ -42,6 +43,31 @@
namespace ZVision {
+void ZVision::shortKeys(Common::Event event) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_s:
+ if (getMenuBarEnable() & menuBar_Save)
+ _scriptManager->changeLocation('g', 'j', 's', 'e', 0);
+ break;
+ case Common::KEYCODE_r:
+ if (getMenuBarEnable() & menuBar_Restore)
+ _scriptManager->changeLocation('g', 'j', 'r', 'e', 0);
+ break;
+ case Common::KEYCODE_p:
+ if (getMenuBarEnable() & menuBar_Settings)
+ _scriptManager->changeLocation('g', 'j', 'p', 'e', 0);
+ break;
+ case Common::KEYCODE_q:
+ if (getMenuBarEnable() & menuBar_Exit)
+ ifQuit();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
void ZVision::cheatCodes(uint8 key) {
pushKeyToCheatBuf(key);
@@ -176,6 +202,7 @@ void ZVision::processEvents() {
_scriptManager->setStateValue(StateKey_KeyPress, vkKey);
_scriptManager->addEvent(_event);
+ shortKeys(_event);
cheatCodes(vkKey);
}
break;
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 041a857..8564e4e 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -209,6 +209,7 @@ private:
void updateRotation();
void registerDefaultSettings();
+ void shortKeys(Common::Event);
void cheatCodes(uint8 key);
void pushKeyToCheatBuf(uint8 key);
Commit: e57c358cead20cbf75332a15c4961ff6c15abf6a
https://github.com/scummvm/scummvm/commit/e57c358cead20cbf75332a15c4961ff6c15abf6a
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:52:20+06:00
Commit Message:
ZVISION: Implement method for getting panorama reverse flag
Changed paths:
engines/zvision/graphics/render_table.cpp
engines/zvision/graphics/render_table.h
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index bb095f0..629cbde 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -245,6 +245,10 @@ void RenderTable::setPanoramaReverse(bool reverse) {
_panoramaOptions.reverse = reverse;
}
+bool RenderTable::getPanoramaReverse() {
+ return _panoramaOptions.reverse;
+}
+
void RenderTable::setPanoramaZeroPoint(uint16 point) {
_panoramaOptions.zeroPoint = point;
}
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index 2e3fd8e..f061b3b 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -78,6 +78,7 @@ public:
void setPanoramaReverse(bool reverse);
void setPanoramaZeroPoint(uint16 point);
uint16 getPanoramaZeroPoint();
+ bool getPanoramaReverse();
void setTiltFoV(float fov);
void setTiltScale(float scale);
Commit: 1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb
https://github.com/scummvm/scummvm/commit/1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:55:10+06:00
Commit Message:
ZVISION: Implement code for pan from keyboard and mouse
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 72e3fa6..38ceb5c 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -189,10 +189,26 @@ void ZVision::processEvents() {
_console->onFrame();
}
break;
+
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ?
+ -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
+ _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
case Common::KEYCODE_q:
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
+
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
+ _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ?
+ -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
+ _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
+ break;
+
default:
break;
}
@@ -208,6 +224,20 @@ void ZVision::processEvents() {
break;
case Common::EVENT_KEYUP:
_scriptManager->addEvent(_event);
+ switch (_event.kbd.keycode) {
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ _kbdVelocity = 0;
+ break;
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
+ _kbdVelocity = 0;
+ break;
+ default:
+ break;
+ }
break;
default:
break;
@@ -261,7 +291,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
if (mspeed <= 0)
mspeed = 400 >> 4;
- _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+ _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
_cursorManager->changeCursor(CursorIndex_Left);
cursorWasChanged = true;
@@ -270,12 +300,12 @@ void ZVision::onMouseMove(const Common::Point &pos) {
int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
if (mspeed <= 0)
mspeed = 400 >> 4;
- _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+ _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
_cursorManager->changeCursor(CursorIndex_Right);
cursorWasChanged = true;
} else {
- _velocity = 0;
+ _mouseVelocity = 0;
}
} else if (renderState == RenderTable::TILT) {
if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) {
@@ -283,7 +313,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
if (mspeed <= 0)
mspeed = 400 >> 4;
- _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+ _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
_cursorManager->changeCursor(CursorIndex_UpArr);
cursorWasChanged = true;
@@ -292,18 +322,18 @@ void ZVision::onMouseMove(const Common::Point &pos) {
int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
if (mspeed <= 0)
mspeed = 400 >> 4;
- _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+ _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
_cursorManager->changeCursor(CursorIndex_DownArr);
cursorWasChanged = true;
} else {
- _velocity = 0;
+ _mouseVelocity = 0;
}
} else {
- _velocity = 0;
+ _mouseVelocity = 0;
}
} else {
- _velocity = 0;
+ _mouseVelocity = 0;
}
if (!cursorWasChanged) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 3518e01..f2f713d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -97,7 +97,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_midiManager(nullptr),
_aud_id(0),
_rendDelay(2),
- _velocity(0) {
+ _kbdVelocity(0),
+ _mouseVelocity(0) {
debug(1, "ZVision::ZVision");
@@ -365,12 +366,17 @@ bool ZVision::canRender() {
}
void ZVision::updateRotation() {
+ int16 _velocity = _mouseVelocity + _kbdVelocity;
+
+ if (_halveDelay)
+ _velocity /= 2;
+
if (_velocity) {
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
+ int16 new_pos = st_pos + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity);
int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint();
if (st_pos >= zero_point && new_pos < zero_point)
@@ -389,7 +395,7 @@ void ZVision::updateRotation() {
} else if (renderState == RenderTable::TILT) {
int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos + _velocity * (1 - 2 * 0);
+ int16 new_pos = st_pos + _velocity;
int16 scr_height = _renderManager->getBkgSize().y;
int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 8564e4e..549ea9b 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -122,7 +122,8 @@ private:
const Common::Rect _workingWindow_ZNM;
int _rendDelay;
- int16 _velocity;
+ int16 _mouseVelocity;
+ int16 _kbdVelocity;
bool _halveDelay;
uint8 _cheatBuff[KEYBUF_SIZE];
Commit: 418b5f6dd28931ef8c7a0a05ae90dde3b36015b7
https://github.com/scummvm/scummvm/commit/418b5f6dd28931ef8c7a0a05ae90dde3b36015b7
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T15:58:35+06:00
Commit Message:
ZVISION: Passive borders check for tilt and panorama for changelocation
Changed paths:
engines/zvision/scripting/script_manager.cpp
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 457b491..a5cb81b 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -628,6 +628,8 @@ void ScriptManager::do_changeLocation() {
_currentLocation = _nextLocation;
execScope(nodeview);
}
+
+ _engine->checkBorders();
}
void ScriptManager::serialize(Common::WriteStream *stream) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index f2f713d..d8b0f20 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -410,6 +410,41 @@ void ZVision::updateRotation() {
}
}
+void ZVision::checkBorders() {
+ RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
+ if (renderState == RenderTable::PANORAMA) {
+ int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 new_pos = st_pos;
+
+ int16 scr_width = _renderManager->getBkgSize().x;
+
+ if (scr_width)
+ new_pos %= scr_width;
+
+ if (new_pos < 0)
+ new_pos += scr_width;
+
+ if (st_pos != new_pos)
+ _renderManager->setBackgroundPosition(new_pos);
+ } else if (renderState == RenderTable::TILT) {
+ int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 new_pos = st_pos;
+
+ int16 scr_height = _renderManager->getBkgSize().y;
+ int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();
+
+ if (new_pos >= (scr_height - tilt_gap))
+ new_pos = scr_height - tilt_gap;
+ if (new_pos <= tilt_gap)
+ new_pos = tilt_gap;
+
+ if (st_pos != new_pos)
+ _renderManager->setBackgroundPosition(new_pos);
+ }
+}
+
void ZVision::rotateTo(int16 _toPos, int16 _time) {
if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA)
return;
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 549ea9b..8cf9dbf 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -195,6 +195,7 @@ public:
bool ifQuit();
+ void checkBorders();
void showDebugMsg(const Common::String &msg, int16 delay = 3000);
private:
Commit: 2d7af4bab7e8c298373307d77d4a3e98cab1b575
https://github.com/scummvm/scummvm/commit/2d7af4bab7e8c298373307d77d4a3e98cab1b575
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:00:02+06:00
Commit Message:
ZVISION: Add call of inventory cycling for Nemesis
Changed paths:
engines/zvision/core/events.cpp
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 38ceb5c..5f8f8e2 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -168,7 +168,9 @@ void ZVision::processEvents() {
case Common::EVENT_RBUTTONDOWN:
_cursorManager->cursorDown(true);
_scriptManager->setStateValue(StateKey_RMouse, 1);
- // TODO: Inventory logic
+
+ if (getGameId() == GID_NEMESIS)
+ _scriptManager->invertory_cycle();
break;
case Common::EVENT_RBUTTONUP:
Commit: bb06ecf798682959bc9e31e92a6624e391e8429d
https://github.com/scummvm/scummvm/commit/bb06ecf798682959bc9e31e92a6624e391e8429d
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:01:23+06:00
Commit Message:
ZVISION: Make menu bar fully enabled after changelocation called
Changed paths:
engines/zvision/scripting/script_manager.cpp
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index a5cb81b..7df4818 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -562,6 +562,8 @@ void ScriptManager::do_changeLocation() {
_referenceTable.clear();
addPuzzlesToReferenceTable(universe);
+ _engine->menuBarEnable(0xFFFF);
+
if (_nextLocation.world != _currentLocation.world) {
cleanScriptScope(nodeview);
cleanScriptScope(room);
Commit: 960bbe53b2160de3747678bd877c532d49c7d147
https://github.com/scummvm/scummvm/commit/960bbe53b2160de3747678bd877c532d49c7d147
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:02:35+06:00
Commit Message:
ZVISION: Fix delays with halveDelay option
Changed paths:
engines/zvision/zvision.cpp
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index d8b0f20..4d9830a 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -300,7 +300,10 @@ bool ZVision::askQuestion(const Common::String &str) {
}
}
_system->updateScreen();
- _system->delayMillis(66);
+ if (_halveDelay)
+ _system->delayMillis(33);
+ else
+ _system->delayMillis(66);
}
_renderManager->deleteSubArea(msgid);
_clock.start();
@@ -325,7 +328,10 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) {
break;
}
_system->updateScreen();
- _system->delayMillis(66);
+ if (_halveDelay)
+ _system->delayMillis(33);
+ else
+ _system->delayMillis(66);
}
_renderManager->deleteSubArea(msgid);
_clock.start();
Commit: e970d121ff1acbe426e652a4ac17deebaf351821
https://github.com/scummvm/scummvm/commit/e970d121ff1acbe426e652a4ac17deebaf351821
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:05:48+06:00
Commit Message:
ZVISION: Lead code of all controls to the same style
Changed paths:
engines/zvision/scripting/controls/fist_control.cpp
engines/zvision/scripting/controls/fist_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/lever_control.h
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/push_toggle_control.h
engines/zvision/scripting/controls/save_control.cpp
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index 89aeb53..4779c5d 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -187,54 +187,58 @@ void FistControl::readDescFile(const Common::String &fileName) {
}
Common::String line;
+ Common::String param;
+ Common::String values;
while (!file.eos()) {
line = file.readLine();
+ getFistParams(line, param, values);
- for (int i = line.size() - 1; i >= 0; i--)
- if (line[i] == '~')
- line.deleteChar(i);
-
- if (line.matchString("*animation_id*", true)) {
+ if (param.matchString("animation_id", true)) {
// Not used
- } else if (line.matchString("*animation*", true)) {
- char filename[64];
- sscanf(line.c_str(), "animation:%s", filename);
- _animation = new MetaAnimation(Common::String(filename), _engine);
- } else if (line.matchString("*anim_rect*", true)) {
+ } else if (param.matchString("animation", true)) {
+ _animation = new MetaAnimation(values, _engine);
+ } else if (param.matchString("anim_rect", true)) {
int left, top, right, bottom;
- sscanf(line.c_str(), "anim_rect:%d %d %d %d", &left, &top, &right, &bottom);
+ sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom);
_anmRect = Common::Rect(left, top, right, bottom);
- } else if (line.matchString("*num_fingers*", true)) {
- sscanf(line.c_str(), "num_fingers:%d", &_fistnum);
+ } else if (param.matchString("num_fingers", true)) {
+ sscanf(values.c_str(), "%d", &_fistnum);
_fistsUp.resize(_fistnum);
_fistsDwn.resize(_fistnum);
- } else if (line.matchString("*entries*", true)) {
- sscanf(line.c_str(), "entries:%d", &_numEntries);
+ } else if (param.matchString("entries", true)) {
+ sscanf(values.c_str(), "%d", &_numEntries);
_entries.resize(_numEntries);
- } else if (line.matchString("*eval_order_ascending*", true)) {
- sscanf(line.c_str(), "eval_order_ascending:%d", &_order);
- } else if (line.matchString("*up_hs_num_*", true)) {
+ } else if (param.matchString("eval_order_ascending", true)) {
+ sscanf(values.c_str(), "%d", &_order);
+ } else if (param.matchString("up_hs_num_*", true)) {
int fist, num;
- sscanf(line.c_str(), "up_hs_num_%d:%d", &fist, &num);
+ num = atoi(values.c_str());
+
+ sscanf(param.c_str(), "up_hs_num_%d", &fist);
_fistsUp[fist].resize(num);
- } else if (line.matchString("*up_hs_*", true)) {
+ } else if (param.matchString("up_hs_*", true)) {
int16 fist, box, x1, y1, x2, y2;
- sscanf(line.c_str(), "up_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2);
+ sscanf(param.c_str(), "up_hs_%hd_%hd", &fist, &box);
+ sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2);
(_fistsUp[fist])[box] = Common::Rect(x1, y1, x2, y2);
- } else if (line.matchString("*down_hs_num_*", true)) {
+ } else if (param.matchString("down_hs_num_*", true)) {
int fist, num;
- sscanf(line.c_str(), "down_hs_num_%d:%d", &fist, &num);
+ num = atoi(values.c_str());
+
+ sscanf(param.c_str(), "down_hs_num_%d", &fist);
_fistsDwn[fist].resize(num);
- } else if (line.matchString("*down_hs_*", true)) {
+ } else if (param.matchString("down_hs_*", true)) {
int16 fist, box, x1, y1, x2, y2;
- sscanf(line.c_str(), "down_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2);
+ sscanf(param.c_str(), "down_hs_%hd_%hd", &fist, &box);
+ sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2);
(_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2);
} else {
int entry, start, end, sound;
char bits_start[33];
char bits_end[33];
- if (sscanf(line.c_str(), "%d:%s %s %d %d (%d)", &entry, bits_start, bits_end, &start, &end, &sound) == 6) {
+ entry = atoi(param.c_str());
+ if (sscanf(values.c_str(), "%s %s %d %d (%d)", bits_start, bits_end, &start, &end, &sound) == 5) {
_entries[entry]._bitsStrt = readBits(bits_start);
_entries[entry]._bitsEnd = readBits(bits_end);
_entries[entry]._anmStrt = start;
@@ -291,4 +295,28 @@ int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Poin
return -1;
}
+void FistControl::getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
+ const char *chrs = input_str.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < input_str.size(); lbr++)
+ if (chrs[lbr] == ':')
+ break;
+
+ if (lbr >= input_str.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ if (chrs[rbr] == '~')
+ break;
+
+ if (rbr >= input_str.size())
+ return;
+
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h
index 940bc96..8b229f9 100644
--- a/engines/zvision/scripting/controls/fist_control.h
+++ b/engines/zvision/scripting/controls/fist_control.h
@@ -79,6 +79,7 @@ private:
void clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr);
uint32 readBits(const char *str);
int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ void getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index e35b300..f8acdbd 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -51,59 +51,63 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*rectangle*", true)) {
+ if (param.matchString("rectangle", true)) {
int x1;
int y1;
int x2;
int y2;
- sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+ sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);
_textRectangle = Common::Rect(x1, y1, x2, y2);
- } else if (line.matchString("*aux_hotspot*", true)) {
+ } else if (param.matchString("aux_hotspot", true)) {
int x1;
int y1;
int x2;
int y2;
- sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+ sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);
_headerRectangle = Common::Rect(x1, y1, x2, y2);
- } else if (line.matchString("*string_init*", true)) {
+ } else if (param.matchString("string_init", true)) {
uint fontFormatNumber;
- sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
+ sscanf(values.c_str(), "%u", &fontFormatNumber);
_string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
- } else if (line.matchString("*chooser_init_string*", true)) {
+ } else if (param.matchString("chooser_init_string", true)) {
uint fontFormatNumber;
- sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
+ sscanf(values.c_str(), "%u", &fontFormatNumber);
_string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
- } else if (line.matchString("*next_tabstop*", true)) {
- sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop);
- } else if (line.matchString("*cursor_dimensions*", true)) {
+ } else if (param.matchString("next_tabstop", true)) {
+ sscanf(values.c_str(), "%u", &_nextTabstop);
+ } else if (param.matchString("cursor_dimensions", true)) {
// Ignore, use the dimensions in the animation file
- } else if (line.matchString("*cursor_animation_frames*", true)) {
+ } else if (param.matchString("cursor_animation_frames", true)) {
// Ignore, use the frame count in the animation file
- } else if (line.matchString("*cursor_animation*", true)) {
+ } else if (param.matchString("cursor_animation", true)) {
char fileName[25];
- sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName);
+ sscanf(values.c_str(), "%25s %*u", fileName);
_animation = new MetaAnimation(fileName, _engine);
_frame = -1;
_frameDelay = 0;
- } else if (line.matchString("*focus*", true)) {
+ } else if (param.matchString("focus", true)) {
_focused = true;
_engine->getScriptManager()->setFocusControlKey(_key);
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
}
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 84cd6fa..9b665ff 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -57,21 +57,26 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*descfile*", true)) {
+ if (param.matchString("descfile", true)) {
char levFileName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName);
+ sscanf(values.c_str(), "%25s", levFileName);
parseLevFile(levFileName);
- } else if (line.matchString("*cursor*", true)) {
+ } else if (param.matchString("cursor", true)) {
char cursorName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName);
+ sscanf(values.c_str(), "%25s", cursorName);
- _cursorName = Common::String(cursorName);
+ _cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName));
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
renderFrame(_currentFrame);
@@ -92,50 +97,47 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
Common::String line;
+ Common::String param;
+ Common::String values;
while (!file.eos()) {
line = file.readLine();
+ getLevParams(line, param, values);
- if (line.matchString("*animation_id*", true)) {
+ if (param.matchString("animation_id", true)) {
// Not used
- } else if (line.matchString("*filename*", true)) {
- char fileNameBuffer[25];
- sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
-
- Common::String animationFileName(fileNameBuffer);
-
- _animation = new MetaAnimation(animationFileName, _engine);
-
- } else if (line.matchString("*skipcolor*", true)) {
+ } else if (param.matchString("filename", true)) {
+ _animation = new MetaAnimation(values, _engine);
+ } else if (param.matchString("skipcolor", true)) {
// Not used
- } else if (line.matchString("*anim_coords*", true)) {
+ } else if (param.matchString("anim_coords", true)) {
int left, top, right, bottom;
- sscanf(line.c_str(), "%*[^:]:%d %d %d %d~", &left, &top, &right, &bottom);
+ sscanf(values.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)) {
+ } else if (param.matchString("mirrored", true)) {
uint mirrored;
- sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
+ sscanf(values.c_str(), "%u", &mirrored);
_mirrored = mirrored == 0 ? false : true;
- } else if (line.matchString("*frames*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
+ } else if (param.matchString("frames", true)) {
+ sscanf(values.c_str(), "%u", &_frameCount);
_frameInfo = new FrameInfo[_frameCount];
- } else if (line.matchString("*elsewhere*", true)) {
+ } else if (param.matchString("elsewhere", true)) {
// Not used
- } else if (line.matchString("*out_of_control*", true)) {
+ } else if (param.matchString("out_of_control", true)) {
// Not used
- } else if (line.matchString("*start_pos*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
+ } else if (param.matchString("start_pos", true)) {
+ sscanf(values.c_str(), "%u", &_startFrame);
_currentFrame = _startFrame;
- } else if (line.matchString("*hotspot_deltas*", true)) {
+ } else if (param.matchString("hotspot_deltas", true)) {
uint x;
uint y;
- sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
+ sscanf(values.c_str(), "%u %u", &x, &y);
_hotspotDelta.x = x;
_hotspotDelta.y = y;
@@ -233,7 +235,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
}
} else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_cursorName));
+ _engine->getCursorManager()->changeCursor(_cursor);
cursorWasChanged = true;
}
@@ -376,4 +378,28 @@ void LeverControl::renderFrame(uint frameNumber) {
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
}
+void LeverControl::getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
+ const char *chrs = input_str.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < input_str.size(); lbr++)
+ if (chrs[lbr] == ':')
+ break;
+
+ if (lbr >= input_str.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ if (chrs[rbr] == '~')
+ break;
+
+ if (rbr >= input_str.size())
+ return;
+
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h
index 712d688..22789f7 100644
--- a/engines/zvision/scripting/controls/lever_control.h
+++ b/engines/zvision/scripting/controls/lever_control.h
@@ -62,7 +62,7 @@ private:
private:
MetaAnimation *_animation;
- Common::String _cursorName;
+ int _cursor;
Common::Rect _animationCoords;
bool _mirrored;
uint _frameCount;
@@ -112,6 +112,7 @@ private:
*/
static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
void renderFrame(uint frameNumber);
+ void getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index bf74a22..03df4b7 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -38,56 +38,52 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
: Control(engine, key, CONTROL_PUSHTGL),
_countTo(2),
_event(Common::EVENT_LBUTTONUP) {
+
+ _hotspots.clear();
+
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
- line.toLowercase();
- _hotspots.clear();
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*_hotspot*", true)) {
+ if (param.matchString("*_hotspot", true)) {
uint x;
uint y;
uint width;
uint height;
- sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
+ sscanf(values.c_str(), "%u,%u,%u,%u", &x, &y, &width, &height);
_hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1));
- } else if (line.matchString("cursor*", true)) {
- char nameBuffer[25];
-
- sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
-
- _hoverCursor = Common::String(nameBuffer);
- } else if (line.matchString("animation*", true)) {
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("animation", true)) {
// Not used
- } else if (line.matchString("sound*", true)) {
+ } else if (param.matchString("sound", true)) {
// Not used
- } else if (line.matchString("count_to*", true)) {
- sscanf(line.c_str(), "%*[^(](%u)", &_countTo);
- } else if (line.matchString("mouse_event*", true)) {
- char nameBuffer[25];
-
- sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
-
- Common::String evntStr(nameBuffer);
- if (evntStr.equalsIgnoreCase("up")) {
+ } else if (param.matchString("count_to", true)) {
+ sscanf(values.c_str(), "%u", &_countTo);
+ } else if (param.matchString("mouse_event", true)) {
+ if (values.equalsIgnoreCase("up")) {
_event = Common::EVENT_LBUTTONUP;
- } else if (evntStr.equalsIgnoreCase("down")) {
+ } else if (values.equalsIgnoreCase("down")) {
_event = Common::EVENT_LBUTTONDOWN;
- } else if (evntStr.equalsIgnoreCase("double")) {
+ } else if (values.equalsIgnoreCase("double")) {
// Not used
}
- } else if (line.matchString("venus_id*", true)) {
+ } else if (param.matchString("venus_id*", true)) {
// Not used
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
- if (_hotspots.size() == 0 || _hoverCursor.empty()) {
+ if (_hotspots.size() == 0) {
warning("Push_toggle %u was parsed incorrectly", key);
}
}
@@ -133,7 +129,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
return false;
if (contain(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor));
+ _engine->getCursorManager()->changeCursor(_cursor);
return true;
}
diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h
index 7b45fb4..6d68b8f 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.h
+++ b/engines/zvision/scripting/controls/push_toggle_control.h
@@ -68,7 +68,7 @@ private:
*/
Common::Array<Common::Rect> _hotspots;
/** The cursor to use when hovering over _hotspot */
- Common::String _hoverCursor;
+ int _cursor;
/** Button maximal values count */
uint _countTo;
diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp
index fda8a70..a0b19db 100644
--- a/engines/zvision/scripting/controls/save_control.cpp
+++ b/engines/zvision/scripting/controls/save_control.cpp
@@ -44,23 +44,23 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*savebox*", true)) {
+ if (param.matchString("savebox", true)) {
int save_id;
int input_id;
- sscanf(line.c_str(), "%*[^(](%d %d)", &save_id, &input_id);
+ sscanf(values.c_str(), "%d %d", &save_id, &input_id);
save_elmnt elmnt;
elmnt.input_key = input_id;
elmnt.save_id = save_id;
elmnt.exist = false;
_inputs.push_back(elmnt);
- } else if (line.matchString("*control_type*", true)) {
- char buf[32];
-
- sscanf(line.c_str(), "%*[^(](%s)", buf);
- if (Common::String(buf).contains("save"))
+ } else if (param.matchString("control_type", true)) {
+ if (values.contains("save"))
_saveControl = true;
else
_saveControl = false;
@@ -68,6 +68,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
Commit: f43326a533faec014fb1987f9ba3729127c46487
https://github.com/scummvm/scummvm/commit/f43326a533faec014fb1987f9ba3729127c46487
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:06:31+06:00
Commit Message:
ZVISION: Clean of useless code
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/zvision.cpp
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 5f8f8e2..0d38e08 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -198,9 +198,6 @@ void ZVision::processEvents() {
_kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ?
-_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
_scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
- case Common::KEYCODE_q:
- if (_event.kbd.hasFlags(Common::KBD_CTRL))
- quitGame();
break;
case Common::KEYCODE_UP:
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 4d9830a..8485642 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -170,33 +170,6 @@ void ZVision::initialize() {
_searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC");
} else if (_gameDescription->gameId == GID_NEMESIS)
_searchManager->loadZix("NEMESIS.ZIX");
- // 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);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zgi_mx", 0, 1, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true);
-
- // 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();
- Common::SeekableReadStream *stream = (*iter)->createReadStream();
- ZfsArchive *archive = new ZfsArchive(name, stream);
-
- delete stream;
-
- SearchMan.add(name, archive);
- }
initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
Commit: e6f66877627ff4ef03ad8d1ea8a64c4278593d22
https://github.com/scummvm/scummvm/commit/e6f66877627ff4ef03ad8d1ea8a64c4278593d22
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-12T16:38:28+06:00
Commit Message:
ZVISION: Merge upstream
Changed paths:
A backends/platform/sdl/amigaos/amigaos.mk
A backends/platform/sdl/ps3/ps3.mk
A backends/platform/symbian/mmp/config.mmh
A backends/platform/symbian/mmp/scummvm_cge2.mmp.in
A backends/vkeybd/packs/vkeybd_small.zip
A backends/vkeybd/packs/vkeybd_small/lowercase-symbols320x240.bmp
A backends/vkeybd/packs/vkeybd_small/lowercase320x240.bmp
A backends/vkeybd/packs/vkeybd_small/uppercase-symbols320x240.bmp
A backends/vkeybd/packs/vkeybd_small/uppercase320x240.bmp
A backends/vkeybd/packs/vkeybd_small/vkeybd_small.xml
A devtools/create_kyradat/resources/eob1_dos_italian.h
A dists/android/res/values-television/margins.xml
A dists/gcw0/default.gcw0.desktop
A dists/gcw0/opk_make.sh
A dists/gcw0/scummvm.png
A dists/gcw0/scummvm.sh
A dists/gcw0/scummvmrc
A engines/cge/POTFILES
A engines/cge2/POTFILES
A engines/cge2/bitmap.cpp
A engines/cge2/bitmap.h
A engines/cge2/cge2.cpp
A engines/cge2/cge2.h
A engines/cge2/cge2_main.cpp
A engines/cge2/cge2_main.h
A engines/cge2/configure.engine
A engines/cge2/console.cpp
A engines/cge2/console.h
A engines/cge2/detection.cpp
A engines/cge2/events.cpp
A engines/cge2/events.h
A engines/cge2/fileio.cpp
A engines/cge2/fileio.h
A engines/cge2/general.h
A engines/cge2/hero.cpp
A engines/cge2/hero.h
A engines/cge2/inventory.cpp
A engines/cge2/map.cpp
A engines/cge2/map.h
A engines/cge2/module.mk
A engines/cge2/saveload.cpp
A engines/cge2/snail.cpp
A engines/cge2/snail.h
A engines/cge2/sound.cpp
A engines/cge2/sound.h
A engines/cge2/spare.cpp
A engines/cge2/spare.h
A engines/cge2/talk.cpp
A engines/cge2/talk.h
A engines/cge2/text.cpp
A engines/cge2/text.h
A engines/cge2/toolbar.cpp
A engines/cge2/vga13h.cpp
A engines/cge2/vga13h.h
A engines/cge2/vmenu.cpp
A engines/cge2/vmenu.h
A engines/fullpipe/mgm.cpp
A engines/fullpipe/mgm.h
A engines/hopkins/POTFILES
A engines/lastexpress/entities/waiter1.cpp
A engines/lastexpress/entities/waiter1.h
A engines/lastexpress/entities/waiter2.cpp
A engines/lastexpress/entities/waiter2.h
A engines/mads/menu_views.cpp
A engines/mads/menu_views.h
A engines/mads/nebular/menu_nebular.cpp
A engines/mads/nebular/menu_nebular.h
A engines/pegasus/interaction.cpp
A engines/prince/animation.cpp
A engines/prince/animation.h
A engines/prince/archive.cpp
A engines/prince/archive.h
A engines/prince/common.h
A engines/prince/configure.engine
A engines/prince/cursor.cpp
A engines/prince/cursor.h
A engines/prince/curve_values.h
A engines/prince/debugger.cpp
A engines/prince/debugger.h
A engines/prince/decompress.cpp
A engines/prince/decompress.h
A engines/prince/detection.cpp
A engines/prince/detection.h
A engines/prince/flags.cpp
A engines/prince/flags.h
A engines/prince/font.cpp
A engines/prince/font.h
A engines/prince/graphics.cpp
A engines/prince/graphics.h
A engines/prince/hero.cpp
A engines/prince/hero.h
A engines/prince/hero_set.h
A engines/prince/mhwanh.cpp
A engines/prince/mhwanh.h
A engines/prince/mob.cpp
A engines/prince/mob.h
A engines/prince/module.mk
A engines/prince/musNum.h
A engines/prince/object.cpp
A engines/prince/object.h
A engines/prince/option_text.h
A engines/prince/prince.cpp
A engines/prince/prince.h
A engines/prince/pscr.cpp
A engines/prince/pscr.h
A engines/prince/resource.h
A engines/prince/saveload.cpp
A engines/prince/script.cpp
A engines/prince/script.h
A engines/prince/sound.cpp
A engines/prince/sound.h
A engines/prince/variatxt.cpp
A engines/prince/variatxt.h
A engines/scumm/cdda.cpp
A engines/scumm/cdda.h
A engines/tsage/POTFILES
A engines/tsage/ringworld2/ringworld2_airduct.cpp
A engines/tsage/ringworld2/ringworld2_airduct.h
A engines/tsage/ringworld2/ringworld2_outpost.cpp
A engines/tsage/ringworld2/ringworld2_outpost.h
A engines/tsage/ringworld2/ringworld2_vampire.cpp
A engines/tsage/ringworld2/ringworld2_vampire.h
A engines/wintermute/POTFILES
A engines/wintermute/game_description.h
A engines/wintermute/video/subtitle_card.cpp
A engines/wintermute/video/subtitle_card.h
A engines/wintermute/video/video_subtitler.cpp
A engines/wintermute/video/video_subtitler.h
A engines/zvision/POTFILES
A graphics/transform_struct.cpp
A graphics/transform_struct.h
A graphics/transform_tools.cpp
A graphics/transform_tools.h
A graphics/transparent_surface.cpp
A graphics/transparent_surface.h
A icons/scummvm_drawer.info
A po/nl_NL.po
R devtools/create_project/msvc8/create_project.sln
R devtools/create_project/msvc8/create_project.vcproj
R dists/android/res-ouya/values-television/margins.xml
R dists/msvc8/create_msvc8.bat
R dists/msvc8/readme.txt
R engines/lastexpress/entities/servers0.cpp
R engines/lastexpress/entities/servers0.h
R engines/lastexpress/entities/servers1.cpp
R engines/lastexpress/entities/servers1.h
R engines/wintermute/graphics/transform_struct.cpp
R engines/wintermute/graphics/transform_struct.h
R engines/wintermute/graphics/transform_tools.cpp
R engines/wintermute/graphics/transform_tools.h
R engines/wintermute/graphics/transparent_surface.cpp
R engines/wintermute/graphics/transparent_surface.h
AUTHORS
COPYRIGHT
NEWS
README
audio/audiostream.cpp
audio/audiostream.h
audio/decoders/aac.cpp
audio/decoders/mp3.cpp
audio/decoders/qdm2.cpp
audio/decoders/quicktime.cpp
audio/softsynth/mt32/BReverbModel.cpp
audio/softsynth/mt32/BReverbModel.h
audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
audio/softsynth/mt32/LA32FloatWaveGenerator.h
audio/softsynth/mt32/LA32Ramp.cpp
audio/softsynth/mt32/LA32Ramp.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/ROMInfo.cpp
audio/softsynth/mt32/ROMInfo.h
audio/softsynth/mt32/Structures.h
audio/softsynth/mt32/Synth.cpp
audio/softsynth/mt32/Synth.h
audio/softsynth/mt32/TVA.cpp
audio/softsynth/mt32/TVA.h
audio/softsynth/mt32/TVF.cpp
audio/softsynth/mt32/TVF.h
audio/softsynth/mt32/TVP.cpp
audio/softsynth/mt32/TVP.h
audio/softsynth/mt32/Tables.cpp
audio/softsynth/mt32/Tables.h
audio/softsynth/mt32/mmath.h
audio/softsynth/mt32/mt32emu.h
backends/audiocd/audiocd.h
backends/events/dinguxsdl/dinguxsdl-events.cpp
backends/events/gph/gph-events.cpp
backends/events/linuxmotosdl/linuxmotosdl-events.cpp
backends/events/maemosdl/maemosdl-events.cpp
backends/events/ps3sdl/ps3sdl-events.cpp
backends/events/samsungtvsdl/samsungtvsdl-events.cpp
backends/fs/amigaos4/amigaos4-fs.cpp
backends/fs/amigaos4/amigaos4-fs.h
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/keymapper/action.h
backends/mixer/sdl/sdl-mixer.cpp
backends/mixer/sdl13/sdl13-mixer.cpp
backends/platform/android/android.mk
backends/platform/android/events.cpp
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
backends/platform/dingux/dingux.mk
backends/platform/gph/caanoo-bundle.mk
backends/platform/gph/gp2x-bundle.mk
backends/platform/gph/gp2xwiz-bundle.mk
backends/platform/linuxmoto/linuxmoto.mk
backends/platform/maemo/debian/changelog
backends/platform/maemo/debian/rules
backends/platform/n64/n64.mk
backends/platform/psp/README.PSP
backends/platform/sdl/amigaos/amigaos-main.cpp
backends/platform/sdl/sdl.cpp
backends/platform/symbian/AdaptAllMMPs.pl
backends/platform/symbian/BuildPackageUpload_AllVersions.pl
backends/platform/symbian/BuildPackageUpload_LocalSettings.pl
backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
backends/platform/symbian/UIQ3/BLD.INF.in
backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
backends/platform/symbian/help/ScummVM.rtf
backends/platform/symbian/mmp/scummvm_agi.mmp.in
backends/platform/symbian/mmp/scummvm_agos.mmp.in
backends/platform/symbian/mmp/scummvm_avalanche.mmp.in
backends/platform/symbian/mmp/scummvm_base.mmp.in
backends/platform/symbian/mmp/scummvm_bbvs.mmp.in
backends/platform/symbian/mmp/scummvm_cge.mmp.in
backends/platform/symbian/mmp/scummvm_cine.mmp.in
backends/platform/symbian/mmp/scummvm_composer.mmp.in
backends/platform/symbian/mmp/scummvm_cruise.mmp.in
backends/platform/symbian/mmp/scummvm_draci.mmp.in
backends/platform/symbian/mmp/scummvm_drascula.mmp.in
backends/platform/symbian/mmp/scummvm_dreamweb.mmp.in
backends/platform/symbian/mmp/scummvm_fullpipe.mmp.in
backends/platform/symbian/mmp/scummvm_gob.mmp.in
backends/platform/symbian/mmp/scummvm_groovie.mmp.in
backends/platform/symbian/mmp/scummvm_hopkins.mmp.in
backends/platform/symbian/mmp/scummvm_hugo.mmp.in
backends/platform/symbian/mmp/scummvm_kyra.mmp.in
backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
backends/platform/symbian/mmp/scummvm_lure.mmp.in
backends/platform/symbian/mmp/scummvm_m4.mmp.in
backends/platform/symbian/mmp/scummvm_made.mmp.in
backends/platform/symbian/mmp/scummvm_mads.mmp.in
backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
backends/platform/symbian/mmp/scummvm_mortevielle.mmp.in
backends/platform/symbian/mmp/scummvm_neverhood.mmp.in
backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
backends/platform/symbian/mmp/scummvm_pegasus.mmp.in
backends/platform/symbian/mmp/scummvm_queen.mmp.in
backends/platform/symbian/mmp/scummvm_saga.mmp.in
backends/platform/symbian/mmp/scummvm_sci.mmp.in
backends/platform/symbian/mmp/scummvm_scumm.mmp.in
backends/platform/symbian/mmp/scummvm_sky.mmp.in
backends/platform/symbian/mmp/scummvm_sword1.mmp.in
backends/platform/symbian/mmp/scummvm_sword2.mmp.in
backends/platform/symbian/mmp/scummvm_sword25.mmp.in
backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
backends/platform/symbian/mmp/scummvm_testbed.mmp.in
backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
backends/platform/symbian/mmp/scummvm_toltecs.mmp.in
backends/platform/symbian/mmp/scummvm_tony.mmp.in
backends/platform/symbian/mmp/scummvm_toon.mmp.in
backends/platform/symbian/mmp/scummvm_touche.mmp.in
backends/platform/symbian/mmp/scummvm_tsage.mmp.in
backends/platform/symbian/mmp/scummvm_tucker.mmp.in
backends/platform/symbian/mmp/scummvm_wintermute.mmp.in
backends/platform/symbian/mmp/scummvm_zvision.mmp.in
backends/platform/tizen/form.cpp
backends/platform/wii/osystem_events.cpp
backends/platform/wii/wii.mk
backends/taskbar/unity/unity-taskbar.cpp
backends/vkeybd/virtual-keyboard.cpp
base/commandLine.cpp
base/internal_version.h
base/main.cpp
base/version.cpp
common/EventMapper.cpp
common/c++11-compat.h
common/config-manager.cpp
common/dcl.cpp
common/endian.h
common/events.h
common/file.h
common/localization.h
common/macresman.h
common/quicktime.h
common/scummsys.h
common/singleton.h
common/str.h
common/stream.h
common/util.h
common/zlib.h
configure
devtools/README
devtools/create_kyradat/create_kyradat.cpp
devtools/create_kyradat/games.cpp
devtools/create_kyradat/resources.cpp
devtools/create_project/create_project.cpp
devtools/create_project/msbuild.cpp
devtools/create_project/msvc10/create_project.vcxproj
devtools/create_project/msvc11/create_project.vcxproj
devtools/create_project/msvc12/create_project.vcxproj
devtools/create_project/scripts/postbuild.cmd
devtools/create_project/visualstudio.cpp
devtools/credits.pl
devtools/scumm-md5.txt
dists/android/AndroidManifest.xml
dists/android/plugin-manifest.xml
dists/engine-data/kyra.dat
dists/gph/README-GPH
dists/gph/scummvm.ini
dists/iphone/Info.plist
dists/irix/scummvm.spec
dists/macosx/Info.plist
dists/openpandora/PXML.xml
dists/openpandora/README-OPENPANDORA
dists/openpandora/README-PND.txt
dists/openpandora/index.html
dists/redhat/scummvm-tools.spec
dists/redhat/scummvm.spec
dists/redhat/scummvm.spec.in
dists/scummvm.rc
dists/slackware/scummvm.SlackBuild
dists/wii/meta.xml
dists/win32/scummvm.nsi
doc/de/Liesmich
doc/de/Neues
engines/advancedDetector.cpp
engines/agos/input.cpp
engines/agos/midi.cpp
engines/bbvs/bbvs.cpp
engines/bbvs/bbvs.h
engines/bbvs/detection.cpp
engines/bbvs/dialogs.cpp
engines/bbvs/dialogs.h
engines/bbvs/gamemodule.cpp
engines/bbvs/gamemodule.h
engines/bbvs/graphics.cpp
engines/bbvs/minigames/bbairguitar.cpp
engines/bbvs/minigames/bbairguitar.h
engines/bbvs/minigames/bbant.cpp
engines/bbvs/minigames/bbant.h
engines/bbvs/minigames/bbloogie.cpp
engines/bbvs/minigames/bbloogie.h
engines/bbvs/minigames/bbtennis.cpp
engines/bbvs/minigames/bbtennis.h
engines/bbvs/minigames/minigame.cpp
engines/bbvs/minigames/minigame.h
engines/bbvs/saveload.cpp
engines/bbvs/scene.cpp
engines/bbvs/spritemodule.cpp
engines/bbvs/videoplayer.cpp
engines/bbvs/walk.cpp
engines/cge/cge.h
engines/cge/detection.cpp
engines/cge/fileio.cpp
engines/cge/vga13h.cpp
engines/cge/vga13h.h
engines/composer/composer.cpp
engines/composer/scripting.cpp
engines/cruise/cruise_main.cpp
engines/drascula/animation.cpp
engines/drascula/drascula.cpp
engines/dreamweb/POTFILES
engines/fullpipe/configure.engine
engines/fullpipe/fullpipe.cpp
engines/fullpipe/fullpipe.h
engines/fullpipe/gameloader.cpp
engines/fullpipe/gfx.cpp
engines/fullpipe/gfx.h
engines/fullpipe/input.cpp
engines/fullpipe/modal.cpp
engines/fullpipe/modal.h
engines/fullpipe/module.mk
engines/fullpipe/motion.cpp
engines/fullpipe/motion.h
engines/fullpipe/scene.cpp
engines/fullpipe/scenes/scene02.cpp
engines/fullpipe/scenes/scene14.cpp
engines/fullpipe/scenes/scene15.cpp
engines/fullpipe/scenes/scene16.cpp
engines/fullpipe/scenes/scene23.cpp
engines/fullpipe/scenes/scene27.cpp
engines/fullpipe/scenes/scene28.cpp
engines/fullpipe/scenes/scene29.cpp
engines/fullpipe/scenes/scene37.cpp
engines/fullpipe/sound.cpp
engines/fullpipe/statics.cpp
engines/gob/POTFILES
engines/gob/detection/tables_ween.h
engines/gob/inter_v1.cpp
engines/groovie/graphics.cpp
engines/groovie/graphics.h
engines/groovie/roq.cpp
engines/groovie/roq.h
engines/groovie/script.cpp
engines/groovie/script.h
engines/hopkins/computer.cpp
engines/hopkins/files.cpp
engines/hopkins/sound.cpp
engines/hopkins/sound.h
engines/hopkins/talk.cpp
engines/kyra/POTFILES
engines/kyra/detection_tables.h
engines/kyra/items_lol.cpp
engines/kyra/sound_adlib.cpp
engines/kyra/staticres.cpp
engines/kyra/staticres_eob.cpp
engines/kyra/text_rpg.cpp
engines/kyra/vqa.cpp
engines/lastexpress/debug.cpp
engines/lastexpress/entities/abbot.cpp
engines/lastexpress/entities/alexei.cpp
engines/lastexpress/entities/anna.cpp
engines/lastexpress/entities/august.cpp
engines/lastexpress/entities/boutarel.cpp
engines/lastexpress/entities/chapters.cpp
engines/lastexpress/entities/chapters.h
engines/lastexpress/entities/cooks.cpp
engines/lastexpress/entities/cooks.h
engines/lastexpress/entities/entity.cpp
engines/lastexpress/entities/gendarmes.cpp
engines/lastexpress/entities/gendarmes.h
engines/lastexpress/entities/hadija.cpp
engines/lastexpress/entities/hadija.h
engines/lastexpress/entities/ivo.cpp
engines/lastexpress/entities/ivo.h
engines/lastexpress/entities/kahina.cpp
engines/lastexpress/entities/kahina.h
engines/lastexpress/entities/kronos.cpp
engines/lastexpress/entities/kronos.h
engines/lastexpress/entities/max.cpp
engines/lastexpress/entities/max.h
engines/lastexpress/entities/milos.cpp
engines/lastexpress/entities/pascale.cpp
engines/lastexpress/entities/pascale.h
engines/lastexpress/entities/rebecca.cpp
engines/lastexpress/entities/tatiana.cpp
engines/lastexpress/game/action.cpp
engines/lastexpress/game/entities.cpp
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/savepoint.cpp
engines/lastexpress/game/savepoint.h
engines/lastexpress/lastexpress.cpp
engines/lastexpress/module.mk
engines/lastexpress/shared.h
engines/lastexpress/sound/entry.cpp
engines/lastexpress/sound/sound.cpp
engines/made/database.cpp
engines/made/resource.cpp
engines/made/screen.cpp
engines/mads/animation.cpp
engines/mads/animation.h
engines/mads/audio.cpp
engines/mads/audio.h
engines/mads/debugger.cpp
engines/mads/debugger.h
engines/mads/dialogs.cpp
engines/mads/dialogs.h
engines/mads/dragonsphere/dragonsphere_scenes.cpp
engines/mads/dragonsphere/game_dragonsphere.cpp
engines/mads/events.cpp
engines/mads/events.h
engines/mads/game.cpp
engines/mads/game.h
engines/mads/mads.cpp
engines/mads/messages.cpp
engines/mads/module.mk
engines/mads/msurface.cpp
engines/mads/msurface.h
engines/mads/nebular/dialogs_nebular.cpp
engines/mads/nebular/dialogs_nebular.h
engines/mads/nebular/game_nebular.cpp
engines/mads/nebular/game_nebular.h
engines/mads/nebular/nebular_scenes.cpp
engines/mads/nebular/nebular_scenes1.cpp
engines/mads/nebular/nebular_scenes5.cpp
engines/mads/nebular/nebular_scenes6.cpp
engines/mads/nebular/nebular_scenes7.cpp
engines/mads/nebular/nebular_scenes8.cpp
engines/mads/nebular/sound_nebular.cpp
engines/mads/nebular/sound_nebular.h
engines/mads/palette.cpp
engines/mads/palette.h
engines/mads/phantom/game_phantom.cpp
engines/mads/phantom/phantom_scenes.cpp
engines/mads/scene.cpp
engines/mads/scene.h
engines/mads/scene_data.cpp
engines/mads/scene_data.h
engines/mads/screen.cpp
engines/mads/screen.h
engines/mads/sequence.cpp
engines/mads/sound.cpp
engines/mads/sound.h
engines/mads/sprites.cpp
engines/mads/user_interface.h
engines/mohawk/myst_stacks/stoneship.cpp
engines/mohawk/myst_state.cpp
engines/mortevielle/detection_tables.h
engines/mortevielle/mortevielle.h
engines/mortevielle/utils.cpp
engines/neverhood/console.cpp
engines/neverhood/graphics.cpp
engines/neverhood/modules/module1400.cpp
engines/neverhood/modules/module1400_sprites.cpp
engines/neverhood/modules/module1400_sprites.h
engines/neverhood/modules/module1600_sprites.cpp
engines/neverhood/sound.cpp
engines/neverhood/sprite.cpp
engines/pegasus/energymonitor.cpp
engines/pegasus/input.cpp
engines/pegasus/interaction.h
engines/pegasus/module.mk
engines/pegasus/neighborhood/caldoria/caldoria.cpp
engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
engines/pegasus/neighborhood/mars/shuttlehud.cpp
engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
engines/pegasus/neighborhood/norad/delta/globegame.cpp
engines/pegasus/neighborhood/norad/subcontrolroom.cpp
engines/pegasus/neighborhood/tsa/fulltsa.cpp
engines/pegasus/neighborhood/tsa/tinytsa.cpp
engines/pegasus/neighborhood/wsc/wsc.cpp
engines/pegasus/pegasus.cpp
engines/queen/POTFILES
engines/queen/logic.cpp
engines/queen/talk.cpp
engines/saga/actor.h
engines/saga/console.cpp
engines/saga/console.h
engines/saga/detection_tables.h
engines/saga/events.cpp
engines/saga/events.h
engines/saga/interface.cpp
engines/saga/introproc_ite.cpp
engines/saga/introproc_saga2.cpp
engines/saga/itedata.cpp
engines/saga/itedata.h
engines/saga/music.cpp
engines/saga/music.h
engines/saga/resource.cpp
engines/saga/resource.h
engines/saga/resource_hrs.cpp
engines/saga/saga.cpp
engines/saga/saveload.cpp
engines/saga/scene.cpp
engines/saga/scene.h
engines/saga/sfuncs.cpp
engines/saga/sfuncs_ihnm.cpp
engines/saga/shorten.cpp
engines/saga/sndres.h
engines/savestate.h
engines/sci/console.cpp
engines/sci/detection.cpp
engines/sci/detection_tables.h
engines/sci/engine/features.cpp
engines/sci/engine/kernel.h
engines/sci/engine/kernel_tables.h
engines/sci/engine/kfile.cpp
engines/sci/engine/kgraphics.cpp
engines/sci/engine/kstring.cpp
engines/sci/engine/savegame.cpp
engines/sci/engine/script_patches.cpp
engines/sci/engine/script_patches.h
engines/sci/engine/seg_manager.cpp
engines/sci/engine/state.cpp
engines/sci/engine/workarounds.cpp
engines/sci/event.cpp
engines/sci/graphics/controls16.cpp
engines/sci/graphics/controls16.h
engines/sci/graphics/cursor.cpp
engines/sci/graphics/font.cpp
engines/sci/graphics/font.h
engines/sci/graphics/frameout.cpp
engines/sci/graphics/paint16.cpp
engines/sci/graphics/paint16.h
engines/sci/graphics/paint32.cpp
engines/sci/graphics/palette.cpp
engines/sci/graphics/palette.h
engines/sci/graphics/picture.cpp
engines/sci/graphics/portrait.cpp
engines/sci/graphics/portrait.h
engines/sci/graphics/ports.cpp
engines/sci/graphics/screen.cpp
engines/sci/graphics/screen.h
engines/sci/graphics/text16.cpp
engines/sci/graphics/text16.h
engines/sci/graphics/transitions.cpp
engines/sci/graphics/view.cpp
engines/sci/module.mk
engines/sci/parser/said.cpp
engines/sci/parser/vocabulary.cpp
engines/sci/resource.cpp
engines/sci/resource.h
engines/sci/resource_audio.cpp
engines/sci/sci.cpp
engines/sci/sci.h
engines/sci/sound/drivers/midi.cpp
engines/sci/sound/music.cpp
engines/sci/sound/music.h
engines/scumm/POTFILES
engines/scumm/charset.cpp
engines/scumm/charset.h
engines/scumm/detection.cpp
engines/scumm/detection.h
engines/scumm/detection_tables.h
engines/scumm/dialogs.cpp
engines/scumm/file.cpp
engines/scumm/file.h
engines/scumm/he/sprite_he.cpp
engines/scumm/input.cpp
engines/scumm/module.mk
engines/scumm/nut_renderer.cpp
engines/scumm/object.cpp
engines/scumm/players/player_ad.cpp
engines/scumm/players/player_mac.cpp
engines/scumm/saveload.cpp
engines/scumm/script.cpp
engines/scumm/script_v5.cpp
engines/scumm/scumm-md5.h
engines/scumm/scumm.cpp
engines/scumm/scumm.h
engines/scumm/smush/smush_font.cpp
engines/scumm/sound.cpp
engines/scumm/sound.h
engines/scumm/vars.cpp
engines/sword1/POTFILES
engines/sword1/animation.cpp
engines/sword1/console.cpp
engines/sword1/console.h
engines/sword1/sound.cpp
engines/sword1/sound.h
engines/sword1/sword1.cpp
engines/sword1/sword1.h
engines/sword2/animation.cpp
engines/sword25/gfx/animation.cpp
engines/sword25/gfx/bitmapresource.h
engines/sword25/gfx/dynamicbitmap.cpp
engines/sword25/gfx/graphicengine.cpp
engines/sword25/gfx/image/image.h
engines/sword25/gfx/image/imgloader.cpp
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/gfx/image/renderedimage.h
engines/sword25/gfx/image/swimage.h
engines/sword25/gfx/image/vectorimage.h
engines/sword25/gfx/image/vectorimagerenderer.cpp
engines/sword25/gfx/renderobjectmanager.cpp
engines/sword25/gfx/staticbitmap.cpp
engines/sword25/gfx/text.cpp
engines/sword25/kernel/persistenceservice.cpp
engines/sword25/sword25.cpp
engines/sword25/util/pluto/pluto.cpp
engines/testbed/sound.cpp
engines/tinsel/tinsel.cpp
engines/toltecs/detection.cpp
engines/tony/game.cpp
engines/tony/gfxcore.cpp
engines/tony/mpal/lzo.cpp
engines/tony/window.cpp
engines/toon/character.cpp
engines/toon/state.cpp
engines/toon/toon.cpp
engines/touche/detection.cpp
engines/tsage/blue_force/blueforce_dialogs.cpp
engines/tsage/debugger.cpp
engines/tsage/debugger.h
engines/tsage/module.mk
engines/tsage/ringworld/ringworld_dialogs.cpp
engines/tsage/ringworld/ringworld_scenes10.cpp
engines/tsage/ringworld2/ringworld2_logic.cpp
engines/tsage/ringworld2/ringworld2_logic.h
engines/tsage/ringworld2/ringworld2_scenes0.cpp
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/tsage/ringworld2/ringworld2_scenes1.h
engines/tsage/ringworld2/ringworld2_scenes3.cpp
engines/tsage/sound.cpp
engines/voyeur/configure.engine
engines/voyeur/files_threads.cpp
engines/voyeur/voyeur.cpp
engines/wintermute/base/base_engine.cpp
engines/wintermute/base/base_engine.h
engines/wintermute/base/base_file_manager.cpp
engines/wintermute/base/base_file_manager.h
engines/wintermute/base/base_frame.cpp
engines/wintermute/base/base_frame.h
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_game.h
engines/wintermute/base/base_game_settings.cpp
engines/wintermute/base/base_game_settings.h
engines/wintermute/base/base_keyboard_state.cpp
engines/wintermute/base/base_object.cpp
engines/wintermute/base/base_object.h
engines/wintermute/base/base_persistence_manager.cpp
engines/wintermute/base/base_sprite.cpp
engines/wintermute/base/base_sprite.h
engines/wintermute/base/base_string_table.cpp
engines/wintermute/base/base_string_table.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/base_sub_frame.h
engines/wintermute/base/font/base_font_truetype.cpp
engines/wintermute/base/gfx/base_image.cpp
engines/wintermute/base/gfx/base_renderer.h
engines/wintermute/base/gfx/base_surface.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.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/base/gfx/osystem/render_ticket.h
engines/wintermute/base/sound/base_sound.cpp
engines/wintermute/base/sound/base_sound_buffer.cpp
engines/wintermute/base/sound/base_sound_buffer.h
engines/wintermute/base/sound/base_sound_manager.cpp
engines/wintermute/dcgf.h
engines/wintermute/dctypes.h
engines/wintermute/detection.cpp
engines/wintermute/detection_tables.h
engines/wintermute/math/rect32.h
engines/wintermute/module.mk
engines/wintermute/utils/utils.cpp
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
engines/wintermute/wintermute.cpp
engines/wintermute/wintermute.h
engines/zvision/fonts/truetype_font.cpp
graphics/VectorRenderer.h
graphics/VectorRendererSpec.cpp
graphics/VectorRendererSpec.h
graphics/conversion.h
graphics/font.cpp
graphics/font.h
graphics/fontman.h
graphics/fonts/ttf.cpp
graphics/module.mk
graphics/pixelformat.h
graphics/surface.h
gui/ThemeEngine.h
gui/about.cpp
gui/browser_osx.mm
gui/credits.h
gui/debugger.h
gui/gui-manager.cpp
gui/launcher.cpp
gui/options.cpp
gui/saveload-dialog.cpp
gui/themes/default.inc
gui/themes/scummclassic.zip
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummmodern.zip
gui/themes/scummmodern/scummmodern_layout.stx
gui/themes/translations.dat
gui/widgets/edittext.cpp
gui/widgets/tab.h
image/codecs/cinepak.cpp
image/codecs/mpeg.h
image/iff.cpp
image/image_decoder.h
image/tga.cpp
po/be_BY.po
po/ca_ES.po
po/cs_CZ.po
po/da_DA.po
po/de_DE.po
po/es_ES.po
po/eu.po
po/fi_FI.po
po/fr_FR.po
po/gl_ES.po
po/hu_HU.po
po/it_IT.po
po/nb_NO.po
po/nn_NO.po
po/pl_PL.po
po/pt_BR.po
po/ru_RU.po
po/scummvm.pot
po/se_SE.po
po/uk_UA.po
ports.mk
test/common/rendermode.h
video/avi_decoder.cpp
video/avi_decoder.h
video/bink_decoder.cpp
video/video_decoder.cpp
video/video_decoder.h
Commit: f7b2cd0a7d067e39ed7973de75d5ce68c5464bc4
https://github.com/scummvm/scummvm/commit/f7b2cd0a7d067e39ed7973de75d5ce68c5464bc4
Author: Kevin Becker (khbecker at gmail.com)
Date: 2014-11-19T07:44:03-05:00
Commit Message:
ZVISION: Added detection for Zork Grand Inquisitor English Demo.
Changed paths:
engines/zvision/detection.cpp
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 1492ade..bd45b39 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -87,6 +87,20 @@ static const ZVisionGameDescription gameDescriptions[] = {
},
{
+ // Zork Grand Inquisitor English demo version
+ {
+ "zgi",
+ "Demo",
+ AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ GID_GRANDINQUISITOR
+ },
+
+ {
AD_TABLE_END_MARKER,
GID_NONE
}
Commit: b12b1e1d256219364860db51977dd6bca7424ed1
https://github.com/scummvm/scummvm/commit/b12b1e1d256219364860db51977dd6bca7424ed1
Author: Kevin Becker (khbecker at gmail.com)
Date: 2014-11-19T07:44:23-05:00
Commit Message:
ZVISION: Added detection for Zork Nemesis English Demo.
Changed paths:
engines/zvision/detection.cpp
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index bd45b39..4f1d7fe 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -73,6 +73,20 @@ static const ZVisionGameDescription gameDescriptions[] = {
},
{
+ // Zork Nemesis English demo version
+ {
+ "znemesis",
+ "Demo",
+ AD_ENTRY1s("SCRIPTS.ZFS", "64f1e881394e9462305104f99513c833", 380539),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ GID_NEMESIS
+ },
+
+ {
// Zork Grand Inquisitor English version
{
"zgi",
Commit: deeeb0646f5c374d0f7635cb5897e2df2962ad37
https://github.com/scummvm/scummvm/commit/deeeb0646f5c374d0f7635cb5897e2df2962ad37
Author: Kevin Becker (khbecker at gmail.com)
Date: 2014-11-19T07:44:44-05:00
Commit Message:
ZVISION: Added detection for Zork Grand Inquisitor English DVD version.
Changed paths:
engines/zvision/detection.cpp
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 4f1d7fe..cd69655 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -87,10 +87,10 @@ static const ZVisionGameDescription gameDescriptions[] = {
},
{
- // Zork Grand Inquisitor English version
+ // Zork Grand Inquisitor English CD version
{
"zgi",
- 0,
+ "CD",
AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944),
Common::EN_ANY,
Common::kPlatformWindows,
@@ -115,6 +115,20 @@ static const ZVisionGameDescription gameDescriptions[] = {
},
{
+ // Zork Grand Inquisitor English DVD version
+ {
+ "zgi",
+ "DVD",
+ AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ GID_GRANDINQUISITOR
+ },
+
+ {
AD_TABLE_END_MARKER,
GID_NONE
}
Commit: 03d33e82bc15100584bec38cfa3d877a4882bcab
https://github.com/scummvm/scummvm/commit/03d33e82bc15100584bec38cfa3d877a4882bcab
Author: Anton (Zidane) (llancelot7 at gmail.com)
Date: 2014-11-19T21:58:07+06:00
Commit Message:
Merge pull request #2 from khbecker/zvision
ZVISION: (SECOND ATTEMPT) Add detection for Zork Nemesis and Zork Grand Inquisitor demos and Zork Grand Inquisitor DVD version
Changed paths:
engines/zvision/detection.cpp
Commit: d5f7a1dc03f2a38774ad1c8dd6741bb9c6fb9848
https://github.com/scummvm/scummvm/commit/d5f7a1dc03f2a38774ad1c8dd6741bb9c6fb9848
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-20T14:02:08+06:00
Commit Message:
ZVISION: Implement forgotten setVenus for controls
Changed paths:
engines/zvision/scripting/control.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/fist_control.cpp
engines/zvision/scripting/controls/hotmov_control.cpp
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/paint_control.cpp
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/safe_control.cpp
engines/zvision/scripting/controls/slot_control.cpp
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index c746f00..9c81569 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "zvision/scripting/control.h"
+#include "zvision/scripting/script_manager.h"
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
@@ -129,4 +130,10 @@ void Control::getParams(const Common::String &input_str, Common::String ¶met
values = Common::String(chrs + lbr + 1, chrs + rbr);
}
+void Control::setVenus() {
+ if (_venus_id >= 0)
+ if (_engine->getScriptManager()->getStateValue(_venus_id) > 0)
+ _engine->getScriptManager()->setStateValue(StateKey_Venus, _venus_id);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 28c7348..b784a66 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -54,8 +54,7 @@ public:
CONTROL_PAINT
};
- Control() : _engine(0), _key(0) {}
- Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type) {}
+ Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venus_id(-1) {}
virtual ~Control() {}
uint32 getKey() {
@@ -121,6 +120,7 @@ public:
virtual bool process(uint32 deltaTimeInMillis) {
return false;
}
+ void setVenus();
protected:
ZVision *_engine;
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index 4779c5d..185bea0 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -155,7 +155,7 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos);
if (n_fist >= 0) {
- //ctrl_setvenus(ct);
+ setVenus();
uint32 oldStatus = _fiststatus;
_fiststatus ^= (1 << n_fist);
@@ -172,8 +172,6 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
}
_engine->getScriptManager()->setStateValue(_key, _fiststatus);
-
- //_engine->getScriptManager()->FlushMouseBtn(SDL_BUTTON_LEFT);
}
return false;
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index b39292f..6969ee1 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -158,6 +158,7 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common:
if (_cycle < _num_cycles) {
if (_frames[_cur_frame].contains(backgroundImageSpacePos)) {
+ setVenus();
_engine->getScriptManager()->setStateValue(_key, 1);
return true;
}
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index f8acdbd..442c6cb 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -103,6 +103,8 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
} else if (param.matchString("focus", true)) {
_focused = true;
_engine->getScriptManager()->setFocusControlKey(_key);
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
}
line = stream.readLine();
@@ -119,10 +121,13 @@ bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
if (!_readOnly) {
// Save
_engine->getScriptManager()->focusControl(_key);
+ setVenus();
} else {
// Restore
- if (_currentInputText.size())
+ if (_currentInputText.size()) {
+ setVenus();
_enterPressed = true;
+ }
}
}
return false;
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 9b665ff..a9836b3 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -141,6 +141,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
_hotspotDelta.x = x;
_hotspotDelta.y = y;
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
} else {
uint frameNumber;
uint x, y;
@@ -191,6 +193,7 @@ bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common
return false;
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ setVenus();
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
}
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
index 2891f1b..54c02a2 100644
--- a/engines/zvision/scripting/controls/paint_control.cpp
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -142,6 +142,7 @@ bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common
int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
if (eligeblity(mouse_item)) {
+ setVenus();
_mouseDown = true;
}
}
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 03df4b7..561dd1d 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -74,8 +74,8 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
} else if (values.equalsIgnoreCase("double")) {
// Not used
}
- } else if (param.matchString("venus_id*", true)) {
- // Not used
+ } else if (param.matchString("venus_id", true)) {
+ _venus_id = atoi(values.c_str());
}
line = stream.readLine();
@@ -100,6 +100,7 @@ bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com
return false;
if (contain(backgroundImageSpacePos)) {
+ setVenus();
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
@@ -116,6 +117,7 @@ bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const C
return false;
if (contain(backgroundImageSpacePos)) {
+ setVenus();
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index ba80914..9df61ce 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -179,6 +179,7 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
if (_rectangle.contains(backgroundImageSpacePos)) {
int32 mR = backgroundImageSpacePos.sqrDist(_center);
if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) {
+ setVenus();
Common::Point tmp = backgroundImageSpacePos - _center;
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
index f78061a..46ee320 100644
--- a/engines/zvision/scripting/controls/slot_control.cpp
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -121,7 +121,7 @@ bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
return false;
if (_hotspot.contains(backgroundImageSpacePos)) {
- //ctrl_setvenus(ct);
+ setVenus();
int item = _engine->getScriptManager()->getStateValue(_key);
int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
Commit: 5b352da304931bafcfcddbe08461488335c7ad57
https://github.com/scummvm/scummvm/commit/5b352da304931bafcfcddbe08461488335c7ad57
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-20T14:48:24+06:00
Commit Message:
ZVISION: More CamelCase and a bit of comments cleanup
Changed paths:
engines/zvision/animation/meta_animation.cpp
engines/zvision/animation/meta_animation.h
engines/zvision/core/events.cpp
engines/zvision/core/menu.cpp
engines/zvision/core/menu.h
engines/zvision/core/midi.cpp
engines/zvision/core/midi.h
engines/zvision/core/save_manager.cpp
engines/zvision/core/search_manager.cpp
engines/zvision/core/search_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/fonts/truetype_font.h
engines/zvision/graphics/effects/fog.h
engines/zvision/graphics/effects/wave.cpp
engines/zvision/graphics/effects/wave.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/control.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/fist_control.cpp
engines/zvision/scripting/controls/fist_control.h
engines/zvision/scripting/controls/hotmov_control.cpp
engines/zvision/scripting/controls/hotmov_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/input_control.h
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/lever_control.h
engines/zvision/scripting/controls/paint_control.cpp
engines/zvision/scripting/controls/paint_control.h
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/safe_control.cpp
engines/zvision/scripting/controls/safe_control.h
engines/zvision/scripting/controls/save_control.cpp
engines/zvision/scripting/controls/save_control.h
engines/zvision/scripting/controls/slot_control.cpp
engines/zvision/scripting/controls/slot_control.h
engines/zvision/scripting/inventory.cpp
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/scripting/sidefx/animation_node.cpp
engines/zvision/scripting/sidefx/animation_node.h
engines/zvision/scripting/sidefx/distort_node.cpp
engines/zvision/scripting/sidefx/distort_node.h
engines/zvision/scripting/sidefx/music_node.cpp
engines/zvision/scripting/sidefx/music_node.h
engines/zvision/scripting/sidefx/ttytext_node.h
engines/zvision/subtitles/subtitles.cpp
engines/zvision/text/text.cpp
engines/zvision/text/text.h
engines/zvision/utility/win_keys.cpp
engines/zvision/utility/win_keys.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp
index 1ea6df6..2e549ec 100644
--- a/engines/zvision/animation/meta_animation.cpp
+++ b/engines/zvision/animation/meta_animation.cpp
@@ -39,7 +39,7 @@ namespace ZVision {
MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
: _fileType(RLF),
- _cur_frame(NULL) {
+ _curFrame(NULL) {
Common::String tmpFileName = fileName;
tmpFileName.toLowercase();
if (tmpFileName.hasSuffix(".rlf")) {
@@ -102,11 +102,11 @@ void MetaAnimation::seekToFrame(int frameNumber) {
const Graphics::Surface *MetaAnimation::decodeNextFrame() {
if (_fileType == RLF)
- _cur_frame = _animation.rlf->decodeNextFrame();
+ _curFrame = _animation.rlf->decodeNextFrame();
else
- _cur_frame = _animation.avi->decodeNextFrame();
+ _curFrame = _animation.avi->decodeNextFrame();
- return _cur_frame;
+ return _curFrame;
}
const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
@@ -114,12 +114,12 @@ const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
frameNumber = frameCount() - 1;
if (_fileType == RLF) {
- _cur_frame = _animation.rlf->getFrameData(frameNumber);
- return _cur_frame;
+ _curFrame = _animation.rlf->getFrameData(frameNumber);
+ return _curFrame;
} else {
_animation.avi->seekToFrame(frameNumber);
- _cur_frame = _animation.avi->decodeNextFrame();
- return _cur_frame;
+ _curFrame = _animation.avi->decodeNextFrame();
+ return _curFrame;
}
}
diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h
index 2ea0031..4795a38 100644
--- a/engines/zvision/animation/meta_animation.h
+++ b/engines/zvision/animation/meta_animation.h
@@ -57,7 +57,7 @@ public:
int32 start;
int32 stop;
int32 loop;
- int32 _cur_frm;
+ int32 _curFrame;
int32 _delay;
Graphics::Surface *_scaled;
};
@@ -77,7 +77,7 @@ private:
FileType _fileType;
int32 _frmDelay;
- const Graphics::Surface *_cur_frame;
+ const Graphics::Surface *_curFrame;
public:
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 0d38e08..873cdb0 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -170,7 +170,7 @@ void ZVision::processEvents() {
_scriptManager->setStateValue(StateKey_RMouse, 1);
if (getGameId() == GID_NEMESIS)
- _scriptManager->invertory_cycle();
+ _scriptManager->inventoryCycle();
break;
case Common::EVENT_RBUTTONUP:
diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp
index 57a1983..5816b3f 100644
--- a/engines/zvision/core/menu.cpp
+++ b/engines/zvision/core/menu.cpp
@@ -43,14 +43,14 @@ enum {
menu_MAIN_EXIT = 3
};
-menuHandler::menuHandler(ZVision *engine) {
+MenuHandler::MenuHandler(ZVision *engine) {
_engine = engine;
- menu_bar_flag = 0xFFFF;
+ menuBarFlag = 0xFFFF;
}
-menuZgi::menuZgi(ZVision *engine) :
- menuHandler(engine) {
- menu_mousefocus = -1;
+MenuZGI::MenuZGI(ZVision *engine) :
+ MenuHandler(engine) {
+ menuMouseFocus = -1;
inmenu = false;
scrolled[0] = false;
scrolled[1] = false;
@@ -58,7 +58,7 @@ menuZgi::menuZgi(ZVision *engine) :
scrollPos[0] = 0.0;
scrollPos[1] = 0.0;
scrollPos[2] = 0.0;
- mouse_on_item = -1;
+ mouseOnItem = -1;
char buf[24];
for (int i = 1; i < 4; i++) {
@@ -77,17 +77,17 @@ menuZgi::menuZgi(ZVision *engine) :
for (int i = 0; i < 50; i++) {
items[i][0] = NULL;
items[i][1] = NULL;
- item_id[i] = 0;
+ itemId[i] = 0;
}
for (int i = 0; i < 12; i++) {
magic[i][0] = NULL;
magic[i][1] = NULL;
- magic_id[i] = 0;
+ magicId[i] = 0;
}
}
-menuZgi::~menuZgi() {
+MenuZGI::~MenuZGI() {
for (int i = 0; i < 3; i++) {
menuback[i][0].free();
menuback[i][1].free();
@@ -118,25 +118,25 @@ menuZgi::~menuZgi() {
}
}
-void menuZgi::onMouseUp(const Common::Point &Pos) {
+void MenuZGI::onMouseUp(const Common::Point &Pos) {
if (Pos.y < 40) {
- switch (menu_mousefocus) {
+ switch (menuMouseFocus) {
case menu_ITEM:
- if (menu_bar_flag & menuBar_Items) {
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
+ if (menuBarFlag & menuBar_Items) {
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
- int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
- if (mouse_item >= 0 && mouse_item < 0xE0) {
- _engine->getScriptManager()->invertory_drop(mouse_item);
- _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i));
- _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item);
+ int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (mouseItem >= 0 && mouseItem < 0xE0) {
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
+ _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i));
+ _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem);
redraw = true;
}
@@ -146,7 +146,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
break;
case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic) {
+ if (menuBarFlag & menuBar_Magic) {
for (int i = 0; i < 12; i++) {
uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
@@ -169,7 +169,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
case menu_MAIN:
// Exit
- if (menu_bar_flag & menuBar_Exit)
+ if (menuBarFlag & menuBar_Exit)
if (Common::Rect(320 + 135,
scrollPos[menu_MAIN],
320 + 135 + 135,
@@ -178,7 +178,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
}
// Settings
- if (menu_bar_flag & menuBar_Settings)
+ if (menuBarFlag & menuBar_Settings)
if (Common::Rect(320 ,
scrollPos[menu_MAIN],
320 + 135,
@@ -187,7 +187,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
}
// Load
- if (menu_bar_flag & menuBar_Restore)
+ if (menuBarFlag & menuBar_Restore)
if (Common::Rect(320 - 135,
scrollPos[menu_MAIN],
320,
@@ -196,7 +196,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
}
// Save
- if (menu_bar_flag & menuBar_Save)
+ if (menuBarFlag & menuBar_Save)
if (Common::Rect(320 - 135 * 2,
scrollPos[menu_MAIN],
320 - 135,
@@ -208,133 +208,133 @@ void menuZgi::onMouseUp(const Common::Point &Pos) {
}
}
-void menuZgi::onMouseMove(const Common::Point &Pos) {
+void MenuZGI::onMouseMove(const Common::Point &Pos) {
if (Pos.y < 40) {
if (!inmenu)
redraw = true;
inmenu = true;
- switch (menu_mousefocus) {
+ switch (menuMouseFocus) {
case menu_ITEM:
- if (menu_bar_flag & menuBar_Items) {
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
- else if (item_count > 50)
- item_count = 50;
+ if (menuBarFlag & menuBar_Items) {
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
+ else if (itemCount > 50)
+ itemCount = 50;
- int last_item = mouse_on_item;
+ int lastItem = mouseOnItem;
- mouse_on_item = -1;
+ mouseOnItem = -1;
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0,
scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) {
- mouse_on_item = i;
+ mouseOnItem = i;
break;
}
}
- if (last_item != mouse_on_item)
- if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) ||
- _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item))
+ if (lastItem != mouseOnItem)
+ if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem))
redraw = true;
}
break;
case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic) {
- int last_item = mouse_on_item;
- mouse_on_item = -1;
+ if (menuBarFlag & menuBar_Magic) {
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
for (int i = 0; i < 12; i++) {
if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0,
668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) {
- mouse_on_item = i;
+ mouseOnItem = i;
break;
}
}
- if (last_item != mouse_on_item)
- if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) ||
- _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item))
+ if (lastItem != mouseOnItem)
+ if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem))
redraw = true;
}
break;
case menu_MAIN: {
- int last_item = mouse_on_item;
- mouse_on_item = -1;
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
// Exit
- if (menu_bar_flag & menuBar_Exit)
+ if (menuBarFlag & menuBar_Exit)
if (Common::Rect(320 + 135,
scrollPos[menu_MAIN],
320 + 135 + 135,
scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_EXIT;
+ mouseOnItem = menu_MAIN_EXIT;
}
// Settings
- if (menu_bar_flag & menuBar_Settings)
+ if (menuBarFlag & menuBar_Settings)
if (Common::Rect(320 ,
scrollPos[menu_MAIN],
320 + 135,
scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_PREF;
+ mouseOnItem = menu_MAIN_PREF;
}
// Load
- if (menu_bar_flag & menuBar_Restore)
+ if (menuBarFlag & menuBar_Restore)
if (Common::Rect(320 - 135,
scrollPos[menu_MAIN],
320,
scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_REST;
+ mouseOnItem = menu_MAIN_REST;
}
// Save
- if (menu_bar_flag & menuBar_Save)
+ if (menuBarFlag & menuBar_Save)
if (Common::Rect(320 - 135 * 2,
scrollPos[menu_MAIN],
320 - 135,
scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_SAVE;
+ mouseOnItem = menu_MAIN_SAVE;
}
- if (last_item != mouse_on_item)
+ if (lastItem != mouseOnItem)
redraw = true;
}
break;
default:
- int cur_menu = menu_mousefocus;
+ int cur_menu = menuMouseFocus;
if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main
- menu_mousefocus = menu_MAIN;
+ menuMouseFocus = menu_MAIN;
scrolled[menu_MAIN] = false;
scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
}
- if (menu_bar_flag & menuBar_Magic)
+ if (menuBarFlag & menuBar_Magic)
if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
- menu_mousefocus = menu_MAGIC;
+ menuMouseFocus = menu_MAGIC;
scrolled[menu_MAGIC] = false;
scrollPos[menu_MAGIC] = 28;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
}
- if (menu_bar_flag & menuBar_Items)
+ if (menuBarFlag & menuBar_Items)
if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
- menu_mousefocus = menu_ITEM;
+ menuMouseFocus = menu_ITEM;
scrolled[menu_ITEM] = false;
scrollPos[menu_ITEM] = 28 - 600;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
}
- if (cur_menu != menu_mousefocus)
+ if (cur_menu != menuMouseFocus)
clean = true;
break;
@@ -345,18 +345,18 @@ void menuZgi::onMouseMove(const Common::Point &Pos) {
inmenu = false;
if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
- menu_mousefocus = -1;
+ menuMouseFocus = -1;
}
}
-void menuZgi::process(uint32 deltatime) {
+void MenuZGI::process(uint32 deltatime) {
if (clean) {
_engine->getRenderManager()->clearMenuSurface();
clean = false;
}
- switch (menu_mousefocus) {
+ switch (menuMouseFocus) {
case menu_ITEM:
- if (menu_bar_flag & menuBar_Items)
+ if (menuBarFlag & menuBar_Items)
if (!scrolled[menu_ITEM]) {
redraw = true;
float scrl = 600.0 * (deltatime / 1000.0);
@@ -374,31 +374,31 @@ void menuZgi::process(uint32 deltatime) {
if (redraw) {
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0);
- int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
- if (item_count == 0)
- item_count = 20;
- else if (item_count > 50)
- item_count = 50;
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
+ else if (itemCount > 50)
+ itemCount = 50;
- for (int i = 0; i < item_count; i++) {
- int itemspace = (600 - 28) / item_count;
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
bool inrect = false;
- if (mouse_on_item == i)
+ if (mouseOnItem == i)
inrect = true;
- uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
+ uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
- if (cur_item_id != 0) {
- if (item_id[i] != cur_item_id) {
+ if (curItemId != 0) {
+ if (itemId[i] != curItemId) {
char buf[16];
- sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ sprintf(buf, "gmzwu%2.2x1.tga", curItemId);
items[i][0] = _engine->getRenderManager()->loadImage(buf, false);
- sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ sprintf(buf, "gmzxu%2.2x1.tga", curItemId);
items[i][1] = _engine->getRenderManager()->loadImage(buf, false);
- item_id[i] = cur_item_id;
+ itemId[i] = curItemId;
}
if (inrect)
@@ -417,7 +417,7 @@ void menuZgi::process(uint32 deltatime) {
delete items[i][1];
items[i][1] = NULL;
}
- item_id[i] = 0;
+ itemId[i] = 0;
}
}
@@ -426,7 +426,7 @@ void menuZgi::process(uint32 deltatime) {
break;
case menu_MAGIC:
- if (menu_bar_flag & menuBar_Magic)
+ if (menuBarFlag & menuBar_Magic)
if (!scrolled[menu_MAGIC]) {
redraw = true;
float scrl = 600.0 * (deltatime / 1000.0);
@@ -447,25 +447,25 @@ void menuZgi::process(uint32 deltatime) {
for (int i = 0; i < 12; i++) {
bool inrect = false;
- if (mouse_on_item == i)
+ if (mouseOnItem == i)
inrect = true;
- uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
- if (cur_item_id) {
+ uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ if (curItemId) {
if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
- cur_item_id = 0xEE + i;
+ curItemId = 0xEE + i;
else
- cur_item_id = 0xE0 + i;
+ curItemId = 0xE0 + i;
}
- if (cur_item_id != 0) {
- if (item_id[i] != cur_item_id) {
+ if (curItemId != 0) {
+ if (itemId[i] != curItemId) {
char buf[16];
- sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id);
+ sprintf(buf, "gmzwu%2.2x1.tga", curItemId);
magic[i][0] = _engine->getRenderManager()->loadImage(buf, false);
- sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id);
+ sprintf(buf, "gmzxu%2.2x1.tga", curItemId);
magic[i][1] = _engine->getRenderManager()->loadImage(buf, false);
- magic_id[i] = cur_item_id;
+ magicId[i] = curItemId;
}
if (inrect)
@@ -484,7 +484,7 @@ void menuZgi::process(uint32 deltatime) {
delete magic[i][1];
magic[i][1] = NULL;
}
- magic_id[i] = 0;
+ magicId[i] = 0;
}
}
redraw = false;
@@ -509,26 +509,26 @@ void menuZgi::process(uint32 deltatime) {
if (redraw) {
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
- if (menu_bar_flag & menuBar_Exit) {
- if (mouse_on_item == menu_MAIN_EXIT)
+ if (menuBarFlag & menuBar_Exit) {
+ if (mouseOnItem == menu_MAIN_EXIT)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Settings) {
- if (mouse_on_item == menu_MAIN_PREF)
+ if (menuBarFlag & menuBar_Settings) {
+ if (mouseOnItem == menu_MAIN_PREF)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Restore) {
- if (mouse_on_item == menu_MAIN_REST)
+ if (menuBarFlag & menuBar_Restore) {
+ if (mouseOnItem == menu_MAIN_REST)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
}
- if (menu_bar_flag & menuBar_Save) {
- if (mouse_on_item == menu_MAIN_SAVE)
+ if (menuBarFlag & menuBar_Save) {
+ if (mouseOnItem == menu_MAIN_SAVE)
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
else
_engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]);
@@ -541,10 +541,10 @@ void menuZgi::process(uint32 deltatime) {
if (inmenu) {
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0);
- if (menu_bar_flag & menuBar_Items)
+ if (menuBarFlag & menuBar_Items)
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0);
- if (menu_bar_flag & menuBar_Magic)
+ if (menuBarFlag & menuBar_Magic)
_engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0);
}
redraw = false;
@@ -554,12 +554,12 @@ void menuZgi::process(uint32 deltatime) {
}
-menuNem::menuNem(ZVision *engine) :
- menuHandler(engine) {
+MenuNemesis::MenuNemesis(ZVision *engine) :
+ MenuHandler(engine) {
inmenu = false;
scrolled = false;
scrollPos = 0.0;
- mouse_on_item = -1;
+ mouseOnItem = -1;
char buf[24];
for (int i = 0; i < 4; i++)
@@ -573,7 +573,7 @@ menuNem::menuNem(ZVision *engine) :
frm = 0;
}
-menuNem::~menuNem() {
+MenuNemesis::~MenuNemesis() {
for (int i = 0; i < 4; i++)
for (int j = 0; j < 6; j++)
but[i][j].free();
@@ -583,10 +583,10 @@ menuNem::~menuNem() {
static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} };
-void menuNem::onMouseUp(const Common::Point &Pos) {
+void MenuNemesis::onMouseUp(const Common::Point &Pos) {
if (Pos.y < 40) {
// Exit
- if (menu_bar_flag & menuBar_Exit)
+ if (menuBarFlag & menuBar_Exit)
if (Common::Rect(buts[3][1],
scrollPos,
buts[3][0] + buts[3][1],
@@ -597,7 +597,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) {
}
// Settings
- if (menu_bar_flag & menuBar_Settings)
+ if (menuBarFlag & menuBar_Settings)
if (Common::Rect(buts[2][1],
scrollPos,
buts[2][0] + buts[2][1],
@@ -608,7 +608,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) {
}
// Load
- if (menu_bar_flag & menuBar_Restore)
+ if (menuBarFlag & menuBar_Restore)
if (Common::Rect(buts[1][1],
scrollPos,
buts[1][0] + buts[1][1],
@@ -619,7 +619,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) {
}
// Save
- if (menu_bar_flag & menuBar_Save)
+ if (menuBarFlag & menuBar_Save)
if (Common::Rect(buts[0][1],
scrollPos,
buts[0][0] + buts[0][1],
@@ -631,7 +631,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) {
}
}
-void menuNem::onMouseMove(const Common::Point &Pos) {
+void MenuNemesis::onMouseMove(const Common::Point &Pos) {
if (Pos.y < 40) {
inmenu = true;
@@ -639,46 +639,46 @@ void menuNem::onMouseMove(const Common::Point &Pos) {
if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2)
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
- int last_item = mouse_on_item;
- mouse_on_item = -1;
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
// Exit
- if (menu_bar_flag & menuBar_Exit)
+ if (menuBarFlag & menuBar_Exit)
if (Common::Rect(buts[3][1],
scrollPos,
buts[3][0] + buts[3][1],
scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_EXIT;
+ mouseOnItem = menu_MAIN_EXIT;
}
// Settings
- if (menu_bar_flag & menuBar_Settings)
+ if (menuBarFlag & menuBar_Settings)
if (Common::Rect(buts[2][1],
scrollPos,
buts[2][0] + buts[2][1],
scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_PREF;
+ mouseOnItem = menu_MAIN_PREF;
}
// Load
- if (menu_bar_flag & menuBar_Restore)
+ if (menuBarFlag & menuBar_Restore)
if (Common::Rect(buts[1][1],
scrollPos,
buts[1][0] + buts[1][1],
scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_REST;
+ mouseOnItem = menu_MAIN_REST;
}
// Save
- if (menu_bar_flag & menuBar_Save)
+ if (menuBarFlag & menuBar_Save)
if (Common::Rect(buts[0][1],
scrollPos,
buts[0][0] + buts[0][1],
scrollPos + 32).contains(Pos)) {
- mouse_on_item = menu_MAIN_SAVE;
+ mouseOnItem = menu_MAIN_SAVE;
}
- if (last_item != mouse_on_item) {
+ if (lastItem != mouseOnItem) {
redraw = true;
frm = 0;
delay = 200;
@@ -687,11 +687,11 @@ void menuNem::onMouseMove(const Common::Point &Pos) {
inmenu = false;
if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
- mouse_on_item = -1;
+ mouseOnItem = -1;
}
}
-void menuNem::process(uint32 deltatime) {
+void MenuNemesis::process(uint32 deltatime) {
if (inmenu) {
if (!scrolled) {
float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
@@ -708,7 +708,7 @@ void menuNem::process(uint32 deltatime) {
scrollPos = 0;
}
- if (mouse_on_item != -1) {
+ if (mouseOnItem != -1) {
delay -= deltatime;
if (delay <= 0 && frm < 4) {
delay = 200;
@@ -720,20 +720,20 @@ void menuNem::process(uint32 deltatime) {
if (redraw) {
_engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
- if (menu_bar_flag & menuBar_Exit)
- if (mouse_on_item == menu_MAIN_EXIT)
+ if (menuBarFlag & menuBar_Exit)
+ if (mouseOnItem == menu_MAIN_EXIT)
_engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
- if (menu_bar_flag & menuBar_Settings)
- if (mouse_on_item == menu_MAIN_PREF)
+ if (menuBarFlag & menuBar_Settings)
+ if (mouseOnItem == menu_MAIN_PREF)
_engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
- if (menu_bar_flag & menuBar_Restore)
- if (mouse_on_item == menu_MAIN_REST)
+ if (menuBarFlag & menuBar_Restore)
+ if (mouseOnItem == menu_MAIN_REST)
_engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
- if (menu_bar_flag & menuBar_Save)
- if (mouse_on_item == menu_MAIN_SAVE)
+ if (menuBarFlag & menuBar_Save)
+ if (mouseOnItem == menu_MAIN_SAVE)
_engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
redraw = false;
diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h
index c2ea822..62683de 100644
--- a/engines/zvision/core/menu.h
+++ b/engines/zvision/core/menu.h
@@ -40,30 +40,30 @@ enum menuBar {
menuBar_Magic = 0x200
};
-class menuHandler {
+class MenuHandler {
public:
- menuHandler(ZVision *engine);
- virtual ~menuHandler() {};
+ MenuHandler(ZVision *engine);
+ virtual ~MenuHandler() {};
virtual void onMouseMove(const Common::Point &Pos) {};
virtual void onMouseDown(const Common::Point &Pos) {};
virtual void onMouseUp(const Common::Point &Pos) {};
virtual void process(uint32 deltaTimeInMillis) {};
void setEnable(uint16 flags) {
- menu_bar_flag = flags;
+ menuBarFlag = flags;
}
uint16 getEnable() {
- return menu_bar_flag;
+ return menuBarFlag;
}
protected:
- uint16 menu_bar_flag;
+ uint16 menuBarFlag;
ZVision *_engine;
};
-class menuZgi: public menuHandler {
+class MenuZGI: public MenuHandler {
public:
- menuZgi(ZVision *engine);
- ~menuZgi();
+ MenuZGI(ZVision *engine);
+ ~MenuZGI();
void onMouseMove(const Common::Point &Pos);
void onMouseUp(const Common::Point &Pos);
void process(uint32 deltaTimeInMillis);
@@ -73,15 +73,15 @@ private:
Graphics::Surface *items[50][2];
- uint item_id[50];
+ uint itemId[50];
Graphics::Surface *magic[12][2];
- uint magic_id[12];
+ uint magicId[12];
- int menu_mousefocus;
+ int menuMouseFocus;
bool inmenu;
- int mouse_on_item;
+ int mouseOnItem;
bool scrolled[3];
float scrollPos[3];
@@ -97,10 +97,10 @@ private:
};
-class menuNem: public menuHandler {
+class MenuNemesis: public MenuHandler {
public:
- menuNem(ZVision *engine);
- ~menuNem();
+ MenuNemesis(ZVision *engine);
+ ~MenuNemesis();
void onMouseMove(const Common::Point &Pos);
void onMouseUp(const Common::Point &Pos);
void process(uint32 deltaTimeInMillis);
@@ -110,7 +110,7 @@ private:
bool inmenu;
- int mouse_on_item;
+ int mouseOnItem;
bool scrolled;
float scrollPos;
diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp
index 5cc8cd0..736be13 100644
--- a/engines/zvision/core/midi.cpp
+++ b/engines/zvision/core/midi.cpp
@@ -26,25 +26,25 @@
namespace ZVision {
-midiManager::midiManager() {
+MidiManager::MidiManager() {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB);
_driver = MidiDriver::createMidi(dev);
_driver->open();
}
-midiManager::~midiManager() {
+MidiManager::~MidiManager() {
stop();
_driver->close();
delete _driver;
}
-void midiManager::stop() {
+void MidiManager::stop() {
for (int8 i = 0; i < 16; i++)
if (_playChannels[i].playing)
noteOff(i);
}
-void midiManager::noteOn(int8 channel, int8 note, int8 velocity) {
+void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) {
assert(channel <= 15);
_playChannels[channel].playing = true;
@@ -52,7 +52,7 @@ void midiManager::noteOn(int8 channel, int8 note, int8 velocity) {
_driver->send(channel | (velocity << 16) | (note << 8) | 0x90);
}
-void midiManager::noteOff(int8 channel) {
+void MidiManager::noteOff(int8 channel) {
assert(channel <= 15);
if (_playChannels[channel].playing) {
@@ -61,26 +61,26 @@ void midiManager::noteOff(int8 channel) {
}
}
-int8 midiManager::getFreeChannel() {
+int8 MidiManager::getFreeChannel() {
for (int8 i = 0; i < 16; i++)
if (!_playChannels[i].playing)
return i;
return -1;
}
-void midiManager::setPan(int8 channel, int8 pan) {
+void MidiManager::setPan(int8 channel, int8 pan) {
assert(channel <= 15);
_driver->send(channel | (pan << 16) | 0xAB0);
}
-void midiManager::setVolume(int8 channel, int8 volume) {
+void MidiManager::setVolume(int8 channel, int8 volume) {
assert(channel <= 15);
_driver->send(channel | (volume << 16) | 0x7B0);
}
-void midiManager::setProgram(int8 channel, int8 prog) {
+void MidiManager::setProgram(int8 channel, int8 prog) {
assert(channel <= 15);
_driver->send(channel | (prog << 8) | 0xC0);
diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h
index 79f8ea3..a3bac19 100644
--- a/engines/zvision/core/midi.h
+++ b/engines/zvision/core/midi.h
@@ -27,10 +27,10 @@
namespace ZVision {
-class midiManager {
+class MidiManager {
public:
- midiManager();
- ~midiManager();
+ MidiManager();
+ ~MidiManager();
void stop();
void noteOn(int8 channel, int8 noteNumber, int8 velocity);
diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp
index 2797b94..9b36824 100644
--- a/engines/zvision/core/save_manager.cpp
+++ b/engines/zvision/core/save_manager.cpp
@@ -165,6 +165,7 @@ Common::Error SaveManager::loadGame(const Common::String &saveName) {
bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
uint32 tag = in->readUint32BE();
+ // Check if it's original savegame than fill header structure
if (tag == MKTAG('Z', 'N', 'S', 'G')) {
header.saveYear = 0;
header.saveMonth = 0;
@@ -216,7 +217,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea
Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
if (saveFile == NULL) {
- // Try to load standart save file
+ // Try to load standard save file
Common::String filename;
if (_engine->getGameId() == GID_GRANDINQUISITOR)
filename = Common::String::format("inqsav%u.sav", slot);
diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp
index fe99772..8350189 100644
--- a/engines/zvision/core/search_manager.cpp
+++ b/engines/zvision/core/search_manager.cpp
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#include "common/debug.h"
#include "zvision/core/search_manager.h"
@@ -29,18 +30,18 @@
namespace ZVision {
-sManager::sManager(const Common::String &root_path, int depth) {
- _root = root_path;
+SearchManager::SearchManager(const Common::String &rootPath, int depth) {
+ _root = rootPath;
if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/')
_root.deleteLastChar();
- Common::FSNode fs_node(_root);
+ Common::FSNode fsNode(_root);
- list_dir_recursive(dir_list, fs_node, depth);
+ listDirRecursive(dirList, fsNode, depth);
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end();)
+ for (Common::List<Common::String>::iterator it = dirList.begin(); it != dirList.end();)
if (it->size() == _root.size())
- it = dir_list.erase(it);
+ it = dirList.erase(it);
else if (it->size() > _root.size()) {
*it = Common::String(it->c_str() + _root.size() + 1);
it++;
@@ -48,7 +49,7 @@ sManager::sManager(const Common::String &root_path, int depth) {
it++;
}
-sManager::~sManager() {
+SearchManager::~SearchManager() {
Common::List<Common::Archive *>::iterator it = archList.begin();
while (it != archList.end()) {
delete *it;
@@ -58,20 +59,20 @@ sManager::~sManager() {
archList.clear();
}
-void sManager::addPatch(const Common::String &src, const Common::String &dst) {
- Common::String lw_name = dst;
- lw_name.toLowercase();
+void SearchManager::addPatch(const Common::String &src, const Common::String &dst) {
+ Common::String lowerCaseName = dst;
+ lowerCaseName.toLowercase();
- sManager::MatchList::iterator it = files.find(lw_name);
+ SearchManager::MatchList::iterator it = files.find(lowerCaseName);
if (it != files.end()) {
- lw_name = src;
- lw_name.toLowercase();
- files[lw_name] = it->_value;
+ lowerCaseName = src;
+ lowerCaseName.toLowercase();
+ files[lowerCaseName] = it->_value;
}
}
-void sManager::addFile(const Common::String &name, Common::Archive *arch) {
+void SearchManager::addFile(const Common::String &name, Common::Archive *arch) {
bool addArch = true;
Common::List<Common::Archive *>::iterator it = archList.begin();
while (it != archList.end()) {
@@ -84,17 +85,17 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) {
if (addArch)
archList.push_back(arch);
- Common::String lw_name = name;
- lw_name.toLowercase();
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
- sManager::Node nod;
- nod.name = lw_name;
+ SearchManager::Node nod;
+ nod.name = lowerCaseName;
nod.arch = arch;
- sManager::MatchList::iterator fit = files.find(lw_name);
+ SearchManager::MatchList::iterator fit = files.find(lowerCaseName);
if (fit == files.end()) {
- files[lw_name] = nod;
+ files[lowerCaseName] = nod;
} else {
Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
if (stream) {
@@ -102,16 +103,16 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) {
fit->_value.arch = arch;
delete stream;
} else {
- files[lw_name] = nod;
+ files[lowerCaseName] = nod;
}
}
}
-Common::File *sManager::openFile(const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
+Common::File *SearchManager::openFile(const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
- sManager::MatchList::iterator fit = files.find(lw_name);
+ SearchManager::MatchList::iterator fit = files.find(lowerCaseName);
if (fit != files.end()) {
Common::File *tmp = new Common::File();
@@ -121,29 +122,29 @@ Common::File *sManager::openFile(const Common::String &name) {
return NULL;
}
-bool sManager::openFile(Common::File &file, const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
+bool SearchManager::openFile(Common::File &file, const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
- sManager::MatchList::iterator fit = files.find(lw_name);
+ SearchManager::MatchList::iterator fit = files.find(lowerCaseName);
if (fit != files.end())
return file.open(fit->_value.name, *fit->_value.arch);
return false;
}
-bool sManager::hasFile(const Common::String &name) {
- Common::String lw_name = name;
- lw_name.toLowercase();
+bool SearchManager::hasFile(const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
- sManager::MatchList::iterator fit = files.find(lw_name);
+ SearchManager::MatchList::iterator fit = files.find(lowerCaseName);
if (fit != files.end())
return true;
return false;
}
-void sManager::loadZix(const Common::String &name) {
+void SearchManager::loadZix(const Common::String &name) {
Common::File file;
file.open(name);
@@ -168,13 +169,13 @@ void sManager::loadZix(const Common::String &name) {
else if (line.matchString("DIR:*", true)) {
Common::String path(line.c_str() + 5);
Common::Archive *arc;
- char n_path[128];
- strcpy(n_path, path.c_str());
+ char tempPath[128];
+ strcpy(tempPath, path.c_str());
for (uint i = 0; i < path.size(); i++)
- if (n_path[i] == '\\')
- n_path[i] = '/';
+ if (tempPath[i] == '\\')
+ tempPath[i] = '/';
- path = Common::String(n_path);
+ path = Common::String(tempPath);
if (path.size() && path[0] == '.')
path.deleteChar(0);
if (path.size() && path[0] == '/')
@@ -187,7 +188,7 @@ void sManager::loadZix(const Common::String &name) {
if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/')
path.deleteLastChar();
if (path.size())
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ for (Common::List<Common::String>::iterator it = dirList.begin(); it != dirList.end(); ++it)
if (path.equalsIgnoreCase(*it)) {
path = *it;
break;
@@ -218,9 +219,9 @@ void sManager::loadZix(const Common::String &name) {
}
}
-void sManager::addDir(const Common::String &name) {
+void SearchManager::addDir(const Common::String &name) {
Common::String path;
- for (Common::List<Common::String>::iterator it = dir_list.begin(); it != dir_list.end(); ++it)
+ for (Common::List<Common::String>::iterator it = dirList.begin(); it != dirList.end(); ++it)
if (name.equalsIgnoreCase(*it)) {
path = *it;
break;
@@ -246,8 +247,8 @@ void sManager::addDir(const Common::String &name) {
zfs->listMembers(zfslist);
for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
- Common::String z_name = (*ziter)->getName();
- addFile(z_name, zfs);
+ Common::String zfsFileName = (*ziter)->getName();
+ addFile(zfsFileName, zfs);
}
}
@@ -260,15 +261,15 @@ void sManager::addDir(const Common::String &name) {
}
}
-void sManager::list_dir_recursive(Common::List<Common::String> &_list, const Common::FSNode &fs_node, int depth) {
- Common::FSList fs_list;
- fs_node.getChildren(fs_list);
+void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const Common::FSNode &fsNode, int depth) {
+ Common::FSList fsList;
+ fsNode.getChildren(fsList);
- _list.push_back(fs_node.getPath());
+ _list.push_back(fsNode.getPath());
if (depth > 1)
- for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it)
- list_dir_recursive(_list, *it, depth - 1);
+ for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it)
+ listDirRecursive(_list, *it, depth - 1);
}
} // End of namespace ZVision
diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h
index c768cb8..180102e 100644
--- a/engines/zvision/core/search_manager.h
+++ b/engines/zvision/core/search_manager.h
@@ -1,5 +1,27 @@
-#ifndef SEARCH_MANAGER_H_INCLUDED
-#define SEARCH_MANAGER_H_INCLUDED
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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_SEARCH_MANAGER_H
+#define ZVISION_SEARCH_MANAGER_H
#include "common/str.h"
#include "common/hash-str.h"
@@ -10,10 +32,10 @@
namespace ZVision {
-class sManager {
+class SearchManager {
public:
- sManager(const Common::String &root_path, int depth);
- ~sManager();
+ SearchManager(const Common::String &rootPath, int depth);
+ ~SearchManager();
void addFile(const Common::String &name, Common::Archive *arch);
void addDir(const Common::String &name);
@@ -27,14 +49,14 @@ public:
private:
- void list_dir_recursive(Common::List<Common::String> &dir_list, const Common::FSNode &fs_node, int depth);
+ void listDirRecursive(Common::List<Common::String> &dirList, const Common::FSNode &fsNode, int depth);
struct Node {
Common::String name;
Common::Archive *arch;
};
- Common::List<Common::String> dir_list;
+ Common::List<Common::String> dirList;
typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList;
@@ -48,4 +70,4 @@ private:
}
-#endif // SEARCH_MANAGER_H_INCLUDED
+#endif // ZVISION_SEARCH_MANAGER_H
diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp
index 22aa16f..638a8ed 100644
--- a/engines/zvision/fonts/truetype_font.cpp
+++ b/engines/zvision/fonts/truetype_font.cpp
@@ -116,24 +116,24 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, u
return surface;
}
-sTTFont::sTTFont(ZVision *engine) {
+StyledTTFont::StyledTTFont(ZVision *engine) {
_engine = engine;
_style = 0;
_font = NULL;
_lineHeight = 0;
}
-sTTFont::~sTTFont() {
+StyledTTFont::~StyledTTFont() {
if (_font)
delete _font;
}
-bool sTTFont::loadFont(const Common::String &fontName, int32 point, uint style) {
+bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) {
_style = style;
return loadFont(fontName, point);
}
-bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
+bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
Common::String newFontName;
if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
@@ -205,7 +205,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
}
}
}
- if (!themeFile) { // Fallback 2.5: Search for ScummModern.zip in SearchMan.
+ if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan.
themeFile = SearchMan.createReadStreamForMember("scummmodern.zip");
}
if (themeFile) {
@@ -243,7 +243,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
return false;
}
-void sTTFont::setStyle(uint newStyle) {
+void StyledTTFont::setStyle(uint newStyle) {
if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) {
_style = newStyle;
loadFont(_fntName, _lineHeight);
@@ -252,31 +252,31 @@ void sTTFont::setStyle(uint newStyle) {
}
}
-int sTTFont::getFontHeight() {
+int StyledTTFont::getFontHeight() {
if (_font)
return _font->getFontHeight();
return 0;
}
-int sTTFont::getMaxCharWidth() {
+int StyledTTFont::getMaxCharWidth() {
if (_font)
return _font->getMaxCharWidth();
return 0;
}
-int sTTFont::getCharWidth(byte chr) {
+int StyledTTFont::getCharWidth(byte chr) {
if (_font)
return _font->getCharWidth(chr);
return 0;
}
-int sTTFont::getKerningOffset(byte left, byte right) {
+int StyledTTFont::getKerningOffset(byte left, byte right) {
if (_font)
return _font->getKerningOffset(left, right);
return 0;
}
-void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) {
+void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) {
if (_font) {
_font->drawChar(dst, chr, x, y, color);
if (_style & STTF_UNDERLINE) {
@@ -292,7 +292,7 @@ void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 co
}
}
-void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) {
+void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) {
if (_font) {
_font->drawString(dst, str, x, y, w, color, align);
if (_style & STTF_UNDERLINE) {
@@ -324,13 +324,13 @@ void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int
}
}
-int sTTFont::getStringWidth(const Common::String &str) {
+int StyledTTFont::getStringWidth(const Common::String &str) {
if (_font)
return _font->getStringWidth(str);
return 0;
}
-Graphics::Surface *sTTFont::renderSolidText(const Common::String &str, uint32 color) {
+Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) {
Graphics::Surface *tmp = new Graphics::Surface;
if (_font) {
int16 w = _font->getStringWidth(str);
diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h
index 0fed3cc..771c02a 100644
--- a/engines/zvision/fonts/truetype_font.h
+++ b/engines/zvision/fonts/truetype_font.h
@@ -77,10 +77,10 @@ public:
};
// Styled TTF
-class sTTFont {
+class StyledTTFont {
public:
- sTTFont(ZVision *engine);
- ~sTTFont();
+ StyledTTFont(ZVision *engine);
+ ~StyledTTFont();
enum {
STTF_BOLD = 1,
diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h
index 62dd1f9..45d6f95 100644
--- a/engines/zvision/graphics/effects/fog.h
+++ b/engines/zvision/graphics/effects/fog.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef FOGFX_H_INCLUDED
-#define FOGFX_H_INCLUDED
+#ifndef ZVISION_FOG_H
+#define ZVISION_FOG_H
#include "zvision/graphics/effect.h"
@@ -49,4 +49,4 @@ private:
};
} // End of namespace ZVision
-#endif // FOGFX_H_INCLUDED
+#endif // ZVISION_FOG_H
diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp
index 88239f3..9f2fbb2 100644
--- a/engines/zvision/graphics/effects/wave.cpp
+++ b/engines/zvision/graphics/effects/wave.cpp
@@ -30,32 +30,32 @@
namespace ZVision {
-WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd):
+WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd):
Effect(engine, key, region, ported) {
_frame = 0;
- _frame_cnt = frames;
+ _frameCount = frames;
- _ampls.resize(_frame_cnt);
- _hw = _region.width() / 2;
- _hh = _region.height() / 2;
+ _ampls.resize(_frameCount);
+ _halfWidth = _region.width() / 2;
+ _halfHeight = _region.height() / 2;
- int32 frmsize = _hw * _hh;
+ int32 frmsize = _halfWidth * _halfHeight;
float phase = 0;
- int16 w_4 = _hw / 2;
- int16 h_4 = _hh / 2;
+ int16 quarterWidth = _halfWidth / 2;
+ int16 quarterHeight = _halfHeight / 2;
- for (int16 i = 0; i < _frame_cnt; i++) {
+ for (int16 i = 0; i < _frameCount; i++) {
_ampls[i].resize(frmsize);
- for (int16 y = 0; y < _hh; y++)
- for (int16 x = 0; x < _hw; x++) {
- int16 dx = (x - w_4);
- int16 dy = (y - h_4);
+ for (int16 y = 0; y < _halfHeight; y++)
+ for (int16 x = 0; x < _halfWidth; x++) {
+ int16 dx = (x - quarterWidth);
+ int16 dy = (y - quarterHeight);
- _ampls[i][x + y * _hw] = ampl * sin(sqrt(dx * dx / (float)s_x + dy * dy / (float)s_y) / (-waveln * 3.1415926) + phase);
+ _ampls[i][x + y * _halfWidth] = ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase);
}
phase += spd;
}
@@ -68,66 +68,66 @@ WaveFx::~WaveFx() {
}
const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) {
- for (int16 y = 0; y < _hh; y++) {
+ for (int16 y = 0; y < _halfHeight; y++) {
uint16 *abc = (uint16 *)_surface.getBasePtr(0, y);
- uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _hh + y);
- uint16 *abc3 = (uint16 *)_surface.getBasePtr(_hw, y);
- uint16 *abc4 = (uint16 *)_surface.getBasePtr(_hw, _hh + y);
-
- for (int16 x = 0; x < _hw; x++) {
- int8 amnt = _ampls[_frame][x + _hw * y];
-
- int16 n_x = x + amnt;
- int16 n_y = y + amnt;
-
- if (n_x < 0)
- n_x = 0;
- if (n_x >= _region.width())
- n_x = _region.width() - 1;
- if (n_y < 0)
- n_y = 0;
- if (n_y >= _region.height())
- n_y = _region.height() - 1;
- *abc = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
-
- n_x = x + amnt + _hw;
- n_y = y + amnt;
-
- if (n_x < 0)
- n_x = 0;
- if (n_x >= _region.width())
- n_x = _region.width() - 1;
- if (n_y < 0)
- n_y = 0;
- if (n_y >= _region.height())
- n_y = _region.height() - 1;
- *abc3 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
-
- n_x = x + amnt;
- n_y = y + amnt + _hh;
-
- if (n_x < 0)
- n_x = 0;
- if (n_x >= _region.width())
- n_x = _region.width() - 1;
- if (n_y < 0)
- n_y = 0;
- if (n_y >= _region.height())
- n_y = _region.height() - 1;
- *abc2 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
-
- n_x = x + amnt + _hw;
- n_y = y + amnt + _hh;
-
- if (n_x < 0)
- n_x = 0;
- if (n_x >= _region.width())
- n_x = _region.width() - 1;
- if (n_y < 0)
- n_y = 0;
- if (n_y >= _region.height())
- n_y = _region.height() - 1;
- *abc4 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y);
+ uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _halfHeight + y);
+ uint16 *abc3 = (uint16 *)_surface.getBasePtr(_halfWidth, y);
+ uint16 *abc4 = (uint16 *)_surface.getBasePtr(_halfWidth, _halfHeight + y);
+
+ for (int16 x = 0; x < _halfWidth; x++) {
+ int8 amnt = _ampls[_frame][x + _halfWidth * y];
+
+ int16 nX = x + amnt;
+ int16 nY = y + amnt;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt + _halfWidth;
+ nY = y + amnt;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc3 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt;
+ nY = y + amnt + _halfHeight;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc2 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt + _halfWidth;
+ nY = y + amnt + _halfHeight;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc4 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
abc++;
abc2++;
@@ -140,7 +140,7 @@ const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) {
}
void WaveFx::update() {
- _frame = (_frame + 1) % _frame_cnt;
+ _frame = (_frame + 1) % _frameCount;
}
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h
index 0046dfc..2e813ed 100644
--- a/engines/zvision/graphics/effects/wave.h
+++ b/engines/zvision/graphics/effects/wave.h
@@ -33,7 +33,7 @@ class ZVision;
class WaveFx : public Effect {
public:
- WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd);
+ WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd);
~WaveFx();
const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
@@ -42,8 +42,8 @@ public:
private:
int16 _frame;
- int16 _frame_cnt;
- int16 _hw, _hh;
+ int16 _frameCount;
+ int16 _halfWidth, _halfHeight;
Common::Array< Common::Array< int8 > > _ampls;
};
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 3e14693..05f8dec 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -78,6 +78,7 @@ RenderManager::~RenderManager() {
void RenderManager::renderBackbufferToScreen() {
Graphics::Surface *out = &_outWnd;
Graphics::Surface *in = &_wrkWnd;
+ Common::Rect outWndDirtyRect;
if (!_effects.empty()) {
bool copied = false;
@@ -114,22 +115,20 @@ void RenderManager::renderBackbufferToScreen() {
if (!_wrkWndDirtyRect.isEmpty()) {
_renderTable.mutateImage(&_outWnd, in);
out = &_outWnd;
- _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight);
+ outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight);
}
} else {
out = in;
- _outWndDirtyRect = _wrkWndDirtyRect;
+ outWndDirtyRect = _wrkWndDirtyRect;
}
- if (!_outWndDirtyRect.isEmpty()) {
- _system->copyRectToScreen(out->getBasePtr(_outWndDirtyRect.left, _outWndDirtyRect.top), out->pitch,
- _outWndDirtyRect.left + _workingWindow.left,
- _outWndDirtyRect.top + _workingWindow.top,
- _outWndDirtyRect.width(),
- _outWndDirtyRect.height());
-
- _outWndDirtyRect = Common::Rect();
+ if (!outWndDirtyRect.isEmpty()) {
+ _system->copyRectToScreen(out->getBasePtr(outWndDirtyRect.left, outWndDirtyRect.top), out->pitch,
+ outWndDirtyRect.left + _workingWindow.left,
+ outWndDirtyRect.top + _workingWindow.top,
+ outWndDirtyRect.width(),
+ outWndDirtyRect.height());
}
}
@@ -472,7 +471,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
return;
// Copy srcRect from src surface to dst surface
- const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
+ const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
int xx = _x;
int yy = _y;
@@ -485,15 +484,15 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
if (_x >= dst.w || _y >= dst.h)
return;
- byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
+ byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy);
int32 w = srcRect.width();
int32 h = srcRect.height();
for (int32 y = 0; y < h; y++) {
- memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel);
- src_buf += src.pitch;
- dst_buf += dst.pitch;
+ memcpy(dstBuffer, srcBuffer, w * src.format.bytesPerPixel);
+ srcBuffer += src.pitch;
+ dstBuffer += dst.pitch;
}
}
@@ -517,7 +516,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1);
// Copy srcRect from src surface to dst surface
- const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
+ const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top);
int xx = _x;
int yy = _y;
@@ -530,7 +529,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
if (_x >= dst.w || _y >= dst.h)
return;
- byte *dst_buf = (byte *)dst.getBasePtr(xx, yy);
+ byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy);
int32 w = srcRect.width();
int32 h = srcRect.height();
@@ -538,37 +537,37 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
for (int32 y = 0; y < h; y++) {
switch (src.format.bytesPerPixel) {
case 1: {
- const uint *src_tmp = (const uint *)src_buf;
- uint *dst_tmp = (uint *)dst_buf;
+ const uint *srcTemp = (const uint *)srcBuffer;
+ uint *dstTemp = (uint *)dstBuffer;
for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
+ if (*srcTemp != _keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
}
}
break;
case 2: {
- const uint16 *src_tmp = (const uint16 *)src_buf;
- uint16 *dst_tmp = (uint16 *)dst_buf;
+ const uint16 *srcTemp = (const uint16 *)srcBuffer;
+ uint16 *dstTemp = (uint16 *)dstBuffer;
for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
+ if (*srcTemp != _keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
}
}
break;
case 4: {
- const uint32 *src_tmp = (const uint32 *)src_buf;
- uint32 *dst_tmp = (uint32 *)dst_buf;
+ const uint32 *srcTemp = (const uint32 *)srcBuffer;
+ uint32 *dstTemp = (uint32 *)dstBuffer;
for (int32 x = 0; x < w; x++) {
- if (*src_tmp != _keycolor)
- *dst_tmp = *src_tmp;
- src_tmp++;
- dst_tmp++;
+ if (*srcTemp != _keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
}
}
break;
@@ -576,8 +575,8 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com
default:
break;
}
- src_buf += src.pitch;
- dst_buf += dst.pitch;
+ srcBuffer += src.pitch;
+ dstBuffer += dst.pitch;
}
}
@@ -796,7 +795,7 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) {
sub.redraw = false;
sub.timer = -1;
sub.todelete = false;
- sub._r = area;
+ sub.r = area;
_subsList[_subid] = sub;
@@ -810,8 +809,8 @@ uint16 RenderManager::createSubArea() {
sub.redraw = false;
sub.timer = -1;
sub.todelete = false;
- sub._r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom);
- sub._r.translate(-_workingWindow.left, -_workingWindow.top);
+ sub.r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom);
+ sub.r.translate(-_workingWindow.left, -_workingWindow.top);
_subsList[_subid] = sub;
@@ -831,7 +830,7 @@ void RenderManager::deleteSubArea(uint16 id, int16 delay) {
void RenderManager::updateSubArea(uint16 id, const Common::String &txt) {
if (_subsList.contains(id)) {
oneSub *sub = &_subsList[id];
- sub->_txt = txt;
+ sub->txt = txt;
sub->redraw = true;
}
}
@@ -857,11 +856,11 @@ void RenderManager::processSubs(uint16 deltatime) {
for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
oneSub *sub = &it->_value;
- if (sub->_txt.size()) {
+ if (sub->txt.size()) {
Graphics::Surface *rndr = new Graphics::Surface();
- rndr->create(sub->_r.width(), sub->_r.height(), _pixelFormat);
- _engine->getTextRenderer()->drawTxtInOneLine(sub->_txt, *rndr);
- blitSurfaceToSurface(*rndr, _subWnd, sub->_r.left - _subWndRect.left + _workingWindow.left, sub->_r.top - _subWndRect.top + _workingWindow.top);
+ rndr->create(sub->r.width(), sub->r.height(), _pixelFormat);
+ _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr);
+ blitSurfaceToSurface(*rndr, _subWnd, sub->r.left - _subWndRect.left + _workingWindow.left, sub->r.top - _subWndRect.top + _workingWindow.top);
rndr->free();
delete rndr;
}
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index d34ecf8..7723c3d 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -54,21 +54,13 @@ public:
private:
struct oneSub {
- Common::Rect _r;
- Common::String _txt;
+ Common::Rect r;
+ Common::String txt;
int16 timer;
bool todelete;
bool redraw;
};
-// struct AlphaDataEntry {
-// Graphics::Surface *data;
-// uint16 alphaColor;
-// uint16 destX;
-// uint16 destY;
-// uint16 width;
-// uint16 height;
-// };
-//
+
typedef Common::HashMap<uint16, oneSub> subMap;
typedef Common::List<Effect *> effectsList;
@@ -82,37 +74,25 @@ private:
Common::Rect _wrkWndDirtyRect;
+ // A buffer for mutate image by tilt or panorama renderers
Graphics::Surface _outWnd;
- Common::Rect _outWndDirtyRect;
-
Common::Rect _bkgDirtyRect;
+ // A buffer for subtitles
Graphics::Surface _subWnd;
Common::Rect _subWndDirtyRect;
+ // A buffer for menu drawing
Graphics::Surface _menuWnd;
Common::Rect _menuWndDirtyRect;
+ // A buffer used for apply graphics effects
Graphics::Surface _effectWnd;
- // A buffer the exact same size as the workingWindow
- // 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
- //AlphaEntryMap _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() */
const int _wrkWidth;
/** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
@@ -129,13 +109,16 @@ private:
*/
const Common::Rect _workingWindow;
+ // Recatangle for subtitles area
Common::Rect _subWndRect;
+ // Recatangle for menu area
Common::Rect _menuWndRect;
/** Used to warp the background image */
RenderTable _renderTable;
+ // A buffer for background image
Graphics::Surface _curBkg;
/** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
int16 _bkgOff;
@@ -144,18 +127,13 @@ private:
/** The height of the current background image */
uint16 _bkgHeight;
+ // Internal subtitles counter
uint16 _subid;
+ // Subtitle list
subMap _subsList;
- /**
- * 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;
-
+ // Visual effects list
effectsList _effects;
public:
@@ -178,13 +156,22 @@ public:
/**
* Blits the image or a portion of the image to the background.
*
- * @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 fileName Name of the image file
+ * @param destX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destY Y position where the image should be put. Coords are in working window space, not screen space!
* @param colorkey Transparent color
*/
void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @param fileName Name of the image file
+ * @param destX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param keyX X position of transparent color
+ * @param keyY Y position of transparent color
+ */
void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY);
/**
@@ -215,7 +202,10 @@ public:
*/
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
+ // Return pointer of RenderTable object
RenderTable *getRenderTable();
+
+ // Return current background offset
uint32 getCurrentBackgroundOffset();
/**
@@ -229,39 +219,64 @@ public:
*/
static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface);
+ // Scale buffer (nearest)
void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
-
+ // Blitting surface-to-surface methods
void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y);
void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey);
void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y);
void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey);
+
+ // Blitting surface-to-background methods
void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y);
void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey);
+
+ // Blitting surface-to-background methods with scale
void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect);
void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey);
+
+ // Blitting surface-to-menu methods
void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y);
void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey);
+ // Subtitles methods
+
+ // Create subtitle area and return ID
uint16 createSubArea(const Common::Rect &area);
uint16 createSubArea();
+
+ // Delete subtitle by ID
void deleteSubArea(uint16 id);
void deleteSubArea(uint16 id, int16 delay);
+
+ // Update subtitle area
void updateSubArea(uint16 id, const Common::String &txt);
+
+ // Processing subtitles
void processSubs(uint16 deltatime);
+
+ // Return background size
Common::Point getBkgSize();
+ // Return portion of background as new surface
Graphics::Surface *getBkgRect(Common::Rect &rect);
+
+ // Load image into new surface
Graphics::Surface *loadImage(const char *file);
Graphics::Surface *loadImage(Common::String &file);
Graphics::Surface *loadImage(const char *file, bool transposed);
Graphics::Surface *loadImage(Common::String &file, bool transposed);
+ // Clear whole/area of menu surface
void clearMenuSurface();
void clearMenuSurface(const Common::Rect &r);
+
+ // Copy menu buffer to screen
void renderMenuToScreen();
+ // Copy needed portion of background surface to workingWindow surface
void prepareBkg();
/**
@@ -275,17 +290,44 @@ public:
* @param destination A reference to the Surface to store the pixel data in
*/
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
+
+ /**
+ * 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
+ * @param transposed Transpose flag
+ */
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
+ // Add visual effect to effects list
void addEffect(Effect *_effect);
+
+ // Delete effect(s) by ID (ID equal to slot of action:region that create this effect)
void deleteEffect(uint32 ID);
+
+ // Create "mask" for effects - (color +/- depth) will be selected as not transparent. Like color selection
+ // xy - base color
+ // depth - +/- of base color
+ // rect - rectangle where select pixels
+ // minD - if not NULL will recieve real bottom border of depth
+ // maxD - if not NULL will recieve real top border of depth
EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD);
+
+ // Create "mask" for effects by simple transparent color
EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
+ // Return background rectangle in screen coordinates
Common::Rect bkgRectToScreen(const Common::Rect &src);
+ // Mark whole background surface as dirty
void markDirty();
+ // Fille background surface by color
void bkgFill(uint8 r, uint8 g, uint8 b);
};
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 199f96b..f792765 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,5 +1,5 @@
MODULE := engines/zvision
-
+
MODULE_OBJS := \
animation/meta_animation.o \
animation/rlf_animation.o \
@@ -53,15 +53,15 @@ MODULE_OBJS := \
utility/win_keys.o \
video/video.o \
video/zork_avi_decoder.o \
- zvision.o
-
+ zvision.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 common rules
include $(srcdir)/rules.mk
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 31f68d7..8ff6bd0 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -275,7 +275,7 @@ bool ActionDissolve::execute() {
ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey) {
- sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_st_angl, &_en_angl, &_st_lin, &_en_lin);
+ sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_startAngle, &_endAngle, &_startLineScale, &_endLineScale);
}
ActionDistort::~ActionDistort() {
@@ -286,7 +286,7 @@ bool ActionDistort::execute() {
if (_engine->getScriptManager()->getSideFX(_distSlot))
return true;
- _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _st_angl, _en_angl, _st_lin, _en_lin));
+ _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _startAngle, _endAngle, _startLineScale, _endLineScale));
return true;
}
@@ -345,22 +345,22 @@ ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::S
bool ActionInventory::execute() {
switch (_type) {
case 0: // add
- _engine->getScriptManager()->invertory_add(_key);
+ _engine->getScriptManager()->inventoryAdd(_key);
break;
case 1: // addi
- _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(_key));
+ _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(_key));
break;
case 2: // drop
if (_key >= 0)
- _engine->getScriptManager()->invertory_drop(_key);
+ _engine->getScriptManager()->inventoryDrop(_key);
else
- _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem));
+ _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem));
break;
case 3: // dropi
- _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(_key));
+ _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(_key));
break;
case 4: // cycle
- _engine->getScriptManager()->invertory_cycle();
+ _engine->getScriptManager()->inventoryCycle();
break;
default:
break;
@@ -463,20 +463,20 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l
ActionMusic::~ActionMusic() {
if (!_universe)
- _engine->getScriptManager()->killSideFx(_slotkey);
+ _engine->getScriptManager()->killSideFx(_slotKey);
}
bool ActionMusic::execute() {
- if (_engine->getScriptManager()->getSideFX(_slotkey))
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
if (_midi) {
- _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotkey, _prog, _note, _volume));
+ _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume));
} else {
if (!_engine->getSearchManager()->hasFile(_fileName))
return true;
- _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, _volume));
}
return true;
@@ -489,20 +489,20 @@ bool ActionMusic::execute() {
ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey),
_pos(0),
- _mus_slot(0) {
+ _musicSlot(0) {
- sscanf(line.c_str(), "%u %d", &_mus_slot, &_pos);
+ sscanf(line.c_str(), "%u %d", &_musicSlot, &_pos);
}
ActionPanTrack::~ActionPanTrack() {
- _engine->getScriptManager()->killSideFx(_slotkey);
+ _engine->getScriptManager()->killSideFx(_slotKey);
}
bool ActionPanTrack::execute() {
- if (_engine->getScriptManager()->getSideFX(_slotkey))
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
- _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotkey, _mus_slot, _pos));
+ _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotKey, _musicSlot, _pos));
return true;
}
@@ -549,18 +549,18 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c
}
ActionPreloadAnimation::~ActionPreloadAnimation() {
- _engine->getScriptManager()->deleteSideFx(_slotkey);
+ _engine->getScriptManager()->deleteSideFx(_slotKey);
}
bool ActionPreloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey);
if (!nod) {
- nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false);
+ nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate, false);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
- _engine->getScriptManager()->setStateValue(_slotkey, 2);
+ _engine->getScriptManager()->setStateValue(_slotKey, 2);
return true;
}
@@ -607,20 +607,20 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C
}
ActionPlayAnimation::~ActionPlayAnimation() {
- _engine->getScriptManager()->deleteSideFx(_slotkey);
+ _engine->getScriptManager()->deleteSideFx(_slotKey);
}
bool ActionPlayAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey);
+ AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey);
if (!nod) {
- nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate);
+ nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
if (nod)
- nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount);
+ nod->addPlayNode(_slotKey, _x, _y, _x2, _y2, _start, _end, _loopCount);
return true;
}
@@ -641,7 +641,7 @@ bool ActionPlayPreloadAnimation::execute() {
AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey);
if (nod)
- nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
+ nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
return true;
}
@@ -676,20 +676,20 @@ ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String
}
ActionRegion::~ActionRegion() {
- _engine->getScriptManager()->killSideFx(_slotkey);
+ _engine->getScriptManager()->killSideFx(_slotKey);
}
bool ActionRegion::execute() {
- if (_engine->getScriptManager()->getSideFX(_slotkey))
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
Effect *effct = NULL;
switch (_type) {
case 0: {
- uint16 s_x, s_y, frames;
+ uint16 centerX, centerY, frames;
double amplitude, waveln, speed;
- sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &s_x, &s_y, &frames, &litude, &waveln, &speed);
- effct = new WaveFx(_engine, _slotkey, _rect, _unk1, frames, s_x, s_y, amplitude, waveln, speed);
+ sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", ¢erX, ¢erY, &frames, &litude, &waveln, &speed);
+ effct = new WaveFx(_engine, _slotKey, _rect, _unk1, frames, centerX, centerY, amplitude, waveln, speed);
}
break;
case 1: {
@@ -701,7 +701,7 @@ bool ActionRegion::execute() {
int8 minD;
int8 maxD;
EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD);
- effct = new LightFx(_engine, _slotkey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD);
+ effct = new LightFx(_engine, _slotKey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD);
}
break;
case 9: {
@@ -717,7 +717,7 @@ bool ActionRegion::execute() {
_rect.setHeight(tempMask.h);
EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0);
- effct = new FogFx(_engine, _slotkey, _rect, _unk1, _map, Common::String(buf));
+ effct = new FogFx(_engine, _slotKey, _rect, _unk1, _map, Common::String(buf));
}
break;
default:
@@ -725,7 +725,7 @@ bool ActionRegion::execute() {
}
if (effct) {
- _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotkey, effct, _delay));
+ _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effct, _delay));
_engine->getRenderManager()->addEffect(effct);
}
@@ -738,10 +738,10 @@ bool ActionRegion::execute() {
ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey) {
- char max_buf[64];
- memset(max_buf, 0, 64);
- sscanf(line.c_str(), "%s", max_buf);
- _max = new ValueSlot(_engine->getScriptManager(), max_buf);
+ char maxBuffer[64];
+ memset(maxBuffer, 0, 64);
+ sscanf(line.c_str(), "%s", maxBuffer);
+ _max = new ValueSlot(_engine->getScriptManager(), maxBuffer);
}
ActionRandom::~ActionRandom() {
@@ -751,7 +751,7 @@ ActionRandom::~ActionRandom() {
bool ActionRandom::execute() {
uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue());
- _engine->getScriptManager()->setStateValue(_slotkey, randNumber);
+ _engine->getScriptManager()->setStateValue(_slotKey, randNumber);
return true;
}
@@ -941,9 +941,9 @@ bool ActionStreamVideo::execute() {
ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey) {
char fileName[25];
- int not_used;
+ int notUsed;
- sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬_used, fileName);
+ sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬Used, fileName);
_fileName = Common::String(fileName);
}
@@ -960,7 +960,7 @@ bool ActionSyncSound::execute() {
if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload
animnode->setNewFrameDelay(66); // ~15fps
- _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotkey, _fileName, _syncto));
+ _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto));
return true;
}
@@ -970,22 +970,22 @@ bool ActionSyncSound::execute() {
ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) :
ResultAction(engine, slotkey) {
- char time_buf[64];
- memset(time_buf, 0, 64);
- sscanf(line.c_str(), "%s", time_buf);
- _time = new ValueSlot(_engine->getScriptManager(), time_buf);
+ char timeBuffer[64];
+ memset(timeBuffer, 0, 64);
+ sscanf(line.c_str(), "%s", timeBuffer);
+ _time = new ValueSlot(_engine->getScriptManager(), timeBuffer);
}
ActionTimer::~ActionTimer() {
if (_time)
delete _time;
- _engine->getScriptManager()->killSideFx(_slotkey);
+ _engine->getScriptManager()->killSideFx(_slotKey);
}
bool ActionTimer::execute() {
- if (_engine->getScriptManager()->getSideFX(_slotkey))
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
- _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue()));
+ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotKey, _time->getValue()));
return true;
}
@@ -1003,13 +1003,13 @@ ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::Strin
}
ActionTtyText::~ActionTtyText() {
- _engine->getScriptManager()->killSideFx(_slotkey);
+ _engine->getScriptManager()->killSideFx(_slotKey);
}
bool ActionTtyText::execute() {
- if (_engine->getScriptManager()->getSideFX(_slotkey))
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
- _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotkey, _filename, _r, _delay));
+ _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotKey, _filename, _r, _delay));
return true;
}
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index 5401af0..03a249e 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -41,7 +41,7 @@ class ValueSlot;
*/
class ResultAction {
public:
- ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {}
+ ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey) {}
virtual ~ResultAction() {}
/**
* This is called by the script system whenever a Puzzle's criteria are found to be true.
@@ -54,40 +54,8 @@ public:
virtual bool execute() = 0;
protected:
ZVision *_engine;
- int32 _slotkey;
-};
-
-
-// The different types of actions
-// DEBUG,
-// 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,
+ int32 _slotKey;
+};
class ActionAdd : public ResultAction {
public:
@@ -217,10 +185,10 @@ public:
private:
int16 _distSlot;
int16 _speed;
- float _st_angl;
- float _en_angl;
- float _st_lin;
- float _en_lin;
+ float _startAngle;
+ float _endAngle;
+ float _startLineScale;
+ float _endLineScale;
};
class ActionEnableControl : public ResultAction {
@@ -290,7 +258,7 @@ public:
private:
int32 _pos;
- uint32 _mus_slot;
+ uint32 _musicSlot;
};
class ActionPlayAnimation : public ResultAction {
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index 9c81569..e69d57f 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -106,24 +106,24 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
-void Control::getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
- const char *chrs = input_str.c_str();
+void Control::getParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
uint lbr;
- for (lbr = 0; lbr < input_str.size(); lbr++)
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
if (chrs[lbr] == '(')
break;
- if (lbr >= input_str.size())
+ if (lbr >= inputStr.size())
return;
uint rbr;
- for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
if (chrs[rbr] == ')')
break;
- if (rbr >= input_str.size())
+ if (rbr >= inputStr.size())
return;
parameter = Common::String(chrs, chrs + lbr);
@@ -131,9 +131,9 @@ void Control::getParams(const Common::String &input_str, Common::String ¶met
}
void Control::setVenus() {
- if (_venus_id >= 0)
- if (_engine->getScriptManager()->getStateValue(_venus_id) > 0)
- _engine->getScriptManager()->setStateValue(StateKey_Venus, _venus_id);
+ if (_venusId >= 0)
+ if (_engine->getScriptManager()->getStateValue(_venusId) > 0)
+ _engine->getScriptManager()->setStateValue(StateKey_Venus, _venusId);
}
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index b784a66..5814c9e 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -54,7 +54,7 @@ public:
CONTROL_PAINT
};
- Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venus_id(-1) {}
+ Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venusId(-1) {}
virtual ~Control() {}
uint32 getKey() {
@@ -120,14 +120,15 @@ public:
virtual bool process(uint32 deltaTimeInMillis) {
return false;
}
+
void setVenus();
protected:
ZVision *_engine;
uint32 _key;
- int32 _venus_id;
+ int32 _venusId;
- void getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
+ void getParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values);
// Static member functions
public:
static void parseFlatControl(ZVision *engine);
@@ -137,15 +138,6 @@ private:
ControlType _type;
};
-// TODO: Implement InputControl
-// TODO: Implement SaveControl
-// TODO: Implement SlotControl
-// 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/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index 185bea0..9bb03cb 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -80,7 +80,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream
} else if (param.matchString("animation_id", true)) {
_animationId = atoi(values.c_str());
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
@@ -152,13 +152,13 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos);
+ int fistNumber = mouseIn(screenSpacePos, backgroundImageSpacePos);
- if (n_fist >= 0) {
+ if (fistNumber >= 0) {
setVenus();
uint32 oldStatus = _fiststatus;
- _fiststatus ^= (1 << n_fist);
+ _fiststatus ^= (1 << fistNumber);
for (int i = 0; i < _numEntries; i++)
if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) {
@@ -233,12 +233,12 @@ void FistControl::readDescFile(const Common::String &fileName) {
(_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2);
} else {
int entry, start, end, sound;
- char bits_start[33];
- char bits_end[33];
+ char bitsStart[33];
+ char bitsEnd[33];
entry = atoi(param.c_str());
- if (sscanf(values.c_str(), "%s %s %d %d (%d)", bits_start, bits_end, &start, &end, &sound) == 5) {
- _entries[entry]._bitsStrt = readBits(bits_start);
- _entries[entry]._bitsEnd = readBits(bits_end);
+ if (sscanf(values.c_str(), "%s %s %d %d (%d)", bitsStart, bitsEnd, &start, &end, &sound) == 5) {
+ _entries[entry]._bitsStrt = readBits(bitsStart);
+ _entries[entry]._bitsEnd = readBits(bitsEnd);
_entries[entry]._anmStrt = start;
_entries[entry]._anmEnd = end;
_entries[entry]._sound = sound;
@@ -293,24 +293,24 @@ int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Poin
return -1;
}
-void FistControl::getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
- const char *chrs = input_str.c_str();
+void FistControl::getFistParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
uint lbr;
- for (lbr = 0; lbr < input_str.size(); lbr++)
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
if (chrs[lbr] == ':')
break;
- if (lbr >= input_str.size())
+ if (lbr >= inputStr.size())
return;
uint rbr;
- for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
if (chrs[rbr] == '~')
break;
- if (rbr >= input_str.size())
+ if (rbr >= inputStr.size())
return;
parameter = Common::String(chrs, chrs + lbr);
diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h
index 8b229f9..33c3c7b 100644
--- a/engines/zvision/scripting/controls/fist_control.h
+++ b/engines/zvision/scripting/controls/fist_control.h
@@ -79,7 +79,7 @@ private:
void clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr);
uint32 readBits(const char *str);
int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- void getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
+ void getFistParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index 6969ee1..fd7afb9 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -44,12 +44,12 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
: Control(engine, key, CONTROL_HOTMOV) {
_animation = NULL;
_cycle = 0;
- _cur_frame = -1;
+ _curFrame = -1;
_lastRenderedFrame = -1;
_frames.clear();
- _frame_time = 0;
- _num_cycles = 0;
- _num_frames = 0;
+ _frameTime = 0;
+ _cyclesCount = 0;
+ _framesCount = 0;
_engine->getScriptManager()->setStateValue(_key, 0);
@@ -73,16 +73,16 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
_rectangle = Common::Rect(x, y, width, height);
} else if (param.matchString("num_frames", true)) {
- _num_frames = atoi(values.c_str());
+ _framesCount = atoi(values.c_str());
} else if (param.matchString("num_cycles", true)) {
- _num_cycles = atoi(values.c_str());
+ _cyclesCount = atoi(values.c_str());
} else if (param.matchString("animation", true)) {
char filename[64];
sscanf(values.c_str(), "%s", filename);
values = Common::String(filename);
_animation = new MetaAnimation(values, _engine);
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
@@ -117,21 +117,21 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_cycle < _num_cycles) {
- _frame_time -= deltaTimeInMillis;
+ if (_cycle < _cyclesCount) {
+ _frameTime -= deltaTimeInMillis;
- if (_frame_time <= 0) {
- _cur_frame++;
- if (_cur_frame >= _num_frames) {
- _cur_frame = 0;
+ if (_frameTime <= 0) {
+ _curFrame++;
+ if (_curFrame >= _framesCount) {
+ _curFrame = 0;
_cycle++;
}
- if (_cycle != _num_cycles)
- renderFrame(_cur_frame);
+ if (_cycle != _cyclesCount)
+ renderFrame(_curFrame);
else
_engine->getScriptManager()->setStateValue(_key, 2);
- _frame_time = _animation->frameTime();
+ _frameTime = _animation->frameTime();
}
}
@@ -142,8 +142,8 @@ bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Commo
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_cycle < _num_cycles) {
- if (_frames[_cur_frame].contains(backgroundImageSpacePos)) {
+ if (_cycle < _cyclesCount) {
+ if (_frames[_curFrame].contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(CursorIndex_Active);
return true;
}
@@ -156,8 +156,8 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common:
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_cycle < _num_cycles) {
- if (_frames[_cur_frame].contains(backgroundImageSpacePos)) {
+ if (_cycle < _cyclesCount) {
+ if (_frames[_curFrame].contains(backgroundImageSpacePos)) {
setVenus();
_engine->getScriptManager()->setStateValue(_key, 1);
return true;
@@ -168,7 +168,7 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common:
}
void HotMovControl::readHsFile(const Common::String &fileName) {
- if (_num_frames == 0)
+ if (_framesCount == 0)
return;
Common::File file;
@@ -179,7 +179,7 @@ void HotMovControl::readHsFile(const Common::String &fileName) {
Common::String line;
- _frames.resize(_num_frames);
+ _frames.resize(_framesCount);
while (!file.eos()) {
line = file.readLine();
@@ -192,7 +192,7 @@ void HotMovControl::readHsFile(const Common::String &fileName) {
sscanf(line.c_str(), "%d:%d %d %d %d~", &frame, &x, &y, &width, &height);
- if (frame >= 0 && frame < _num_frames)
+ if (frame >= 0 && frame < _framesCount)
_frames[frame] = Common::Rect(x, y, width, height);
}
file.close();
diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h
index ea12bab..9e01b40 100644
--- a/engines/zvision/scripting/controls/hotmov_control.h
+++ b/engines/zvision/scripting/controls/hotmov_control.h
@@ -39,12 +39,12 @@ public:
~HotMovControl();
private:
- int32 _num_frames;
- int32 _frame_time;
- int32 _cur_frame;
+ int32 _framesCount;
+ int32 _frameTime;
+ int32 _curFrame;
int32 _lastRenderedFrame;
int32 _cycle;
- int32 _num_cycles;
+ int32 _cyclesCount;
MetaAnimation *_animation;
Common::Rect _rectangle;
Common::Array<Common::Rect> _frames;
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index 442c6cb..8af436b 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -79,13 +79,13 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
sscanf(values.c_str(), "%u", &fontFormatNumber);
- _string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
+ _stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
} else if (param.matchString("chooser_init_string", true)) {
uint fontFormatNumber;
sscanf(values.c_str(), "%u", &fontFormatNumber);
- _string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
+ _stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
} else if (param.matchString("next_tabstop", true)) {
sscanf(values.c_str(), "%u", &_nextTabstop);
} else if (param.matchString("cursor_dimensions", true)) {
@@ -104,7 +104,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_focused = true;
_engine->getScriptManager()->setFocusControlKey(_key);
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
@@ -201,9 +201,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) {
txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat);
if (!_readOnly || !_focused)
- _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_init, txt);
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt);
else
- _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_chooser_init, txt);
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt);
_engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top);
@@ -211,15 +211,15 @@ bool InputControl::process(uint32 deltaTimeInMillis) {
}
if (_animation && !_readOnly && _focused) {
- bool need_draw = true;// = _textChanged;
+ bool needDraw = true;// = _textChanged;
_frameDelay -= deltaTimeInMillis;
if (_frameDelay <= 0) {
_frame = (_frame + 1) % _animation->frameCount();
_frameDelay = _animation->frameTime();
- need_draw = true;
+ needDraw = true;
}
- if (need_draw) {
+ if (needDraw) {
const Graphics::Surface *srf = _animation->getFrameData(_frame);
uint32 xx = _textRectangle.left + _txtWidth;
if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width()))
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 5e2190f..9a829d3 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -40,8 +40,8 @@ public:
private:
Common::Rect _textRectangle;
Common::Rect _headerRectangle;
- cTxtStyle _string_init;
- cTxtStyle _string_chooser_init;
+ cTxtStyle _stringInit;
+ cTxtStyle _stringChooserInit;
uint32 _nextTabstop;
bool _focused;
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index a9836b3..1f176ef 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -142,7 +142,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
_hotspotDelta.x = x;
_hotspotDelta.y = y;
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
} else {
uint frameNumber;
uint x, y;
@@ -381,24 +381,24 @@ void LeverControl::renderFrame(uint frameNumber) {
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
}
-void LeverControl::getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) {
- const char *chrs = input_str.c_str();
+void LeverControl::getLevParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
uint lbr;
- for (lbr = 0; lbr < input_str.size(); lbr++)
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
if (chrs[lbr] == ':')
break;
- if (lbr >= input_str.size())
+ if (lbr >= inputStr.size())
return;
uint rbr;
- for (rbr = lbr + 1; rbr < input_str.size(); rbr++)
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
if (chrs[rbr] == '~')
break;
- if (rbr >= input_str.size())
+ if (rbr >= inputStr.size())
return;
parameter = Common::String(chrs, chrs + lbr);
diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h
index 22789f7..8de6d1e 100644
--- a/engines/zvision/scripting/controls/lever_control.h
+++ b/engines/zvision/scripting/controls/lever_control.h
@@ -112,7 +112,7 @@ private:
*/
static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
void renderFrame(uint frameNumber);
- void getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values);
+ void getLevParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
index 54c02a2..cb3c17e 100644
--- a/engines/zvision/scripting/controls/paint_control.cpp
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -64,7 +64,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
} else if (param.matchString("brush_file", true)) {
_brush = _engine->getRenderManager()->loadImage(values, false);
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
} else if (param.matchString("paint_file", true)) {
_paint = _engine->getRenderManager()->loadImage(values, false);
} else if (param.matchString("eligible_objects", true)) {
@@ -88,7 +88,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
int obj = atoi(st);
- _eligible_objects.push_back(obj);
+ _eligibleObjects.push_back(obj);
}
}
@@ -139,9 +139,9 @@ bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common
return false;
if (_rectangle.contains(backgroundImageSpacePos)) {
- int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
- if (eligeblity(mouse_item)) {
+ if (eligeblity(mouseItem)) {
setVenus();
_mouseDown = true;
}
@@ -155,9 +155,9 @@ bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common
return false;
if (_rectangle.contains(backgroundImageSpacePos)) {
- int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
- if (eligeblity(mouse_item)) {
+ if (eligeblity(mouseItem)) {
_engine->getCursorManager()->changeCursor(_cursor);
if (_mouseDown) {
@@ -178,30 +178,30 @@ bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common
return false;
}
-bool PaintControl::eligeblity(int item_id) {
- for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
- if (*it == item_id)
+bool PaintControl::eligeblity(int itemId) {
+ for (Common::List<int>::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++)
+ if (*it == itemId)
return true;
return false;
}
Common::Rect PaintControl::paint(const Common::Point &point) {
- Common::Rect paint_rect = Common::Rect(_brush->w, _brush->h);
- paint_rect.moveTo(point);
- paint_rect.clip(_rectangle);
-
- if (!paint_rect.isEmpty()) {
- Common::Rect brush_rect = paint_rect;
- brush_rect.translate(-point.x, -point.y);
-
- Common::Rect bkg_rect = paint_rect;
- bkg_rect.translate(-_rectangle.left, -_rectangle.top);
-
- for (int yy = 0; yy < brush_rect.height(); yy++) {
- uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy);
- uint16 *from = (uint16 *)_paint->getBasePtr(bkg_rect.left, bkg_rect.top + yy);
- uint16 *to = (uint16 *)_bkg->getBasePtr(bkg_rect.left, bkg_rect.top + yy);
- for (int xx = 0; xx < brush_rect.width(); xx++) {
+ Common::Rect paintRect = Common::Rect(_brush->w, _brush->h);
+ paintRect.moveTo(point);
+ paintRect.clip(_rectangle);
+
+ if (!paintRect.isEmpty()) {
+ Common::Rect brushRect = paintRect;
+ brushRect.translate(-point.x, -point.y);
+
+ Common::Rect bkgRect = paintRect;
+ bkgRect.translate(-_rectangle.left, -_rectangle.top);
+
+ for (int yy = 0; yy < brushRect.height(); yy++) {
+ uint16 *mask = (uint16 *)_brush->getBasePtr(brushRect.left, brushRect.top + yy);
+ uint16 *from = (uint16 *)_paint->getBasePtr(bkgRect.left, bkgRect.top + yy);
+ uint16 *to = (uint16 *)_bkg->getBasePtr(bkgRect.left, bkgRect.top + yy);
+ for (int xx = 0; xx < brushRect.width(); xx++) {
if (*mask != 0)
*(to + xx) = *(from + xx);
@@ -210,7 +210,7 @@ Common::Rect PaintControl::paint(const Common::Point &point) {
}
}
- return paint_rect;
+ return paintRect;
}
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h
index 54b96e8..aac4755 100644
--- a/engines/zvision/scripting/controls/paint_control.h
+++ b/engines/zvision/scripting/controls/paint_control.h
@@ -75,14 +75,14 @@ private:
Graphics::Surface *_bkg;
Graphics::Surface *_brush;
- Common::List<int> _eligible_objects;
+ Common::List<int> _eligibleObjects;
int _cursor;
Common::Rect _rectangle;
bool _mouseDown;
- bool eligeblity(int item_id);
+ bool eligeblity(int itemId);
Common::Rect paint(const Common::Point &point);
};
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 561dd1d..ea4e947 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -75,7 +75,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
// Not used
}
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index 9df61ce..de1ece5 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -43,18 +43,18 @@ namespace ZVision {
SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
: Control(engine, key, CONTROL_SAFE) {
- _num_states = 0;
- _cur_state = 0;
+ _statesCount = 0;
+ _curState = 0;
_animation = NULL;
- _radius_inner = 0;
- _radius_inner_sq = 0;
- _radius_outer = 0;
- _radius_outer_sq = 0;
- _zero_pointer = 0;
- _start_pointer = 0;
- _cur_frame = -1;
- _to_frame = 0;
- _frame_time = 0;
+ _innerRaduis = 0;
+ _innerRadiusSqr = 0;
+ _outerRadius = 0;
+ _outerRadiusSqr = 0;
+ _zeroPointer = 0;
+ _startPointer = 0;
+ _curFrame = -1;
+ _targetFrame = 0;
+ _frameTime = 0;
_lastRenderedFrame = -1;
// Loop until we find the closing brace
@@ -77,7 +77,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
_rectangle = Common::Rect(x, y, width, height);
} else if (param.matchString("num_states", true)) {
- _num_states = atoi(values.c_str());
+ _statesCount = atoi(values.c_str());
} else if (param.matchString("center", true)) {
int x;
int y;
@@ -85,29 +85,29 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
sscanf(values.c_str(), "%d %d", &x, &y);
_center = Common::Point(x, y);
} else if (param.matchString("dial_inner_radius", true)) {
- _radius_inner = atoi(values.c_str());
- _radius_inner_sq = _radius_inner * _radius_inner;
+ _innerRaduis = atoi(values.c_str());
+ _innerRadiusSqr = _innerRaduis * _innerRaduis;
} else if (param.matchString("radius", true)) {
- _radius_outer = atoi(values.c_str());
- _radius_outer_sq = _radius_outer * _radius_outer;
+ _outerRadius = atoi(values.c_str());
+ _outerRadiusSqr = _outerRadius * _outerRadius;
} else if (param.matchString("zero_radians_offset", true)) {
- _zero_pointer = atoi(values.c_str());
+ _zeroPointer = atoi(values.c_str());
} else if (param.matchString("pointer_offset", true)) {
- _start_pointer = atoi(values.c_str());
- _cur_state = _start_pointer;
+ _startPointer = atoi(values.c_str());
+ _curState = _startPointer;
} else if (param.matchString("cursor", true)) {
// Not used
} else if (param.matchString("mirrored", true)) {
// Not used
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
- renderFrame(_cur_state);
+ renderFrame(_curState);
}
SafeControl::~SafeControl() {
@@ -121,7 +121,7 @@ void SafeControl::renderFrame(uint frameNumber) {
_lastRenderedFrame = frameNumber;
} else if ((int16)frameNumber < _lastRenderedFrame) {
_lastRenderedFrame = frameNumber;
- frameNumber = (_num_states * 2) - frameNumber;
+ frameNumber = (_statesCount * 2) - frameNumber;
} else {
_lastRenderedFrame = frameNumber;
}
@@ -139,21 +139,20 @@ bool SafeControl::process(uint32 deltaTimeInMillis) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_cur_frame != _to_frame) {
- _frame_time -= deltaTimeInMillis;
+ if (_curFrame != _targetFrame) {
+ _frameTime -= deltaTimeInMillis;
- if (_frame_time <= 0) {
- if (_cur_frame < _to_frame) {
- _cur_frame++;
- renderFrame(_cur_frame);
- } else if (_cur_frame > _to_frame) {
- _cur_frame--;
- renderFrame(_cur_frame);
+ if (_frameTime <= 0) {
+ if (_curFrame < _targetFrame) {
+ _curFrame++;
+ renderFrame(_curFrame);
+ } else if (_curFrame > _targetFrame) {
+ _curFrame--;
+ renderFrame(_curFrame);
}
- _frame_time = _animation->frameTime();
+ _frameTime = _animation->frameTime();
}
}
-
return false;
}
@@ -163,12 +162,11 @@ bool SafeControl::onMouseMove(const Common::Point &screenSpacePos, const Common:
if (_rectangle.contains(backgroundImageSpacePos)) {
int32 mR = backgroundImageSpacePos.sqrDist(_center);
- if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) {
+ if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) {
_engine->getCursorManager()->changeCursor(CursorIndex_Active);
return true;
}
}
-
return false;
}
@@ -178,30 +176,29 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
if (_rectangle.contains(backgroundImageSpacePos)) {
int32 mR = backgroundImageSpacePos.sqrDist(_center);
- if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) {
+ if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) {
setVenus();
Common::Point tmp = backgroundImageSpacePos - _center;
float dd = atan2(tmp.x, tmp.y) * 57.29578;
- int16 dp_state = 360 / _num_states;
+ int16 dp_state = 360 / _statesCount;
- int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states;
+ int16 m_state = (_statesCount - ((((int16)dd + 540) % 360) / dp_state)) % _statesCount;
- int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1) % _num_states;
+ int16 tmp2 = (m_state + _curState - _zeroPointer + _statesCount - 1) % _statesCount;
- _cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states;
+ _curFrame = (_curState + _statesCount - _startPointer) % _statesCount;
- _cur_state = (_num_states * 2 + tmp2) % _num_states;
+ _curState = (_statesCount * 2 + tmp2) % _statesCount;
- _to_frame = (_cur_state + _num_states - _start_pointer) % _num_states;
+ _targetFrame = (_curState + _statesCount - _startPointer) % _statesCount;
- _engine->getScriptManager()->setStateValue(_key, _cur_state);
+ _engine->getScriptManager()->setStateValue(_key, _curState);
return true;
}
}
-
return false;
}
diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h
index 2477d8c..e682e35 100644
--- a/engines/zvision/scripting/controls/safe_control.h
+++ b/engines/zvision/scripting/controls/safe_control.h
@@ -40,20 +40,20 @@ public:
~SafeControl();
private:
- int16 _num_states;
- int16 _cur_state;
+ int16 _statesCount;
+ int16 _curState;
MetaAnimation *_animation;
Common::Point _center;
Common::Rect _rectangle;
- int16 _radius_inner;
- int32 _radius_inner_sq;
- int16 _radius_outer;
- int32 _radius_outer_sq;
- int16 _zero_pointer;
- int16 _start_pointer;
- int16 _cur_frame;
- int16 _to_frame;
- int32 _frame_time;
+ int16 _innerRaduis;
+ int32 _innerRadiusSqr;
+ int16 _outerRadius;
+ int32 _outerRadiusSqr;
+ int16 _zeroPointer;
+ int16 _startPointer;
+ int16 _curFrame;
+ int16 _targetFrame;
+ int32 _frameTime;
int16 _lastRenderedFrame;
diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp
index a0b19db..7e1a65a 100644
--- a/engines/zvision/scripting/controls/save_control.cpp
+++ b/engines/zvision/scripting/controls/save_control.cpp
@@ -50,13 +50,13 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
while (!stream.eos() && !line.contains('}')) {
if (param.matchString("savebox", true)) {
- int save_id;
- int input_id;
+ int saveId;
+ int inputId;
- sscanf(values.c_str(), "%d %d", &save_id, &input_id);
- save_elmnt elmnt;
- elmnt.input_key = input_id;
- elmnt.save_id = save_id;
+ sscanf(values.c_str(), "%d %d", &saveId, &inputId);
+ saveElement elmnt;
+ elmnt.inputKey = inputId;
+ elmnt.saveId = saveId;
elmnt.exist = false;
_inputs.push_back(elmnt);
} else if (param.matchString("control_type", true)) {
@@ -72,11 +72,11 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
- Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key);
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey);
if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
InputControl *inp = (InputControl *)ctrl;
inp->setReadOnly(!_saveControl);
- Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->save_id);
+ Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->saveId);
if (save) {
SaveGameHeader header;
_engine->getSaveManager()->readSaveGameHeader(save, header);
@@ -90,7 +90,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
bool SaveControl::process(uint32 deltaTimeInMillis) {
for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
- Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key);
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey);
if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
InputControl *inp = (InputControl *)ctrl;
if (inp->enterPress()) {
@@ -102,7 +102,7 @@ bool SaveControl::process(uint32 deltaTimeInMillis) {
toSave = false;
if (toSave) {
- _engine->getSaveManager()->saveGameBuffered(iter->save_id, inp->getText());
+ _engine->getSaveManager()->saveGameBuffered(iter->saveId, inp->getText());
_engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000);
_engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation());
}
@@ -110,7 +110,7 @@ bool SaveControl::process(uint32 deltaTimeInMillis) {
_engine->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000);
}
} else {
- _engine->getSaveManager()->loadGame(iter->save_id);
+ _engine->getSaveManager()->loadGame(iter->saveId);
return true;
}
break;
diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h
index 942b9c9..fefb0e0 100644
--- a/engines/zvision/scripting/controls/save_control.h
+++ b/engines/zvision/scripting/controls/save_control.h
@@ -35,12 +35,12 @@ public:
SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
private:
- struct save_elmnt {
- int save_id;
- int input_key;
+ struct saveElement {
+ int saveId;
+ int inputKey;
bool exist;
};
- typedef Common::List<save_elmnt> saveElmntList;
+ typedef Common::List<saveElement> saveElmntList;
saveElmntList _inputs;
bool _saveControl;
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
index 46ee320..074d190 100644
--- a/engines/zvision/scripting/controls/slot_control.cpp
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -38,7 +38,7 @@ namespace ZVision {
SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
: Control(engine, key, CONTROL_SLOT) {
- _rendered_item = 0;
+ _renderedItem = 0;
_bkg = NULL;
// Loop until we find the closing brace
@@ -70,9 +70,9 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
} else if (param.matchString("cursor", true)) {
_cursor = _engine->getCursorManager()->getCursorId(values);
} else if (param.matchString("distance_id", true)) {
- sscanf(values.c_str(), "%c", &_distance_id);
+ sscanf(values.c_str(), "%c", &_distanceId);
} else if (param.matchString("venus_id", true)) {
- _venus_id = atoi(values.c_str());
+ _venusId = atoi(values.c_str());
} else if (param.matchString("eligible_objects", true)) {
char buf[256];
memset(buf, 0, 256);
@@ -94,7 +94,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
int obj = atoi(st);
- _eligible_objects.push_back(obj);
+ _eligibleObjects.push_back(obj);
}
}
@@ -124,26 +124,26 @@ bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
setVenus();
int item = _engine->getScriptManager()->getStateValue(_key);
- int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
if (item != 0) {
- if (mouse_item != 0) {
- if (eligeblity(mouse_item)) {
- _engine->getScriptManager()->invertory_drop(mouse_item);
- _engine->getScriptManager()->invertory_add(item);
- _engine->getScriptManager()->setStateValue(_key, mouse_item);
+ if (mouseItem != 0) {
+ if (eligeblity(mouseItem)) {
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
+ _engine->getScriptManager()->inventoryAdd(item);
+ _engine->getScriptManager()->setStateValue(_key, mouseItem);
}
} else {
- _engine->getScriptManager()->invertory_add(item);
+ _engine->getScriptManager()->inventoryAdd(item);
_engine->getScriptManager()->setStateValue(_key, 0);
}
- } else if (mouse_item == 0) {
+ } else if (mouseItem == 0) {
if (eligeblity(0)) {
- _engine->getScriptManager()->invertory_drop(0);
+ _engine->getScriptManager()->inventoryDrop(0);
_engine->getScriptManager()->setStateValue(_key, 0);
}
- } else if (eligeblity(mouse_item)) {
- _engine->getScriptManager()->setStateValue(_key, mouse_item);
- _engine->getScriptManager()->invertory_drop(mouse_item);
+ } else if (eligeblity(mouseItem)) {
+ _engine->getScriptManager()->setStateValue(_key, mouseItem);
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
}
}
return false;
@@ -166,13 +166,13 @@ bool SlotControl::process(uint32 deltaTimeInMillis) {
return false;
if (_engine->canRender()) {
- int cur_item = _engine->getScriptManager()->getStateValue(_key);
- if (cur_item != _rendered_item) {
- if (_rendered_item != 0 && cur_item == 0) {
+ int curItem = _engine->getScriptManager()->getStateValue(_key);
+ if (curItem != _renderedItem) {
+ if (_renderedItem != 0 && curItem == 0) {
_engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
- _rendered_item = cur_item;
+ _renderedItem = curItem;
} else {
- if (_rendered_item == 0) {
+ if (_renderedItem == 0) {
if (_bkg)
delete _bkg;
@@ -183,9 +183,9 @@ bool SlotControl::process(uint32 deltaTimeInMillis) {
char buf[16];
if (_engine->getGameId() == GID_NEMESIS)
- sprintf(buf, "%d%cobj.tga", cur_item, _distance_id);
+ sprintf(buf, "%d%cobj.tga", curItem, _distanceId);
else
- sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item);
+ sprintf(buf, "g0z%cu%2.2x1.tga", _distanceId, curItem);
Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);
@@ -202,16 +202,16 @@ bool SlotControl::process(uint32 deltaTimeInMillis) {
delete srf;
- _rendered_item = cur_item;
+ _renderedItem = curItem;
}
}
}
return false;
}
-bool SlotControl::eligeblity(int item_id) {
- for (Common::List<int>::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++)
- if (*it == item_id)
+bool SlotControl::eligeblity(int itemId) {
+ for (Common::List<int>::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++)
+ if (*it == itemId)
return true;
return false;
}
diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h
index 7799785..86fd261 100644
--- a/engines/zvision/scripting/controls/slot_control.h
+++ b/engines/zvision/scripting/controls/slot_control.h
@@ -66,13 +66,13 @@ private:
Common::Rect _hotspot;
int _cursor;
- char _distance_id;
+ char _distanceId;
- int _rendered_item;
+ int _renderedItem;
- Common::List<int> _eligible_objects;
+ Common::List<int> _eligibleObjects;
- bool eligeblity(int item_id);
+ bool eligeblity(int itemId);
Graphics::Surface *_bkg;
diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp
index f8b2297..98d0633 100644
--- a/engines/zvision/scripting/inventory.cpp
+++ b/engines/zvision/scripting/inventory.cpp
@@ -27,95 +27,95 @@
namespace ZVision {
-int8 ScriptManager::invertory_getCount() {
+int8 ScriptManager::inventoryGetCount() {
return getStateValue(StateKey_Inv_Cnt_Slot);
}
-void ScriptManager::invertory_setCount(int8 cnt) {
+void ScriptManager::inventorySetCount(int8 cnt) {
setStateValue(StateKey_Inv_Cnt_Slot, cnt);
}
-int16 ScriptManager::invertory_getItem(int8 id) {
+int16 ScriptManager::inventoryGetItem(int8 id) {
if (id < 49 && id >= 0)
return getStateValue(StateKey_Inv_1_Slot + id);
return -1;
}
-void ScriptManager::invertory_setItem(int8 id, int16 item) {
+void ScriptManager::inventorySetItem(int8 id, int16 item) {
if (id < 49 && id >= 0)
setStateValue(StateKey_Inv_1_Slot + id, item);
}
-void ScriptManager::invertory_add(int16 item) {
- int8 cnt = invertory_getCount();
+void ScriptManager::inventoryAdd(int16 item) {
+ int8 cnt = inventoryGetCount();
if (cnt < 49) {
- bool not_exist = true;
+ bool notExist = true;
if (cnt == 0) {
- invertory_setItem(0, 0);
- invertory_setCount(1); // we needed empty item for cycle code
+ inventorySetItem(0, 0);
+ inventorySetCount(1); // we needed empty item for cycle code
cnt = 1;
}
for (int8 cur = 0; cur < cnt; cur++)
- if (invertory_getItem(cur) == item) {
- not_exist = false;
+ if (inventoryGetItem(cur) == item) {
+ notExist = false;
break;
}
- if (not_exist) {
+ if (notExist) {
for (int8 i = cnt; i > 0; i--)
- invertory_setItem(i, invertory_getItem(i - 1));
+ inventorySetItem(i, inventoryGetItem(i - 1));
- invertory_setItem(0, item);
+ inventorySetItem(0, item);
setStateValue(StateKey_InventoryItem, item);
- invertory_setCount(cnt + 1);
+ inventorySetCount(cnt + 1);
}
}
}
-void ScriptManager::invertory_drop(int16 item) {
- int8 items_cnt = invertory_getCount();
+void ScriptManager::inventoryDrop(int16 item) {
+ int8 itemCount = inventoryGetCount();
// if items in inventory > 0
- if (items_cnt != 0) {
+ if (itemCount != 0) {
int8 index = 0;
// finding needed item
- while (index < items_cnt) {
- if (invertory_getItem(index) == item)
+ while (index < itemCount) {
+ if (inventoryGetItem(index) == item)
break;
index++;
}
// if item in the inventory
- if (items_cnt != index) {
+ if (itemCount != index) {
// shift all items left with rewrite founded item
- for (int8 v = index; v < items_cnt - 1 ; v++)
- invertory_setItem(v, invertory_getItem(v + 1));
+ for (int8 v = index; v < itemCount - 1 ; v++)
+ inventorySetItem(v, inventoryGetItem(v + 1));
// del last item
- invertory_setItem(items_cnt - 1, 0);
- invertory_setCount(invertory_getCount() - 1);
+ inventorySetItem(itemCount - 1, 0);
+ inventorySetCount(inventoryGetCount() - 1);
- setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+ setStateValue(StateKey_InventoryItem, inventoryGetItem(0));
}
}
}
-void ScriptManager::invertory_cycle() {
- int8 item_cnt = invertory_getCount();
- int8 cur_item = invertory_getItem(0);
- if (item_cnt > 1) {
- for (int8 i = 0; i < item_cnt - 1; i++)
- invertory_setItem(i, invertory_getItem(i + 1));
+void ScriptManager::inventoryCycle() {
+ int8 itemCount = inventoryGetCount();
+ int8 curItem = inventoryGetItem(0);
+ if (itemCount > 1) {
+ for (int8 i = 0; i < itemCount - 1; i++)
+ inventorySetItem(i, inventoryGetItem(i + 1));
- invertory_setItem(item_cnt - 1, cur_item);
+ inventorySetItem(itemCount - 1, curItem);
- setStateValue(StateKey_InventoryItem, invertory_getItem(0));
+ setStateValue(StateKey_InventoryItem, inventoryGetItem(0));
}
}
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 5e0387f..697de58 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -46,7 +46,7 @@
namespace ZVision {
-void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) {
+void ScriptManager::parseScrFile(const Common::String &fileName, ScriptScope &scope) {
Common::File file;
if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Script file not found: %s", fileName.c_str());
@@ -70,15 +70,15 @@ void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &s
if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST)
setStateValue(puzzle->key, 0);
parsePuzzle(puzzle, file);
- scope._puzzles.push_back(puzzle);
+ scope.puzzles.push_back(puzzle);
} else if (line.matchString("control:*", true)) {
Control *ctrl = parseControl(line, file);
if (ctrl)
- scope._controls.push_back(ctrl);
+ scope.controls.push_back(ctrl);
}
}
- scope.proc_count = 0;
+ scope.procCount = 0;
}
void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
@@ -196,8 +196,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
for (pos = startpos; pos < line.size(); pos++)
if (chrs[pos] == '(')
break;
- Common::String s_slot(chrs + startpos, chrs + pos);
- slot = atoi(s_slot.c_str());
+ Common::String strSlot(chrs + startpos, chrs + pos);
+ slot = atoi(strSlot.c_str());
startpos = pos + 1;
}
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 7df4818..2a54cc4 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -76,7 +76,7 @@ void ScriptManager::update(uint deltaTimeMillis) {
_currentLocation.room != _nextLocation.room ||
_currentLocation.view != _nextLocation.view ||
_currentLocation.world != _nextLocation.world)
- do_changeLocation();
+ ChangeLocationReal();
updateNodes(deltaTimeMillis);
if (! execScope(nodeview))
@@ -90,35 +90,35 @@ void ScriptManager::update(uint deltaTimeMillis) {
updateControls(deltaTimeMillis);
}
-bool ScriptManager::execScope(script_scope &scope) {
+bool ScriptManager::execScope(ScriptScope &scope) {
// Swap queues
- PuzzleList *tmp = scope.exec_queue;
- scope.exec_queue = scope.scope_queue;
- scope.scope_queue = tmp;
- scope.scope_queue->clear();
+ PuzzleList *tmp = scope.execQueue;
+ scope.execQueue = scope.scopeQueue;
+ scope.scopeQueue = tmp;
+ scope.scopeQueue->clear();
- for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter)
(*PuzzleIter)->addedBySetState = 0;
- if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) {
- for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
- if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ if (scope.procCount < 2 || getStateValue(StateKey_ExecScopeStyle)) {
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter)
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount))
return false;
} else {
- for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter)
- if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ for (PuzzleList::iterator PuzzleIter = scope.execQueue->begin(); PuzzleIter != scope.execQueue->end(); ++PuzzleIter)
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount))
return false;
}
- if (scope.proc_count < 2) {
- scope.proc_count++;
+ if (scope.procCount < 2) {
+ scope.procCount++;
}
return true;
}
-void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
+void ScriptManager::referenceTableAddPuzzle(uint32 key, PuzzleRef ref) {
if (_referenceTable.contains(key)) {
- Common::Array<puzzle_ref> *arr = &_referenceTable[key];
+ Common::Array<PuzzleRef> *arr = &_referenceTable[key];
for (uint32 i = 0; i < arr->size(); i++)
if ((*arr)[i].puz == ref.puz)
return;
@@ -127,12 +127,12 @@ void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
_referenceTable[key].push_back(ref);
}
-void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) {
+void ScriptManager::addPuzzlesToReferenceTable(ScriptScope &scope) {
// Iterate through each local Puzzle
- for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) {
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) {
Puzzle *puzzlePtr = (*PuzzleIter);
- puzzle_ref ref;
+ PuzzleRef ref;
ref.scope = &scope;
ref.puz = puzzlePtr;
@@ -270,22 +270,22 @@ void ScriptManager::cleanStateTable() {
}
}
-void ScriptManager::cleanScriptScope(script_scope &scope) {
- scope._priv_queue_one.clear();
- scope._priv_queue_two.clear();
- scope.scope_queue = &scope._priv_queue_one;
- scope.exec_queue = &scope._priv_queue_two;
- for (PuzzleList::iterator iter = scope._puzzles.begin(); iter != scope._puzzles.end(); ++iter)
+void ScriptManager::cleanScriptScope(ScriptScope &scope) {
+ scope.privQueueOne.clear();
+ scope.privQueueTwo.clear();
+ scope.scopeQueue = &scope.privQueueOne;
+ scope.execQueue = &scope.privQueueTwo;
+ for (PuzzleList::iterator iter = scope.puzzles.begin(); iter != scope.puzzles.end(); ++iter)
delete(*iter);
- scope._puzzles.clear();
+ scope.puzzles.clear();
- for (ControlList::iterator iter = scope._controls.begin(); iter != scope._controls.end(); ++iter)
+ for (ControlList::iterator iter = scope.controls.begin(); iter != scope.controls.end(); ++iter)
delete(*iter);
- scope._controls.clear();
+ scope.controls.clear();
- scope.proc_count = 0;
+ scope.procCount = 0;
}
int ScriptManager::getStateValue(uint32 key) {
@@ -297,10 +297,10 @@ int ScriptManager::getStateValue(uint32 key) {
void ScriptManager::queuePuzzles(uint32 key) {
if (_referenceTable.contains(key)) {
- Common::Array<puzzle_ref> *arr = &_referenceTable[key];
+ Common::Array<PuzzleRef> *arr = &_referenceTable[key];
for (int32 i = arr->size() - 1; i >= 0; i--)
if (!(*arr)[i].puz->addedBySetState) {
- (*arr)[i].scope->scope_queue->push_back((*arr)[i].puz);
+ (*arr)[i].scope->scopeQueue->push_back((*arr)[i].puz);
(*arr)[i].puz->addedBySetState = true;
}
}
@@ -518,7 +518,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi
}
}
-void ScriptManager::do_changeLocation() {
+void ScriptManager::ChangeLocationReal() {
assert(_nextLocation.world != 0);
debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
@@ -605,7 +605,7 @@ void ScriptManager::do_changeLocation() {
addPuzzlesToReferenceTable(nodeview);
}
- _activeControls = &nodeview._controls;
+ _activeControls = &nodeview.controls;
// Revert to the idle cursor
_engine->getCursorManager()->changeCursor(CursorIndex_Idle);
@@ -701,19 +701,17 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
return;
}
- Location next_loc;
+ Location nextLocation;
- next_loc.world = stream->readByte();
- next_loc.room = stream->readByte();
- next_loc.node = stream->readByte();
- next_loc.view = stream->readByte();
- next_loc.offset = stream->readUint32LE() & 0x0000FFFF;
+ nextLocation.world = stream->readByte();
+ nextLocation.room = stream->readByte();
+ nextLocation.node = stream->readByte();
+ nextLocation.view = stream->readByte();
+ nextLocation.offset = stream->readUint32LE() & 0x0000FFFF;
- // What the fck, eos is not 'return pos >= size'
- // while (!stream->eos()) {*/
while (stream->pos() < stream->size()) {
uint32 tag = stream->readUint32BE();
- uint32 tag_size = stream->readUint32LE();
+ uint32 tagSize = stream->readUint32LE();
switch (tag) {
case MKTAG('T', 'I', 'M', 'R'): {
uint32 key = stream->readUint32LE();
@@ -726,22 +724,22 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
}
break;
case MKTAG('F', 'L', 'A', 'G'):
- for (uint32 i = 0; i < tag_size / 2; i++)
+ for (uint32 i = 0; i < tagSize / 2; i++)
setStateFlagSilent(i, stream->readUint16LE());
break;
case MKTAG('P', 'U', 'Z', 'Z'):
- for (uint32 i = 0; i < tag_size / 2; i++)
+ for (uint32 i = 0; i < tagSize / 2; i++)
setStateValueSilent(i, stream->readUint16LE());
break;
default:
- stream->seek(tag_size, SEEK_CUR);
+ stream->seek(tagSize, SEEK_CUR);
}
}
- _nextLocation = next_loc;
+ _nextLocation = nextLocation;
+
+ ChangeLocationReal();
- do_changeLocation();
- // Place for read prefs
_engine->setRenderDelay(10);
setStateValue(StateKey_RestoreFlag, 1);
@@ -792,23 +790,23 @@ void ScriptManager::flushEvent(Common::EventType type) {
}
}
-ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val):
- _sc_man(sc_man) {
+ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue):
+ _scriptManager(scriptManager) {
value = 0;
slot = false;
- const char *is_slot = strstr(slot_val, "[");
- if (is_slot) {
+ const char *isSlot = strstr(slotValue, "[");
+ if (isSlot) {
slot = true;
- value = atoi(is_slot + 1);
+ value = atoi(isSlot + 1);
} else {
slot = false;
- value = atoi(slot_val);
+ value = atoi(slotValue);
}
}
int16 ValueSlot::getValue() {
if (slot) {
if (value >= 0)
- return _sc_man->getStateValue(value);
+ return _scriptManager->getStateValue(value);
else
return 0;
} else
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index ddb8c88..5701cde 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -123,24 +123,24 @@ public:
private:
ZVision *_engine;
- struct script_scope {
- uint32 proc_count;
+ struct ScriptScope {
+ uint32 procCount;
- PuzzleList *scope_queue; // For adding puzzles to queue
- PuzzleList *exec_queue; // Switch to it when execute
- PuzzleList _priv_queue_one;
- PuzzleList _priv_queue_two;
+ PuzzleList *scopeQueue; // For adding puzzles to queue
+ PuzzleList *execQueue; // Switch to it when execute
+ PuzzleList privQueueOne;
+ PuzzleList privQueueTwo;
- PuzzleList _puzzles;
- ControlList _controls;
+ PuzzleList puzzles;
+ ControlList controls;
};
- struct puzzle_ref {
+ struct PuzzleRef {
Puzzle *puz;
- script_scope *scope;
+ ScriptScope *scope;
};
- typedef Common::HashMap<uint32, Common::Array<puzzle_ref> > PuzzleMap;
+ typedef Common::HashMap<uint32, Common::Array<PuzzleRef> > PuzzleMap;
/**
* Holds the global state variable. Do NOT directly modify this. Use the accessors and
@@ -157,10 +157,10 @@ private:
EventList _controlEvents;
- script_scope universe;
- script_scope world;
- script_scope room;
- script_scope nodeview;
+ ScriptScope universe;
+ ScriptScope world;
+ ScriptScope room;
+ ScriptScope nodeview;
/** Holds the currently active timers, musics, other */
SideFXList _activeSideFx;
@@ -249,30 +249,30 @@ public:
Location getLastMenuLocation();
private:
- void referenceTableAddPuzzle(uint32 key, puzzle_ref ref);
- void addPuzzlesToReferenceTable(script_scope &scope);
+ void referenceTableAddPuzzle(uint32 key, PuzzleRef ref);
+ void addPuzzlesToReferenceTable(ScriptScope &scope);
void updateNodes(uint deltaTimeMillis);
void updateControls(uint deltaTimeMillis);
bool checkPuzzleCriteria(Puzzle *puzzle, uint counter);
void cleanStateTable();
- void cleanScriptScope(script_scope &scope);
- bool execScope(script_scope &scope);
+ void cleanScriptScope(ScriptScope &scope);
+ bool execScope(ScriptScope &scope);
/** Perform change location */
- void do_changeLocation();
+ void ChangeLocationReal();
- int8 invertory_getCount();
- void invertory_setCount(int8 cnt);
- int16 invertory_getItem(int8 id);
- void invertory_setItem(int8 id, int16 item);
+ int8 inventoryGetCount();
+ void inventorySetCount(int8 cnt);
+ int16 inventoryGetItem(int8 id);
+ void inventorySetItem(int8 id, int16 item);
void setStateFlagSilent(uint32 key, uint value);
void setStateValueSilent(uint32 key, int value);
public:
- void invertory_add(int16 item);
- void invertory_drop(int16 item);
- void invertory_cycle();
+ void inventoryAdd(int16 item);
+ void inventoryDrop(int16 item);
+ void inventoryCycle();
// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
/**
@@ -281,7 +281,7 @@ public:
* @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, script_scope &scope);
+ void parseScrFile(const Common::String &fileName, ScriptScope &scope);
private:
/**
@@ -332,12 +332,12 @@ private:
class ValueSlot {
public:
- ValueSlot(ScriptManager *sc_man, const char *slot_val);
+ ValueSlot(ScriptManager *scriptManager, const char *slotValue);
int16 getValue();
private:
int16 value;
bool slot;
- ScriptManager *_sc_man;
+ ScriptManager *_scriptManager;
};
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
index bd9c543..98ac4e3 100644
--- a/engines/zvision/scripting/sidefx/animation_node.cpp
+++ b/engines/zvision/scripting/sidefx/animation_node.cpp
@@ -75,19 +75,19 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
const Graphics::Surface *frame = NULL;
- if (nod->_cur_frm == -1) { // Start of new playlist node
- nod->_cur_frm = nod->start;
+ if (nod->_curFrame == -1) { // Start of new playlist node
+ nod->_curFrame = nod->start;
- _animation->seekToFrame(nod->_cur_frm);
+ _animation->seekToFrame(nod->_curFrame);
frame = _animation->decodeNextFrame();
nod->_delay = _frmDelay;
if (nod->slot)
_engine->getScriptManager()->setStateValue(nod->slot, 1);
} else {
- nod->_cur_frm++;
+ nod->_curFrame++;
- if (nod->_cur_frm > nod->stop) {
+ if (nod->_curFrame > nod->stop) {
nod->loop--;
if (nod->loop == 0) {
@@ -99,8 +99,8 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
return _DisposeAfterUse;
}
- nod->_cur_frm = nod->start;
- _animation->seekToFrame(nod->_cur_frm);
+ nod->_curFrame = nod->start;
+ _animation->seekToFrame(nod->_curFrame);
}
frame = _animation->decodeNextFrame();
@@ -156,18 +156,18 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) {
-void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) {
+void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) {
playnode nod;
nod.loop = loops;
nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
- nod.start = start_frame;
- nod.stop = end_frame;
+ nod.start = startFrame;
+ nod.stop = endFrame;
if (nod.stop >= (int)_animation->frameCount())
nod.stop = _animation->frameCount() - 1;
nod.slot = slot;
- nod._cur_frm = -1;
+ nod._curFrame = -1;
nod._delay = 0;
nod._scaled = NULL;
_playList.push_back(nod);
diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h
index 4d1c74b..dab3d88 100644
--- a/engines/zvision/scripting/sidefx/animation_node.h
+++ b/engines/zvision/scripting/sidefx/animation_node.h
@@ -52,7 +52,7 @@ public:
int32 start;
int32 stop;
int32 loop;
- int32 _cur_frm;
+ int32 _curFrame;
int32 _delay;
Graphics::Surface *_scaled;
};
@@ -71,7 +71,7 @@ private:
public:
bool process(uint32 deltaTimeInMillis);
- void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1);
+ void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1);
bool stop();
diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp
index 576a1f8..9be6b29 100644
--- a/engines/zvision/scripting/sidefx/distort_node.cpp
+++ b/engines/zvision/scripting/sidefx/distort_node.cpp
@@ -34,7 +34,7 @@
namespace ZVision {
-DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin)
+DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale)
: SideFX(engine, key, SIDEFX_DISTORT) {
_angle = _engine->getRenderManager()->getRenderTable()->getAngle();
@@ -42,15 +42,15 @@ DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl
_speed = speed;
_incr = true;
- _st_angl = st_angl;
- _en_angl = en_angl;
- _st_lin = st_lin;
- _en_lin = en_lin;
+ _startAngle = startAngle;
+ _endAngle = endAngle;
+ _startLineScale = startLineScale;
+ _endLineScale = endLineScale;
_curFrame = 1.0;
- _diff_angl = en_angl - st_angl;
- _diff_lin = en_lin - st_lin;
+ _diffAngle = endAngle - startAngle;
+ _diffLinScale = endLineScale - startLineScale;
_frmSpeed = (float)speed / 15.0;
_frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
@@ -85,7 +85,7 @@ bool DistortNode::process(uint32 deltaTimeInMillis) {
float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
- setParams(_st_angl + diff * _diff_angl, _st_lin + diff * _diff_lin);
+ setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale);
return false;
}
diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h
index cba9c5e..787a69b 100644
--- a/engines/zvision/scripting/sidefx/distort_node.h
+++ b/engines/zvision/scripting/sidefx/distort_node.h
@@ -31,21 +31,21 @@ class ZVision;
class DistortNode : public SideFX {
public:
- DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin);
+ DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale);
~DistortNode();
bool process(uint32 deltaTimeInMillis);
private:
int16 _speed;
- float _st_angl;
- float _en_angl;
- float _st_lin;
- float _en_lin;
+ float _startAngle;
+ float _endAngle;
+ float _startLineScale;
+ float _endLineScale;
float _frmSpeed;
- float _diff_angl;
- float _diff_lin;
+ float _diffAngle;
+ float _diffLinScale;
bool _incr;
int16 _frames;
diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp
index 4420da3..e9baadb 100644
--- a/engines/zvision/scripting/sidefx/music_node.cpp
+++ b/engines/zvision/scripting/sidefx/music_node.cpp
@@ -38,15 +38,15 @@
namespace ZVision {
MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
- : MusicNode_BASE(engine, key, SIDEFX_AUDIO) {
+ : MusicNodeBASE(engine, key, SIDEFX_AUDIO) {
_loop = loop;
_volume = volume;
_crossfade = false;
- _crossfade_target = 0;
- _crossfade_time = 0;
+ _crossfadeTarget = 0;
+ _crossfadeTime = 0;
_attenuate = 0;
_pantrack = false;
- _pantrack_X = 0;
+ _pantrackPosition = 0;
_sub = NULL;
Audio::RewindableAudioStream *audioStream;
@@ -93,7 +93,7 @@ MusicNode::~MusicNode() {
void MusicNode::setPanTrack(int16 pos) {
if (!_stereo) {
_pantrack = true;
- _pantrack_X = pos;
+ _pantrackPosition = pos;
setVolume(_volume);
}
}
@@ -104,8 +104,8 @@ void MusicNode::unsetPanTrack() {
}
void MusicNode::setFade(int32 time, uint8 target) {
- _crossfade_target = target;
- _crossfade_time = time;
+ _crossfadeTarget = target;
+ _crossfadeTime = time;
_crossfade = true;
}
@@ -116,14 +116,14 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
uint8 _newvol = _volume;
if (_crossfade) {
- if (_crossfade_time > 0) {
- if ((int32)deltaTimeInMillis > _crossfade_time)
- deltaTimeInMillis = _crossfade_time;
- _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis;
- _crossfade_time -= deltaTimeInMillis;
+ if (_crossfadeTime > 0) {
+ if ((int32)deltaTimeInMillis > _crossfadeTime)
+ deltaTimeInMillis = _crossfadeTime;
+ _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis;
+ _crossfadeTime -= deltaTimeInMillis;
} else {
_crossfade = false;
- _newvol = _crossfade_target;
+ _newvol = _crossfadeTarget;
}
}
@@ -136,17 +136,17 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
return false;
}
-void MusicNode::setVolume(uint8 new_volume) {
+void MusicNode::setVolume(uint8 newVolume) {
if (_pantrack) {
- int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
- cur_x -= _pantrack_X;
+ int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+ curX -= _pantrackPosition;
int32 _width = _engine->getRenderManager()->getBkgSize().x;
- if (cur_x < (-_width) / 2)
- cur_x += _width;
- else if (cur_x >= _width / 2)
- cur_x -= _width;
+ if (curX < (-_width) / 2)
+ curX += _width;
+ else if (curX >= _width / 2)
+ curX -= _width;
- float norm = (float)cur_x / ((float)_width / 2.0);
+ float norm = (float)curX / ((float)_width / 2.0);
float lvl = fabs(norm);
if (lvl > 0.5)
lvl = (lvl - 0.5) * 1.7;
@@ -157,16 +157,16 @@ void MusicNode::setVolume(uint8 new_volume) {
if (_engine->_mixer->isSoundHandleActive(_handle)) {
_engine->_mixer->setChannelBalance(_handle, bal);
- _engine->_mixer->setChannelVolume(_handle, new_volume * lvl);
+ _engine->_mixer->setChannelVolume(_handle, newVolume * lvl);
}
} else {
if (_engine->_mixer->isSoundHandleActive(_handle)) {
_engine->_mixer->setChannelBalance(_handle, 0);
- _engine->_mixer->setChannelVolume(_handle, new_volume);
+ _engine->_mixer->setChannelVolume(_handle, newVolume);
}
}
- _volume = new_volume;
+ _volume = newVolume;
}
PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
@@ -175,7 +175,7 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode_BASE *mus = (MusicNode_BASE *)fx;
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
mus->setPanTrack(pos);
}
}
@@ -183,14 +183,14 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
PanTrackNode::~PanTrackNode() {
SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNode_BASE *mus = (MusicNode_BASE *)fx;
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
mus->unsetPanTrack();
}
}
MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
- : MusicNode_BASE(engine, key, SIDEFX_AUDIO) {
+ : MusicNodeBASE(engine, key, SIDEFX_AUDIO) {
_volume = volume;
_prog = program;
_noteNumber = note;
@@ -230,11 +230,11 @@ bool MusicMidiNode::process(uint32 deltaTimeInMillis) {
return false;
}
-void MusicMidiNode::setVolume(uint8 new_volume) {
+void MusicMidiNode::setVolume(uint8 newVolume) {
if (_chan >= 0) {
- _engine->getMidiManager()->setVolume(_chan, new_volume);
+ _engine->getMidiManager()->setVolume(_chan, newVolume);
}
- _volume = new_volume;
+ _volume = newVolume;
}
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
index 262b130..954e2f4 100644
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -33,10 +33,10 @@ class String;
namespace ZVision {
-class MusicNode_BASE : public SideFX {
+class MusicNodeBASE : public SideFX {
public:
- MusicNode_BASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {}
- ~MusicNode_BASE() {}
+ MusicNodeBASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {}
+ ~MusicNodeBASE() {}
/**
* Decrement the timer by the delta time. If the timer is finished, set the status
@@ -55,7 +55,7 @@ public:
virtual void setFade(int32 time, uint8 target) = 0;
};
-class MusicNode : public MusicNode_BASE {
+class MusicNode : public MusicNodeBASE {
public:
MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
~MusicNode();
@@ -79,19 +79,19 @@ public:
private:
int32 _timeLeft;
bool _pantrack;
- int32 _pantrack_X;
+ int32 _pantrackPosition;
int32 _attenuate;
uint8 _volume;
bool _loop;
bool _crossfade;
- uint8 _crossfade_target;
- int32 _crossfade_time;
+ uint8 _crossfadeTarget;
+ int32 _crossfadeTime;
bool _stereo;
Audio::SoundHandle _handle;
Subtitle *_sub;
};
-class MusicMidiNode : public MusicNode_BASE {
+class MusicMidiNode : public MusicNodeBASE {
public:
MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
~MusicMidiNode();
diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h
index a6326c7..a229129 100644
--- a/engines/zvision/scripting/sidefx/ttytext_node.h
+++ b/engines/zvision/scripting/sidefx/ttytext_node.h
@@ -50,15 +50,12 @@ public:
bool process(uint32 deltaTimeInMillis);
private:
Common::Rect _r;
- //int16 x;
- //int16 y;
- //uint16 w;
- //uint16 h;
+
cTxtStyle _style;
- sTTFont _fnt;
+ StyledTTFont _fnt;
Common::String _txtbuf;
uint32 _txtpos;
- //int32 txtsize;
+
int32 _delay;
int32 _nexttime;
Graphics::Surface _img;
diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp
index 4ca48f7..1f68b24 100644
--- a/engines/zvision/subtitles/subtitles.cpp
+++ b/engines/zvision/subtitles/subtitles.cpp
@@ -52,12 +52,12 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
if (_engine->getSearchManager()->openFile(txt, filename)) {
while (!txt.eos()) {
Common::String txtline = readWideLine(txt);
- sub cur_sub;
- cur_sub.start = -1;
- cur_sub.stop = -1;
- cur_sub.sub = txtline;
+ sub curSubtitle;
+ curSubtitle.start = -1;
+ curSubtitle.stop = -1;
+ curSubtitle.sub = txtline;
- _subs.push_back(cur_sub);
+ _subs.push_back(curSubtitle);
}
txt.close();
}
diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp
index efb0fb4..872d687 100644
--- a/engines/zvision/text/text.cpp
+++ b/engines/zvision/text/text.cpp
@@ -233,71 +233,71 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
}
void cTxtStyle::readAllStyle(const Common::String &txt) {
- int16 strt = -1;
- int16 endt = -1;
+ int16 startTextPosition = -1;
+ int16 endTextPosition = -1;
for (uint16 i = 0; i < txt.size(); i++) {
if (txt[i] == '<')
- strt = i;
+ startTextPosition = i;
else if (txt[i] == '>') {
- endt = i;
- if (strt != -1)
- if ((endt - strt - 1) > 0)
- parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1);
+ endTextPosition = i;
+ if (startTextPosition != -1)
+ if ((endTextPosition - startTextPosition - 1) > 0)
+ parseStyle(Common::String(txt.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1);
}
}
}
-void cTxtStyle::setFontStyle(sTTFont &font) {
- uint temp_stl = 0;
+void cTxtStyle::setFontStyle(StyledTTFont &font) {
+ uint tempStyle = 0;
if (bold)
- temp_stl |= sTTFont::STTF_BOLD;
+ tempStyle |= StyledTTFont::STTF_BOLD;
if (italic)
- temp_stl |= sTTFont::STTF_ITALIC;
+ tempStyle |= StyledTTFont::STTF_ITALIC;
if (underline)
- temp_stl |= sTTFont::STTF_UNDERLINE;
+ tempStyle |= StyledTTFont::STTF_UNDERLINE;
if (strikeout)
- temp_stl |= sTTFont::STTF_STRIKEOUT;
+ tempStyle |= StyledTTFont::STTF_STRIKEOUT;
if (sharp)
- temp_stl |= sTTFont::STTF_SHARP;
+ tempStyle |= StyledTTFont::STTF_SHARP;
- font.setStyle(temp_stl);
+ font.setStyle(tempStyle);
}
-void cTxtStyle::setFont(sTTFont &font) {
- uint temp_stl = 0;
+void cTxtStyle::setFont(StyledTTFont &font) {
+ uint tempStyle = 0;
if (bold)
- temp_stl |= sTTFont::STTF_BOLD;
+ tempStyle |= StyledTTFont::STTF_BOLD;
if (italic)
- temp_stl |= sTTFont::STTF_ITALIC;
+ tempStyle |= StyledTTFont::STTF_ITALIC;
if (underline)
- temp_stl |= sTTFont::STTF_UNDERLINE;
+ tempStyle |= StyledTTFont::STTF_UNDERLINE;
if (strikeout)
- temp_stl |= sTTFont::STTF_STRIKEOUT;
+ tempStyle |= StyledTTFont::STTF_STRIKEOUT;
if (sharp)
- temp_stl |= sTTFont::STTF_SHARP;
+ tempStyle |= StyledTTFont::STTF_SHARP;
- font.loadFont(fontname, size, temp_stl);
+ font.loadFont(fontname, size, tempStyle);
}
-Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
+Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
style.setFontStyle(fnt);
uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue);
return fnt.renderSolidText(txt, clr);
}
-void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
+void TextRenderer::drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
if (justify == TXT_JUSTIFY_LEFT)
fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft);
else if (justify == TXT_JUSTIFY_CENTER)
@@ -306,33 +306,33 @@ void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, u
fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight);
}
-int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) {
- sTTFont font(_engine);
- fnt_stl.setFont(font);
+int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst) {
+ StyledTTFont font(_engine);
+ fontStyle.setFont(font);
dst.fillRect(Common::Rect(dst.w, dst.h), 0);
- uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue);
+ uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle.red, fontStyle.green, fontStyle.blue);
int16 w;
w = font.getStringWidth(txt);
- drawTxtWithJustify(txt, font, clr, dst, 0, fnt_stl.justify);
+ drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle.justify);
return w;
}
-void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
+void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it
const int TXT_CFG_TEXTURES_PER_LINE = 6;
cTxtStyle style, style2;
- int16 strt = -1;
- int16 endt = -1;
+ int16 startTextPosition = -1;
+ int16 endTextPosition = -1;
int16 i = 0;
int16 dx = 0, dy = 0;
- int16 txt_w;
- int16 txtpos = 0;
+ int16 textPixelWidth;
+ int16 textPosition = 0;
Common::String buf;
Common::String buf2;
@@ -350,7 +350,7 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
int16 stringlen = text.size();
- sTTFont font(_engine);
+ StyledTTFont font(_engine);
style.setFont(font);
@@ -361,19 +361,19 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
if (text[i] == '<') {
int16 ret = 0;
- strt = i;
+ startTextPosition = i;
while (i < stringlen && text[i] != '>')
i++;
- endt = i;
- if (strt != -1)
- if ((endt - strt - 1) > 0) {
+ endTextPosition = i;
+ if (startTextPosition != -1)
+ if ((endTextPosition - startTextPosition - 1) > 0) {
style2 = style;
- ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1);
+ ret = style.parseStyle(Common::String(text.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1);
}
if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
if (buf.size() > 0) {
- txt_w = font.getStringWidth(buf);
+ textPixelWidth = font.getStringWidth(buf);
TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2);
TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
@@ -382,8 +382,8 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
buf.clear();
prevbufspace = 0;
- txtpos = 0;
- dx += txt_w;
+ textPosition = 0;
+ dx += textPixelWidth;
}
if (ret & TXT_RET_FNTCHG) {
@@ -403,25 +403,25 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
Common::String buf3;
buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox));
buf += buf3;
- txtpos += buf3.size();
+ textPosition += buf3.size();
}
} else {
buf += text[i];
- txtpos++;
+ textPosition++;
if (text[i] == ' ') {
- prevbufspace = txtpos - 1;
+ prevbufspace = textPosition - 1;
prevtxtspace = i;
}
if (font.isLoaded()) {
- txt_w = font.getStringWidth(buf);
- if (txt_w + dx > dst.w) {
+ textPixelWidth = font.getStringWidth(buf);
+ if (textPixelWidth + dx > dst.w) {
if (prevbufspace == 0) {
prevtxtspace = i;
- prevbufspace = txtpos - 1;
+ prevbufspace = textPosition - 1;
}
buf2 = Common::String(buf.c_str(), prevbufspace + 1);
@@ -433,7 +433,7 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
buf.clear();
i = prevtxtspace;
prevbufspace = 0;
- txtpos = 0;
+ textPosition = 0;
currentline++;
currentlineitm = 0;
dx = 0;
@@ -494,7 +494,7 @@ Common::String readWideLine(Common::SeekableReadStream &stream) {
break;
}
- // Crush each octet pair to a single octet with a simple cast
+ // Crush each octet pair to a UTF-8 sequence
if (value < 0x80) {
asciiString += (char)(value & 0x7F);
} else if (value >= 0x80 && value < 0x800) {
diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h
index 4b318fd..c246838 100644
--- a/engines/zvision/text/text.h
+++ b/engines/zvision/text/text.h
@@ -56,8 +56,8 @@ public:
cTxtStyle();
txtReturn parseStyle(const Common::String &strin, int16 len);
void readAllStyle(const Common::String &txt);
- void setFontStyle(sTTFont &font);
- void setFont(sTTFont &font);
+ void setFontStyle(StyledTTFont &font);
+ void setFont(StyledTTFont &font);
public:
Common::String fontname;
@@ -78,13 +78,13 @@ public:
// char image ??
};
-class textRenderer {
+class TextRenderer {
public:
- textRenderer(ZVision *engine): _engine(engine) {};
+ TextRenderer(ZVision *engine): _engine(engine) {};
- void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
- int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst);
- Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style);
+ void drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
+ int32 drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst);
+ Graphics::Surface *render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style);
void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst);
private:
diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp
index 3441fb8..86ed7c5 100644
--- a/engines/zvision/utility/win_keys.cpp
+++ b/engines/zvision/utility/win_keys.cpp
@@ -24,17 +24,17 @@
namespace ZVision {
-uint8 VKkey(Common::KeyCode scumm_key) {
- if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z)
- return 0x41 + scumm_key - Common::KEYCODE_a;
- if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9)
- return 0x30 + scumm_key - Common::KEYCODE_0;
- if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15)
- return 0x70 + scumm_key - Common::KEYCODE_F1;
- if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9)
- return 0x60 + scumm_key - Common::KEYCODE_KP0;
+uint8 VKkey(Common::KeyCode scummKeyCode) {
+ if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z)
+ return 0x41 + scummKeyCode - Common::KEYCODE_a;
+ if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9)
+ return 0x30 + scummKeyCode - Common::KEYCODE_0;
+ if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15)
+ return 0x70 + scummKeyCode - Common::KEYCODE_F1;
+ if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9)
+ return 0x60 + scummKeyCode - Common::KEYCODE_KP0;
- switch (scumm_key) {
+ switch (scummKeyCode) {
case Common::KEYCODE_BACKSPACE:
return 0x8;
case Common::KEYCODE_TAB:
diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h
index a79a03a..53d76c4 100644
--- a/engines/zvision/utility/win_keys.h
+++ b/engines/zvision/utility/win_keys.h
@@ -20,13 +20,13 @@
*
*/
-#ifndef ZVISION_WINKEY_H
-#define ZVISION_WINKEY_H
+#ifndef ZVISION_WIN_KEYS_H
+#define ZVISION_WIN_KEYS_H
#include "common/keyboard.h"
namespace ZVision {
-uint8 VKkey(Common::KeyCode scumm_key);
+uint8 VKkey(Common::KeyCode scummKeyCode);
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 8485642..62342f0 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -95,7 +95,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_stringManager(nullptr),
_cursorManager(nullptr),
_midiManager(nullptr),
- _aud_id(0),
+ _audioId(0),
_rendDelay(2),
_kbdVelocity(0),
_mouseVelocity(0) {
@@ -147,7 +147,7 @@ void ZVision::saveSettings() {
void ZVision::initialize() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
- _searchManager = new sManager(ConfMan.get("path"), 6);
+ _searchManager = new SearchManager(ConfMan.get("path"), 6);
_searchManager->addDir("FONTS");
_searchManager->addDir("addon");
@@ -182,13 +182,13 @@ void ZVision::initialize() {
_saveManager = new SaveManager(this);
_stringManager = new StringManager(this);
_cursorManager = new CursorManager(this, &_pixelFormat);
- _textRenderer = new textRenderer(this);
- _midiManager = new midiManager();
+ _textRenderer = new TextRenderer(this);
+ _midiManager = new MidiManager();
if (_gameDescription->gameId == GID_GRANDINQUISITOR)
- _menu = new menuZgi(this);
+ _menu = new MenuZGI(this);
else
- _menu = new menuNem(this);
+ _menu = new MenuNemesis(this);
// Initialize the managers
_cursorManager->initialize();
@@ -290,8 +290,8 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) {
_renderManager->renderBackbufferToScreen();
_clock.stop();
- uint32 stop_time = _system->getMillis() + milsecs;
- while (_system->getMillis() < stop_time) {
+ uint32 stopTime = _system->getMillis() + milsecs;
+ while (_system->getMillis() < stopTime) {
Common::Event evnt;
while (_eventMan->pollEvent(evnt)) {
if (evnt.type == Common::EVENT_KEYDOWN &&
@@ -353,38 +353,38 @@ void ZVision::updateRotation() {
if (_velocity) {
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
- int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+ int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity);
+ int16 newPosition = startPosition + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity);
- int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint();
- if (st_pos >= zero_point && new_pos < zero_point)
+ int16 zeroPoint = _renderManager->getRenderTable()->getPanoramaZeroPoint();
+ if (startPosition >= zeroPoint && newPosition < zeroPoint)
_scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1);
- if (st_pos <= zero_point && new_pos > zero_point)
+ if (startPosition <= zeroPoint && newPosition > zeroPoint)
_scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1);
- int16 scr_width = _renderManager->getBkgSize().x;
- if (scr_width)
- new_pos %= scr_width;
+ int16 screenWidth = _renderManager->getBkgSize().x;
+ if (screenWidth)
+ newPosition %= screenWidth;
- if (new_pos < 0)
- new_pos += scr_width;
+ if (newPosition < 0)
+ newPosition += screenWidth;
- _renderManager->setBackgroundPosition(new_pos);
+ _renderManager->setBackgroundPosition(newPosition);
} else if (renderState == RenderTable::TILT) {
- int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+ int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos + _velocity;
+ int16 newPosition = startPosition + _velocity;
- int16 scr_height = _renderManager->getBkgSize().y;
- int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();
+ int16 screenHeight = _renderManager->getBkgSize().y;
+ int16 tiltGap = _renderManager->getRenderTable()->getTiltGap();
- if (new_pos >= (scr_height - tilt_gap))
- new_pos = scr_height - tilt_gap;
- if (new_pos <= tilt_gap)
- new_pos = tilt_gap;
+ if (newPosition >= (screenHeight - tiltGap))
+ newPosition = screenHeight - tiltGap;
+ if (newPosition <= tiltGap)
+ newPosition = tiltGap;
- _renderManager->setBackgroundPosition(new_pos);
+ _renderManager->setBackgroundPosition(newPosition);
}
}
}
@@ -392,35 +392,35 @@ void ZVision::updateRotation() {
void ZVision::checkBorders() {
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
- int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+ int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos;
+ int16 newPosition = startPosition;
- int16 scr_width = _renderManager->getBkgSize().x;
+ int16 screenWidth = _renderManager->getBkgSize().x;
- if (scr_width)
- new_pos %= scr_width;
+ if (screenWidth)
+ newPosition %= screenWidth;
- if (new_pos < 0)
- new_pos += scr_width;
+ if (newPosition < 0)
+ newPosition += screenWidth;
- if (st_pos != new_pos)
- _renderManager->setBackgroundPosition(new_pos);
+ if (startPosition != newPosition)
+ _renderManager->setBackgroundPosition(newPosition);
} else if (renderState == RenderTable::TILT) {
- int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);
+ int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
- int16 new_pos = st_pos;
+ int16 newPosition = startPosition;
- int16 scr_height = _renderManager->getBkgSize().y;
- int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();
+ int16 screenHeight = _renderManager->getBkgSize().y;
+ int16 tiltGap = _renderManager->getRenderTable()->getTiltGap();
- if (new_pos >= (scr_height - tilt_gap))
- new_pos = scr_height - tilt_gap;
- if (new_pos <= tilt_gap)
- new_pos = tilt_gap;
+ if (newPosition >= (screenHeight - tiltGap))
+ newPosition = screenHeight - tiltGap;
+ if (newPosition <= tiltGap)
+ newPosition = tiltGap;
- if (st_pos != new_pos)
- _renderManager->setBackgroundPosition(new_pos);
+ if (startPosition != newPosition)
+ _renderManager->setBackgroundPosition(newPosition);
}
}
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 8cf9dbf..8b14cfa 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -52,10 +52,10 @@ class CursorManager;
class StringManager;
class SaveManager;
class RlfAnimation;
-class menuHandler;
-class textRenderer;
+class MenuHandler;
+class TextRenderer;
class Subtitle;
-class midiManager;
+class MidiManager;
class ZVision : public Engine {
public:
@@ -104,16 +104,16 @@ private:
CursorManager *_cursorManager;
SaveManager *_saveManager;
StringManager *_stringManager;
- menuHandler *_menu;
- sManager *_searchManager;
- textRenderer *_textRenderer;
- midiManager *_midiManager;
+ MenuHandler *_menu;
+ SearchManager *_searchManager;
+ TextRenderer *_textRenderer;
+ MidiManager *_midiManager;
// Clock
Clock _clock;
// Audio ID
- int _aud_id;
+ int _audioId;
// To prevent allocation every time we process events
Common::Event _event;
@@ -148,13 +148,13 @@ public:
StringManager *getStringManager() const {
return _stringManager;
}
- sManager *getSearchManager() const {
+ SearchManager *getSearchManager() const {
return _searchManager;
}
- textRenderer *getTextRenderer() const {
+ TextRenderer *getTextRenderer() const {
return _textRenderer;
}
- midiManager *getMidiManager() const {
+ MidiManager *getMidiManager() const {
return _midiManager;
}
Common::RandomSource *getRandomSource() const {
Commit: 596a904a0c6aedba5bbe45cdfa931425450626c8
https://github.com/scummvm/scummvm/commit/596a904a0c6aedba5bbe45cdfa931425450626c8
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2014-11-20T14:55:35+06:00
Commit Message:
ZVISION: Remove wrong TODO from scripting/sidefx.h
Changed paths:
engines/zvision/scripting/sidefx.h
diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h
index 2c53467..5bb14f0 100644
--- a/engines/zvision/scripting/sidefx.h
+++ b/engines/zvision/scripting/sidefx.h
@@ -109,16 +109,6 @@ protected:
public:
};
-
-// TODO: Implement InputControl
-// TODO: Implement SaveControl
-// TODO: Implement SlotControl
-// TODO: Implement SafeControl
-// TODO: Implement FistControl
-// TODO: Implement HotMovieControl
-// TODO: Implement PaintControl
-// TODO: Implement TilterControl
-
} // End of namespace ZVision
#endif // SIDEFX_H_INCLUDED
Commit: 637102d33b9ab69724c1badd9515e0e26a4b4b88
https://github.com/scummvm/scummvm/commit/637102d33b9ab69724c1badd9515e0e26a4b4b88
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-03T00:06:38+02:00
Commit Message:
Merge pull request #532 from Marisa-Chan/zvision
ZVISION: More complete engine implementation
Changed paths:
A engines/zvision/animation/meta_animation.cpp
A engines/zvision/animation/meta_animation.h
A engines/zvision/core/menu.cpp
A engines/zvision/core/midi.cpp
A engines/zvision/core/midi.h
A engines/zvision/core/search_manager.cpp
A engines/zvision/core/search_manager.h
A engines/zvision/graphics/effect.h
A engines/zvision/graphics/effects/fog.cpp
A engines/zvision/graphics/effects/fog.h
A engines/zvision/graphics/effects/light.cpp
A engines/zvision/graphics/effects/light.h
A engines/zvision/graphics/effects/wave.cpp
A engines/zvision/graphics/effects/wave.h
A engines/zvision/scripting/controls/fist_control.cpp
A engines/zvision/scripting/controls/fist_control.h
A engines/zvision/scripting/controls/hotmov_control.cpp
A engines/zvision/scripting/controls/hotmov_control.h
A engines/zvision/scripting/controls/paint_control.cpp
A engines/zvision/scripting/controls/paint_control.h
A engines/zvision/scripting/controls/safe_control.cpp
A engines/zvision/scripting/controls/safe_control.h
A engines/zvision/scripting/controls/save_control.cpp
A engines/zvision/scripting/controls/save_control.h
A engines/zvision/scripting/controls/slot_control.cpp
A engines/zvision/scripting/controls/slot_control.h
A engines/zvision/scripting/controls/titler_control.cpp
A engines/zvision/scripting/controls/titler_control.h
A engines/zvision/scripting/inventory.cpp
A engines/zvision/scripting/sidefx.cpp
A engines/zvision/scripting/sidefx.h
A engines/zvision/scripting/sidefx/animation_node.cpp
A engines/zvision/scripting/sidefx/animation_node.h
A engines/zvision/scripting/sidefx/distort_node.cpp
A engines/zvision/scripting/sidefx/distort_node.h
A engines/zvision/scripting/sidefx/music_node.cpp
A engines/zvision/scripting/sidefx/music_node.h
A engines/zvision/scripting/sidefx/region_node.cpp
A engines/zvision/scripting/sidefx/region_node.h
A engines/zvision/scripting/sidefx/syncsound_node.cpp
A engines/zvision/scripting/sidefx/syncsound_node.h
A engines/zvision/scripting/sidefx/timer_node.cpp
A engines/zvision/scripting/sidefx/timer_node.h
A engines/zvision/scripting/sidefx/ttytext_node.cpp
A engines/zvision/scripting/sidefx/ttytext_node.h
A engines/zvision/subtitles/subtitles.cpp
A engines/zvision/text/string_manager.cpp
A engines/zvision/text/string_manager.h
A engines/zvision/text/text.cpp
A engines/zvision/text/text.h
A engines/zvision/utility/win_keys.cpp
A engines/zvision/utility/win_keys.h
R engines/zvision/inventory/inventory_manager.h
R engines/zvision/scripting/controls/animation_control.cpp
R engines/zvision/scripting/controls/animation_control.h
R engines/zvision/scripting/controls/timer_node.cpp
R engines/zvision/scripting/controls/timer_node.h
R engines/zvision/strings/string_manager.cpp
R engines/zvision/strings/string_manager.h
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation/rlf_animation.h
engines/zvision/archives/zfs_archive.cpp
engines/zvision/archives/zfs_archive.h
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/core/menu.h
engines/zvision/core/save_manager.cpp
engines/zvision/core/save_manager.h
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor.h
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/detection.cpp
engines/zvision/fonts/truetype_font.cpp
engines/zvision/fonts/truetype_font.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/graphics/render_table.cpp
engines/zvision/graphics/render_table.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/actions.h
engines/zvision/scripting/control.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/input_control.h
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/lever_control.h
engines/zvision/scripting/controls/push_toggle_control.cpp
engines/zvision/scripting/controls/push_toggle_control.h
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
engines/zvision/subtitles/subtitles.h
engines/zvision/utility/clock.h
engines/zvision/utility/lzss_read_stream.cpp
engines/zvision/utility/lzss_read_stream.h
engines/zvision/utility/single_value_container.h
engines/zvision/utility/utility.cpp
engines/zvision/utility/utility.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
More information about the Scummvm-git-logs
mailing list