2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-12-25 13:04:01 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-12-25 13:04:01 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-12-25 13:04:01 +00:00
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/scumm.h"
|
2006-03-03 15:16:02 +00:00
|
|
|
#include "scumm/file.h"
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/nut_renderer.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
#include "scumm/util.h"
|
2002-12-25 13:04:01 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
NutRenderer::NutRenderer(ScummEngine *vm, const char *filename) :
|
2003-06-07 00:33:46 +00:00
|
|
|
_vm(vm),
|
2007-01-21 17:14:53 +00:00
|
|
|
_numChars(0),
|
2007-02-03 05:50:35 +00:00
|
|
|
_maxCharSize(0),
|
|
|
|
_charBuffer(0),
|
2007-01-21 17:14:53 +00:00
|
|
|
_decodedData(0) {
|
2005-06-18 15:44:40 +00:00
|
|
|
memset(_chars, 0, sizeof(_chars));
|
2007-01-27 02:26:37 +00:00
|
|
|
loadFont(filename);
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NutRenderer::~NutRenderer() {
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] _charBuffer;
|
|
|
|
delete[] _decodedData;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
void smush_decode_codec1(byte *dst, const byte *src, int left, int top, int width, int height, int pitch);
|
2007-01-21 17:14:53 +00:00
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
void NutRenderer::codec1(byte *dst, const byte *src, int width, int height, int pitch) {
|
|
|
|
smush_decode_codec1(dst, src, 0, 0, width, height, pitch);
|
|
|
|
for (int i = 0; i < width * height; i++)
|
|
|
|
_paletteMap[dst[i]] = 1;
|
2007-01-21 17:14:53 +00:00
|
|
|
}
|
2005-06-17 18:10:51 +00:00
|
|
|
|
2007-01-27 02:26:37 +00:00
|
|
|
void NutRenderer::codec21(byte *dst, const byte *src, int width, int height, int pitch) {
|
2005-06-17 18:10:51 +00:00
|
|
|
while (height--) {
|
2007-01-21 17:14:53 +00:00
|
|
|
byte *dstPtrNext = dst + pitch;
|
|
|
|
const byte *srcPtrNext = src + 2 + READ_LE_UINT16(src);
|
|
|
|
src += 2;
|
2005-06-17 18:10:51 +00:00
|
|
|
int len = width;
|
|
|
|
do {
|
|
|
|
int offs = READ_LE_UINT16(src); src += 2;
|
2007-02-03 05:50:35 +00:00
|
|
|
dst += offs;
|
2005-06-17 18:10:51 +00:00
|
|
|
len -= offs;
|
|
|
|
if (len <= 0) {
|
|
|
|
break;
|
2003-01-19 11:00:21 +00:00
|
|
|
}
|
2005-06-17 18:10:51 +00:00
|
|
|
int w = READ_LE_UINT16(src) + 1; src += 2;
|
|
|
|
len -= w;
|
|
|
|
if (len < 0) {
|
|
|
|
w += len;
|
2003-09-06 16:42:28 +00:00
|
|
|
}
|
2005-06-17 18:10:51 +00:00
|
|
|
// the original codec44 handles this part slightly differently (this is the only difference with codec21) :
|
|
|
|
// src bytes equal to 255 are replaced by 0 in dst
|
|
|
|
// src bytes equal to 1 are replaced by a color passed as an argument in the original function
|
|
|
|
// other src bytes values are copied as-is
|
2007-02-03 05:50:35 +00:00
|
|
|
for (int i = 0; i < w; i++) {
|
|
|
|
_paletteMap[src[i]] = 1;
|
2007-01-21 17:14:53 +00:00
|
|
|
}
|
2007-02-03 05:50:35 +00:00
|
|
|
memcpy(dst, src, w);
|
|
|
|
dst += w;
|
2007-01-21 17:14:53 +00:00
|
|
|
src += w;
|
2005-06-17 18:10:51 +00:00
|
|
|
} while (len > 0);
|
|
|
|
dst = dstPtrNext;
|
|
|
|
src = srcPtrNext;
|
2003-09-06 16:42:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-27 02:26:37 +00:00
|
|
|
void NutRenderer::loadFont(const char *filename) {
|
2004-07-26 23:15:01 +00:00
|
|
|
ScummFile file;
|
|
|
|
_vm->openFile(file, filename);
|
2005-08-19 22:36:08 +00:00
|
|
|
if (!file.isOpen()) {
|
2005-08-14 02:04:26 +00:00
|
|
|
error("NutRenderer::loadFont() Can't open font file: %s", filename);
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 tag = file.readUint32BE();
|
2007-01-27 02:30:17 +00:00
|
|
|
if (tag != MKID_BE('ANIM')) {
|
2005-08-14 02:04:26 +00:00
|
|
|
error("NutRenderer::loadFont() there is no ANIM chunk in font header");
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 length = file.readUint32BE();
|
2007-01-21 17:14:53 +00:00
|
|
|
byte *dataSrc = new byte[length];
|
2003-06-04 23:32:09 +00:00
|
|
|
file.read(dataSrc, length);
|
2002-12-25 13:04:01 +00:00
|
|
|
file.close();
|
|
|
|
|
2007-01-27 02:30:17 +00:00
|
|
|
if (READ_BE_UINT32(dataSrc) != MKID_BE('AHDR')) {
|
2005-08-14 02:04:26 +00:00
|
|
|
error("NutRenderer::loadFont() there is no AHDR chunk in font header");
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
2003-11-08 21:59:32 +00:00
|
|
|
|
2007-01-21 17:14:53 +00:00
|
|
|
// We pre-decode the font, which may seem wasteful at first. Actually,
|
|
|
|
// the memory needed for just the decoded glyphs is smaller than the
|
|
|
|
// whole of the undecoded font file.
|
|
|
|
|
2004-10-09 00:47:47 +00:00
|
|
|
_numChars = READ_LE_UINT16(dataSrc + 10);
|
2005-06-18 15:44:40 +00:00
|
|
|
assert(_numChars <= ARRAYSIZE(_chars));
|
2007-01-21 17:14:53 +00:00
|
|
|
|
2004-04-04 19:50:52 +00:00
|
|
|
uint32 offset = 0;
|
2007-01-21 17:14:53 +00:00
|
|
|
uint32 decodedLength = 0;
|
2007-02-03 05:50:35 +00:00
|
|
|
int l;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
_paletteMap = new byte[256];
|
|
|
|
for (l = 0; l < 256; l++) {
|
|
|
|
_paletteMap[l] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = 0; l < _numChars; l++) {
|
2007-01-21 17:14:53 +00:00
|
|
|
offset += READ_BE_UINT32(dataSrc + offset + 4) + 16;
|
|
|
|
int width = READ_LE_UINT16(dataSrc + offset + 14);
|
|
|
|
int height = READ_LE_UINT16(dataSrc + offset + 16);
|
2007-02-03 05:50:35 +00:00
|
|
|
int size = width * height;
|
|
|
|
decodedLength += size;
|
|
|
|
if (size > _maxCharSize)
|
|
|
|
_maxCharSize = size;
|
2007-01-21 17:14:53 +00:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
debug(1, "NutRenderer::loadFont('%s') - decodedLength = %d", filename, decodedLength);
|
2007-01-21 17:14:53 +00:00
|
|
|
|
|
|
|
_decodedData = new byte[decodedLength];
|
|
|
|
byte *decodedPtr = _decodedData;
|
|
|
|
|
|
|
|
offset = 0;
|
2007-02-03 05:50:35 +00:00
|
|
|
for (l = 0; l < _numChars; l++) {
|
2004-04-04 19:50:52 +00:00
|
|
|
offset += READ_BE_UINT32(dataSrc + offset + 4) + 8;
|
2007-01-27 02:30:17 +00:00
|
|
|
if (READ_BE_UINT32(dataSrc + offset) != MKID_BE('FRME')) {
|
2005-08-14 02:04:26 +00:00
|
|
|
error("NutRenderer::loadFont(%s) there is no FRME chunk %d (offset %x)", filename, l, offset);
|
2003-03-04 02:45:50 +00:00
|
|
|
break;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
2005-06-17 18:10:51 +00:00
|
|
|
offset += 8;
|
2007-01-27 02:30:17 +00:00
|
|
|
if (READ_BE_UINT32(dataSrc + offset) != MKID_BE('FOBJ')) {
|
2005-08-14 02:04:26 +00:00
|
|
|
error("NutRenderer::loadFont(%s) there is no FOBJ chunk in FRME chunk %d (offset %x)", filename, l, offset);
|
2005-06-17 18:10:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
int codec = READ_LE_UINT16(dataSrc + offset + 8);
|
2007-01-21 17:14:53 +00:00
|
|
|
// _chars[l].xoffs = READ_LE_UINT16(dataSrc + offset + 10);
|
|
|
|
// _chars[l].yoffs = READ_LE_UINT16(dataSrc + offset + 12);
|
2005-06-17 18:10:51 +00:00
|
|
|
_chars[l].width = READ_LE_UINT16(dataSrc + offset + 14);
|
|
|
|
_chars[l].height = READ_LE_UINT16(dataSrc + offset + 16);
|
2007-01-21 17:14:53 +00:00
|
|
|
_chars[l].src = decodedPtr;
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
decodedPtr += (_chars[l].width * _chars[l].height);
|
2007-01-21 17:14:53 +00:00
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
// If characters have transparency, then bytes just get skipped and
|
|
|
|
// so there may appear some garbage. That's why we have to fill it
|
|
|
|
// with a default color first.
|
|
|
|
if (codec == 44) {
|
|
|
|
memset(_chars[l].src, kSmush44TransparentColor, _chars[l].width * _chars[l].height);
|
|
|
|
_paletteMap[kSmush44TransparentColor] = 1;
|
|
|
|
_chars[l].transparency = kSmush44TransparentColor;
|
2007-01-21 17:14:53 +00:00
|
|
|
} else {
|
2007-02-03 05:50:35 +00:00
|
|
|
memset(_chars[l].src, kDefaultTransparentColor, _chars[l].width * _chars[l].height);
|
|
|
|
_paletteMap[kDefaultTransparentColor] = 1;
|
|
|
|
_chars[l].transparency = kDefaultTransparentColor;
|
2007-01-21 17:14:53 +00:00
|
|
|
}
|
|
|
|
|
2005-06-17 18:10:51 +00:00
|
|
|
const uint8 *fobjptr = dataSrc + offset + 22;
|
|
|
|
switch (codec) {
|
|
|
|
case 1:
|
2007-02-03 05:50:35 +00:00
|
|
|
codec1(_chars[l].src, fobjptr, _chars[l].width, _chars[l].height, _chars[l].width);
|
2005-06-17 18:10:51 +00:00
|
|
|
break;
|
|
|
|
case 21:
|
|
|
|
case 44:
|
2007-02-03 05:50:35 +00:00
|
|
|
codec21(_chars[l].src, fobjptr, _chars[l].width, _chars[l].height, _chars[l].width);
|
2005-06-17 18:10:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("NutRenderer::loadFont: unknown codec: %d", codec);
|
|
|
|
}
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
// We have decoded the font. Now let's see if we can re-compress it to
|
|
|
|
// a more compact format. Start by counting the number of colors.
|
|
|
|
|
|
|
|
int numColors = 0;
|
|
|
|
for (l = 0; l < 256; l++) {
|
|
|
|
if (_paletteMap[l]) {
|
|
|
|
if (numColors < ARRAYSIZE(_palette)) {
|
|
|
|
_paletteMap[l] = numColors;
|
|
|
|
_palette[numColors] = l;
|
|
|
|
}
|
|
|
|
numColors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now _palette contains all the used colors, and _paletteMap maps the
|
|
|
|
// real color to the palette index.
|
|
|
|
|
|
|
|
if (numColors <= 2)
|
|
|
|
_bpp = 1;
|
|
|
|
else if (numColors <= 4)
|
|
|
|
_bpp = 2;
|
|
|
|
else if (numColors <= 16)
|
|
|
|
_bpp = 4;
|
|
|
|
else
|
|
|
|
_bpp = 8;
|
|
|
|
|
|
|
|
if (_bpp < 8) {
|
|
|
|
int compressedLength = 0;
|
|
|
|
for (l = 0; l < 256; l++) {
|
|
|
|
compressedLength += (((_bpp * _chars[l].width + 7) / 8) * _chars[l].height);
|
|
|
|
}
|
|
|
|
|
|
|
|
debug(1, "NutRenderer::loadFont('%s') - compressedLength = %d (%d bpp)", filename, compressedLength, _bpp);
|
|
|
|
|
|
|
|
byte *compressedData = new byte[compressedLength];
|
|
|
|
memset(compressedData, 0, compressedLength);
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
for (l = 0; l < 256; l++) {
|
|
|
|
byte *src = _chars[l].src;
|
|
|
|
byte *dst = compressedData + offset;
|
|
|
|
int srcPitch = _chars[l].width;
|
|
|
|
int dstPitch = (_bpp * _chars[l].width + 7) / 8;
|
|
|
|
|
|
|
|
for (int h = 0; h < _chars[l].height; h++) {
|
|
|
|
byte bit = 0x80;
|
|
|
|
byte *nextDst = dst + dstPitch;
|
|
|
|
for (int w = 0; w < srcPitch; w++) {
|
|
|
|
byte color = _paletteMap[src[w]];
|
|
|
|
for (int i = 0; i < _bpp; i++) {
|
|
|
|
if (color & (1 << i))
|
|
|
|
*dst |= bit;
|
|
|
|
bit >>= 1;
|
|
|
|
}
|
|
|
|
if (!bit) {
|
|
|
|
bit = 0x80;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
src += srcPitch;
|
|
|
|
dst = nextDst;
|
|
|
|
}
|
|
|
|
_chars[l].src = compressedData + offset;
|
|
|
|
offset += (dstPitch * _chars[l].height);
|
|
|
|
}
|
|
|
|
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] _decodedData;
|
2007-02-03 05:50:35 +00:00
|
|
|
_decodedData = compressedData;
|
|
|
|
|
|
|
|
_charBuffer = new byte[_maxCharSize];
|
|
|
|
}
|
|
|
|
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] dataSrc;
|
|
|
|
delete[] _paletteMap;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
2004-10-09 00:47:47 +00:00
|
|
|
int NutRenderer::getCharWidth(byte c) const {
|
2004-10-23 23:08:53 +00:00
|
|
|
if (c >= 0x80 && _vm->_useCJKMode)
|
|
|
|
return _vm->_2byteWidth / 2;
|
2003-06-04 23:32:09 +00:00
|
|
|
|
2004-10-09 00:47:47 +00:00
|
|
|
if (c >= _numChars)
|
|
|
|
error("invalid character in NutRenderer::getCharWidth : %d (%d)", c, _numChars);
|
2003-06-04 23:32:09 +00:00
|
|
|
|
|
|
|
return _chars[c].width;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
2004-10-09 00:47:47 +00:00
|
|
|
int NutRenderer::getCharHeight(byte c) const {
|
2004-10-23 23:08:53 +00:00
|
|
|
if (c >= 0x80 && _vm->_useCJKMode)
|
|
|
|
return _vm->_2byteHeight;
|
2003-06-04 23:32:09 +00:00
|
|
|
|
2004-10-09 00:47:47 +00:00
|
|
|
if (c >= _numChars)
|
|
|
|
error("invalid character in NutRenderer::getCharHeight : %d (%d)", c, _numChars);
|
2003-06-04 23:32:09 +00:00
|
|
|
|
|
|
|
return _chars[c].height;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:50:35 +00:00
|
|
|
byte *NutRenderer::unpackChar(byte c) {
|
|
|
|
if (_bpp == 8)
|
|
|
|
return _chars[c].src;
|
|
|
|
|
|
|
|
byte *src = _chars[c].src;
|
|
|
|
int pitch = (_bpp * _chars[c].width + 7) / 8;
|
|
|
|
|
|
|
|
for (int ty = 0; ty < _chars[c].height; ty++) {
|
|
|
|
for (int tx = 0; tx < _chars[c].width; tx++) {
|
|
|
|
byte val;
|
|
|
|
int offset;
|
|
|
|
byte bit;
|
|
|
|
|
|
|
|
switch (_bpp) {
|
|
|
|
case 1:
|
|
|
|
offset = tx / 8;
|
|
|
|
bit = 0x80 >> (tx % 8);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
offset = tx / 4;
|
|
|
|
bit = 0x80 >> (2 * (tx % 4));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
offset = tx / 2;
|
|
|
|
bit = 0x80 >> (4 * (tx % 2));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < _bpp; i++) {
|
|
|
|
if (src[offset] & (bit >> i))
|
|
|
|
val |= (1 << i);
|
|
|
|
}
|
|
|
|
|
|
|
|
_charBuffer[ty * _chars[c].width + tx] = _palette[val];
|
|
|
|
}
|
|
|
|
src += pitch;
|
2003-06-04 23:32:09 +00:00
|
|
|
}
|
2007-02-03 05:50:35 +00:00
|
|
|
|
|
|
|
return _charBuffer;
|
2003-06-04 23:32:09 +00:00
|
|
|
}
|
|
|
|
|
2003-09-06 16:42:28 +00:00
|
|
|
void NutRenderer::drawFrame(byte *dst, int c, int x, int y) {
|
2007-01-21 17:14:53 +00:00
|
|
|
const int width = MIN((int)_chars[c].width, _vm->_screenWidth - x);
|
|
|
|
const int height = MIN((int)_chars[c].height, _vm->_screenHeight - y);
|
2007-02-03 05:50:35 +00:00
|
|
|
const byte *src = unpackChar(c);
|
2004-01-07 13:29:30 +00:00
|
|
|
const int srcPitch = _chars[c].width;
|
2003-09-06 16:42:28 +00:00
|
|
|
byte bits = 0;
|
|
|
|
|
2004-01-07 13:29:30 +00:00
|
|
|
const int minX = x < 0 ? -x : 0;
|
|
|
|
const int minY = y < 0 ? -y : 0;
|
|
|
|
|
2004-01-15 22:37:48 +00:00
|
|
|
if (height <= 0 || width <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-06 16:42:28 +00:00
|
|
|
dst += _vm->_screenWidth * y + x;
|
2004-01-07 13:29:30 +00:00
|
|
|
if (minY) {
|
|
|
|
src += minY * srcPitch;
|
|
|
|
dst += minY * _vm->_screenWidth;
|
|
|
|
}
|
2004-01-15 22:37:48 +00:00
|
|
|
|
2004-01-07 13:29:30 +00:00
|
|
|
for (int ty = minY; ty < height; ty++) {
|
|
|
|
for (int tx = minX; tx < width; tx++) {
|
|
|
|
bits = src[tx];
|
2004-02-02 22:40:20 +00:00
|
|
|
if (bits != 231 && bits) {
|
2003-09-06 16:42:28 +00:00
|
|
|
dst[tx] = bits;
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 13:29:30 +00:00
|
|
|
src += srcPitch;
|
2003-09-06 16:42:28 +00:00
|
|
|
dst += _vm->_screenWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-08 22:10:38 +00:00
|
|
|
void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) {
|
|
|
|
byte *dst = (byte *)s.pixels + y * s.pitch + x;
|
2007-01-21 17:14:53 +00:00
|
|
|
const int width = MIN((int)_chars[c].width, s.w - x);
|
|
|
|
const int height = MIN((int)_chars[c].height, s.h - y);
|
2007-02-03 05:50:35 +00:00
|
|
|
const byte *src = unpackChar(c);
|
|
|
|
int srcPitch = _chars[c].width;
|
2003-06-04 23:32:09 +00:00
|
|
|
|
2004-01-07 13:29:30 +00:00
|
|
|
const int minX = x < 0 ? -x : 0;
|
|
|
|
const int minY = y < 0 ? -y : 0;
|
2003-11-08 21:59:32 +00:00
|
|
|
|
2004-01-15 22:37:48 +00:00
|
|
|
if (height <= 0 || width <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-07 13:29:30 +00:00
|
|
|
if (minY) {
|
|
|
|
src += minY * srcPitch;
|
2004-08-08 22:10:38 +00:00
|
|
|
dst += minY * s.pitch;
|
2004-01-07 13:29:30 +00:00
|
|
|
}
|
2004-01-15 22:37:48 +00:00
|
|
|
|
2004-01-07 13:29:30 +00:00
|
|
|
for (int ty = minY; ty < height; ty++) {
|
2007-02-03 05:50:35 +00:00
|
|
|
for (int tx = minX; tx < width; tx++) {
|
|
|
|
if (src[tx] != _chars[c].transparency) {
|
|
|
|
if (src[tx] == 1) {
|
2007-01-21 17:14:53 +00:00
|
|
|
dst[tx] = color;
|
2007-02-03 05:50:35 +00:00
|
|
|
} else {
|
|
|
|
dst[tx] = src[tx];
|
2007-01-21 17:14:53 +00:00
|
|
|
}
|
2002-12-31 20:52:11 +00:00
|
|
|
}
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
2004-01-07 13:29:30 +00:00
|
|
|
src += srcPitch;
|
2004-08-08 22:10:38 +00:00
|
|
|
dst += s.pitch;
|
2002-12-25 13:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-04 14:37:43 +00:00
|
|
|
|
2004-08-08 22:10:38 +00:00
|
|
|
void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) {
|
|
|
|
byte *dst = (byte *)s.pixels + y * s.pitch + x;
|
2004-01-15 22:37:48 +00:00
|
|
|
const int width = _vm->_2byteWidth;
|
2004-08-08 22:10:38 +00:00
|
|
|
const int height = MIN(_vm->_2byteHeight, s.h - y);
|
2005-08-19 22:36:08 +00:00
|
|
|
const byte *src = _vm->get2byteCharPtr(c);
|
2003-06-04 14:37:43 +00:00
|
|
|
byte bits = 0;
|
|
|
|
|
2004-01-15 22:37:48 +00:00
|
|
|
if (height <= 0 || width <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-04 14:37:43 +00:00
|
|
|
for (int ty = 0; ty < height; ty++) {
|
|
|
|
for (int tx = 0; tx < width; tx++) {
|
2004-01-07 13:29:30 +00:00
|
|
|
if ((tx & 7) == 0)
|
2003-06-04 14:37:43 +00:00
|
|
|
bits = *src++;
|
2004-08-08 22:10:38 +00:00
|
|
|
if (x + tx < 0 || x + tx >= s.w || y + ty < 0)
|
2003-06-04 14:37:43 +00:00
|
|
|
continue;
|
2005-05-15 10:40:28 +00:00
|
|
|
if (bits & revBitMask(tx % 8)) {
|
2003-06-04 14:37:43 +00:00
|
|
|
dst[tx] = color;
|
|
|
|
}
|
|
|
|
}
|
2004-08-08 22:10:38 +00:00
|
|
|
dst += s.pitch;
|
2003-06-04 14:37:43 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-03 18:33:57 +00:00
|
|
|
|
|
|
|
} // End of namespace Scumm
|