diff options
author | Peter Kohaut | 2016-10-08 21:06:22 +0200 |
---|---|---|
committer | Peter Kohaut | 2016-10-08 21:06:22 +0200 |
commit | f30f3c46e38d91729983a36e87f629d6b3a47a34 (patch) | |
tree | 5f1026a7fdbb339ffbe15cd0c02a1b1970538433 /engines/bladerunner/font.cpp | |
parent | c934941e4f1d72723924f6f6fb7b76712784ff82 (diff) | |
download | scummvm-rg350-f30f3c46e38d91729983a36e87f629d6b3a47a34.tar.gz scummvm-rg350-f30f3c46e38d91729983a36e87f629d6b3a47a34.tar.bz2 scummvm-rg350-f30f3c46e38d91729983a36e87f629d6b3a47a34.zip |
BLADERUNNER: added item pickup effect
also added support for rendering items on screen (not in the world)
pickup effect can be tested in debug compilation by clicking on any object (not item, but object like, hydrant, or doors) in first scene
Diffstat (limited to 'engines/bladerunner/font.cpp')
-rw-r--r-- | engines/bladerunner/font.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp index 972f50a784..124e9c967e 100644 --- a/engines/bladerunner/font.cpp +++ b/engines/bladerunner/font.cpp @@ -68,7 +68,7 @@ bool Font::open(const Common::String &fileName, int screenWidth, int screenHeigh _characters[i]._height = stream->readUint32LE(); _characters[i]._dataOffset = stream->readUint32LE(); } - for(int i = 0; i < _dataSize; i++) { + for (int i = 0; i < _dataSize; i++) { _data[i] = stream->readUint16LE(); } return true; @@ -100,20 +100,8 @@ void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, i return; } - if (x < 0) { - x = 0; - } - if (y < 0) { - y = 0; - } - - int textWidth = getTextWidth(text); - if (textWidth + x >= _screenWidth) { - x = _screenWidth - (textWidth + 1); - } - if (_maxHeight + y >= _screenHeight) { - y = _screenHeight - _maxHeight; - } + x = CLIP(x, 0, _screenWidth - getTextWidth(text) + 1); + y = CLIP(y, 0, _screenHeight - _maxHeight); const char *character = text.c_str(); while (*character != 0) { @@ -176,16 +164,17 @@ void Font::replaceColor(uint16 oldColor, uint16 newColor) { } void Font::drawCharacter(const char character, Graphics::Surface &surface, int x, int y) { - if (x < 0 || x >= _screenWidth || y < 0 || y >= _screenHeight || !_data || character + 1 >= _characterCount) { + char characterIndex = character + 1; + if (x < 0 || x >= _screenWidth || y < 0 || y >= _screenHeight || !_data || characterIndex >= _characterCount) { return; } - uint16 *dstPtr = (uint16*)surface.getBasePtr(x + _characters[character + 1]._x, y + _characters[character + 1]._y); - uint16 *srcPtr = &_data[_characters[character + 1]._dataOffset]; - int width = _characters[character + 1]._width; - int height = _characters[character + 1]._height; + uint16 *dstPtr = (uint16*)surface.getBasePtr(x + _characters[characterIndex]._x, y + _characters[characterIndex]._y); + uint16 *srcPtr = &_data[_characters[characterIndex]._dataOffset]; + int width = _characters[characterIndex]._width; + int height = _characters[characterIndex]._height; if (_intersperse && y & 1) { - dstPtr += surface.w; + dstPtr += surface.pitch / 2; } int endY = height + y - 1; @@ -194,17 +183,17 @@ void Font::drawCharacter(const char character, Graphics::Surface &surface, int x int currentX = x; int endX = width + x - 1; while (currentX <= endX && currentX < _screenWidth) { - if (!(*srcPtr & 0x8000)) { + if ((*srcPtr & 0x8000) == 0) { *dstPtr = *srcPtr; } dstPtr++; srcPtr++; currentX++; } - dstPtr += surface.w - width; + dstPtr += surface.pitch / 2 - width; if (_intersperse) { srcPtr += width; - dstPtr += surface.w; + dstPtr += surface.pitch / 2; currentY++; } currentY++; |