From d655fb5530e2a6ffc23d3a8c3d6009e02eec8fcc Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 10 Mar 2019 00:49:56 +0100 Subject: CRYOMNI3D: Add function to change sprite color --- engines/cryomni3d/sprites.cpp | 12 ++++++++++++ engines/cryomni3d/sprites.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/engines/cryomni3d/sprites.cpp b/engines/cryomni3d/sprites.cpp index b1c5f95b0e..df09afb24f 100644 --- a/engines/cryomni3d/sprites.cpp +++ b/engines/cryomni3d/sprites.cpp @@ -146,6 +146,18 @@ void Sprites::replaceSprite(unsigned int oldSpriteId, unsigned int newSpriteId) _cursors[oldSpriteId]->refCnt++; } +void Sprites::replaceSpriteColor(unsigned int spriteId, byte currentColor, byte newColor) { + MAP_ID(spriteId); + + byte *data = _cursors[spriteId]->_data; + unsigned int size = _cursors[spriteId]->_width * _cursors[spriteId]->_height; + for (; size > 0; size--, data++) { + if (*data == currentColor) { + *data = newColor; + } + } +} + unsigned int Sprites::getSpritesCount() const { if (_map) { return _map->size(); diff --git a/engines/cryomni3d/sprites.h b/engines/cryomni3d/sprites.h index 5721ea8532..bd4a8673db 100644 --- a/engines/cryomni3d/sprites.h +++ b/engines/cryomni3d/sprites.h @@ -52,6 +52,8 @@ public: unsigned int getSpritesCount() const; + void replaceSpriteColor(unsigned int spriteId, byte currentColor, byte newColor); + const Graphics::Surface &getSurface(unsigned int spriteId) const; const Graphics::Cursor &getCursor(unsigned int spriteId) const; -- cgit v1.2.3