2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2002-03-20 17:51:07 +00:00
|
|
|
* Copyright (C) 2001/2002 The ScummVM project
|
2001-10-09 14:30:12 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-11-06 20:00:47 +00:00
|
|
|
* $Header$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "scumm.h"
|
2002-05-14 23:32:34 +00:00
|
|
|
#include "actor.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
const byte revBitMask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::ignorePakCols(int a)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
int n;
|
|
|
|
n = _height;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a > 1)
|
|
|
|
n *= a;
|
2001-10-09 14:30:12 +00:00
|
|
|
do {
|
|
|
|
_repcolor = *_srcptr++;
|
2002-04-11 17:19:16 +00:00
|
|
|
_replen = _repcolor & _maskval;
|
|
|
|
if (_replen == 0) {
|
2001-10-09 14:30:12 +00:00
|
|
|
_replen = *_srcptr++;
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
if (!--n) {
|
|
|
|
_repcolor >>= _shrval;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (--_replen);
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const byte cost_scaleTable[256] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
255, 253, 125, 189, 61, 221, 93, 157, 29, 237,
|
|
|
|
109, 173, 45, 205, 77, 141, 13, 245, 117, 181,
|
|
|
|
53, 213, 85, 149, 21, 229, 101, 165, 37, 197, 69,
|
|
|
|
133, 5, 249, 121, 185, 57, 217, 89, 153, 25, 233,
|
|
|
|
105, 169, 41, 201, 73, 137, 9, 241, 113, 177, 49,
|
|
|
|
209, 81, 145, 17, 225, 97, 161, 33, 193, 65, 129,
|
|
|
|
1, 251, 123, 187, 59, 219, 91, 155, 27, 235, 107,
|
|
|
|
171, 43, 203, 75, 139, 11, 243, 115, 179, 51, 211,
|
|
|
|
83, 147, 19, 227, 99, 163, 35, 195, 67, 131, 3,
|
|
|
|
247, 119, 183, 55, 215, 87, 151, 23, 231, 103,
|
|
|
|
167, 39, 199, 71, 135, 7, 239, 111, 175, 47, 207,
|
|
|
|
79, 143, 15, 223, 95, 159, 31, 191, 63, 127, 0,
|
|
|
|
128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208,
|
|
|
|
48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104,
|
|
|
|
232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132,
|
|
|
|
68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52,
|
|
|
|
180, 116, 244, 12, 140, 76, 204, 44, 172, 108,
|
|
|
|
236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130,
|
|
|
|
66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50,
|
|
|
|
178, 114, 242, 10, 138, 74, 202, 42, 170, 106,
|
|
|
|
234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134,
|
|
|
|
70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54,
|
|
|
|
182, 118, 246, 14, 142, 78, 206, 46, 174, 110,
|
|
|
|
238, 30, 158, 94, 222, 62, 190, 126, 254
|
2001-10-09 14:30:12 +00:00
|
|
|
};
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte CostumeRenderer::mainRoutine(Actor * a, int slot, int frame)
|
|
|
|
{
|
|
|
|
int xmove, ymove, i, b, s;
|
2001-10-09 14:30:12 +00:00
|
|
|
uint scal;
|
|
|
|
byte scaling;
|
|
|
|
byte charsetmask, masking;
|
|
|
|
byte unk19;
|
2002-04-11 17:19:16 +00:00
|
|
|
int ex1, ex2;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP _maskval = 0xF;
|
2001-10-09 14:30:12 +00:00
|
|
|
_shrval = 4;
|
2001-12-27 17:51:58 +00:00
|
|
|
if (_loaded._numColors == 32) {
|
2001-10-09 14:30:12 +00:00
|
|
|
_maskval = 7;
|
|
|
|
_shrval = 3;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_width2 = _srcptr[0];
|
|
|
|
_width = _width2;
|
|
|
|
_height2 = _srcptr[2];
|
|
|
|
_height = _height2;
|
2002-04-11 17:19:16 +00:00
|
|
|
xmove = (int16) READ_LE_UINT16(_srcptr + 4) + _xmove;
|
|
|
|
ymove = (int16) READ_LE_UINT16(_srcptr + 6) + _ymove;
|
|
|
|
_xmove += (int16) READ_LE_UINT16(_srcptr + 8);
|
|
|
|
_ymove -= (int16) READ_LE_UINT16(_srcptr + 10);
|
2001-10-09 14:30:12 +00:00
|
|
|
_srcptr += 12;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (_loaded._ptr[7] & 0x7F) {
|
|
|
|
case 0x60:
|
|
|
|
case 0x61:
|
2001-10-16 10:01:48 +00:00
|
|
|
ex1 = _srcptr[0];
|
|
|
|
ex2 = _srcptr[1];
|
|
|
|
_srcptr += 2;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (ex1 != 0xFF || ex2 != 0xFF) {
|
|
|
|
ex1 = READ_LE_UINT16(_loaded._ptr + _loaded._numColors + 10 + ex1 * 2);
|
|
|
|
_srcptr =
|
|
|
|
_loaded._ptr + READ_LE_UINT16(_loaded._ptr + ex1 + ex2 * 2) + 14;
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_xpos = _actorX;
|
|
|
|
_ypos = _actorY;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
scaling = _scaleX == 255 && _scaleY == 255 ? 0 : 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
s = 0;
|
|
|
|
|
|
|
|
if (scaling) {
|
|
|
|
_scaleIndexXStep = -1;
|
|
|
|
if (xmove < 0) {
|
|
|
|
xmove = -xmove;
|
|
|
|
_scaleIndexXStep = 1;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_mirror) {
|
2001-10-09 14:30:12 +00:00
|
|
|
unk19 = _scaleIndexX = 128 - xmove;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < xmove; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
scal = cost_scaleTable[_scaleIndexX++];
|
|
|
|
if (scal < _scaleX)
|
|
|
|
_xpos -= _scaleIndexXStep;
|
|
|
|
}
|
|
|
|
_right = _left = _xpos;
|
|
|
|
_scaleIndexX = unk19;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _width; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_right < 0) {
|
|
|
|
s++;
|
|
|
|
unk19 = _scaleIndexX;
|
|
|
|
}
|
|
|
|
scal = cost_scaleTable[_scaleIndexX++];
|
|
|
|
if (scal < _scaleX)
|
|
|
|
_right++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
unk19 = _scaleIndexX = xmove + 128;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < xmove; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
scal = cost_scaleTable[_scaleIndexX--];
|
|
|
|
if (scal < _scaleX)
|
|
|
|
_xpos += _scaleIndexXStep;
|
|
|
|
}
|
|
|
|
_right = _left = _xpos;
|
|
|
|
_scaleIndexX = unk19;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _width; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_left > 319) {
|
|
|
|
s++;
|
|
|
|
unk19 = _scaleIndexX;
|
|
|
|
}
|
|
|
|
scal = cost_scaleTable[_scaleIndexX--];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (scal < _scaleX)
|
2001-10-09 14:30:12 +00:00
|
|
|
_left--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_scaleIndexX = unk19;
|
|
|
|
if (s)
|
|
|
|
s--;
|
|
|
|
_scaleIndexYStep = -1;
|
|
|
|
if (ymove < 0) {
|
|
|
|
ymove = -ymove;
|
|
|
|
_scaleIndexYStep = 1;
|
|
|
|
}
|
|
|
|
_scaleIndexY = 128 - ymove;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < ymove; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
scal = cost_scaleTable[_scaleIndexY++];
|
|
|
|
if (scal < _scaleY)
|
|
|
|
_ypos -= _scaleIndexYStep;
|
|
|
|
}
|
|
|
|
_top = _bottom = _ypos;
|
|
|
|
_scaleIndexY = 128 - ymove;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _height; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
scal = cost_scaleTable[_scaleIndexY++];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (scal < _scaleY)
|
2001-10-09 14:30:12 +00:00
|
|
|
_bottom++;
|
|
|
|
}
|
|
|
|
_scaleIndexY = _scaleIndexYTop = 128 - ymove;
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_mirror == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
xmove = -xmove;
|
|
|
|
_xpos += xmove;
|
|
|
|
_ypos += ymove;
|
|
|
|
if (_mirror) {
|
|
|
|
_left = _xpos;
|
|
|
|
_right = _xpos + _width;
|
|
|
|
} else {
|
|
|
|
_left = _xpos - _width;
|
|
|
|
_right = _xpos;
|
|
|
|
}
|
|
|
|
_top = _ypos;
|
|
|
|
_bottom = _top + _height;
|
|
|
|
}
|
|
|
|
|
|
|
|
_scaleIndexXStep = -1;
|
|
|
|
if (_mirror)
|
|
|
|
_scaleIndexXStep = 1;
|
|
|
|
_ypostop = _ypos;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
_vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, 1 << a->number);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
if (_top >= (int)_outheight || _bottom <= 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
_ypitch = _height * 320;
|
|
|
|
_docontinue = 0;
|
|
|
|
b = 1;
|
|
|
|
if (_left > 319 || _right <= 0)
|
2001-12-27 17:51:58 +00:00
|
|
|
return 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_mirror) {
|
|
|
|
_ypitch--;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (scaling == 0) {
|
2001-10-09 14:30:12 +00:00
|
|
|
s = -_xpos;
|
|
|
|
}
|
|
|
|
if (s > 0) {
|
|
|
|
_width2 -= s;
|
|
|
|
ignorePakCols(s);
|
|
|
|
_xpos = 0;
|
|
|
|
_docontinue = 1;
|
|
|
|
} else {
|
|
|
|
s = _right - 320;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (s <= 0) {
|
2001-10-09 14:30:12 +00:00
|
|
|
b = 2;
|
|
|
|
} else {
|
|
|
|
_width2 -= s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_ypitch++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (scaling == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
s = _right - 320;
|
|
|
|
if (s > 0) {
|
|
|
|
_width2 -= s;
|
|
|
|
ignorePakCols(s);
|
|
|
|
_xpos = 319;
|
|
|
|
_docontinue = 1;
|
|
|
|
} else {
|
|
|
|
s = -1 - _left;
|
|
|
|
if (s <= 0)
|
|
|
|
b = 2;
|
|
|
|
else
|
|
|
|
_width2 -= s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_width2 == 0)
|
2001-10-16 10:01:48 +00:00
|
|
|
return 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if ((uint) _top > (uint) _outheight)
|
2001-10-09 14:30:12 +00:00
|
|
|
_top = 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_left < 0)
|
|
|
|
_left = 0;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if ((uint) _bottom > _outheight)
|
2001-12-27 17:51:58 +00:00
|
|
|
_bottom = _outheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
if (a->top > _top)
|
|
|
|
a->top = _top;
|
|
|
|
|
|
|
|
if (a->bottom < _bottom)
|
|
|
|
a->bottom = _bottom;
|
|
|
|
|
|
|
|
if (_height2 + _top >= 256) {
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP return 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
_bgbak_ptr =
|
2002-04-19 12:38:03 +00:00
|
|
|
_vm->getResourceAddress(rtBuffer,5) + _vm->virtscr[0].xstart + _ypos * 320 + _xpos;
|
2002-04-11 17:19:16 +00:00
|
|
|
_backbuff_ptr =
|
|
|
|
_vm->virtscr[0].screenPtr + _vm->virtscr[0].xstart + _ypos * 320 + _xpos;
|
|
|
|
charsetmask =
|
|
|
|
_vm->hasCharsetMask(_left, _top + _vm->virtscr[0].topline, _right,
|
|
|
|
_vm->virtscr[0].topline + _bottom);
|
2001-10-09 14:30:12 +00:00
|
|
|
masking = 0;
|
|
|
|
|
2002-05-01 09:37:03 +00:00
|
|
|
if (_vm->_features & GF_SMALL_HEADER)
|
|
|
|
masking = _zbuf;
|
|
|
|
else
|
2002-04-19 12:38:03 +00:00
|
|
|
masking = _vm->isMaskActiveAt(_left, _top, _right, _bottom,_vm->getResourceAddress(rtBuffer,9) +
|
2002-05-01 09:37:03 +00:00
|
|
|
_vm->gdi._imgBufOffs[_zbuf] + _vm->_screenStartStrip);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-05-01 19:03:54 +00:00
|
|
|
if (masking || charsetmask) {
|
2002-04-19 12:38:03 +00:00
|
|
|
_mask_ptr =_vm->getResourceAddress(rtBuffer,9) + _ypos * 40 + _vm->_screenStartStrip;
|
2001-10-26 17:34:50 +00:00
|
|
|
_imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!charsetmask && _zbuf != 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
_mask_ptr += _imgbufoffs;
|
|
|
|
_mask_ptr_dest = _mask_ptr + _xpos / 8;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP if (a->shadow_mode) {
|
2002-04-19 12:38:03 +00:00
|
|
|
proc_special(a,(masking<<1)+charsetmask);
|
2001-11-11 16:54:45 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch ((scaling << 2) | (masking << 1) | charsetmask) {
|
|
|
|
case 0:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc6(); // no scaling, no masking, no charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc5(); // no scaling, masking or charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc4(); // no scaling, masking and charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc1(); // scaling, no masking, no charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 5:
|
|
|
|
case 6:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc2(); // scaling, masking or charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2002-04-19 12:38:03 +00:00
|
|
|
proc3(); // scaling, masking and charsetmask
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP return b;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc6()
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
byte len;
|
|
|
|
byte *src, *dst;
|
2002-04-11 17:19:16 +00:00
|
|
|
byte width, height, pcolor;
|
2001-10-09 14:30:12 +00:00
|
|
|
int color;
|
|
|
|
uint y;
|
|
|
|
uint scrheight;
|
|
|
|
|
|
|
|
y = _ypos;
|
|
|
|
len = _replen;
|
|
|
|
src = _srcptr;
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
color = _repcolor;
|
2001-12-27 17:51:58 +00:00
|
|
|
scrheight = _outheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
width = _width2;
|
|
|
|
height = _height2;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-09 14:30:12 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (color && y < scrheight) {
|
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13) {
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
}
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst += 320;
|
|
|
|
y++;
|
|
|
|
if (!--height) {
|
|
|
|
if (!--width)
|
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
dst -= _ypitch;
|
|
|
|
y = _ypostop;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (--len);
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc5()
|
|
|
|
{
|
|
|
|
byte *mask, *src, *dst;
|
|
|
|
byte maskbit, len, height, pcolor;
|
|
|
|
uint y, scrheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
int color;
|
|
|
|
|
|
|
|
mask = _mask_ptr = _mask_ptr_dest;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-09 14:30:12 +00:00
|
|
|
y = _ypos;
|
|
|
|
src = _srcptr;
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
2001-12-27 17:51:58 +00:00
|
|
|
scrheight = _outheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
height = _height2;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-09 14:30:12 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (color && y < scrheight && !(*mask & maskbit)) {
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
y++;
|
|
|
|
mask += 40;
|
|
|
|
if (!--height) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!--_width2)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
dst -= _ypitch;
|
|
|
|
y = _ypostop;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_scaleIndexXStep != 1) {
|
|
|
|
maskbit <<= 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!maskbit) {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
_mask_ptr--;
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit >>= 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!maskbit) {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = 0x80;
|
2001-10-09 14:30:12 +00:00
|
|
|
_mask_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mask = _mask_ptr;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc4()
|
|
|
|
{
|
|
|
|
byte *mask, *src, *dst;
|
|
|
|
byte maskbit, len, height, pcolor;
|
|
|
|
uint y, scrheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
int color;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
mask = _mask_ptr = _mask_ptr_dest;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-09 14:30:12 +00:00
|
|
|
y = _ypos;
|
|
|
|
src = _srcptr;
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
2001-12-27 17:51:58 +00:00
|
|
|
scrheight = _outheight;
|
2001-10-09 14:30:12 +00:00
|
|
|
height = _height2;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-09 14:30:12 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (color && y < scrheight && !((*mask | mask[_imgbufoffs]) & maskbit)) {
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
y++;
|
|
|
|
mask += 40;
|
|
|
|
if (!--height) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!--_width2)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
dst -= _ypitch;
|
|
|
|
y = _ypostop;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_scaleIndexXStep != 1) {
|
|
|
|
maskbit <<= 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!maskbit) {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
_mask_ptr--;
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit >>= 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!maskbit) {
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = 0x80;
|
2001-10-09 14:30:12 +00:00
|
|
|
_mask_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mask = _mask_ptr;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc3()
|
|
|
|
{
|
|
|
|
byte *mask, *src, *dst;
|
|
|
|
byte maskbit, len, height, pcolor, width;
|
|
|
|
int color, t;
|
2001-10-16 20:31:27 +00:00
|
|
|
uint y;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-16 20:31:27 +00:00
|
|
|
mask = _mask_ptr_dest;
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-16 20:31:27 +00:00
|
|
|
height = _height2;
|
|
|
|
width = _width2;
|
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
|
|
|
src = _srcptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-16 20:31:27 +00:00
|
|
|
y = _ypos;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-16 20:31:27 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-16 20:31:27 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
2001-10-16 20:31:27 +00:00
|
|
|
do {
|
|
|
|
if (cost_scaleTable[_scaleIndexY++] < _scaleY) {
|
2002-04-19 12:38:03 +00:00
|
|
|
if (color && y < _outheight && !((*mask | mask[_imgbufoffs]) & maskbit)) {
|
2001-10-16 20:31:27 +00:00
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2001-10-16 20:31:27 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
mask += 40;
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!--width)
|
2001-10-16 20:31:27 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
y = _ypostop;
|
|
|
|
_scaleIndexY = _scaleIndexYTop;
|
|
|
|
t = _scaleIndexX;
|
|
|
|
_scaleIndexX = t + _scaleIndexXStep;
|
|
|
|
if (cost_scaleTable[t] < _scaleX) {
|
|
|
|
_xpos += _scaleIndexXStep;
|
|
|
|
if (_xpos >= 320)
|
|
|
|
return;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-26 17:34:50 +00:00
|
|
|
_backbuff_ptr += _scaleIndexXStep;
|
2001-10-16 20:31:27 +00:00
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
mask = _mask_ptr + (_xpos >> 3);
|
2001-10-16 20:31:27 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-16 20:31:27 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc2()
|
|
|
|
{
|
|
|
|
byte *mask, *src, *dst;
|
|
|
|
byte maskbit, len, height, pcolor, width;
|
|
|
|
int color, t;
|
2001-10-09 14:30:12 +00:00
|
|
|
uint y;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
mask = _mask_ptr_dest;
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
height = _height2;
|
|
|
|
width = _width2;
|
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
|
|
|
src = _srcptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-09 14:30:12 +00:00
|
|
|
y = _ypos;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-09 14:30:12 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
2001-10-09 14:30:12 +00:00
|
|
|
do {
|
|
|
|
if (cost_scaleTable[_scaleIndexY++] < _scaleY) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (color && y < _outheight && !(*mask & maskbit)) {
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
mask += 40;
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!--width)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
y = _ypostop;
|
|
|
|
_scaleIndexY = _scaleIndexYTop;
|
|
|
|
t = _scaleIndexX;
|
|
|
|
_scaleIndexX = t + _scaleIndexXStep;
|
|
|
|
if (cost_scaleTable[t] < _scaleX) {
|
|
|
|
_xpos += _scaleIndexXStep;
|
|
|
|
if (_xpos >= 320)
|
|
|
|
return;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-26 17:34:50 +00:00
|
|
|
_backbuff_ptr += _scaleIndexXStep;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
mask = _mask_ptr + (_xpos >> 3);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::proc1()
|
|
|
|
{
|
|
|
|
byte *mask, *src, *dst, *dstorg;
|
|
|
|
byte maskbit, len, height, pcolor, width;
|
2001-10-09 14:30:12 +00:00
|
|
|
uint y;
|
|
|
|
int color;
|
|
|
|
int t;
|
|
|
|
|
|
|
|
mask = _mask_ptr = _mask_ptr_dest;
|
2002-04-11 17:19:16 +00:00
|
|
|
maskbit = revBitMask[_xpos & 7];
|
2001-10-09 14:30:12 +00:00
|
|
|
y = _ypos;
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
dstorg = dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
height = _height2;
|
|
|
|
width = _width2;
|
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
|
|
|
src = _srcptr;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-04-11 17:19:16 +00:00
|
|
|
color = len >> _shrval;
|
2001-10-09 14:30:12 +00:00
|
|
|
len &= _maskval;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
do {
|
|
|
|
if (cost_scaleTable[_scaleIndexY++] < _scaleY) {
|
2001-12-27 17:51:58 +00:00
|
|
|
if (color && y < _outheight) {
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2001-10-09 14:30:12 +00:00
|
|
|
pcolor = _transEffect[*dst];
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!--width)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
y = _ypostop;
|
|
|
|
_scaleIndexY = _scaleIndexYTop;
|
|
|
|
t = _scaleIndexX;
|
|
|
|
_scaleIndexX = t + _scaleIndexXStep;
|
|
|
|
if (cost_scaleTable[t] < _scaleX) {
|
|
|
|
_xpos += _scaleIndexXStep;
|
|
|
|
if (_xpos >= 320)
|
|
|
|
return;
|
2001-10-26 17:34:50 +00:00
|
|
|
_backbuff_ptr += _scaleIndexXStep;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
dst = _backbuff_ptr;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-19 12:38:03 +00:00
|
|
|
void CostumeRenderer::proc_special(Actor *a, byte mask2)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2002-04-19 12:38:03 +00:00
|
|
|
byte *mask, *src, *dst, *dstorg;
|
|
|
|
byte maskbit, len, height, pcolor, width;
|
|
|
|
uint y;
|
|
|
|
int color;
|
|
|
|
int t;
|
|
|
|
|
|
|
|
byte shadow1;
|
|
|
|
byte shadow2;
|
|
|
|
byte shadow3;
|
|
|
|
byte shadow4;
|
|
|
|
byte shadow5;
|
|
|
|
|
|
|
|
shadow1=a->shadow_mode & 0x80;
|
|
|
|
shadow2=a->shadow_mode & 0x40;
|
|
|
|
shadow3=a->shadow_mode & 0x20;
|
|
|
|
shadow4=a->shadow_mode & 0x10;
|
|
|
|
shadow5=a->shadow_mode & 0x0F;
|
|
|
|
|
|
|
|
mask = _mask_ptr = _mask_ptr_dest;
|
|
|
|
maskbit = revBitMask[_xpos & 7];
|
|
|
|
y = _ypos;
|
|
|
|
|
|
|
|
mask = _mask_ptr_dest;
|
|
|
|
dstorg = dst = _backbuff_ptr;
|
|
|
|
height = _height2;
|
|
|
|
width = _width2;
|
|
|
|
len = _replen;
|
|
|
|
color = _repcolor;
|
|
|
|
src = _srcptr;
|
|
|
|
|
|
|
|
if(_mirror == 0)
|
|
|
|
shadow5=-shadow5;
|
|
|
|
|
|
|
|
maskbit = revBitMask[_xpos & 7];
|
|
|
|
|
|
|
|
dst = _backbuff_ptr;
|
|
|
|
|
|
|
|
if(mask2 !=0 && mask2 < 3)
|
|
|
|
_imgbufoffs = 0;
|
|
|
|
|
|
|
|
if (_docontinue)
|
|
|
|
goto StartPos;
|
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
|
|
|
color = len >> _shrval;
|
|
|
|
len &= _maskval;
|
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
|
|
|
do { // ok
|
|
|
|
if (cost_scaleTable[_scaleIndexY++] < _scaleY) {
|
|
|
|
if (color && y < _outheight) {
|
|
|
|
if (!mask2 || (mask2 && !((*mask | mask[_imgbufoffs]) & maskbit)))
|
|
|
|
{
|
|
|
|
if(shadow3 == 0)
|
|
|
|
{
|
|
|
|
pcolor = _palette[color];
|
|
|
|
if (pcolor != 13)
|
|
|
|
goto proc_special_end;
|
|
|
|
|
|
|
|
}
|
|
|
|
if(shadow2 != 0)
|
|
|
|
{
|
|
|
|
warning("proc_special: shadow2 unimplemented");
|
2002-04-19 17:06:08 +00:00
|
|
|
pcolor = 0;
|
2002-04-19 12:38:03 +00:00
|
|
|
}
|
|
|
|
else // we don't need all the random stuff, just the background copy
|
|
|
|
{
|
|
|
|
pcolor=_vm->_proc_special_palette[*dst];
|
|
|
|
}
|
2002-04-20 09:30:04 +00:00
|
|
|
proc_special_end:; *dst = pcolor;
|
2002-04-19 12:38:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
mask += 40;
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
|
|
|
if (!--width)
|
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
y = _ypostop;
|
|
|
|
_scaleIndexY = _scaleIndexYTop;
|
|
|
|
t = _scaleIndexX;
|
|
|
|
_scaleIndexX = t + _scaleIndexXStep;
|
|
|
|
if (cost_scaleTable[t] < _scaleX) {
|
|
|
|
_xpos += _scaleIndexXStep;
|
|
|
|
if (_xpos >= 320)
|
|
|
|
return;
|
|
|
|
maskbit = revBitMask[_xpos & 7];
|
|
|
|
_backbuff_ptr += _scaleIndexXStep;
|
|
|
|
}
|
|
|
|
dst = _backbuff_ptr;
|
|
|
|
mask = _mask_ptr + (_xpos >> 3);
|
|
|
|
}
|
|
|
|
StartPos:;
|
|
|
|
} while (--len);
|
|
|
|
} while (1);
|
|
|
|
|
2001-11-11 16:54:45 +00:00
|
|
|
}
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
#if 0
|
2002-04-11 17:19:16 +00:00
|
|
|
void CostumeRenderer::loadCostume(int id)
|
|
|
|
{
|
2001-11-14 20:09:39 +00:00
|
|
|
_ptr = _vm->getResourceAddress(rtCostume, id);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (_vm->_features & GF_AFTER_V6) {
|
2001-10-23 19:51:50 +00:00
|
|
|
_ptr += 8;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (!(_vm->_features & GF_SMALL_HEADER)) {
|
2001-10-23 19:51:50 +00:00
|
|
|
_ptr += 2;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (_ptr[7] & 0x7F) {
|
2001-10-09 14:30:12 +00:00
|
|
|
case 0x58:
|
|
|
|
_numColors = 16;
|
|
|
|
break;
|
|
|
|
case 0x59:
|
|
|
|
_numColors = 32;
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 0x60: /* New since version 6 */
|
2001-10-16 10:01:48 +00:00
|
|
|
_numColors = 16;
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 0x61: /* New since version 6 */
|
2001-10-16 10:01:48 +00:00
|
|
|
_numColors = 32;
|
|
|
|
break;
|
2001-10-09 14:30:12 +00:00
|
|
|
default:
|
|
|
|
error("Costume %d is invalid", id);
|
|
|
|
}
|
|
|
|
|
|
|
|
_dataptr = _ptr + READ_LE_UINT16(_ptr + _numColors + 8);
|
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::initActorCostumeData(Actor * a)
|
|
|
|
{
|
2001-11-26 19:57:57 +00:00
|
|
|
CostumeData *cd = &a->cost;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
cd->stopped = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2001-11-26 19:57:57 +00:00
|
|
|
cd->active[i] = 0;
|
|
|
|
cd->curpos[i] = cd->start[i] = cd->end[i] = cd->frame[i] = 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte CostumeRenderer::drawOneSlot(Actor * a, int slot)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!(_vm->_features & GF_AFTER_V7)) {
|
2002-03-05 23:05:55 +00:00
|
|
|
int i;
|
|
|
|
int code;
|
|
|
|
CostumeData *cd = &a->cost;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (cd->curpos[slot] == 0xFFFF || cd->stopped & (1 << slot))
|
2002-03-05 23:05:55 +00:00
|
|
|
return 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
i = cd->curpos[slot] & 0x7FFF;
|
2002-04-19 15:34:35 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
_frameptr =
|
2002-04-19 15:34:35 +00:00
|
|
|
_loaded._ptr + READ_LE_UINT16(_loaded._ptr + _loaded._numColors + slot * 2 + 10);
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
code = _loaded._dataptr[i] & 0x7F;
|
|
|
|
|
|
|
|
_srcptr = _loaded._ptr + READ_LE_UINT16(_frameptr + code * 2);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-03-05 23:05:55 +00:00
|
|
|
if (code != 0x7B) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_vm->_features & GF_OLD256) || code < 0x79)
|
|
|
|
return mainRoutine(a, slot, code);
|
2002-03-05 23:05:55 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte CostumeRenderer::drawCostume(Actor * a)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
|
|
|
byte r = 0;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_xmove = _ymove = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i != 16; i++)
|
|
|
|
r |= drawOneSlot(a, i);
|
2001-10-09 14:30:12 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
int Scumm::cost_frameToAnim(Actor * a, int frame)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
return newDirToOldDir(a->facing) + frame * 4;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::loadCostume(LoadedCostume * lc, int costume)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_ptr = getResourceAddress(rtCostume, costume);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (_features & GF_AFTER_V6) {
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_ptr += 8;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (!(_features & GF_SMALL_HEADER)) {
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_ptr += 2;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (lc->_ptr[7] & 0x7F) {
|
2001-12-27 17:51:58 +00:00
|
|
|
case 0x58:
|
|
|
|
lc->_numColors = 16;
|
|
|
|
break;
|
|
|
|
case 0x59:
|
|
|
|
lc->_numColors = 32;
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 0x60: /* New since version 6 */
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_numColors = 16;
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 0x61: /* New since version 6 */
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_numColors = 32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Costume %d is invalid", costume);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
lc->_dataptr = lc->_ptr + READ_LE_UINT16(lc->_ptr + lc->_numColors + 8);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::cost_decodeData(Actor * a, int frame, uint usemask)
|
|
|
|
{
|
|
|
|
byte *p, *r;
|
|
|
|
uint mask, j;
|
2001-11-26 19:57:57 +00:00
|
|
|
int i;
|
2002-04-11 17:19:16 +00:00
|
|
|
byte extra, cmd;
|
2001-11-26 19:57:57 +00:00
|
|
|
byte *dataptr;
|
|
|
|
int anim;
|
2001-12-27 17:51:58 +00:00
|
|
|
LoadedCostume lc;
|
|
|
|
|
|
|
|
loadCostume(&lc, a->costume);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
anim = cost_frameToAnim(a, frame);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
p = lc._ptr;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (anim > p[6]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
r = p + READ_LE_UINT16(p + anim * 2 + lc._numColors + 42);
|
|
|
|
if (r == p) {
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (_features & GF_OLD256)
|
2002-02-21 22:48:13 +00:00
|
|
|
dataptr = p + *(p + lc._numColors + 8);
|
|
|
|
else
|
|
|
|
dataptr = p + READ_LE_UINT16(p + lc._numColors + 8);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
mask = READ_LE_UINT16(r);
|
2002-04-11 17:19:16 +00:00
|
|
|
r += 2;
|
2001-11-26 19:57:57 +00:00
|
|
|
i = 0;
|
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (mask & 0x8000) {
|
|
|
|
if (_features & GF_OLD256) {
|
2002-02-21 23:43:19 +00:00
|
|
|
j = 0;
|
2002-02-21 22:48:13 +00:00
|
|
|
j = *(r);
|
|
|
|
r++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (j == 0xFF)
|
|
|
|
j = 0xFFFF;
|
2002-02-21 22:48:13 +00:00
|
|
|
} else {
|
|
|
|
j = READ_LE_UINT16(r);
|
2002-04-11 17:19:16 +00:00
|
|
|
r += 2;
|
2002-02-21 22:48:13 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
if (usemask & 0x8000) {
|
|
|
|
if (j == 0xFFFF) {
|
2001-11-26 19:57:57 +00:00
|
|
|
a->cost.curpos[i] = 0xFFFF;
|
|
|
|
a->cost.start[i] = 0;
|
|
|
|
a->cost.frame[i] = frame;
|
|
|
|
} else {
|
|
|
|
extra = *r++;
|
|
|
|
cmd = dataptr[j];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (cmd == 0x7A) {
|
|
|
|
a->cost.stopped &= ~(1 << i);
|
|
|
|
} else if (cmd == 0x79) {
|
|
|
|
a->cost.stopped |= (1 << i);
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
|
|
|
a->cost.curpos[i] = a->cost.start[i] = j;
|
2002-04-11 17:19:16 +00:00
|
|
|
a->cost.end[i] = j + (extra & 0x7F);
|
|
|
|
if (extra & 0x80)
|
2001-11-26 19:57:57 +00:00
|
|
|
a->cost.curpos[i] |= 0x8000;
|
|
|
|
a->cost.frame[i] = frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (j != 0xFFFF)
|
2001-11-26 19:57:57 +00:00
|
|
|
r++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
usemask <<= 1;
|
|
|
|
mask <<= 1;
|
|
|
|
} while ((uint16)mask);
|
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::cost_setPalette(CostumeRenderer * cr, byte *palette)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
int i;
|
|
|
|
byte color;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < cr->_loaded._numColors; i++) {
|
2001-12-27 17:51:58 +00:00
|
|
|
color = palette[i];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (color == 255)
|
|
|
|
color = cr->_loaded._ptr[8 + i];
|
2001-12-27 17:51:58 +00:00
|
|
|
cr->_palette[i] = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::cost_setFacing(CostumeRenderer * cr, Actor * a)
|
|
|
|
{
|
|
|
|
cr->_mirror = newDirToOldDir(a->facing) != 0
|
|
|
|
|| (cr->_loaded._ptr[7] & 0x80);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::cost_setCostume(CostumeRenderer * cr, int costume)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
loadCostume(&cr->_loaded, costume);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte Scumm::cost_increaseAnims(LoadedCostume * lc, Actor * a)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
int i;
|
|
|
|
byte r = 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i != 16; i++) {
|
|
|
|
if (a->cost.curpos[i] != 0xFFFF)
|
|
|
|
r += cost_increaseAnim(lc, a, i);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte Scumm::cost_increaseAnim(LoadedCostume * lc, Actor * a, int slot)
|
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
int highflag;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, end;
|
|
|
|
byte code, nc;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a->cost.curpos[slot] == 0xFFFF)
|
2001-12-27 17:51:58 +00:00
|
|
|
return 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
highflag = a->cost.curpos[slot] & 0x8000;
|
|
|
|
i = a->cost.curpos[slot] & 0x7FFF;
|
2001-12-27 17:51:58 +00:00
|
|
|
end = a->cost.end[slot];
|
2002-04-11 17:19:16 +00:00
|
|
|
code = lc->_dataptr[i] & 0x7F;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (!highflag) {
|
|
|
|
if (i++ >= end)
|
|
|
|
i = a->cost.start[slot];
|
|
|
|
} else {
|
|
|
|
if (i != end)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
nc = lc->_dataptr[i];
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (nc == 0x7C) {
|
2001-12-27 17:51:58 +00:00
|
|
|
a->cost.animCounter1++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a->cost.start[slot] != end)
|
2001-12-27 17:51:58 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V6) {
|
|
|
|
if (nc >= 0x71 && nc <= 0x78) {
|
|
|
|
addSoundToQueue2(a->sound[nc - 0x71]);
|
|
|
|
if (a->cost.start[slot] != end)
|
2001-12-27 17:51:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (nc == 0x78) {
|
2001-12-27 17:51:58 +00:00
|
|
|
a->cost.animCounter2++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a->cost.start[slot] != end)
|
2001-12-27 17:51:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
a->cost.curpos[slot] = i | highflag;
|
|
|
|
return (lc->_dataptr[i] & 0x7F) != code;
|
|
|
|
} while (1);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2002-05-20 14:41:47 +00:00
|
|
|
|
|
|
|
bool Scumm::isCostumeInUse(int cost)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Actor *a;
|
|
|
|
|
|
|
|
if (_roomResource != 0)
|
|
|
|
for (i = 1; i < NUM_ACTORS; i++) {
|
|
|
|
a = derefActor(i);
|
|
|
|
if (a->isInCurrentRoom() && a->costume == cost)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|