aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-10 15:39:20 -0400
committerPaul Gilbert2016-07-10 16:10:51 -0400
commit91336a86115f600e626c333441aa1369b435ab92 (patch)
tree78b9b7ebb30f8992c1dc621a6b5cb3e0592f7df7
parent8e5f7a9453deff3436fc937292a0ff825acd7454 (diff)
downloadscummvm-rg350-91336a86115f600e626c333441aa1369b435ab92.tar.gz
scummvm-rg350-91336a86115f600e626c333441aa1369b435ab92.tar.bz2
scummvm-rg350-91336a86115f600e626c333441aa1369b435ab92.zip
TITANIC: Implement playing a range of frames within movie
-rw-r--r--engines/titanic/core/background.cpp4
-rw-r--r--engines/titanic/core/game_object.cpp12
-rw-r--r--engines/titanic/core/game_object.h17
-rw-r--r--engines/titanic/game/cdrom_tray.cpp12
-rw-r--r--engines/titanic/game/computer.cpp14
-rw-r--r--engines/titanic/game/television.cpp12
-rw-r--r--engines/titanic/gfx/st_button.cpp2
-rw-r--r--engines/titanic/pet_control/pet_element.cpp8
-rw-r--r--engines/titanic/pet_control/pet_element.h5
-rw-r--r--engines/titanic/support/movie.cpp21
-rw-r--r--engines/titanic/support/movie.h9
-rw-r--r--engines/titanic/support/video_surface.cpp8
-rw-r--r--engines/titanic/support/video_surface.h8
13 files changed, 71 insertions, 61 deletions
diff --git a/engines/titanic/core/background.cpp b/engines/titanic/core/background.cpp
index 5859719026..52ff4c4ac2 100644
--- a/engines/titanic/core/background.cpp
+++ b/engines/titanic/core/background.cpp
@@ -58,9 +58,9 @@ void CBackground::load(SimpleFile *file) {
bool CBackground::StatusChangeMsg(CStatusChangeMsg *msg) {
setVisible(true);
if (_fieldDC) {
- fn1(_fieldBC, _fieldC0, 16);
+ playMovie(_fieldBC, _fieldC0, 16);
} else {
- fn1(_fieldBC, _fieldC0, 0);
+ playMovie(_fieldBC, _fieldC0, 0);
}
return true;
}
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 425c2274d7..a798c4db98 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -350,7 +350,7 @@ void CGameObject::petFn3(CTreeItem *item) {
pet->fn3(item);
}
-void CGameObject::fn1(int val1, int val2, int val3) {
+void CGameObject::playMovie(uint startFrame, uint endFrame, int val3) {
_frameNumber = -1;
if (!_surface) {
if (!_resource.empty())
@@ -364,30 +364,30 @@ void CGameObject::fn1(int val1, int val2, int val3) {
if (movie)
movie->_gameObject = this;
- _surface->playMovie(val1, val2, val3, val3 != 0);
+ _surface->playMovie(startFrame, endFrame, val3, val3 != 0);
if (val3 & 0x10)
getGameManager()->_gameState.addMovie(_surface->_movie);
}
}
-void CGameObject::changeStatus(int newStatus) {
+void CGameObject::playMovie(uint flags) {
_frameNumber = -1;
if (!_surface && !_resource.empty()) {
loadResource(_resource);
_resource.clear();
}
- CVideoSurface *surface = (newStatus & 4) ? _surface : nullptr;
+ CVideoSurface *surface = (flags & 4) ? _surface : nullptr;
if (_surface) {
- _surface->playMovie(newStatus, surface);
+ _surface->playMovie(flags, surface);
// TODO: Figure out where to do this legitimately
OSMovie *movie = static_cast<OSMovie *>(_surface->_movie);
if (movie)
movie->_gameObject = this;
- if (newStatus & 0x10) {
+ if (flags & 0x10) {
getGameManager()->_gameState.addMovie(_surface->_movie);
}
}
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 6acaeff00f..ab1833934b 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -178,13 +178,6 @@ public:
*/
bool checkPoint(const Point &pt, bool ignore40 = false, bool visibleOnly = false);
- void fn1(int val1, int val2, int val3);
-
- /**
- * Change the object's status
- */
- void changeStatus(int newStatus);
-
/**
* Set the position of the object
*/
@@ -202,6 +195,16 @@ public:
* Loads a frame
*/
void loadFrame(int frameNumber);
+
+ /**
+ * Change the object's status
+ */
+ void playMovie(uint flags);
+
+ /**
+ * Play the movie specified in _resource
+ */
+ void playMovie(uint startFrame, uint endFrame, int val3);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game/cdrom_tray.cpp b/engines/titanic/game/cdrom_tray.cpp
index 5f576d1263..1b2d6baf07 100644
--- a/engines/titanic/game/cdrom_tray.cpp
+++ b/engines/titanic/game/cdrom_tray.cpp
@@ -56,7 +56,7 @@ bool CCDROMTray::ActMsg(CActMsg *msg) {
if (msg->_action == "ClickedOn") {
if (_state) {
if (_insertedCD == "None") {
- fn1(55, 65, 0);
+ playMovie(55, 65, 0);
playSound("a#35.wav", 50, 0, 0);
_state = 0;
} else {
@@ -70,24 +70,24 @@ bool CCDROMTray::ActMsg(CActMsg *msg) {
loadFrame(52);
}
} else if (_insertedCD == "None") {
- fn1(44, 54, 0);
+ playMovie(44, 54, 0);
playSound("a#34.wav", 50, 0, 0);
_state = 1;
} else if (_insertedCD == "newCD1" || _insertedCD == "newCD2") {
- fn1(22, 32, 0);
+ playMovie(22, 32, 0);
playSound("a#34.wav", 50, 0, 0);
_state = 1;
} else if (_insertedCD == "newSTCD") {
- fn1(0, 10, 0);
+ playMovie(0, 10, 0);
playSound("a#34.wav", 50, 0, 0);
_state = 1;
}
} else if (_state) {
if (msg->_action == "newCD1" || msg->_action == "newCD2") {
- fn1(33, 43, 4);
+ playMovie(33, 43, 4);
playSound("a#35.wav", 50, 0, 0);
} else if (msg->_action == "newSTCD") {
- fn1(11, 21, 4);
+ playMovie(11, 21, 4);
playSound("a#35.wav", 50, 0, 0);
} else {
return true;
diff --git a/engines/titanic/game/computer.cpp b/engines/titanic/game/computer.cpp
index 95330f6448..d2a2cc1935 100644
--- a/engines/titanic/game/computer.cpp
+++ b/engines/titanic/game/computer.cpp
@@ -47,14 +47,14 @@ void CComputer::load(SimpleFile *file) {
bool CComputer::ActMsg(CActMsg *msg) {
if (_state) {
playSound("a#35.wav", 100, 0, 0);
- fn1(32, 42, 0);
+ playMovie(32, 42, 0);
if (msg->_action == "CD1")
- fn1(43, 49, 0);
+ playMovie(43, 49, 0);
else if (msg->_action == "CD2")
- fn1(50, 79, 0);
+ playMovie(50, 79, 0);
else if (msg->_action == "STCD")
- fn1(80, 90, 4);
+ playMovie(80, 90, 4);
_currentCD = msg->_action;
_state = 0;
@@ -67,11 +67,11 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (_currentCD == "None") {
if (_state) {
playSound("a#35.wav", 100, 0, 0);
- fn1(11, 21, 0);
+ playMovie(11, 21, 0);
_state = 0;
} else {
playSound("a#34.wav", 100, 0, 0);
- fn1(0, 10, 0);
+ playMovie(0, 10, 0);
_state = 1;
}
} else {
@@ -82,7 +82,7 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
_currentCD = "None";
} else {
playSound("a#34.wav", 100, 0, 0);
- fn1(21, 31, 0);
+ playMovie(21, 31, 0);
_state = 1;
}
}
diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp
index 2ad84d3ff9..6e1f5ca54c 100644
--- a/engines/titanic/game/television.cpp
+++ b/engines/titanic/game/television.cpp
@@ -148,8 +148,8 @@ bool CTelevision::EnterViewMsg(CEnterViewMsg *msg) {
return true;
}
-static const int FRAMES1[9] = { 0, 0, 56, 112, 168, 224, 280, 336, 392 };
-static const int FRAMES2[8] = { 0, 55, 111, 167, 223, 279, 335, 391 };
+static const int START_FRAMES[9] = { 0, 0, 56, 112, 168, 224, 280, 336, 392 };
+static const int END_FRAMES[8] = { 0, 55, 111, 167, 223, 279, 335, 391 };
bool CTelevision::PETUpMsg(CPETUpMsg *msg) {
if (msg->_name == "Television" && _isOn) {
@@ -158,7 +158,7 @@ bool CTelevision::PETUpMsg(CPETUpMsg *msg) {
_fieldE0 = _fieldE0 % _fieldE4 + 1;
stopMovie();
- fn1(FRAMES1[_fieldE0], FRAMES2[_fieldE0], 4);
+ playMovie(START_FRAMES[_fieldE0], END_FRAMES[_fieldE0], 4);
}
return true;
@@ -173,7 +173,7 @@ bool CTelevision::PETDownMsg(CPETDownMsg *msg) {
_fieldE0 = _fieldE0 % _fieldE4 + 1;
stopMovie();
- fn1(FRAMES1[_fieldE0], FRAMES2[_fieldE0], 4);
+ playMovie(START_FRAMES[_fieldE0], END_FRAMES[_fieldE0], 4);
}
return true;
@@ -182,7 +182,7 @@ bool CTelevision::PETDownMsg(CPETDownMsg *msg) {
bool CTelevision::StatusChangeMsg(CStatusChangeMsg *msg) {
if (_isOn) {
stopMovie();
- changeStatus(0);
+ playMovie(0);
}
return true;
@@ -211,7 +211,7 @@ bool CTelevision::PETActivateMsg(CPETActivateMsg *msg) {
if (_isOn) {
setVisible(true);
- fn1(0, 55, 0);
+ playMovie(0, 55, 0);
_fieldE0 = 1;
} else {
stopMovie();
diff --git a/engines/titanic/gfx/st_button.cpp b/engines/titanic/gfx/st_button.cpp
index 827fb4a0d4..b45d990c31 100644
--- a/engines/titanic/gfx/st_button.cpp
+++ b/engines/titanic/gfx/st_button.cpp
@@ -67,7 +67,7 @@ void CSTButton::load(SimpleFile *file) {
}
bool CSTButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
- changeStatus(0);
+ playMovie(0);
playSound(_soundName, 100, 0, 0);
return true;
diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp
index 68c258c0fb..625415fb62 100644
--- a/engines/titanic/pet_control/pet_element.cpp
+++ b/engines/titanic/pet_control/pet_element.cpp
@@ -62,18 +62,18 @@ bool CPetElement::contains2(const Common::Point &pt) const {
return _bounds.contains(pt);
}
-void CPetElement::proc11(int val1, int val2) const {
+void CPetElement::playMovie(uint startFrame, uint endFrame) const {
CGameObject *gameObject = getObject();
if (gameObject)
- gameObject->fn1(val1, val2, 0);
+ gameObject->playMovie(startFrame, endFrame, 0);
}
-void CPetElement::changeStatus(int newStatus) const {
+void CPetElement::changeStatus(int val) const {
CGameObject *gameObject = getObject();
if (gameObject)
- gameObject->changeStatus(newStatus);
+ gameObject->playMovie(val);
}
bool CPetElement::hasActiveMovie() const {
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
index a53715ddb9..de9f552ec8 100644
--- a/engines/titanic/pet_control/pet_element.h
+++ b/engines/titanic/pet_control/pet_element.h
@@ -84,7 +84,10 @@ public:
*/
virtual bool contains2(const Common::Point &pt) const;
- virtual void proc11(int val1, int val2) const;
+ /**
+ * Plays back a range of frames in the loaded video file for the element
+ */
+ virtual void playMovie(uint startFrame, uint endFrame) const;
/**
* Change the status of the associated object
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 0627da8c4f..6f66bec7a7 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -49,14 +49,14 @@ bool CMovie::get10() {
/*------------------------------------------------------------------------*/
OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) :
- _videoSurface(surface), _gameObject(nullptr) {
+ _videoSurface(surface), _gameObject(nullptr), _endFrame(-1) {
_video = new Video::AVIDecoder();
if (!_video->loadFile(name.getString()))
error("Could not open video - %s", name.getString().c_str());
}
OSMovie::OSMovie(Common::SeekableReadStream *stream, CVideoSurface *surface) :
- _videoSurface(surface), _gameObject(nullptr) {
+ _videoSurface(surface), _gameObject(nullptr), _endFrame(-1) {
_video = new Video::AVIDecoder();
if (!_video->loadStream(stream))
error("Could not parse movie stream");
@@ -67,16 +67,18 @@ OSMovie::~OSMovie() {
delete _video;
}
-void OSMovie::play(int v1, CVideoSurface *surface) {
- warning("TODO: OSMovie::proc8");
- play(0, 0, 0, 0);
+void OSMovie::play(uint flags, CVideoSurface *surface) {
+ uint endFrame = _video->getFrameCount();
+ play(0, endFrame, 0, 0);
}
-void OSMovie::play(int v1, int v2, int v3, bool v4) {
+void OSMovie::play(uint startFrame, uint endFrame, int v3, bool v4) {
warning("TODO: OSMovie::play properly");
- //setFrame(v1); ?
- _video->seek(0);
+
_video->start();
+ _video->seekToFrame(startFrame);
+ _endFrame = endFrame;
+
g_vm->_activeMovies.push_back(this);
_state = MOVIE_NONE;
}
@@ -142,7 +144,8 @@ MovieState OSMovie::getState() {
void OSMovie::update() {
if (_state != MOVIE_STOPPED) {
if (_video->isPlaying()) {
- if (_video->endOfVideo()) {
+ if (_video->getCurFrame() >= _endFrame) {
+ _video->stop();
_state = MOVIE_FINISHED;
} else if (_video->needsUpdate()) {
decodeFrame();
diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h
index d88c7b0be9..a871af6fc7 100644
--- a/engines/titanic/support/movie.h
+++ b/engines/titanic/support/movie.h
@@ -52,12 +52,12 @@ public:
/**
* Plays the movie
*/
- virtual void play(int v1, CVideoSurface *surface) = 0;
+ virtual void play(uint flags, CVideoSurface *surface) = 0;
/**
* Plays the movie
*/
- virtual void play(int v1, int v2, int v3, bool v4) = 0;
+ virtual void play(uint startFrame, uint endFrame, int v3, bool v4) = 0;
virtual void proc10() = 0;
virtual void proc11() = 0;
@@ -89,6 +89,7 @@ class OSMovie : public CMovie {
private:
Video::VideoDecoder *_video;
CVideoSurface *_videoSurface;
+ int _endFrame;
/**
* Decodes the next frame
@@ -104,12 +105,12 @@ public:
/**
* Plays the movie
*/
- virtual void play(int v1, CVideoSurface *surface);
+ virtual void play(uint flags, CVideoSurface *surface);
/**
* Plays the movie
*/
- virtual void play(int v1, int v2, int v3, bool v4);
+ virtual void play(uint startFrame, uint endFrame, int v3, bool v4);
virtual void proc10();
virtual void proc11();
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 3fb513c5fc..089b216347 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -379,14 +379,14 @@ void OSVideoSurface::shiftColors() {
// we already convert 16-bit surfaces as soon as they're loaded
}
-void OSVideoSurface::playMovie(int newStatus, CVideoSurface *surface) {
+void OSVideoSurface::playMovie(uint flags, CVideoSurface *surface) {
if (loadIfReady() && _movie)
- _movie->play(newStatus, surface);
+ _movie->play(flags, surface);
}
-void OSVideoSurface::playMovie(int v1, int v2, int v3, bool v4) {
+void OSVideoSurface::playMovie(uint startFrame, uint endFrame, int v3, bool v4) {
if (loadIfReady() && _movie) {
- _movie->play(v1, v2, v3, v4);
+ _movie->play(startFrame, endFrame, v3, v4);
}
}
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index c4947ca766..2ec2c9ddba 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -158,13 +158,13 @@ public:
* Plays a movie, loading it from the specified _resource
* if not already loaded
*/
- virtual void playMovie(int newStatus, CVideoSurface *surface) = 0;
+ virtual void playMovie(uint flags, CVideoSurface *surface) = 0;
/**
* Plays a movie, loading it from the specified _resource
* if not already loaded
*/
- virtual void playMovie(int v1, int v2, int v3, bool v4) = 0;
+ virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4) = 0;
/**
* Stops any movie currently attached to the surface
@@ -317,13 +317,13 @@ public:
* Plays a movie, loading it from the specified _resource
* if not already loaded
*/
- virtual void playMovie(int newStatus, CVideoSurface *surface);
+ virtual void playMovie(uint flags, CVideoSurface *surface);
/**
* Plays a movie, loading it from the specified _resource
* if not already loaded
*/
- virtual void playMovie(int v1, int v2, int v3, bool v4);
+ virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4);
/**
* Stops any movie currently attached to the surface