aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/direct_draw.cpp9
-rw-r--r--engines/titanic/direct_draw.h10
-rw-r--r--engines/titanic/simple_file.cpp9
-rw-r--r--engines/titanic/simple_file.h8
-rw-r--r--engines/titanic/video_surface.cpp37
-rw-r--r--engines/titanic/video_surface.h21
6 files changed, 82 insertions, 12 deletions
diff --git a/engines/titanic/direct_draw.cpp b/engines/titanic/direct_draw.cpp
index 17e13610e0..1d0ddab4fb 100644
--- a/engines/titanic/direct_draw.cpp
+++ b/engines/titanic/direct_draw.cpp
@@ -110,6 +110,15 @@ DirectDrawSurface *DirectDrawManager::createSurface(int w, int h, int surfaceNum
/*------------------------------------------------------------------------*/
+void *DirectDrawSurface::lock(const Common::Rect *bounds, int flags) {
+ assert(w != 0 && h != 0);
+ return getPixels();
+}
+
+void DirectDrawSurface::unlock() {
+ assert(w != 0 && h != 0);
+}
+
void DirectDrawSurface::fill(const Common::Rect *bounds, uint32 color) {
Common::Rect tempBounds;
diff --git a/engines/titanic/direct_draw.h b/engines/titanic/direct_draw.h
index bd6a77dc2d..71210f1b28 100644
--- a/engines/titanic/direct_draw.h
+++ b/engines/titanic/direct_draw.h
@@ -43,6 +43,16 @@ struct DDSurfaceDesc {
class DirectDrawSurface : public Graphics::Surface {
public:
/**
+ * Lock the surface for access
+ */
+ void *lock(const Common::Rect *bounds, int flags);
+
+ /**
+ * Unlocks the surface at the end of direct accesses
+ */
+ void unlock();
+
+ /**
* Fills an area of the surfae with the specified color. If no bounds are passed,
* then the entire surface is filled
*/
diff --git a/engines/titanic/simple_file.cpp b/engines/titanic/simple_file.cpp
index 4be8bb3d88..f2fdf4effb 100644
--- a/engines/titanic/simple_file.cpp
+++ b/engines/titanic/simple_file.cpp
@@ -331,4 +331,13 @@ void SimpleFile::writeClassEnd(int indent) {
write("}\n", 2);
}
+/*------------------------------------------------------------------------*/
+
+StdCWadFile::StdCWadFile(const CString &name): SimpleFile() {
+ if (!_file.open(name))
+ error("Could not open file - %s", name.c_str());
+
+ open(&_file);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/simple_file.h b/engines/titanic/simple_file.h
index cc68d2d54c..0a452e49cd 100644
--- a/engines/titanic/simple_file.h
+++ b/engines/titanic/simple_file.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_SIMPLE_FILE_H
#define TITANIC_SIMPLE_FILE_H
+#include "common/file.h"
#include "common/rect.h"
#include "common/savefile.h"
#include "common/stream.h"
@@ -202,6 +203,13 @@ public:
}
};
+class StdCWadFile : public SimpleFile {
+private:
+ Common::File _file;
+public:
+ StdCWadFile(const CString &name);
+};
+
} // End of namespace Titanic
#endif /* TITANIC_SIMPLE_FILE_H */
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index e649532b81..771c7779e0 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -28,7 +28,7 @@ namespace Titanic {
int CVideoSurface::_videoSurfaceCounter = 0;
CVideoSurface::CVideoSurface(CScreenManager *screenManager) :
- _screenManager(screenManager), _field2C(0),
+ _screenManager(screenManager), _pixels(nullptr),
_field34(0), _field38(0), _field3C(0), _field40(0),
_field44(4), _field48(0), _field50(1) {
_videoSurfaceNum = _videoSurfaceCounter++;
@@ -79,6 +79,22 @@ void OSVideoSurface::loadMovie() {
warning("TODO");
}
+bool OSVideoSurface::lock() {
+ if (!proc42())
+ return false;
+
+ ++_lockCount;
+ _pixels = (uint16 *)_ddSurface->lock(nullptr, 0);
+ return true;
+}
+
+void OSVideoSurface::unlock() {
+ if (_pixels)
+ _ddSurface->unlock();
+ _pixels = nullptr;
+ --_lockCount;
+}
+
bool OSVideoSurface::hasSurface() {
return _ddSurface != nullptr;
}
@@ -98,11 +114,10 @@ int OSVideoSurface::getPitch() const {
return _ddSurface->pitch;
}
-void OSVideoSurface::load() {
+bool OSVideoSurface::load() {
if (!_resourceKey.scanForFile())
- return;
+ return false;
- bool result = true;
switch (_resourceKey.fileTypeSuffix()) {
case FILETYPE_IMAGE:
switch (_resourceKey.imageTypeSuffix()) {
@@ -126,4 +141,18 @@ void OSVideoSurface::load() {
}
}
+bool OSVideoSurface::proc42() {
+ _videoSurfaceNum = _videoSurfaceCounter;
+
+ if (hasSurface()) {
+ return true;
+ } else if (_field38) {
+ _field50 = 1;
+ load();
+ return true;
+ } else {
+ return false;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index 1c4bf322ab..445165c9df 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -35,13 +35,13 @@ namespace Titanic {
class CScreenManager;
class CVideoSurface : public ListItem {
-private:
+protected:
static int _videoSurfaceCounter;
protected:
CScreenManager *_screenManager;
CResourceKey _resourceKey;
DirectDrawSurface *_ddSurface;
- int _field2C;
+ uint16 *_pixels;
int _field34;
bool _field38;
int _field3C;
@@ -50,7 +50,7 @@ protected:
int _field48;
int _videoSurfaceNum;
int _field50;
- int _accessCtr;
+ int _lockCount;
public:
CVideoSurface(CScreenManager *screenManager);
@@ -82,7 +82,7 @@ public:
/**
* Lock the surface for direct access to the pixels
*/
- virtual void lock() = 0;
+ virtual bool lock() = 0;
/**
* Unlocks the surface after prior calls to lock()
@@ -97,7 +97,7 @@ public:
/**
* Returns the width of the surface
*/
- virtual int getWidth() = 0;
+ virtual int getWidth() const = 0;
/**
* Returns the height of the surface
@@ -108,10 +108,13 @@ public:
* Returns the pitch of the surface in bytes
*/
virtual int getPitch() const = 0;
+
/**
* Loads the surface data based on the currently set resource key
*/
- virtual void load() const = 0;
+ virtual bool load() = 0;
+
+ virtual bool proc42() = 0;
};
class OSVideoSurface : public CVideoSurface {
@@ -142,7 +145,7 @@ public:
/**
* Lock the surface for direct access to the pixels
*/
- virtual void lock();
+ virtual bool lock();
/**
* Unlocks the surface after prior calls to lock()
@@ -172,7 +175,9 @@ public:
/**
* Loads the surface data based on the currently set resource key
*/
- virtual void load();
+ virtual bool load();
+
+ virtual bool proc42();
};
} // End of namespace Titanic