diff options
author | lukaslw | 2014-08-01 17:38:04 +0200 |
---|---|---|
committer | lukaslw | 2014-08-01 17:38:04 +0200 |
commit | 3c29d61f6705a6f05d86fa2599a6992d2d17e3ac (patch) | |
tree | 9c0033d66c9a1cbf1cb5c52ca27b8159d194d432 /engines/prince/font.cpp | |
parent | b3589c76da856239828377a3011525a888b04920 (diff) | |
download | scummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.tar.gz scummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.tar.bz2 scummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.zip |
PRINCE: Code clean-up
Diffstat (limited to 'engines/prince/font.cpp')
-rw-r--r-- | engines/prince/font.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/engines/prince/font.cpp b/engines/prince/font.cpp index 40b6d014e6..0ac61f29be 100644 --- a/engines/prince/font.cpp +++ b/engines/prince/font.cpp @@ -23,24 +23,25 @@ #include "common/archive.h" #include "common/debug.h" #include "common/stream.h" -#include "common/str.h" - -#include "graphics/surface.h" #include "prince/font.h" namespace Prince { -Font::Font() { +Font::Font() : _fontData(nullptr) { } Font::~Font() { - delete [] _fontData; + if (_fontData != nullptr) { + free(_fontData); + _fontData = nullptr; + } } bool Font::loadFromStream(Common::SeekableReadStream &stream) { stream.seek(0); - _fontData = new byte[stream.size()]; + uint32 dataSize = stream.size(); + _fontData = (byte *)malloc(dataSize); stream.read(_fontData, stream.size()); return true; } @@ -55,11 +56,11 @@ int Font::getMaxCharWidth() const { Font::ChrData Font::getChrData(byte chr) const { chr -= 32; - uint16 chrOffset = 4*chr+6; + uint16 chrOffset = 4 * chr + 6; ChrData chrData; - chrData._width = _fontData[chrOffset+2]; - chrData._height = _fontData[chrOffset+3]; + chrData._width = _fontData[chrOffset + 2]; + chrData._height = _fontData[chrOffset + 3]; chrData._pixels = _fontData + READ_LE_UINT16(_fontData + chrOffset); return chrData; @@ -72,20 +73,18 @@ int Font::getCharWidth(uint32 chr) const { void Font::drawChar(Graphics::Surface *dst, uint32 chr, int posX, int posY, uint32 color) const { const ChrData chrData = getChrData(chr); - for (int y = 0; y < chrData._height; ++y) { - for (int x = 0; x < chrData._width; ++x) { + for (int y = 0; y < chrData._height; y++) { + for (int x = 0; x < chrData._width; x++) { byte d = chrData._pixels[x + (chrData._width * y)]; if (d == 0) d = 255; else if (d == 1) d = 0; else if (d == 2) d = color; else if (d == 3) d = 0; if (d != 255) { - *(byte*)dst->getBasePtr(posX + x, posY + y) = d; + *(byte *)dst->getBasePtr(posX + x, posY + y) = d; } } } } -} - -/* vim: set tabstop=4 expandtab!: */ +} // End of namespace Prince |