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.
|
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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/scumm.h"
|
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/costume.h"
|
2002-08-29 23:45:15 +00:00
|
|
|
#include "scumm/sound.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
#include "scumm/util.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2005-05-15 10:02:13 +00:00
|
|
|
const byte smallCostumeScaleTable[256] = {
|
2003-06-19 17:50:10 +00:00
|
|
|
0xFF, 0xFD, 0x7D, 0xBD, 0x3D, 0xDD, 0x5D, 0x9D,
|
|
|
|
0x1D, 0xED, 0x6D, 0xAD, 0x2D, 0xCD, 0x4D, 0x8D,
|
|
|
|
0x0D, 0xF5, 0x75, 0xB5, 0x35, 0xD5, 0x55, 0x95,
|
|
|
|
0x15, 0xE5, 0x65, 0xA5, 0x25, 0xC5, 0x45, 0x85,
|
|
|
|
0x05, 0xF9, 0x79, 0xB9, 0x39, 0xD9, 0x59, 0x99,
|
|
|
|
0x19, 0xE9, 0x69, 0xA9, 0x29, 0xC9, 0x49, 0x89,
|
|
|
|
0x09, 0xF1, 0x71, 0xB1, 0x31, 0xD1, 0x51, 0x91,
|
|
|
|
0x11, 0xE1, 0x61, 0xA1, 0x21, 0xC1, 0x41, 0x81,
|
|
|
|
0x01, 0xFB, 0x7B, 0xBB, 0x3B, 0xDB, 0x5B, 0x9B,
|
|
|
|
0x1B, 0xEB, 0x6B, 0xAB, 0x2B, 0xCB, 0x4B, 0x8B,
|
|
|
|
0x0B, 0xF3, 0x73, 0xB3, 0x33, 0xD3, 0x53, 0x93,
|
|
|
|
0x13, 0xE3, 0x63, 0xA3, 0x23, 0xC3, 0x43, 0x83,
|
|
|
|
0x03, 0xF7, 0x77, 0xB7, 0x37, 0xD7, 0x57, 0x97,
|
|
|
|
0x17, 0xE7, 0x67, 0xA7, 0x27, 0xC7, 0x47, 0x87,
|
|
|
|
0x07, 0xEF, 0x6F, 0xAF, 0x2F, 0xCF, 0x4F, 0x8F,
|
|
|
|
0x0F, 0xDF, 0x5F, 0x9F, 0x1F, 0xBF, 0x3F, 0x7F,
|
|
|
|
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
|
|
|
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
|
|
|
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
|
|
|
0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
|
|
|
|
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
|
|
|
|
0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
|
|
|
|
0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
|
|
|
|
0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
|
|
|
|
0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
|
|
|
|
0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
|
|
|
|
0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
|
|
|
|
0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
|
|
|
|
0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
|
|
|
|
0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
|
|
|
|
0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
|
|
|
|
0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE
|
2001-10-09 14:30:12 +00:00
|
|
|
};
|
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
static const int v1MMNESLookup[25] = {
|
|
|
|
0x00, 0x03, 0x01, 0x06, 0x08,
|
|
|
|
0x02, 0x00, 0x07, 0x0C, 0x04,
|
|
|
|
0x09, 0x0A, 0x12, 0x0B, 0x14,
|
|
|
|
0x0D, 0x11, 0x0F, 0x0E, 0x10,
|
2007-09-19 08:40:12 +00:00
|
|
|
0x17, 0x00, 0x01, 0x05, 0x16
|
2005-03-27 00:42:53 +00:00
|
|
|
};
|
|
|
|
|
2010-03-16 14:34:25 +00:00
|
|
|
static const byte v0ActorTalkArray[0x19] = {
|
2010-03-16 08:59:48 +00:00
|
|
|
0x00, 0x06, 0x06, 0x06, 0x06,
|
|
|
|
0x06, 0x06, 0x00, 0x46, 0x06,
|
|
|
|
0x06, 0x06, 0x06, 0xFF, 0xFF,
|
|
|
|
0x06, 0xC0, 0x06, 0x06, 0x00,
|
|
|
|
0xC0, 0xC0, 0x00, 0x06, 0x06
|
|
|
|
};
|
2005-03-27 00:42:53 +00:00
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
byte ClassicCostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) {
|
2004-06-25 08:10:34 +00:00
|
|
|
int i, skip = 0;
|
2003-05-28 21:08:56 +00:00
|
|
|
byte drawFlag = 1;
|
|
|
|
bool use_scaling;
|
2003-04-23 08:26:28 +00:00
|
|
|
byte startScaleIndexX;
|
2002-04-11 17:19:16 +00:00
|
|
|
int ex1, ex2;
|
2004-01-08 03:10:16 +00:00
|
|
|
Common::Rect rect;
|
2003-05-29 02:46:06 +00:00
|
|
|
int step;
|
2004-11-25 23:36:02 +00:00
|
|
|
Codec1 v1;
|
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
const int scaletableSize = 128;
|
2006-02-20 16:51:30 +00:00
|
|
|
const bool newAmiCost = (_vm->_game.version == 5) && (_vm->_game.platform == Common::kPlatformAmiga);
|
2009-10-25 14:20:47 +00:00
|
|
|
const bool pcEngCost = (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine);
|
2003-08-11 06:24:19 +00:00
|
|
|
|
2005-05-15 10:02:13 +00:00
|
|
|
v1.scaletable = smallCostumeScaleTable;
|
2003-05-30 21:37:58 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
if (_loaded._numColors == 32) {
|
2003-05-29 02:14:31 +00:00
|
|
|
v1.mask = 7;
|
|
|
|
v1.shr = 3;
|
2003-05-30 21:37:58 +00:00
|
|
|
} else {
|
2004-09-02 23:16:58 +00:00
|
|
|
v1.mask = 15;
|
2003-05-30 21:37:58 +00:00
|
|
|
v1.shr = 4;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-07-08 12:28:57 +00:00
|
|
|
switch (_loaded._format) {
|
2002-04-11 17:19:16 +00:00
|
|
|
case 0x60:
|
|
|
|
case 0x61:
|
2003-07-08 16:17:41 +00:00
|
|
|
// This format is used e.g. in the Sam&Max intro
|
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) {
|
2003-07-08 12:28:57 +00:00
|
|
|
ex1 = READ_LE_UINT16(_loaded._frameOffsets + ex1 * 2);
|
2003-07-08 13:11:42 +00:00
|
|
|
_srcptr = _loaded._baseptr + READ_LE_UINT16(_loaded._baseptr + 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
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
use_scaling = (_scaleX != 0xFF) || (_scaleY != 0xFF);
|
|
|
|
|
2003-05-29 02:14:31 +00:00
|
|
|
v1.x = _actorX;
|
|
|
|
v1.y = _actorY;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-28 21:08:56 +00:00
|
|
|
if (use_scaling) {
|
2004-06-25 08:10:34 +00:00
|
|
|
|
|
|
|
/* Scale direction */
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.scaleXstep = -1;
|
2003-05-29 10:16:00 +00:00
|
|
|
if (xmoveCur < 0) {
|
|
|
|
xmoveCur = -xmoveCur;
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.scaleXstep = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 06:29:10 +00:00
|
|
|
// It's possible that the scale indexes will overflow and wrap
|
|
|
|
// around to zero, so it's important that we use the same
|
|
|
|
// method of accessing it both when calculating the size of the
|
|
|
|
// scaled costume, and when drawing it. See bug #1519667.
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_mirror) {
|
2004-06-25 08:10:34 +00:00
|
|
|
/* Adjust X position */
|
2004-09-02 23:16:58 +00:00
|
|
|
startScaleIndexX = _scaleIndexX = scaletableSize - xmoveCur;
|
2003-05-29 10:16:00 +00:00
|
|
|
for (i = 0; i < xmoveCur; i++) {
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexX++] < _scaleX)
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.x -= v1.scaleXstep;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
rect.left = rect.right = v1.x;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2003-04-23 08:26:28 +00:00
|
|
|
_scaleIndexX = startScaleIndexX;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _width; i++) {
|
2004-01-08 03:10:16 +00:00
|
|
|
if (rect.right < 0) {
|
2003-05-29 02:46:06 +00:00
|
|
|
skip++;
|
2003-04-23 08:26:28 +00:00
|
|
|
startScaleIndexX = _scaleIndexX;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexX++] < _scaleX)
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.right++;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-06-25 08:10:34 +00:00
|
|
|
/* No mirror */
|
|
|
|
/* Adjust X position */
|
2004-09-02 23:16:58 +00:00
|
|
|
startScaleIndexX = _scaleIndexX = xmoveCur + scaletableSize;
|
2003-05-29 10:16:00 +00:00
|
|
|
for (i = 0; i < xmoveCur; i++) {
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexX--] < _scaleX)
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
rect.left = rect.right = v1.x;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2003-04-23 08:26:28 +00:00
|
|
|
_scaleIndexX = startScaleIndexX;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _width; i++) {
|
2004-10-09 00:06:36 +00:00
|
|
|
if (rect.left >= _out.w) {
|
2003-04-23 08:26:28 +00:00
|
|
|
startScaleIndexX = _scaleIndexX;
|
2004-06-25 08:10:34 +00:00
|
|
|
skip++;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexX--] < _scaleX)
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.left--;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
2003-04-23 08:26:28 +00:00
|
|
|
_scaleIndexX = startScaleIndexX;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2003-05-29 02:46:06 +00:00
|
|
|
if (skip)
|
|
|
|
skip--;
|
|
|
|
|
|
|
|
step = -1;
|
2003-05-29 10:16:00 +00:00
|
|
|
if (ymoveCur < 0) {
|
|
|
|
ymoveCur = -ymoveCur;
|
2003-05-29 02:46:06 +00:00
|
|
|
step = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
_scaleIndexY = scaletableSize - ymoveCur;
|
2003-05-29 10:16:00 +00:00
|
|
|
for (i = 0; i < ymoveCur; i++) {
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexY++] < _scaleY)
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.y -= step;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.top = rect.bottom = v1.y;
|
2004-09-02 23:16:58 +00:00
|
|
|
_scaleIndexY = scaletableSize - ymoveCur;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _height; i++) {
|
2004-09-02 23:16:58 +00:00
|
|
|
if (v1.scaletable[_scaleIndexY++] < _scaleY)
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.bottom++;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
_scaleIndexY = scaletableSize - ymoveCur;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2003-05-29 02:14:31 +00:00
|
|
|
if (!_mirror)
|
2003-05-29 10:16:00 +00:00
|
|
|
xmoveCur = -xmoveCur;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2003-05-29 10:16:00 +00:00
|
|
|
v1.x += xmoveCur;
|
|
|
|
v1.y += ymoveCur;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_mirror) {
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.left = v1.x;
|
|
|
|
rect.right = v1.x + _width;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.left = v1.x - _width;
|
|
|
|
rect.right = v1.x;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.top = v1.y;
|
|
|
|
rect.bottom = rect.top + _height;
|
2004-06-25 08:10:34 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-05-30 21:37:58 +00:00
|
|
|
v1.skip_width = _width;
|
|
|
|
v1.scaleXstep = _mirror ? 1 : -1;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.version == 1)
|
2004-08-10 02:17:34 +00:00
|
|
|
// V1 games uses 8 x 8 pixels for actors
|
2004-01-08 03:10:16 +00:00
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right + 8, rect.top, rect.bottom, _actorID);
|
2003-11-23 07:59:45 +00:00
|
|
|
else
|
2004-01-08 03:10:16 +00:00
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right + 1, rect.top, rect.bottom, _actorID);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (rect.top >= _out.h || rect.bottom <= 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
return 0;
|
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (rect.left >= _out.w || rect.right <= 0)
|
2003-05-30 00:41:58 +00:00
|
|
|
return 0;
|
2003-05-28 21:08:56 +00:00
|
|
|
|
2003-05-29 10:46:07 +00:00
|
|
|
v1.replen = 0;
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_mirror) {
|
2003-05-29 02:14:31 +00:00
|
|
|
if (!use_scaling)
|
2003-05-29 02:46:06 +00:00
|
|
|
skip = -v1.x;
|
|
|
|
if (skip > 0) {
|
2009-10-25 14:20:47 +00:00
|
|
|
if (!newAmiCost && !pcEngCost && _loaded._format != 0x57) {
|
2003-08-11 03:45:12 +00:00
|
|
|
v1.skip_width -= skip;
|
2004-11-25 23:36:02 +00:00
|
|
|
codec1_ignorePakCols(v1, skip);
|
2003-08-11 03:45:12 +00:00
|
|
|
v1.x = 0;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2004-10-09 00:06:36 +00:00
|
|
|
skip = rect.right - _out.w;
|
2003-05-29 02:46:06 +00:00
|
|
|
if (skip <= 0) {
|
2003-05-28 21:08:56 +00:00
|
|
|
drawFlag = 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2003-05-30 21:37:58 +00:00
|
|
|
v1.skip_width -= skip;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2003-05-29 02:14:31 +00:00
|
|
|
if (!use_scaling)
|
2004-10-09 00:06:36 +00:00
|
|
|
skip = rect.right - _out.w;
|
2003-05-29 02:46:06 +00:00
|
|
|
if (skip > 0) {
|
2009-10-25 14:20:47 +00:00
|
|
|
if (!newAmiCost && !pcEngCost && _loaded._format != 0x57) {
|
2003-08-11 03:45:12 +00:00
|
|
|
v1.skip_width -= skip;
|
2004-11-25 23:36:02 +00:00
|
|
|
codec1_ignorePakCols(v1, skip);
|
2004-10-09 00:06:36 +00:00
|
|
|
v1.x = _out.w - 1;
|
2003-08-11 03:45:12 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2004-08-10 02:17:34 +00:00
|
|
|
// V1 games uses 8 x 8 pixels for actors
|
2004-08-10 02:13:25 +00:00
|
|
|
if (_loaded._format == 0x57)
|
|
|
|
skip = -8 - rect.left;
|
|
|
|
else
|
|
|
|
skip = -1 - rect.left;
|
2003-05-29 02:46:06 +00:00
|
|
|
if (skip <= 0)
|
2003-05-28 21:08:56 +00:00
|
|
|
drawFlag = 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
else
|
2003-05-30 21:37:58 +00:00
|
|
|
v1.skip_width -= skip;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-30 21:37:58 +00:00
|
|
|
if (v1.skip_width <= 0)
|
2001-10-16 10:01:48 +00:00
|
|
|
return 0;
|
|
|
|
|
2004-01-08 03:10:16 +00:00
|
|
|
if (rect.left < 0)
|
|
|
|
rect.left = 0;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2004-04-06 01:06:54 +00:00
|
|
|
if (rect.top < 0)
|
2004-01-08 03:10:16 +00:00
|
|
|
rect.top = 0;
|
2003-05-29 18:45:58 +00:00
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (rect.top > _out.h)
|
|
|
|
rect.top = _out.h;
|
2004-04-06 01:06:54 +00:00
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (rect.bottom > _out.h)
|
|
|
|
rect.bottom = _out.h;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-01-08 03:10:16 +00:00
|
|
|
if (_draw_top > rect.top)
|
|
|
|
_draw_top = rect.top;
|
2004-04-04 19:41:02 +00:00
|
|
|
if (_draw_bottom < rect.bottom)
|
|
|
|
_draw_bottom = rect.bottom;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-01-08 03:10:16 +00:00
|
|
|
if (_height + rect.top >= 256) {
|
2003-01-05 23:53:16 +00:00
|
|
|
return 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2009-10-26 09:11:18 +00:00
|
|
|
v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-08-08 22:10:38 +00:00
|
|
|
v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-08-17 16:53:00 +00:00
|
|
|
if (_loaded._format == 0x57) {
|
|
|
|
// The v1 costume renderer needs the actor number, which is
|
2004-01-05 16:19:14 +00:00
|
|
|
// the same thing as the costume renderer's _actorID.
|
2004-11-25 23:36:02 +00:00
|
|
|
procC64(v1, _actorID);
|
2003-08-17 16:53:00 +00:00
|
|
|
} else if (newAmiCost)
|
2004-11-25 23:36:02 +00:00
|
|
|
proc3_ami(v1);
|
2009-10-25 14:20:47 +00:00
|
|
|
else if (pcEngCost)
|
|
|
|
procPCEngine(v1);
|
2003-05-18 18:36:14 +00:00
|
|
|
else
|
2004-11-25 23:36:02 +00:00
|
|
|
proc3(v1);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-28 21:08:56 +00:00
|
|
|
return drawFlag;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2004-07-26 13:53:24 +00:00
|
|
|
static const int v1MMActorPalatte1[25] = {
|
2003-08-25 21:00:12 +00:00
|
|
|
8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
|
|
|
|
};
|
2004-07-26 13:53:24 +00:00
|
|
|
static const int v1MMActorPalatte2[25] = {
|
2003-08-25 21:00:12 +00:00
|
|
|
0, 7, 2, 6, 9, 1, 3, 7, 7, 1, 1, 9, 1, 4, 5, 5, 4, 1, 0, 5, 4, 2, 2, 7, 7
|
|
|
|
};
|
2003-08-25 13:13:43 +00:00
|
|
|
|
|
|
|
#define MASK_AT(xoff) \
|
2005-05-15 10:40:28 +00:00
|
|
|
(mask && (mask[((v1.x + xoff) / 8)] & revBitMask((v1.x + xoff) & 7)))
|
2003-08-25 13:13:43 +00:00
|
|
|
#define LINE(c,p) \
|
|
|
|
pcolor = (color >> c) & 3; \
|
|
|
|
if (pcolor) { \
|
|
|
|
if (!MASK_AT(p)) \
|
|
|
|
dst[p] = palette[pcolor]; \
|
2003-11-16 20:52:57 +00:00
|
|
|
if (!MASK_AT(p + 1)) \
|
|
|
|
dst[p + 1] = palette[pcolor]; \
|
2003-08-25 13:13:43 +00:00
|
|
|
}
|
2003-08-17 05:46:48 +00:00
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
void ClassicCostumeRenderer::procC64(Codec1 &v1, int actor) {
|
2003-08-25 13:13:43 +00:00
|
|
|
const byte *mask, *src;
|
2003-06-19 10:45:21 +00:00
|
|
|
byte *dst;
|
2003-07-13 02:45:31 +00:00
|
|
|
byte len;
|
2004-04-04 22:43:54 +00:00
|
|
|
int y;
|
|
|
|
uint height;
|
2003-07-13 11:13:50 +00:00
|
|
|
byte color, pcolor;
|
|
|
|
bool rep;
|
2003-06-19 10:45:21 +00:00
|
|
|
|
2003-07-13 11:13:50 +00:00
|
|
|
y = v1.y;
|
2003-06-19 10:45:21 +00:00
|
|
|
src = _srcptr;
|
|
|
|
dst = v1.destptr;
|
2003-07-08 12:28:57 +00:00
|
|
|
len = v1.replen;
|
|
|
|
color = v1.repcolor;
|
2003-07-13 11:13:50 +00:00
|
|
|
height = _height;
|
2003-06-19 10:45:21 +00:00
|
|
|
|
2003-11-16 20:52:57 +00:00
|
|
|
v1.skip_width /= 8;
|
2003-07-13 10:35:05 +00:00
|
|
|
|
2003-08-25 21:00:12 +00:00
|
|
|
// Set up the palette data
|
2003-08-18 06:59:18 +00:00
|
|
|
byte palette[4] = { 0, 0, 0, 0 };
|
2006-03-14 14:06:44 +00:00
|
|
|
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) {
|
|
|
|
if (_vm->_game.id == GID_MANIAC) {
|
|
|
|
palette[1] = v1MMActorPalatte1[actor];
|
|
|
|
palette[2] = v1MMActorPalatte2[actor];
|
|
|
|
} else {
|
2006-03-14 15:36:04 +00:00
|
|
|
// Adjust for C64 version of Zak McKracken
|
2006-03-14 14:06:44 +00:00
|
|
|
palette[1] = (_vm->_game.platform == Common::kPlatformC64) ? 10 : 8;
|
|
|
|
palette[2] = _palette[actor];
|
|
|
|
}
|
|
|
|
} else {
|
2003-08-18 10:46:42 +00:00
|
|
|
palette[2] = 11;
|
|
|
|
palette[3] = 11;
|
2003-08-18 02:16:48 +00:00
|
|
|
}
|
2003-08-25 13:13:43 +00:00
|
|
|
mask = v1.mask_ptr;
|
2003-07-13 11:13:50 +00:00
|
|
|
|
|
|
|
if (len)
|
|
|
|
goto StartPos;
|
|
|
|
|
2003-07-13 10:35:05 +00:00
|
|
|
do {
|
2003-07-13 11:13:50 +00:00
|
|
|
len = *src++;
|
|
|
|
if (len & 0x80)
|
2003-06-19 10:45:21 +00:00
|
|
|
color = *src++;
|
2003-07-13 11:13:50 +00:00
|
|
|
StartPos:;
|
|
|
|
rep = (len & 0x80) != 0;
|
|
|
|
len &= 0x7f;
|
|
|
|
while (len--) {
|
|
|
|
if (!rep)
|
2003-07-07 15:12:21 +00:00
|
|
|
color = *src++;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (0 <= y && y < _out.h && 0 <= v1.x && v1.x < _out.w) {
|
2003-07-13 10:35:05 +00:00
|
|
|
if (!_mirror) {
|
2003-08-25 13:13:43 +00:00
|
|
|
LINE(0, 0); LINE(2, 2); LINE(4, 4); LINE(6, 6);
|
2003-07-13 10:35:05 +00:00
|
|
|
} else {
|
2003-08-25 13:13:43 +00:00
|
|
|
LINE(6, 0); LINE(4, 2); LINE(2, 4); LINE(0, 6);
|
2003-07-07 15:12:21 +00:00
|
|
|
}
|
2003-07-13 11:13:50 +00:00
|
|
|
}
|
2004-10-09 00:06:36 +00:00
|
|
|
dst += _out.pitch;
|
2003-07-13 11:13:50 +00:00
|
|
|
y++;
|
2003-08-25 13:13:43 +00:00
|
|
|
mask += _numStrips;
|
2003-07-13 11:13:50 +00:00
|
|
|
if (!--height) {
|
|
|
|
if (!--v1.skip_width)
|
|
|
|
return;
|
|
|
|
height = _height;
|
|
|
|
y = v1.y;
|
|
|
|
v1.x += 8 * v1.scaleXstep;
|
2004-10-09 00:06:36 +00:00
|
|
|
if (v1.x < 0 || v1.x >= _out.w)
|
2003-07-13 11:13:50 +00:00
|
|
|
return;
|
2003-08-25 13:13:43 +00:00
|
|
|
mask = v1.mask_ptr;
|
2003-07-13 11:13:50 +00:00
|
|
|
v1.destptr += 8 * v1.scaleXstep;
|
|
|
|
dst = v1.destptr;
|
2003-07-07 15:12:21 +00:00
|
|
|
}
|
2003-06-19 10:45:21 +00:00
|
|
|
}
|
2003-11-16 23:53:00 +00:00
|
|
|
} while (1);
|
2003-06-19 10:45:21 +00:00
|
|
|
}
|
|
|
|
|
2003-08-25 13:13:43 +00:00
|
|
|
#undef LINE
|
|
|
|
#undef MASK_AT
|
|
|
|
|
2008-02-03 01:26:12 +00:00
|
|
|
#ifdef USE_ARM_COSTUME_ASM
|
2011-04-23 01:28:26 +00:00
|
|
|
|
|
|
|
#ifndef IPHONE
|
|
|
|
#define ClassicProc3RendererShadowARM _ClassicProc3RendererShadowARM
|
|
|
|
#endif
|
|
|
|
|
2008-02-03 01:26:12 +00:00
|
|
|
extern "C" int ClassicProc3RendererShadowARM(int _scaleY,
|
|
|
|
ClassicCostumeRenderer::Codec1 *v1,
|
|
|
|
Graphics::Surface *_out,
|
|
|
|
const byte *src,
|
|
|
|
int height,
|
|
|
|
int _scaleX,
|
|
|
|
int _scaleIndexX,
|
|
|
|
byte *_shadow_table,
|
2010-02-26 16:17:12 +00:00
|
|
|
uint16 _palette[32],
|
2008-02-03 01:26:12 +00:00
|
|
|
int32 _numStrips,
|
|
|
|
int _scaleIndexY);
|
|
|
|
#endif
|
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
void ClassicCostumeRenderer::proc3(Codec1 &v1) {
|
2003-05-29 02:14:31 +00:00
|
|
|
const byte *mask, *src;
|
|
|
|
byte *dst;
|
2003-05-30 21:37:58 +00:00
|
|
|
byte len, maskbit;
|
2004-04-04 22:43:54 +00:00
|
|
|
int y;
|
|
|
|
uint color, height, pcolor;
|
2006-07-10 06:29:10 +00:00
|
|
|
byte scaleIndexY;
|
2003-05-18 18:36:14 +00:00
|
|
|
bool masked;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2008-02-03 01:26:12 +00:00
|
|
|
#ifdef USE_ARM_COSTUME_ASM
|
2008-02-03 09:35:04 +00:00
|
|
|
if (((_shadow_mode & 0x20) == 0) &&
|
2008-02-03 01:26:12 +00:00
|
|
|
(v1.mask_ptr != NULL) &&
|
|
|
|
(_shadow_table != NULL))
|
|
|
|
{
|
|
|
|
_scaleIndexX = ClassicProc3RendererShadowARM(_scaleY,
|
|
|
|
&v1,
|
|
|
|
&_out,
|
2008-02-03 13:12:51 +00:00
|
|
|
_srcptr,
|
2008-02-03 01:26:12 +00:00
|
|
|
_height,
|
|
|
|
_scaleX,
|
|
|
|
_scaleIndexX,
|
|
|
|
_shadow_table,
|
|
|
|
_palette,
|
|
|
|
_numStrips,
|
|
|
|
_scaleIndexY);
|
2008-02-03 13:12:51 +00:00
|
|
|
return;
|
2008-02-03 01:26:12 +00:00
|
|
|
}
|
|
|
|
#endif /* USE_ARM_COSTUME_ASM */
|
|
|
|
|
2003-05-29 02:14:31 +00:00
|
|
|
y = v1.y;
|
2002-08-04 00:04:50 +00:00
|
|
|
src = _srcptr;
|
2003-05-29 02:14:31 +00:00
|
|
|
dst = v1.destptr;
|
2003-05-29 10:46:07 +00:00
|
|
|
len = v1.replen;
|
2003-05-29 02:14:31 +00:00
|
|
|
color = v1.repcolor;
|
|
|
|
height = _height;
|
2001-10-16 20:31:27 +00:00
|
|
|
|
2006-07-10 06:29:10 +00:00
|
|
|
scaleIndexY = _scaleIndexY;
|
2005-05-15 10:40:28 +00:00
|
|
|
maskbit = revBitMask(v1.x & 7);
|
2003-11-16 20:52:57 +00:00
|
|
|
mask = v1.mask_ptr + v1.x / 8;
|
2003-05-29 18:45:58 +00:00
|
|
|
|
2003-05-29 11:07:54 +00:00
|
|
|
if (len)
|
2002-04-11 17:19:16 +00:00
|
|
|
goto StartPos;
|
2001-10-16 20:31:27 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2003-05-29 02:14:31 +00:00
|
|
|
color = len >> v1.shr;
|
|
|
|
len &= v1.mask;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
2002-08-04 00:04:50 +00:00
|
|
|
|
2001-10-16 20:31:27 +00:00
|
|
|
do {
|
2006-07-10 06:29:10 +00:00
|
|
|
if (_scaleY == 255 || v1.scaletable[scaleIndexY++] < _scaleY) {
|
2006-10-04 05:11:58 +00:00
|
|
|
masked = (y < 0 || y >= _out.h) || (v1.x < 0 || v1.x >= _out.w) || (v1.mask_ptr && (mask[0] & maskbit));
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2004-04-06 01:06:54 +00:00
|
|
|
if (color && !masked) {
|
2003-05-18 18:36:14 +00:00
|
|
|
if (_shadow_mode & 0x20) {
|
2004-07-25 09:21:58 +00:00
|
|
|
pcolor = _shadow_table[*dst];
|
2003-05-18 18:36:14 +00:00
|
|
|
} else {
|
|
|
|
pcolor = _palette[color];
|
|
|
|
if (pcolor == 13 && _shadow_table)
|
|
|
|
pcolor = _shadow_table[*dst];
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
*dst = pcolor;
|
|
|
|
}
|
2004-10-09 00:06:36 +00:00
|
|
|
dst += _out.pitch;
|
2002-10-24 06:28:54 +00:00
|
|
|
mask += _numStrips;
|
2001-10-09 14:30:12 +00:00
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2003-05-30 21:37:58 +00:00
|
|
|
if (!--v1.skip_width)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
height = _height;
|
2003-05-29 02:46:06 +00:00
|
|
|
y = v1.y;
|
|
|
|
|
2006-07-10 06:29:10 +00:00
|
|
|
scaleIndexY = _scaleIndexY;
|
2003-05-30 21:37:58 +00:00
|
|
|
|
|
|
|
if (_scaleX == 255 || v1.scaletable[_scaleIndexX] < _scaleX) {
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
2004-10-09 00:06:36 +00:00
|
|
|
if (v1.x < 0 || v1.x >= _out.w)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
2005-05-15 10:40:28 +00:00
|
|
|
maskbit = revBitMask(v1.x & 7);
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.destptr += v1.scaleXstep;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2003-05-29 02:46:06 +00:00
|
|
|
_scaleIndexX += v1.scaleXstep;
|
2003-05-29 02:14:31 +00:00
|
|
|
dst = v1.destptr;
|
2003-11-16 20:52:57 +00:00
|
|
|
mask = v1.mask_ptr + v1.x / 8;
|
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
|
|
|
}
|
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
void ClassicCostumeRenderer::proc3_ami(Codec1 &v1) {
|
2003-05-29 02:14:31 +00:00
|
|
|
const byte *mask, *src;
|
|
|
|
byte *dst;
|
2003-05-18 18:36:14 +00:00
|
|
|
byte maskbit, len, height, width;
|
2003-05-29 02:46:06 +00:00
|
|
|
int color;
|
2004-04-04 22:43:54 +00:00
|
|
|
int y;
|
2003-05-18 18:36:14 +00:00
|
|
|
bool masked;
|
2002-08-24 13:06:44 +00:00
|
|
|
int oldXpos, oldScaleIndexX;
|
2002-07-18 18:42:51 +00:00
|
|
|
|
2003-11-16 20:52:57 +00:00
|
|
|
mask = v1.mask_ptr + v1.x / 8;
|
2003-05-29 02:14:31 +00:00
|
|
|
dst = v1.destptr;
|
|
|
|
height = _height;
|
2002-07-18 18:42:51 +00:00
|
|
|
width = _width;
|
|
|
|
src = _srcptr;
|
2005-05-15 10:40:28 +00:00
|
|
|
maskbit = revBitMask(v1.x & 7);
|
2003-05-29 02:14:31 +00:00
|
|
|
y = v1.y;
|
|
|
|
oldXpos = v1.x;
|
2002-07-18 18:42:51 +00:00
|
|
|
oldScaleIndexX = _scaleIndexX;
|
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2003-05-29 02:14:31 +00:00
|
|
|
color = len >> v1.shr;
|
|
|
|
len &= v1.mask;
|
2002-07-18 18:42:51 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
do {
|
2004-09-02 23:16:58 +00:00
|
|
|
if (_scaleY == 255 || v1.scaletable[_scaleIndexY] < _scaleY) {
|
2006-10-04 05:11:58 +00:00
|
|
|
masked = (y < 0 || y >= _out.h) || (v1.x < 0 || v1.x >= _out.w) || (v1.mask_ptr && (mask[0] & maskbit));
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-10-04 05:11:58 +00:00
|
|
|
if (color && !masked) {
|
2003-05-18 18:36:14 +00:00
|
|
|
*dst = _palette[color];
|
2002-07-18 18:42:51 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 23:16:58 +00:00
|
|
|
if (_scaleX == 255 || v1.scaletable[_scaleIndexX] < _scaleX) {
|
2003-05-29 02:46:06 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
|
|
|
dst += v1.scaleXstep;
|
2005-05-15 10:40:28 +00:00
|
|
|
maskbit = revBitMask(v1.x & 7);
|
2002-07-18 18:42:51 +00:00
|
|
|
}
|
2003-05-29 02:46:06 +00:00
|
|
|
_scaleIndexX += v1.scaleXstep;
|
2003-11-16 20:52:57 +00:00
|
|
|
mask = v1.mask_ptr + v1.x / 8;
|
2002-07-18 18:42:51 +00:00
|
|
|
}
|
|
|
|
if (!--width) {
|
|
|
|
if (!--height)
|
|
|
|
return;
|
|
|
|
|
2004-10-09 00:06:36 +00:00
|
|
|
if (y >= _out.h)
|
2002-07-18 18:42:51 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-29 02:14:31 +00:00
|
|
|
if (v1.x != oldXpos) {
|
2004-10-09 00:06:36 +00:00
|
|
|
dst += _out.pitch - (v1.x - oldXpos);
|
2003-05-29 02:14:31 +00:00
|
|
|
v1.mask_ptr += _numStrips;
|
2005-09-15 10:25:23 +00:00
|
|
|
mask = v1.mask_ptr + oldXpos / 8;
|
|
|
|
maskbit = revBitMask(oldXpos & 7);
|
2002-07-18 18:42:51 +00:00
|
|
|
y++;
|
|
|
|
}
|
|
|
|
width = _width;
|
2003-05-29 02:14:31 +00:00
|
|
|
v1.x = oldXpos;
|
2002-07-18 18:42:51 +00:00
|
|
|
_scaleIndexX = oldScaleIndexX;
|
|
|
|
_scaleIndexY++;
|
|
|
|
}
|
|
|
|
} while (--len);
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2009-10-25 14:20:47 +00:00
|
|
|
void PCESetCostumeData(byte block[16][16], int index, byte value) {
|
|
|
|
int row = (index % 16);
|
|
|
|
int plane = (index / 16) % 4;
|
|
|
|
int colOffset = (index < 64) ? 8 : 0;
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
int bit = (value >> (7-i)) & 0x1;
|
|
|
|
block[row][i + colOffset] |= bit << plane;
|
|
|
|
}
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2009-10-25 14:20:47 +00:00
|
|
|
void ClassicCostumeRenderer::procPCEngine(Codec1 &v1) {
|
|
|
|
const byte *mask, *src;
|
|
|
|
byte *dst;
|
|
|
|
byte maskbit;
|
2009-10-26 02:45:26 +00:00
|
|
|
int xPos, yPos;
|
2009-10-26 12:29:57 +00:00
|
|
|
uint pcolor, width, height;
|
2009-10-26 02:45:26 +00:00
|
|
|
bool masked;
|
2009-10-25 14:20:47 +00:00
|
|
|
int vertShift;
|
2009-10-26 02:45:26 +00:00
|
|
|
int xStep;
|
2009-10-25 14:20:47 +00:00
|
|
|
byte block[16][16];
|
|
|
|
|
|
|
|
src = _srcptr;
|
|
|
|
width = _width / 16;
|
|
|
|
height = _height / 16;
|
|
|
|
|
|
|
|
if (_numBlocks == 0)
|
2007-03-03 23:02:54 +00:00
|
|
|
return;
|
2009-10-25 14:20:47 +00:00
|
|
|
|
2009-10-26 02:45:26 +00:00
|
|
|
xStep = _mirror ? +1 : -1;
|
2009-10-25 14:20:47 +00:00
|
|
|
|
|
|
|
for (uint x = 0; x < width; ++x) {
|
2009-10-26 02:45:26 +00:00
|
|
|
yPos = 0;
|
2009-10-25 14:20:47 +00:00
|
|
|
for (uint y = 0; y < height; ++y) {
|
|
|
|
vertShift = *src++;
|
|
|
|
if (vertShift == 0xFF) {
|
2009-10-26 02:45:26 +00:00
|
|
|
yPos += 16;
|
2009-10-25 14:20:47 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
2009-10-26 02:45:26 +00:00
|
|
|
yPos += vertShift;
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(block, 0, sizeof(block));
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
while (index < 128) {
|
|
|
|
byte cmd = *src++;
|
|
|
|
int cnt = (cmd & 0x3F) + 1;
|
|
|
|
if (!(cmd & 0xC0)) {
|
|
|
|
for (int i = 0; i < cnt; ++i)
|
|
|
|
PCESetCostumeData(block, index++, 0);
|
|
|
|
} else if (cmd & 0x80) {
|
|
|
|
int value = *src++;
|
|
|
|
for (int i = 0; i < cnt; ++i)
|
|
|
|
PCESetCostumeData(block, index++, value);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < cnt; ++i)
|
|
|
|
PCESetCostumeData(block, index++, *src++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (index != 128) {
|
2010-11-01 21:37:47 +00:00
|
|
|
warning("ClassicCostumeRenderer::procPCEngine: index %d != 128\n", index);
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int row = 0; row < 16; ++row) {
|
2009-10-26 02:45:26 +00:00
|
|
|
xPos = xStep * x * 16;
|
2009-10-25 14:20:47 +00:00
|
|
|
for (int col = 0; col < 16; ++col) {
|
2009-10-26 09:11:18 +00:00
|
|
|
dst = v1.destptr + yPos * _out.pitch + xPos * _vm->_bytesPerPixel;
|
2009-10-26 02:45:26 +00:00
|
|
|
mask = v1.mask_ptr + yPos * _numStrips + (v1.x + xPos) / 8;
|
|
|
|
maskbit = revBitMask((v1.x + xPos) % 8);
|
|
|
|
|
2009-10-26 12:29:57 +00:00
|
|
|
pcolor = block[row][col];
|
2010-01-25 01:39:44 +00:00
|
|
|
masked = (v1.y + yPos < 0 || v1.y + yPos >= _out.h) ||
|
|
|
|
(v1.x + xPos < 0 || v1.x + xPos >= _out.w) ||
|
2009-10-26 02:45:26 +00:00
|
|
|
(v1.mask_ptr && (mask[0] & maskbit));
|
|
|
|
|
2009-10-26 12:29:57 +00:00
|
|
|
if (pcolor && !masked) {
|
|
|
|
WRITE_UINT16(dst, ((uint16*)_palette)[pcolor]);
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
2009-10-26 02:45:26 +00:00
|
|
|
|
|
|
|
xPos += xStep;
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
2009-10-26 02:45:26 +00:00
|
|
|
yPos++;
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-03 23:02:54 +00:00
|
|
|
}
|
2009-10-25 14:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicCostumeLoader::loadCostume(int id) {
|
|
|
|
_id = id;
|
|
|
|
byte *ptr = _vm->getResourceAddress(rtCostume, id);
|
2007-03-03 23:02:54 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.version >= 6)
|
2003-07-08 16:31:01 +00:00
|
|
|
ptr += 8;
|
2006-02-20 16:51:30 +00:00
|
|
|
else if (_vm->_game.features & GF_OLD_BUNDLE)
|
2003-07-08 16:31:01 +00:00
|
|
|
ptr += -2;
|
2006-02-20 16:51:30 +00:00
|
|
|
else if (_vm->_game.features & GF_SMALL_HEADER)
|
2003-07-08 16:31:01 +00:00
|
|
|
ptr += 0;
|
2003-04-12 19:51:14 +00:00
|
|
|
else
|
2003-07-08 16:31:01 +00:00
|
|
|
ptr += 2;
|
2001-10-23 19:51:50 +00:00
|
|
|
|
2003-07-08 16:31:01 +00:00
|
|
|
_baseptr = ptr;
|
2003-04-22 20:48:53 +00:00
|
|
|
|
2003-07-08 16:31:01 +00:00
|
|
|
_numAnim = ptr[6];
|
|
|
|
_format = ptr[7] & 0x7F;
|
|
|
|
_mirror = (ptr[7] & 0x80) != 0;
|
|
|
|
_palette = ptr + 8;
|
2009-10-25 14:20:47 +00:00
|
|
|
|
|
|
|
if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine) {
|
|
|
|
_numColors = 16;
|
|
|
|
|
|
|
|
ptr += 8 + 17;
|
|
|
|
_animCmds = READ_LE_UINT16(ptr) + ptr + 2;
|
|
|
|
_frameOffsets = ptr + 2;
|
|
|
|
_dataOffsets = ptr + 34;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-07-08 12:28:57 +00:00
|
|
|
switch (_format) {
|
2003-06-06 22:35:23 +00:00
|
|
|
case 0x57: // Only used in V1 games
|
|
|
|
_numColors = 0;
|
|
|
|
break;
|
2001-10-09 14:30:12 +00:00
|
|
|
case 0x58:
|
|
|
|
_numColors = 16;
|
|
|
|
break;
|
|
|
|
case 0x59:
|
|
|
|
_numColors = 32;
|
|
|
|
break;
|
2003-06-06 22:35:23 +00:00
|
|
|
case 0x60: // New since version 6
|
2001-10-16 10:01:48 +00:00
|
|
|
_numColors = 16;
|
|
|
|
break;
|
2003-06-06 22:35:23 +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:
|
2003-08-12 05:28:11 +00:00
|
|
|
error("Costume %d with format 0x%X is invalid", id, _format);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2003-07-08 13:11:42 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
|
|
|
// In GF_OLD_BUNDLE games, there is no actual palette, just a single color byte.
|
2003-04-22 18:57:10 +00:00
|
|
|
// Don't forget, these games were designed around a fixed 16 color HW palette :-)
|
2003-11-07 02:11:41 +00:00
|
|
|
// In addition, all offsets are shifted by 2; we accomodate that via a separate
|
2003-04-22 20:48:53 +00:00
|
|
|
// _baseptr value (instead of adding tons of if's throughout the code).
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.features & GF_OLD_BUNDLE) {
|
2003-07-14 19:24:34 +00:00
|
|
|
_numColors = (_format == 0x57) ? 0 : 1;
|
2003-04-22 20:48:53 +00:00
|
|
|
_baseptr += 2;
|
|
|
|
}
|
2003-07-08 16:31:01 +00:00
|
|
|
ptr += 8 + _numColors;
|
|
|
|
_frameOffsets = ptr + 2;
|
2003-07-14 19:24:34 +00:00
|
|
|
if (_format == 0x57) {
|
2003-07-08 17:08:44 +00:00
|
|
|
_dataOffsets = ptr + 18;
|
|
|
|
_baseptr += 4;
|
|
|
|
} else {
|
|
|
|
_dataOffsets = ptr + 34;
|
|
|
|
}
|
2003-07-08 16:31:01 +00:00
|
|
|
_animCmds = _baseptr + READ_LE_UINT16(ptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
byte NESCostumeRenderer::drawLimb(const Actor *a, int limb) {
|
2005-03-26 23:40:01 +00:00
|
|
|
const byte darkpalette[16] = {0x00,0x00,0x2D,0x3D,0x00,0x00,0x2D,0x3D,0x00,0x00,0x2D,0x3D,0x00,0x00,0x2D,0x3D};
|
2005-03-14 21:13:35 +00:00
|
|
|
const CostumeData &cost = a->_cost;
|
2005-04-01 21:35:44 +00:00
|
|
|
const byte *palette, *src, *sprdata;
|
|
|
|
int anim, frameNum, frame, offset, numSprites;
|
2005-03-14 21:13:35 +00:00
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
// If the specified limb is stopped or not existing, do nothing.
|
2005-04-01 21:35:44 +00:00
|
|
|
if (cost.curpos[limb] == 0xFFFF)
|
2005-03-27 00:23:38 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-03-14 14:06:44 +00:00
|
|
|
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_base_palette)
|
2005-03-26 23:40:01 +00:00
|
|
|
palette = _vm->_NESPalette[1];
|
|
|
|
else
|
|
|
|
palette = darkpalette;
|
|
|
|
|
2005-03-14 21:13:35 +00:00
|
|
|
src = _loaded._dataOffsets;
|
2005-04-01 21:35:44 +00:00
|
|
|
anim = 4 * cost.frame[limb] + newDirToOldDir(a->getFacing());
|
|
|
|
frameNum = cost.curpos[limb];
|
|
|
|
frame = src[src[2 * anim] + frameNum];
|
2005-03-14 21:13:35 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
offset = READ_LE_UINT16(_vm->_NEScostdesc + v1MMNESLookup[_loaded._id] * 2);
|
|
|
|
numSprites = _vm->_NEScostlens[offset + frame] + 1;
|
|
|
|
sprdata = _vm->_NEScostdata + READ_LE_UINT16(_vm->_NEScostoffs + 2 * (offset + frame)) + numSprites * 3;
|
2005-03-14 21:13:35 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
bool flipped = (newDirToOldDir(a->getFacing()) == 1);
|
|
|
|
int left = 239, right = 0, top = 239, bottom = 0;
|
2005-05-18 23:17:04 +00:00
|
|
|
byte *maskBuf = _vm->getMaskBuffer(0, 0, 1);
|
2005-03-14 21:13:35 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
for (int spr = 0; spr < numSprites; spr++) {
|
|
|
|
byte mask, tile, sprpal;
|
|
|
|
int8 y, x;
|
2005-03-15 02:08:53 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
sprdata -= 3;
|
2005-03-14 21:13:35 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
mask = (sprdata[0] & 0x80) ? 0x01 : 0x80;
|
|
|
|
y = sprdata[0] << 1;
|
|
|
|
y >>= 1;
|
2005-03-15 04:05:15 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
tile = sprdata[1];
|
2005-03-15 17:56:50 +00:00
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
sprpal = (sprdata[2] & 0x03) << 2;
|
|
|
|
x = sprdata[2];
|
|
|
|
x >>= 2;
|
2005-03-21 23:51:48 +00:00
|
|
|
|
2005-03-15 17:56:50 +00:00
|
|
|
if (flipped) {
|
2005-03-15 04:05:15 +00:00
|
|
|
mask = (mask == 0x80) ? 0x01 : 0x80;
|
|
|
|
x = -x;
|
|
|
|
}
|
2005-03-15 02:08:53 +00:00
|
|
|
|
2007-02-15 10:30:30 +00:00
|
|
|
left = MIN(left, _actorX + x);
|
|
|
|
right = MAX(right, _actorX + x + 8);
|
|
|
|
top = MIN(top, _actorY + y);
|
|
|
|
bottom = MAX(bottom, _actorY + y + 8);
|
|
|
|
|
2005-03-21 23:51:48 +00:00
|
|
|
if ((_actorX + x < 0) || (_actorX + x + 8 >= _out.w))
|
|
|
|
continue;
|
|
|
|
if ((_actorY + y < 0) || (_actorY + y + 8 >= _out.h))
|
|
|
|
continue;
|
|
|
|
|
2005-03-15 02:08:53 +00:00
|
|
|
for (int ty = 0; ty < 8; ty++) {
|
2005-03-24 03:22:32 +00:00
|
|
|
byte c1 = _vm->_NESPatTable[0][tile * 16 + ty];
|
|
|
|
byte c2 = _vm->_NESPatTable[0][tile * 16 + ty + 8];
|
2005-03-25 02:13:02 +00:00
|
|
|
|
2005-03-15 02:08:53 +00:00
|
|
|
for (int tx = 0; tx < 8; tx++) {
|
2005-03-26 23:40:01 +00:00
|
|
|
unsigned char c = ((c1 & mask) ? 1 : 0) | ((c2 & mask) ? 2 : 0) | sprpal;
|
2005-03-15 02:08:53 +00:00
|
|
|
if (mask == 0x01) {
|
|
|
|
c1 >>= 1;
|
|
|
|
c2 >>= 1;
|
|
|
|
} else {
|
|
|
|
c1 <<= 1;
|
|
|
|
c2 <<= 1;
|
|
|
|
}
|
|
|
|
if (!(c & 3))
|
|
|
|
continue;
|
2005-03-26 03:49:06 +00:00
|
|
|
int my = _actorY + y + ty;
|
|
|
|
int mx = _actorX + x + tx;
|
2005-05-18 23:17:04 +00:00
|
|
|
if (!(_zbuf && (maskBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7))))
|
2005-03-26 23:40:01 +00:00
|
|
|
*((byte *)_out.pixels + my * _out.pitch + mx) = palette[c];
|
2005-03-14 21:13:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-15 17:56:50 +00:00
|
|
|
|
|
|
|
_draw_top = top;
|
|
|
|
_draw_bottom = bottom;
|
|
|
|
|
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, left, right, top, bottom, _actorID);
|
2005-03-27 00:23:38 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-03-14 21:13:35 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 14:20:47 +00:00
|
|
|
#define PCE_SIGNED(a) (((a) & 0x80) ? -((a) & 0x7F) : (a))
|
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
byte ClassicCostumeRenderer::drawLimb(const Actor *a, int limb) {
|
2003-01-05 23:53:16 +00:00
|
|
|
int i;
|
|
|
|
int code;
|
2009-10-26 02:45:26 +00:00
|
|
|
const byte *baseptr, *frameptr;
|
2005-03-11 01:10:06 +00:00
|
|
|
const CostumeData &cost = a->_cost;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-29 02:46:06 +00:00
|
|
|
// If the specified limb is stopped or not existing, do nothing.
|
2003-01-05 23:53:16 +00:00
|
|
|
if (cost.curpos[limb] == 0xFFFF || cost.stopped & (1 << limb))
|
|
|
|
return 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-05-29 02:46:06 +00:00
|
|
|
// Determine the position the limb is at
|
2003-01-05 23:53:16 +00:00
|
|
|
i = cost.curpos[limb] & 0x7FFF;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-10-26 02:45:26 +00:00
|
|
|
baseptr = _loaded._baseptr;
|
|
|
|
|
2003-07-08 12:28:57 +00:00
|
|
|
// Get the frame pointer for that limb
|
2009-10-26 02:45:26 +00:00
|
|
|
if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine)
|
|
|
|
baseptr = _loaded._frameOffsets + limb * 2 + 2;
|
|
|
|
frameptr = baseptr + READ_LE_UINT16(_loaded._frameOffsets + limb * 2);
|
2003-07-08 17:08:44 +00:00
|
|
|
|
2003-05-29 02:46:06 +00:00
|
|
|
// Determine the offset to the costume data for the limb at position i
|
2003-07-08 16:31:01 +00:00
|
|
|
code = _loaded._animCmds[i] & 0x7F;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-05-29 02:46:06 +00:00
|
|
|
// Code 0x7B indicates a limb for which there is nothing to draw
|
2003-01-05 23:53:16 +00:00
|
|
|
if (code != 0x7B) {
|
2009-10-26 02:45:26 +00:00
|
|
|
if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine)
|
|
|
|
baseptr = frameptr + code * 2 + 2;
|
|
|
|
_srcptr = baseptr + READ_LE_UINT16(frameptr + code * 2);
|
2003-07-08 17:08:44 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(_vm->_game.features & GF_OLD256) || code < 0x79) {
|
2003-05-29 10:31:05 +00:00
|
|
|
const CostumeInfo *costumeInfo;
|
|
|
|
int xmoveCur, ymoveCur;
|
|
|
|
|
2009-10-26 02:45:26 +00:00
|
|
|
if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine) {
|
|
|
|
_numBlocks = _srcptr[0];
|
|
|
|
_width = _srcptr[1] * 16;
|
|
|
|
_height = _srcptr[2] * 16;
|
|
|
|
xmoveCur = _xmove + PCE_SIGNED(_srcptr[3]);
|
|
|
|
ymoveCur = _ymove + PCE_SIGNED(_srcptr[4]);
|
|
|
|
_xmove += PCE_SIGNED(_srcptr[5]);
|
2009-11-05 11:40:33 +00:00
|
|
|
_ymove -= PCE_SIGNED(_srcptr[6]);
|
2009-10-26 02:45:26 +00:00
|
|
|
_srcptr += 7;
|
|
|
|
} else if (_loaded._format == 0x57) {
|
2003-07-08 17:22:53 +00:00
|
|
|
_width = _srcptr[0] * 8;
|
2003-06-19 15:52:17 +00:00
|
|
|
_height = _srcptr[1];
|
2003-07-13 02:45:31 +00:00
|
|
|
xmoveCur = _xmove + (int8)_srcptr[2] * 8;
|
|
|
|
ymoveCur = _ymove - (int8)_srcptr[3];
|
|
|
|
_xmove += (int8)_srcptr[4] * 8;
|
|
|
|
_ymove -= (int8)_srcptr[5];
|
2003-06-19 21:09:51 +00:00
|
|
|
_srcptr += 6;
|
2003-06-19 15:52:17 +00:00
|
|
|
} else {
|
|
|
|
costumeInfo = (const CostumeInfo *)_srcptr;
|
|
|
|
_width = READ_LE_UINT16(&costumeInfo->width);
|
|
|
|
_height = READ_LE_UINT16(&costumeInfo->height);
|
|
|
|
xmoveCur = _xmove + (int16)READ_LE_UINT16(&costumeInfo->rel_x);
|
|
|
|
ymoveCur = _ymove + (int16)READ_LE_UINT16(&costumeInfo->rel_y);
|
|
|
|
_xmove += (int16)READ_LE_UINT16(&costumeInfo->move_x);
|
|
|
|
_ymove -= (int16)READ_LE_UINT16(&costumeInfo->move_y);
|
|
|
|
_srcptr += 12;
|
|
|
|
}
|
2003-07-13 10:35:05 +00:00
|
|
|
|
2003-05-29 10:31:05 +00:00
|
|
|
return mainRoutine(xmoveCur, ymoveCur);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2009-06-04 11:03:45 +00:00
|
|
|
void NESCostumeRenderer::setPalette(uint16 *palette) {
|
2005-03-27 00:23:38 +00:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void NESCostumeRenderer::setFacing(const Actor *a) {
|
2005-03-27 00:42:53 +00:00
|
|
|
// TODO
|
|
|
|
//_mirror = newDirToOldDir(a->getFacing()) != 0 || _loaded._mirror;
|
2005-03-27 00:23:38 +00:00
|
|
|
}
|
|
|
|
|
2005-10-29 01:59:18 +00:00
|
|
|
void NESCostumeRenderer::setCostume(int costume, int shadow) {
|
2005-03-27 00:23:38 +00:00
|
|
|
_loaded.loadCostume(costume);
|
|
|
|
}
|
|
|
|
|
2009-11-22 11:43:12 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
2009-10-21 12:59:10 +00:00
|
|
|
void PCEngineCostumeRenderer::setPalette(uint16 *palette) {
|
2009-10-26 12:29:57 +00:00
|
|
|
const byte* ptr = _loaded._palette;
|
|
|
|
byte rgb[45];
|
|
|
|
byte *rgbPtr = rgb;
|
|
|
|
_vm->readPCEPalette(&ptr, &rgbPtr, 15);
|
|
|
|
|
|
|
|
_palette[0] = 0;
|
|
|
|
for (int i = 0; i < 15; ++i)
|
|
|
|
_palette[i + 1] = _vm->get16BitColor(rgb[i * 3 + 0], rgb[i * 3 + 1], rgb[i * 3 + 2]);
|
2009-10-21 12:59:10 +00:00
|
|
|
}
|
2009-11-22 11:43:12 +00:00
|
|
|
#endif
|
2009-10-21 12:59:10 +00:00
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
void ClassicCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) {
|
2003-05-29 02:46:06 +00:00
|
|
|
const byte *r;
|
2009-10-25 14:20:47 +00:00
|
|
|
const byte *baseptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
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
|
|
|
int anim;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
loadCostume(a->_costume);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2005-03-15 21:48:06 +00:00
|
|
|
anim = newDirToOldDir(a->getFacing()) + frame * 4;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
if (anim > _numAnim) {
|
2003-04-14 07:02:07 +00:00
|
|
|
return;
|
2003-04-13 19:53:39 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 14:20:47 +00:00
|
|
|
if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine)
|
|
|
|
baseptr = _dataOffsets + anim * 2 + 2;
|
|
|
|
else
|
|
|
|
baseptr = _baseptr;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2009-10-25 14:20:47 +00:00
|
|
|
r = baseptr + READ_LE_UINT16(_dataOffsets + anim * 2);
|
|
|
|
if (r == baseptr) {
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.version == 1) {
|
2003-07-08 16:47:15 +00:00
|
|
|
mask = *r++ << 8;
|
2003-07-08 13:11:42 +00:00
|
|
|
} else {
|
|
|
|
mask = READ_LE_UINT16(r);
|
|
|
|
r += 2;
|
2003-07-08 16:53:18 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
i = 0;
|
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (mask & 0x8000) {
|
2009-10-25 14:20:47 +00:00
|
|
|
if ((_vm->_game.version <= 3) &&
|
|
|
|
!(_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine))
|
|
|
|
{
|
2003-04-22 18:57:10 +00:00
|
|
|
j = *r++;
|
2003-04-22 20:48:53 +00:00
|
|
|
|
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) {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.curpos[i] = 0xFFFF;
|
|
|
|
a->_cost.start[i] = 0;
|
|
|
|
a->_cost.frame[i] = frame;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
|
|
|
extra = *r++;
|
2005-03-27 00:42:53 +00:00
|
|
|
cmd = _animCmds[j];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (cmd == 0x7A) {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.stopped &= ~(1 << i);
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (cmd == 0x79) {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.stopped |= (1 << i);
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.curpos[i] = a->_cost.start[i] = j;
|
|
|
|
a->_cost.end[i] = j + (extra & 0x7F);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (extra & 0x80)
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.curpos[i] |= 0x8000;
|
|
|
|
a->_cost.frame[i] = frame;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} 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;
|
2003-08-13 23:07:05 +00:00
|
|
|
} while (mask&0xFFFF);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2009-06-04 11:03:45 +00:00
|
|
|
void ClassicCostumeRenderer::setPalette(uint16 *palette) {
|
2001-12-27 17:51:58 +00:00
|
|
|
int i;
|
2009-06-05 06:47:49 +00:00
|
|
|
byte color;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
if (_loaded._format == 0x57) {
|
2009-06-04 11:03:45 +00:00
|
|
|
for (i = 0; i < 13; i++)
|
2009-06-05 06:47:49 +00:00
|
|
|
_palette[i] = palette[i];
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_vm->_game.features & GF_OLD_BUNDLE) {
|
2006-03-14 14:06:44 +00:00
|
|
|
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) {
|
2009-06-04 11:03:45 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
2009-06-05 06:47:49 +00:00
|
|
|
_palette[i] = palette[i];
|
2002-08-19 17:23:48 +00:00
|
|
|
} else {
|
2009-06-04 11:03:45 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
_palette[i] = 8;
|
2003-04-22 19:59:30 +00:00
|
|
|
_palette[12] = 0;
|
|
|
|
}
|
2003-07-08 12:28:57 +00:00
|
|
|
_palette[_loaded._palette[0]] = _palette[0];
|
2003-04-22 19:59:30 +00:00
|
|
|
} else {
|
2006-03-14 14:06:44 +00:00
|
|
|
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) {
|
2003-05-13 23:03:18 +00:00
|
|
|
for (i = 0; i < _loaded._numColors; i++) {
|
2003-04-22 19:59:30 +00:00
|
|
|
color = palette[i];
|
|
|
|
if (color == 255)
|
2003-07-08 12:28:57 +00:00
|
|
|
color = _loaded._palette[i];
|
2003-05-13 23:03:18 +00:00
|
|
|
_palette[i] = color;
|
2003-04-22 19:59:30 +00:00
|
|
|
}
|
2003-05-13 23:03:18 +00:00
|
|
|
} else {
|
|
|
|
memset(_palette, 8, _loaded._numColors);
|
|
|
|
_palette[12] = 0;
|
2002-08-19 17:23:48 +00:00
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-27 00:23:38 +00:00
|
|
|
void ClassicCostumeRenderer::setFacing(const Actor *a) {
|
2003-07-24 17:44:00 +00:00
|
|
|
_mirror = newDirToOldDir(a->getFacing()) != 0 || _loaded._mirror;
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
|
2005-10-29 01:59:18 +00:00
|
|
|
void ClassicCostumeRenderer::setCostume(int costume, int shadow) {
|
2002-07-15 22:56:24 +00:00
|
|
|
_loaded.loadCostume(costume);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
byte ClassicCostumeLoader::increaseAnims(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++) {
|
2005-03-11 01:10:06 +00:00
|
|
|
if (a->_cost.curpos[i] != 0xFFFF)
|
2002-07-15 22:56:24 +00:00
|
|
|
r += increaseAnim(a, i);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
byte ClassicCostumeLoader::increaseAnim(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
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
if (a->_cost.curpos[slot] == 0xFFFF)
|
2001-12-27 17:51:58 +00:00
|
|
|
return 0;
|
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
highflag = a->_cost.curpos[slot] & 0x8000;
|
|
|
|
i = a->_cost.curpos[slot] & 0x7FFF;
|
|
|
|
end = a->_cost.end[slot];
|
2003-07-08 16:31:01 +00:00
|
|
|
code = _animCmds[i] & 0x7F;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.version <= 3) {
|
2003-07-08 16:31:01 +00:00
|
|
|
if (_animCmds[i] & 0x80)
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.soundCounter++;
|
2003-06-01 18:20:38 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
do {
|
|
|
|
if (!highflag) {
|
|
|
|
if (i++ >= end)
|
2005-03-11 01:10:06 +00:00
|
|
|
i = a->_cost.start[slot];
|
2001-12-27 17:51:58 +00:00
|
|
|
} else {
|
|
|
|
if (i != end)
|
|
|
|
i++;
|
|
|
|
}
|
2003-07-08 16:31:01 +00:00
|
|
|
nc = _animCmds[i];
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (nc == 0x7C) {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.animCounter++;
|
|
|
|
if (a->_cost.start[slot] != end)
|
2001-12-27 17:51:58 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_vm->_game.version >= 6) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (nc >= 0x71 && nc <= 0x78) {
|
2006-02-20 16:51:30 +00:00
|
|
|
uint sound = (_vm->_game.heversion == 60) ? 0x78 - nc : nc - 0x71;
|
2005-03-11 01:10:06 +00:00
|
|
|
_vm->_sound->addSoundToQueue2(a->_sound[sound]);
|
|
|
|
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) {
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.soundCounter++;
|
|
|
|
if (a->_cost.start[slot] != end)
|
2001-12-27 17:51:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
a->_cost.curpos[slot] = i | highflag;
|
2003-07-08 16:31:01 +00:00
|
|
|
return (_animCmds[i] & 0x7F) != code;
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2002-05-20 14:41:47 +00:00
|
|
|
|
2005-03-27 00:42:53 +00:00
|
|
|
/**
|
|
|
|
* costume ID -> v1MMNESLookup[] -> desc -> lens & offs -> data -> Gfx & pal
|
|
|
|
*/
|
|
|
|
void NESCostumeLoader::loadCostume(int id) {
|
|
|
|
_id = id;
|
|
|
|
_baseptr = _vm->getResourceAddress(rtCostume, id);
|
2005-04-01 02:14:00 +00:00
|
|
|
_dataOffsets = _baseptr + 2;
|
2005-04-01 21:35:44 +00:00
|
|
|
_numAnim = 0x17;
|
2005-03-27 00:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NESCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) {
|
|
|
|
int anim;
|
|
|
|
|
|
|
|
loadCostume(a->_costume);
|
|
|
|
|
2005-04-01 21:35:44 +00:00
|
|
|
anim = 4 * frame + newDirToOldDir(a->getFacing());
|
2005-03-27 00:42:53 +00:00
|
|
|
|
|
|
|
if (anim > _numAnim) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
a->_cost.curpos[0] = 0;
|
|
|
|
a->_cost.start[0] = 0;
|
2005-04-01 21:35:44 +00:00
|
|
|
a->_cost.end[0] = _dataOffsets[2 * anim + 1];
|
2005-03-27 00:42:53 +00:00
|
|
|
a->_cost.frame[0] = frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte NESCostumeLoader::increaseAnims(Actor *a) {
|
|
|
|
int i;
|
|
|
|
byte r = 0;
|
|
|
|
|
|
|
|
for (i = 0; i != 16; i++) {
|
|
|
|
if (a->_cost.curpos[i] != 0xFFFF)
|
|
|
|
r += increaseAnim(a, i);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte NESCostumeLoader::increaseAnim(Actor *a, int slot) {
|
2005-04-01 21:35:44 +00:00
|
|
|
int oldframe = a->_cost.curpos[slot]++;
|
2005-03-27 00:42:53 +00:00
|
|
|
if (a->_cost.curpos[slot] >= a->_cost.end[slot])
|
|
|
|
a->_cost.curpos[slot] = a->_cost.start[slot];
|
2005-04-01 21:35:44 +00:00
|
|
|
return (a->_cost.curpos[slot] != oldframe);
|
2005-03-27 00:42:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-03 02:04:58 +00:00
|
|
|
static const byte actorColorsMMC64[25] = {
|
|
|
|
0, 7, 2, 6, 9, 1, 3, 7, 7, 1, 1, 9, 1, 4, 5, 5, 4, 1, 0, 5, 4, 2, 2, 7, 7
|
2005-09-22 13:31:21 +00:00
|
|
|
};
|
|
|
|
|
2006-03-13 06:06:51 +00:00
|
|
|
#define MASK_AT(xoff) \
|
|
|
|
(mask && (mask[((destX + xoff) / 8)] & revBitMask((destX + xoff) & 7)))
|
2006-03-03 02:04:58 +00:00
|
|
|
#define LINE(c,p) \
|
|
|
|
pcolor = (color >> c) & 3; \
|
|
|
|
if (pcolor) { \
|
2006-03-13 06:06:51 +00:00
|
|
|
if (!MASK_AT(p)) \
|
|
|
|
dst[p] = palette[pcolor]; \
|
|
|
|
if (!MASK_AT(p + 1)) \
|
|
|
|
dst[p + 1] = palette[pcolor]; \
|
2006-03-03 02:04:58 +00:00
|
|
|
}
|
|
|
|
|
2005-05-21 03:30:23 +00:00
|
|
|
byte C64CostumeRenderer::drawLimb(const Actor *a, int limb) {
|
2005-09-22 13:31:21 +00:00
|
|
|
if (limb >= 8)
|
|
|
|
return 0;
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
if (a->_cost.start[limb] == 0xFFFF)
|
|
|
|
return 0;
|
|
|
|
|
2005-09-22 13:31:21 +00:00
|
|
|
if (limb == 0) {
|
|
|
|
_draw_top = 200;
|
|
|
|
_draw_bottom = 0;
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
bool flipped = (a->_cost.start[limb] & 0x80) != 0;
|
|
|
|
byte frameStart = _loaded._frameOffsets[a->_cost.frame[limb]];
|
|
|
|
byte frame = _loaded._frameOffsets[frameStart + a->_cost.curpos[limb]];
|
|
|
|
if (frame == 0xFF)
|
|
|
|
return 0;
|
2005-09-22 13:31:21 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
byte ptrLow = _loaded._baseptr[frame];
|
|
|
|
byte ptrHigh = ptrLow + _loaded._dataOffsets[4];
|
|
|
|
int frameOffset = (_loaded._baseptr[ptrHigh] << 8) + _loaded._baseptr[ptrLow + 2]; // 0x23EF / 0x2400
|
2005-09-22 13:31:21 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
const byte *data = _loaded._baseptr + frameOffset;
|
2006-03-03 02:04:58 +00:00
|
|
|
|
|
|
|
// Set up the palette data
|
|
|
|
byte palette[4] = { 0, 0, 0, 0 };
|
2006-03-14 14:06:44 +00:00
|
|
|
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) {
|
2006-03-03 02:04:58 +00:00
|
|
|
palette[1] = 10;
|
|
|
|
palette[2] = actorColorsMMC64[_actorID];
|
2006-03-14 13:36:13 +00:00
|
|
|
} else {
|
|
|
|
palette[2] = 11;
|
|
|
|
palette[3] = 11;
|
2006-03-03 02:04:58 +00:00
|
|
|
}
|
2005-09-22 13:31:21 +00:00
|
|
|
|
2009-11-24 23:34:03 +00:00
|
|
|
int width = data[0];
|
|
|
|
int height = data[1];
|
|
|
|
int offsetX = _xmove + data[2];
|
|
|
|
int offsetY = _ymove + data[3];
|
|
|
|
_xmove += (int8)data[4];
|
|
|
|
_ymove += (int8)data[5];
|
|
|
|
data += 6;
|
2005-09-22 13:31:21 +00:00
|
|
|
|
|
|
|
if (!width || !height)
|
|
|
|
return 0;
|
|
|
|
|
2010-03-16 08:38:06 +00:00
|
|
|
int xpos = _actorX + (flipped ? -1 : +1) * (offsetX * 8 - a->_width / 2);
|
|
|
|
// +1 as we appear to be 1 pixel away from the original interpreter
|
|
|
|
int ypos = _actorY - offsetY + 1;
|
2005-09-22 13:31:21 +00:00
|
|
|
|
2006-03-02 02:10:54 +00:00
|
|
|
// This code is very similar to procC64()
|
2006-03-03 02:04:58 +00:00
|
|
|
for (int y = 0; y < height; ++y) {
|
|
|
|
for (int x = 0; x < width; ++x) {
|
|
|
|
byte color = data[y * width + x];
|
|
|
|
byte pcolor;
|
|
|
|
|
2010-03-16 08:38:06 +00:00
|
|
|
int destX = xpos + (flipped ? -(x + 1) : x) * 8;
|
|
|
|
int destY = ypos + y;
|
|
|
|
|
2006-03-03 02:04:58 +00:00
|
|
|
if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) {
|
2006-03-13 06:06:51 +00:00
|
|
|
byte *dst = (byte *)_out.pixels + destY * _out.pitch + destX;
|
|
|
|
byte *mask = _vm->getMaskBuffer(0, destY, _zbuf);
|
2006-03-03 02:04:58 +00:00
|
|
|
if (flipped) {
|
|
|
|
LINE(0, 0); LINE(2, 2); LINE(4, 4); LINE(6, 6);
|
|
|
|
} else {
|
|
|
|
LINE(6, 0); LINE(4, 2); LINE(2, 4); LINE(0, 6);
|
2005-09-22 13:31:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_draw_top = MIN(_draw_top, ypos);
|
2009-07-25 05:39:57 +00:00
|
|
|
_draw_bottom = MAX(_draw_bottom, ypos + height);
|
2010-03-16 08:38:06 +00:00
|
|
|
if (flipped)
|
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, xpos - (width * 8), xpos, ypos, ypos + height, _actorID);
|
|
|
|
else
|
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, xpos, xpos + (width * 8), ypos, ypos + height, _actorID);
|
2005-05-21 03:30:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-03 02:04:58 +00:00
|
|
|
#undef LINE
|
2006-03-13 06:06:51 +00:00
|
|
|
#undef MASK_AT
|
2006-03-03 02:04:58 +00:00
|
|
|
|
2005-10-29 01:59:18 +00:00
|
|
|
void C64CostumeRenderer::setCostume(int costume, int shadow) {
|
2005-05-21 03:30:23 +00:00
|
|
|
_loaded.loadCostume(costume);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C64CostumeLoader::loadCostume(int id) {
|
2005-05-31 22:09:35 +00:00
|
|
|
const byte *ptr = _vm->getResourceAddress(rtCostume, id);
|
2009-07-25 05:39:57 +00:00
|
|
|
|
2005-05-21 03:30:23 +00:00
|
|
|
_id = id;
|
2005-05-31 22:09:35 +00:00
|
|
|
_baseptr = ptr + 9;
|
|
|
|
|
|
|
|
_format = 0x57;
|
|
|
|
_numColors = 0;
|
|
|
|
_numAnim = 0;
|
|
|
|
_mirror = 0;
|
|
|
|
_palette = &actorColorsMMC64[id];
|
|
|
|
|
|
|
|
_frameOffsets = _baseptr + READ_LE_UINT16(ptr + 5);
|
|
|
|
_dataOffsets = ptr;
|
|
|
|
_animCmds = _baseptr + READ_LE_UINT16(ptr + 7);
|
2005-09-22 13:31:21 +00:00
|
|
|
|
|
|
|
_maxHeight = 0;
|
2009-07-25 05:39:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void C64CostumeLoader::frameUpdate(ActorC64 *a, int cmd ) {
|
|
|
|
byte limbFrames = 0;
|
|
|
|
|
|
|
|
// Each costume-command has 8 limbs (0x2622)
|
|
|
|
cmd <<= 3;
|
|
|
|
|
|
|
|
for (int limb = 0, pos = 0; limb < 8; ++limb, pos = 0) {
|
|
|
|
// get a limb frames ptr from the costume command
|
|
|
|
limbFrames = ((_animCmds + cmd)[limb]);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
// Dont change limb if entry is invalid
|
|
|
|
if (limbFrames == 0xFF)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Has limb frames ptr changed since last update?
|
|
|
|
if (a->_cost.start[limb] == limbFrames)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Set new limb command addresses
|
|
|
|
a->_cost.start[limb] = limbFrames;
|
|
|
|
a->_cost.frame[limb] = _frameOffsets[limb] + (limbFrames & 0x7f); // limb animation-frames ptr
|
|
|
|
|
|
|
|
// Get first entry of a limbs' frames
|
|
|
|
byte frameStart = _frameOffsets[ a->_cost.frame[limb]];
|
|
|
|
|
|
|
|
// Loop each frame in this limb until we reach the end marker
|
|
|
|
while (pos != 0xFF) { // This is just so we dont overflow
|
|
|
|
byte frame = _frameOffsets[frameStart + pos];
|
|
|
|
|
|
|
|
// Each animation-frame until we find end
|
|
|
|
if (frame == 0xFF)
|
|
|
|
break;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
byte ptrLow = _baseptr[frame];
|
|
|
|
byte ptrHigh = ptrLow + _dataOffsets[4];
|
|
|
|
int frameOffset = (_baseptr[ptrHigh] << 8) + _baseptr[ptrLow + 2]; // 0x23EF / 0x2400
|
|
|
|
|
|
|
|
const byte *data = _baseptr + frameOffset;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
if (data[3] > _maxHeight)
|
|
|
|
_maxHeight = data[3] + 1;
|
|
|
|
|
|
|
|
++pos;
|
2005-09-22 13:31:21 +00:00
|
|
|
}
|
2009-07-25 05:39:57 +00:00
|
|
|
|
|
|
|
// Set ending position of limb frames
|
|
|
|
a->_cost.end[limb] = pos - 1;
|
|
|
|
a->_cost.curpos[limb] = 0;
|
2005-09-22 13:31:21 +00:00
|
|
|
}
|
2005-05-21 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
// based on 0x2BCA, doesn't match disassembly because 'oldDir' variable
|
|
|
|
// is not the same value as stored in the original interpreter
|
2009-07-25 09:36:16 +00:00
|
|
|
int C64CostumeLoader::dirToDirStop(int oldDir) {
|
2009-07-25 05:39:57 +00:00
|
|
|
switch (oldDir) {
|
|
|
|
case 0:
|
|
|
|
return 4; // Left
|
|
|
|
case 1:
|
|
|
|
return 5; // Right
|
|
|
|
case 2:
|
|
|
|
return 6; // Face Camera
|
|
|
|
case 3:
|
|
|
|
return 7; // Face Away
|
|
|
|
}
|
|
|
|
// shouldnt' be reached
|
|
|
|
return 4;
|
2005-05-21 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
void C64CostumeLoader::actorSpeak(ActorC64 *a, int &cmd) {
|
2010-03-16 14:34:25 +00:00
|
|
|
if (v0ActorTalkArray[a->_number] & 0x80)
|
2010-03-16 08:59:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
if ((a->_speaking & 0x80))
|
|
|
|
cmd += 0x0C;
|
|
|
|
else
|
|
|
|
cmd += 0x10;
|
2005-05-21 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
void C64CostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) {
|
2009-07-25 09:36:16 +00:00
|
|
|
ActorC64 *A = (ActorC64 *)a;
|
2009-07-25 05:39:57 +00:00
|
|
|
int dir = newDirToOldDir(a->getFacing());
|
|
|
|
int command = dir;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
|
|
|
loadCostume(a->_costume);
|
2009-07-25 05:39:57 +00:00
|
|
|
|
|
|
|
// Enable/Disable speaking flag
|
|
|
|
if (frame == a->_talkStartFrame) {
|
2010-03-16 14:34:25 +00:00
|
|
|
if (v0ActorTalkArray[a->_number] & 0x40)
|
2010-03-16 08:59:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
A->_speaking = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (frame == a->_talkStopFrame) {
|
|
|
|
A->_speaking = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Different command for stand frame
|
|
|
|
if (frame == a->_standFrame)
|
2010-01-25 01:39:44 +00:00
|
|
|
command = dirToDirStop(dir);
|
2009-07-25 05:39:57 +00:00
|
|
|
|
|
|
|
// Update the limb frames
|
|
|
|
frameUpdate(A, command);
|
|
|
|
|
|
|
|
// Keep current command/frame mode
|
|
|
|
A->_costCommand = dir;
|
|
|
|
A->_costFrame = frame;
|
|
|
|
|
|
|
|
// Update 'speaking' frames?
|
|
|
|
if (A->_speaking) {
|
|
|
|
command = dir; // Incase standing frame was set as cmd
|
|
|
|
actorSpeak(A, command);
|
|
|
|
|
|
|
|
// Update the limb speak frames
|
|
|
|
frameUpdate(A, command);
|
|
|
|
}
|
2005-05-21 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
byte C64CostumeLoader::increaseAnims(Actor *a) {
|
2009-07-25 09:36:16 +00:00
|
|
|
ActorC64 *A = (ActorC64 *)a;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
// check if the actor speak flag has changed since last frame increase
|
|
|
|
if (A->_speaking != A->_speakingPrev) {
|
|
|
|
int cmd = A->_costCommand;
|
|
|
|
A->_speakingPrev = A->_speaking;
|
|
|
|
|
2010-03-16 08:59:48 +00:00
|
|
|
actorSpeak(A, cmd);
|
2009-07-25 05:39:57 +00:00
|
|
|
|
|
|
|
// Update the limb frames
|
|
|
|
frameUpdate(A, cmd);
|
|
|
|
}
|
|
|
|
|
2009-11-26 00:45:06 +00:00
|
|
|
if (A->_moving && _vm->_currentRoom != 1 && _vm->_currentRoom != 44) {
|
|
|
|
if (a->_cost.soundPos == 0)
|
|
|
|
a->_cost.soundCounter++;
|
2010-03-16 08:59:48 +00:00
|
|
|
|
|
|
|
// Is this the correct location?
|
|
|
|
// 0x073C
|
2010-03-16 14:34:25 +00:00
|
|
|
if (v0ActorTalkArray[a->_number] & 0x3F)
|
2010-03-16 08:59:48 +00:00
|
|
|
a->_cost.soundPos = (a->_cost.soundPos + 1) % 3;
|
2009-11-26 00:45:06 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 05:39:57 +00:00
|
|
|
// increase each frame pos
|
|
|
|
for (int limb = 0; limb < 8; ++limb) {
|
|
|
|
if (a->_cost.curpos[limb] < a->_cost.end[limb])
|
|
|
|
a->_cost.curpos[limb]++;
|
|
|
|
else
|
|
|
|
a->_cost.curpos[limb] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2005-03-27 00:42:53 +00:00
|
|
|
|
2003-10-09 14:17:06 +00:00
|
|
|
} // End of namespace Scumm
|