diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/core/resource_key.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/core/resource_key.h | 2 | ||||
-rw-r--r-- | engines/titanic/video_surface.cpp | 50 | ||||
-rw-r--r-- | engines/titanic/video_surface.h | 30 |
4 files changed, 66 insertions, 18 deletions
diff --git a/engines/titanic/core/resource_key.cpp b/engines/titanic/core/resource_key.cpp index 4b52082b77..089df9856a 100644 --- a/engines/titanic/core/resource_key.cpp +++ b/engines/titanic/core/resource_key.cpp @@ -58,7 +58,7 @@ void CResourceKey::setValue(const CString &name) { _value = _value.mid(idx + 1); } -CString CResourceKey::exists() { +CString CResourceKey::exists() const { CString name = _key; // Check for a resource being specified within an ST container diff --git a/engines/titanic/core/resource_key.h b/engines/titanic/core/resource_key.h index 111cec5c7c..dc4c791cea 100644 --- a/engines/titanic/core/resource_key.h +++ b/engines/titanic/core/resource_key.h @@ -56,7 +56,7 @@ public: * Checks whether a file for the given key exists, * and returns it's filename if it does */ - CString exists(); + CString exists() const; /** * Scans for a file with a matching name diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index 4f79cd8189..19dcf25610 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -35,14 +35,12 @@ CVideoSurface::CVideoSurface(CScreenManager *screenManager) : _videoSurfaceNum = _videoSurfaceCounter++; } - CVideoSurface::~CVideoSurface() { if (_ddSurface) _videoSurfaceCounter -= freeSurface(); --_videoSurfaceCounter; } - void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) { _screenManager = screenManager; _ddSurface = surface; @@ -76,16 +74,21 @@ void OSVideoSurface::loadResource(const CResourceKey &key) { load(); } -void OSVideoSurface::loadTarga() { +void OSVideoSurface::loadTarga(const CResourceKey &key) { warning("TODO"); } -void OSVideoSurface::loadJPEG() { - CString filename = _resourceKey.exists(); +void OSVideoSurface::loadJPEG(const CResourceKey &key) { + CString filename = key.exists(); + + // Decode the image CJPEGDecode decoder(filename); + decoder.decode(*this); + if (proc26() == 2) + shiftColors(); - warning("TODO"); + _resourceKey = key; } void OSVideoSurface::loadMovie() { @@ -135,6 +138,14 @@ void OSVideoSurface::resize(int width, int height) { _videoSurfaceCounter += _ddSurface->getSize(); } +int OSVideoSurface::proc26() { + if (!loadIfReady()) + assert(0); + + warning("TODO"); + return 0; +} + bool OSVideoSurface::load() { if (!_resourceKey.scanForFile()) return false; @@ -143,10 +154,10 @@ bool OSVideoSurface::load() { case FILETYPE_IMAGE: switch (_resourceKey.imageTypeSuffix()) { case IMAGETYPE_TARGA: - loadTarga(); + loadTarga(_resourceKey); break; case IMAGETYPE_JPEG: - loadJPEG(); + loadJPEG(_resourceKey); break; default: break; @@ -162,6 +173,29 @@ bool OSVideoSurface::load() { } } +void OSVideoSurface::shiftColors() { + if (!loadIfReady()) + return; + + if (!lock()) + assert(0); + + int width = getWidth(); + int height = getHeight(); + int pitch = getPitch(); + uint16 *pixels = _pixels; + uint16 *p; + int x, y; + + for (y = 0; y < height; ++y, pixels += pitch) { + for (x = 0, p = pixels; x < width; ++x, ++p) { + *p = ((*p & 0xFFE0) * 2) | (*p & 0x1F); + } + } + + unlock(); +} + bool OSVideoSurface::loadIfReady() { _videoSurfaceNum = _videoSurfaceCounter; diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index cd1fc2e786..838529f770 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -68,12 +68,12 @@ public: /** * Loads a Targa image file specified by the resource key */ - virtual void loadTarga() = 0; + virtual void loadTarga(const CResourceKey &key) = 0; /** * Loads a JPEG image file specified by the resource key */ - virtual void loadJPEG() = 0; + virtual void loadJPEG(const CResourceKey &key) = 0; /** * Loads a movie file specified by the resource key @@ -115,10 +115,12 @@ public: */ virtual void resize(int width, int height) = 0; + virtual int proc26() = 0; + /** - * Loads the surface data based on the currently set resource key + * Shifts the colors of the surface.. maybe greys it out? */ - virtual bool load() = 0; + virtual void shiftColors() = 0; /** * Loads the surface's resource if there's one pending @@ -126,6 +128,11 @@ public: virtual bool loadIfReady() = 0; /** + * Loads the surface data based on the currently set resource key + */ + virtual bool load() = 0; + + /** * Frees the underlying surface */ virtual int freeSurface() { return 0; } @@ -144,12 +151,12 @@ public: /** * Loads a Targa image file specified by the resource key */ - virtual void loadTarga(); + virtual void loadTarga(const CResourceKey &key); /** * Loads a JPEG image file specified by the resource key */ - virtual void loadJPEG(); + virtual void loadJPEG(const CResourceKey &key); /** * Loads a movie file specified by the resource key @@ -191,10 +198,12 @@ public: */ virtual void resize(int width, int height); + virtual int proc26(); + /** - * Loads the surface data based on the currently set resource key + * Shifts the colors of the surface.. maybe greys it out? */ - virtual bool load(); + virtual void shiftColors(); /** * Loads the surface's resource if there's one pending @@ -202,6 +211,11 @@ public: virtual bool loadIfReady(); /** + * Loads the surface data based on the currently set resource key + */ + virtual bool load(); + + /** * Frees the underlying surface */ virtual int freeSurface(); |