2001-11-26 19:57:57 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
2001-11-26 19:57:57 +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.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "scumm.h"
|
2002-05-14 23:32:34 +00:00
|
|
|
#include "actor.h"
|
2002-05-23 21:22:08 +00:00
|
|
|
#include "akos.h"
|
2002-12-16 21:21:55 +00:00
|
|
|
#include "imuse.h"
|
2003-02-22 10:39:50 +00:00
|
|
|
#include "sound.h"
|
2003-01-05 23:53:16 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
#if !defined(__GNUC__)
|
|
|
|
#pragma START_PACK_STRUCTS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct AkosHeader {
|
|
|
|
byte unk_1[2];
|
|
|
|
byte flags;
|
|
|
|
byte unk_2;
|
|
|
|
uint16 num_anims;
|
|
|
|
uint16 unk_3;
|
|
|
|
uint16 codec;
|
|
|
|
} GCC_PACK;
|
|
|
|
|
|
|
|
struct AkosOffset {
|
|
|
|
uint32 akcd;
|
|
|
|
uint16 akci;
|
|
|
|
} GCC_PACK;
|
|
|
|
|
|
|
|
struct AkosCI {
|
|
|
|
uint16 width, height;
|
|
|
|
int16 rel_x, rel_y;
|
|
|
|
int16 move_x, move_y;
|
|
|
|
} GCC_PACK;
|
|
|
|
|
|
|
|
#if !defined(__GNUC__)
|
|
|
|
#pragma END_PACK_STRUCTS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
enum AkosOpcodes {
|
|
|
|
AKC_Return = 0xC001,
|
|
|
|
AKC_SetVar = 0xC010,
|
|
|
|
AKC_CmdQue3 = 0xC015,
|
|
|
|
AKC_ComplexChan = 0xC020,
|
|
|
|
AKC_Jump = 0xC030,
|
|
|
|
AKC_JumpIfSet = 0xC031,
|
|
|
|
AKC_AddVar = 0xC040,
|
|
|
|
AKC_Ignore = 0xC050,
|
|
|
|
AKC_IncVar = 0xC060,
|
|
|
|
AKC_CmdQue3Quick = 0xC061,
|
2003-03-03 00:45:38 +00:00
|
|
|
AKC_JumpStart = 0xC070,
|
|
|
|
AKC_JumpE = 0xC070,
|
|
|
|
AKC_JumpNE = 0xC071,
|
|
|
|
AKC_JumpL = 0xC072,
|
|
|
|
AKC_JumpLE = 0xC073,
|
|
|
|
AKC_JumpG = 0xC074,
|
|
|
|
AKC_JumpGE = 0xC075,
|
2003-01-05 23:53:16 +00:00
|
|
|
AKC_StartAnim = 0xC080,
|
|
|
|
AKC_StartVarAnim = 0xC081,
|
|
|
|
AKC_Random = 0xC082,
|
|
|
|
AKC_SetActorClip = 0xC083,
|
|
|
|
AKC_StartAnimInActor = 0xC084,
|
|
|
|
AKC_SetVarInActor = 0xC085,
|
|
|
|
AKC_HideActor = 0xC086,
|
|
|
|
AKC_SetDrawOffs = 0xC087,
|
|
|
|
AKC_JumpTable = 0xC088,
|
|
|
|
AKC_SoundStuff = 0xC089,
|
|
|
|
AKC_Flip = 0xC08A,
|
|
|
|
AKC_Cmd3 = 0xC08B,
|
|
|
|
AKC_Ignore3 = 0xC08C,
|
|
|
|
AKC_Ignore2 = 0xC08D,
|
2003-03-03 00:45:38 +00:00
|
|
|
AKC_SkipStart = 0xC090,
|
|
|
|
AKC_SkipE = 0xC090,
|
|
|
|
AKC_SkipNE = 0xC091,
|
|
|
|
AKC_SkipL = 0xC092,
|
|
|
|
AKC_SkipLE = 0xC093,
|
|
|
|
AKC_SkipG = 0xC094,
|
|
|
|
AKC_SkipGE = 0xC095,
|
2003-01-12 18:35:01 +00:00
|
|
|
AKC_ClearFlag = 0xC09F,
|
|
|
|
AKC_EndSeq = 0xC0FF
|
2003-01-05 23:53:16 +00:00
|
|
|
};
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::akos_hasManyDirections(Actor *a) {
|
2003-01-06 13:41:29 +00:00
|
|
|
byte *akos;
|
|
|
|
AkosHeader *akhd;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-06 13:41:29 +00:00
|
|
|
akos = getResourceAddress(rtCostume, a->costume);
|
|
|
|
assert(akos);
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2003-01-06 13:41:29 +00:00
|
|
|
akhd = (AkosHeader *) findResourceData(MKID('AKHD'), akos);
|
|
|
|
return (akhd->flags & 2) != 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
int Scumm::akos_frameToAnim(Actor *a, int frame) {
|
2002-07-02 20:08:42 +00:00
|
|
|
if (akos_hasManyDirections(a))
|
|
|
|
return toSimpleDir(1, a->facing) + frame * 8;
|
|
|
|
else
|
2001-11-26 19:57:57 +00:00
|
|
|
return newDirToOldDir(a->facing) + frame * 4;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::akos_decodeData(Actor *a, int frame, uint usemask) {
|
2001-11-26 19:57:57 +00:00
|
|
|
uint anim;
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *akos, *r;
|
2001-11-26 19:57:57 +00:00
|
|
|
AkosHeader *akhd;
|
|
|
|
uint offs;
|
|
|
|
int i;
|
|
|
|
byte code;
|
2002-04-11 17:19:16 +00:00
|
|
|
uint16 start, len;
|
2001-11-26 19:57:57 +00:00
|
|
|
uint16 mask;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (a->costume == 0)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
anim = akos_frameToAnim(a, frame);
|
|
|
|
|
|
|
|
akos = getResourceAddress(rtCostume, a->costume);
|
|
|
|
assert(akos);
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
akhd = (AkosHeader *) findResourceData(MKID('AKHD'), akos);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (anim >= READ_LE_UINT16(&akhd->num_anims))
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
r = findResourceData(MKID('AKCH'), akos);
|
|
|
|
assert(r);
|
|
|
|
|
|
|
|
offs = READ_LE_UINT16(r + anim * sizeof(uint16));
|
2002-04-11 17:19:16 +00:00
|
|
|
if (offs == 0)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
r += offs;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
mask = READ_LE_UINT16(r);
|
2002-04-11 17:19:16 +00:00
|
|
|
r += sizeof(uint16);
|
2001-11-26 19:57:57 +00:00
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (mask & 0x8000) {
|
2001-11-26 19:57:57 +00:00
|
|
|
code = *r++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (usemask & 0x8000) {
|
|
|
|
switch (code) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case 1:
|
|
|
|
a->cost.active[i] = 0;
|
|
|
|
a->cost.frame[i] = frame;
|
|
|
|
a->cost.end[i] = 0;
|
|
|
|
a->cost.start[i] = 0;
|
|
|
|
a->cost.curpos[i] = 0;
|
|
|
|
break;
|
|
|
|
case 4:
|
2002-04-11 17:19:16 +00:00
|
|
|
a->cost.stopped |= 1 << i;
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-04-11 17:19:16 +00:00
|
|
|
a->cost.stopped &= ~(1 << i);
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
start = READ_LE_UINT16(r);
|
2002-04-11 17:19:16 +00:00
|
|
|
len = READ_LE_UINT16(r + sizeof(uint16));
|
|
|
|
r += sizeof(uint16) * 2;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
a->cost.active[i] = code;
|
|
|
|
a->cost.frame[i] = frame;
|
|
|
|
a->cost.end[i] = start + len;
|
|
|
|
a->cost.start[i] = start;
|
|
|
|
a->cost.curpos[i] = start;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code != 1 && code != 4 && code != 5)
|
|
|
|
r += sizeof(uint16) * 2;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2002-04-11 17:19:16 +00:00
|
|
|
mask <<= 1;
|
|
|
|
usemask <<= 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
} while ((uint16)mask);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::setPalette(byte *new_palette) {
|
2002-05-23 00:37:00 +00:00
|
|
|
byte *the_akpl;
|
2001-11-26 19:57:57 +00:00
|
|
|
uint size, i;
|
|
|
|
|
2002-05-23 21:22:08 +00:00
|
|
|
the_akpl = _vm->findResourceData(MKID('AKPL'), akos);
|
|
|
|
size = _vm->getResourceDataSize(akpl);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
if (size > 256)
|
|
|
|
error("akos_setPalette: %d is too many colors", size);
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
2002-05-23 00:37:00 +00:00
|
|
|
palette[i] = new_palette[i] != 0xFF ? new_palette[i] : the_akpl[i];
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2002-11-06 07:28:39 +00:00
|
|
|
|
|
|
|
if (size == 256) {
|
|
|
|
byte color = new_palette[0];
|
|
|
|
if (color == 255) {
|
|
|
|
palette[0] = color;
|
|
|
|
} else {
|
|
|
|
_vm->_bompActorPalletePtr = palette;
|
|
|
|
}
|
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::setCostume(int costume) {
|
2002-05-23 21:22:08 +00:00
|
|
|
akos = _vm->getResourceAddress(rtCostume, costume);
|
2002-05-23 00:37:00 +00:00
|
|
|
assert(akos);
|
|
|
|
|
2002-05-23 21:22:08 +00:00
|
|
|
akhd = (AkosHeader *) _vm->findResourceData(MKID('AKHD'), akos);
|
|
|
|
akof = (AkosOffset *) _vm->findResourceData(MKID('AKOF'), akos);
|
|
|
|
akci = _vm->findResourceData(MKID('AKCI'), akos);
|
|
|
|
aksq = _vm->findResourceData(MKID('AKSQ'), akos);
|
|
|
|
akcd = _vm->findResourceData(MKID('AKCD'), akos);
|
|
|
|
akpl = _vm->findResourceData(MKID('AKPL'), akos);
|
2002-05-23 00:37:00 +00:00
|
|
|
codec = READ_LE_UINT16(&akhd->codec);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::setFacing(Actor *a) {
|
2003-01-07 17:35:20 +00:00
|
|
|
_mirror = (newDirToOldDir(a->facing) != 0 || akhd->flags & 1);
|
2001-11-26 19:57:57 +00:00
|
|
|
if (a->flip)
|
2003-01-07 17:35:20 +00:00
|
|
|
_mirror = !_mirror;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte AkosRenderer::drawLimb(const CostumeData &cost, int limb) {
|
2001-11-26 19:57:57 +00:00
|
|
|
uint code;
|
|
|
|
byte *p;
|
|
|
|
AkosOffset *off;
|
2002-05-23 00:37:00 +00:00
|
|
|
AkosCI *the_akci;
|
2002-04-11 17:19:16 +00:00
|
|
|
uint i, extra;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
if (!cost.active[limb] || cost.stopped & (1 << limb))
|
2001-11-26 19:57:57 +00:00
|
|
|
return false;
|
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
p = aksq + cost.curpos[limb];
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
code = p[0];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code & 0x80)
|
|
|
|
code = (code << 8) | p[1];
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-12 18:35:01 +00:00
|
|
|
if (code == AKC_Return || code == AKC_EndSeq)
|
2001-11-26 19:57:57 +00:00
|
|
|
return false;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code != AKC_ComplexChan) {
|
2002-05-23 00:37:00 +00:00
|
|
|
off = akof + (code & 0xFFF);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
assert((code & 0xFFF) * 6 < READ_BE_UINT32_UNALIGNED((byte *)akof - 4) - 8);
|
2002-04-11 17:19:16 +00:00
|
|
|
assert((code & 0x7000) == 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
srcptr = akcd + READ_LE_UINT32(&off->akcd);
|
|
|
|
the_akci = (AkosCI *) (akci + READ_LE_UINT16(&off->akci));
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
_xmoveCur = _xmove + (int16)READ_LE_UINT16(&the_akci->rel_x);
|
|
|
|
_ymoveCur = _ymove + (int16)READ_LE_UINT16(&the_akci->rel_y);
|
2002-10-22 11:47:45 +00:00
|
|
|
_width = READ_LE_UINT16(&the_akci->width);
|
|
|
|
_height = READ_LE_UINT16(&the_akci->height);
|
2003-01-07 17:35:20 +00:00
|
|
|
_xmove += (int16)READ_LE_UINT16(&the_akci->move_x);
|
|
|
|
_ymove -= (int16)READ_LE_UINT16(&the_akci->move_y);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
switch (codec) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case 1:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec1();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec5();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case 16:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec16();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-05-23 00:37:00 +00:00
|
|
|
error("akos_drawCostumeChannel: invalid codec %d", codec);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
extra = p[2];
|
2002-04-11 17:19:16 +00:00
|
|
|
p += 3;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i != extra; i++) {
|
2001-11-26 19:57:57 +00:00
|
|
|
code = p[4];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code & 0x80)
|
|
|
|
code = ((code & 0xF) << 8) | p[5];
|
2002-05-23 00:37:00 +00:00
|
|
|
off = akof + code;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
srcptr = akcd + READ_LE_UINT32(&off->akcd);
|
|
|
|
the_akci = (AkosCI *) (akci + READ_LE_UINT16(&off->akci));
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
_xmoveCur = _xmove + (int16)READ_LE_UINT16(p + 0);
|
|
|
|
_ymoveCur = _ymove + (int16)READ_LE_UINT16(p + 2);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
p += (p[4] & 0x80) ? 6 : 5;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-10-22 11:47:45 +00:00
|
|
|
_width = READ_LE_UINT16(&the_akci->width);
|
|
|
|
_height = READ_LE_UINT16(&the_akci->height);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
switch (codec) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case 1:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec1();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec5();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case 16:
|
2002-05-23 00:37:00 +00:00
|
|
|
codec16();
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-05-23 00:37:00 +00:00
|
|
|
error("akos_drawCostumeChannel: invalid codec %d", codec);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1_genericDecode() {
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *src, *dst;
|
2002-12-28 11:33:10 +00:00
|
|
|
byte len, maskbit;
|
|
|
|
uint y, color, height;
|
2001-12-27 17:51:58 +00:00
|
|
|
const byte *scaleytab, *mask;
|
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
y = v1.y;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
len = v1.replen;
|
|
|
|
src = srcptr;
|
|
|
|
dst = v1.destptr;
|
|
|
|
color = v1.repcolor;
|
|
|
|
height = _height;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (len)
|
|
|
|
goto StartPos;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-10-22 12:18:17 +00:00
|
|
|
color = len >> v1.shl;
|
|
|
|
len &= v1.mask;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
do {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (*scaleytab++ < _scaleY) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (color && y < outheight
|
|
|
|
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
|
|
|
|
*dst = palette[color];
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2002-10-24 06:28:54 +00:00
|
|
|
mask += _numStrips;
|
2002-10-22 12:18:17 +00:00
|
|
|
dst += outwidth;
|
2001-12-27 17:51:58 +00:00
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (!--v1.skip_width)
|
2001-12-27 17:51:58 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
height = _height;
|
|
|
|
y = v1.y;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[v1.tmp_x] < _scaleX) {
|
2002-10-22 12:18:17 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
2002-11-19 01:45:08 +00:00
|
|
|
if (v1.x < 0 || v1.x >= _vm->_realWidth)
|
2001-12-27 17:51:58 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
v1.destptr += v1.scaleXstep;
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2002-10-22 12:18:17 +00:00
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
|
|
|
v1.tmp_x += v1.scaleXstep;
|
|
|
|
dst = v1.destptr;
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-12-27 17:51:58 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1_spec1() {
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *src, *dst;
|
2002-12-28 11:33:10 +00:00
|
|
|
byte len, maskbit;
|
|
|
|
uint y, color, height;
|
2002-10-22 11:47:45 +00:00
|
|
|
byte pcolor;
|
2001-12-27 17:51:58 +00:00
|
|
|
const byte *scaleytab, *mask;
|
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
y = v1.y;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
len = v1.replen;
|
|
|
|
src = srcptr;
|
|
|
|
dst = v1.destptr;
|
|
|
|
color = v1.repcolor;
|
|
|
|
height = _height;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (len)
|
|
|
|
goto StartPos;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-10-22 12:18:17 +00:00
|
|
|
color = len >> v1.shl;
|
|
|
|
len &= v1.mask;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
do {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (*scaleytab++ < _scaleY) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (color && y < outheight
|
|
|
|
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
|
|
|
|
pcolor = palette[color];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (pcolor == 13)
|
2003-01-07 17:35:20 +00:00
|
|
|
pcolor = _shadow_table[*dst];
|
2001-11-26 19:57:57 +00:00
|
|
|
*dst = pcolor;
|
|
|
|
}
|
2002-10-24 06:28:54 +00:00
|
|
|
mask += _numStrips;
|
2002-10-22 12:18:17 +00:00
|
|
|
dst += outwidth;
|
2001-11-26 19:57:57 +00:00
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (!--v1.skip_width)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
height = _height;
|
|
|
|
y = v1.y;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[v1.tmp_x] < _scaleX) {
|
2002-10-22 12:18:17 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
2002-11-19 01:45:08 +00:00
|
|
|
if (v1.x < 0 || v1.x >= _vm->_realWidth)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
v1.destptr += v1.scaleXstep;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2002-10-22 12:18:17 +00:00
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
|
|
|
v1.tmp_x += v1.scaleXstep;
|
|
|
|
dst = v1.destptr;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
StartPos:;
|
2001-11-26 19:57:57 +00:00
|
|
|
} while (--len);
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1_spec2() {
|
2002-10-22 12:18:17 +00:00
|
|
|
warning("codec1_spec2"); // TODO
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1_spec3() {
|
2002-10-16 13:43:31 +00:00
|
|
|
byte *src, *dst;
|
2002-12-28 11:33:10 +00:00
|
|
|
byte len, maskbit;
|
|
|
|
uint y, color, height;
|
2002-10-22 11:47:45 +00:00
|
|
|
uint pcolor;
|
2002-10-16 13:43:31 +00:00
|
|
|
const byte *scaleytab, *mask;
|
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
y = v1.y;
|
2002-10-16 13:43:31 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
len = v1.replen;
|
|
|
|
src = srcptr;
|
|
|
|
dst = v1.destptr;
|
|
|
|
color = v1.repcolor;
|
|
|
|
height = _height;
|
2002-10-16 13:43:31 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
2002-10-16 13:43:31 +00:00
|
|
|
|
|
|
|
if (len)
|
|
|
|
goto StartPos;
|
|
|
|
|
|
|
|
do {
|
|
|
|
len = *src++;
|
2002-10-22 12:18:17 +00:00
|
|
|
color = len >> v1.shl;
|
|
|
|
len &= v1.mask;
|
2002-10-16 13:43:31 +00:00
|
|
|
if (!len)
|
|
|
|
len = *src++;
|
|
|
|
|
|
|
|
do {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (*scaleytab++ < _scaleY) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (color && y < outheight
|
|
|
|
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
|
|
|
|
pcolor = palette[color];
|
2002-10-16 13:43:31 +00:00
|
|
|
if (pcolor < 8) {
|
|
|
|
pcolor = (pcolor << 8) + *dst;
|
2003-01-07 17:35:20 +00:00
|
|
|
*dst = _shadow_table[pcolor];
|
2002-10-16 13:43:31 +00:00
|
|
|
} else {
|
|
|
|
*dst = pcolor;
|
|
|
|
}
|
|
|
|
}
|
2002-10-24 06:28:54 +00:00
|
|
|
mask += _numStrips;
|
2002-10-22 12:18:17 +00:00
|
|
|
dst += outwidth;
|
2002-10-16 13:43:31 +00:00
|
|
|
y++;
|
|
|
|
}
|
|
|
|
if (!--height) {
|
2002-10-22 12:18:17 +00:00
|
|
|
if (!--v1.skip_width)
|
2002-10-16 13:43:31 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
height = _height;
|
|
|
|
y = v1.y;
|
2002-10-16 13:43:31 +00:00
|
|
|
|
2002-10-22 12:18:17 +00:00
|
|
|
scaleytab = &v1.scaletable[v1.tmp_y];
|
2002-10-16 13:43:31 +00:00
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[v1.tmp_x] < _scaleX) {
|
2002-10-22 12:18:17 +00:00
|
|
|
v1.x += v1.scaleXstep;
|
2002-11-19 01:45:08 +00:00
|
|
|
if (v1.x < 0 || v1.x >= _vm->_realWidth)
|
2002-10-16 13:43:31 +00:00
|
|
|
return;
|
2002-10-22 12:18:17 +00:00
|
|
|
maskbit = revBitMask[v1.x & 7];
|
|
|
|
v1.destptr += v1.scaleXstep;
|
2002-10-16 13:43:31 +00:00
|
|
|
}
|
2002-10-22 12:18:17 +00:00
|
|
|
mask = v1.mask_ptr + (v1.x >> 3);
|
|
|
|
v1.tmp_x += v1.scaleXstep;
|
|
|
|
dst = v1.destptr;
|
2002-10-16 13:43:31 +00:00
|
|
|
}
|
|
|
|
StartPos:;
|
|
|
|
} while (--len);
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
const byte default_scale_table[768] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
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,
|
|
|
|
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
|
|
|
|
0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
|
|
|
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
|
|
|
|
0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
|
|
|
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
|
|
|
|
0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
|
|
|
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
|
|
|
|
0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
|
|
|
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
|
|
|
|
0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
|
|
|
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
|
|
|
|
0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
|
|
|
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
|
|
|
|
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
|
|
|
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
|
|
|
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFE,
|
|
|
|
|
|
|
|
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,
|
|
|
|
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
|
|
|
|
0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
|
|
|
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
|
|
|
|
0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
|
|
|
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
|
|
|
|
0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
|
|
|
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
|
|
|
|
0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
|
|
|
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
|
|
|
|
0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
|
|
|
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
|
|
|
|
0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
|
|
|
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
|
|
|
|
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
|
|
|
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
|
|
|
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFE,
|
|
|
|
|
|
|
|
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,
|
|
|
|
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
|
|
|
|
0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
|
|
|
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
|
|
|
|
0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
|
|
|
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
|
|
|
|
0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
|
|
|
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
|
|
|
|
0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
|
|
|
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
|
|
|
|
0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
|
|
|
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
|
|
|
|
0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
|
|
|
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
|
|
|
|
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
|
|
|
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
|
|
|
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF,
|
2001-11-26 19:57:57 +00:00
|
|
|
};
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1() {
|
2001-11-26 19:57:57 +00:00
|
|
|
int num_colors;
|
|
|
|
bool use_scaling;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, j;
|
2002-05-23 00:37:00 +00:00
|
|
|
int cur_x, x_right, x_left, skip = 0, tmp_x, tmp_y;
|
|
|
|
int cur_y, y_top, y_bottom;
|
2001-11-26 19:57:57 +00:00
|
|
|
bool y_clipping;
|
|
|
|
bool masking;
|
|
|
|
int step;
|
|
|
|
|
|
|
|
/* implement custom scale table */
|
2002-04-21 19:38:00 +00:00
|
|
|
|
2002-12-27 14:04:25 +00:00
|
|
|
v1.scaletable = default_scale_table;
|
2002-04-24 04:26:09 +00:00
|
|
|
|
2002-12-27 14:04:25 +00:00
|
|
|
// FIXME - which value for VAR_CUSTOMSCALETABLE in V8 ?
|
2002-07-07 19:31:51 +00:00
|
|
|
if (_vm->isGlobInMemory(rtString, _vm->_vars[_vm->VAR_CUSTOMSCALETABLE])) {
|
2002-05-23 21:22:08 +00:00
|
|
|
v1.scaletable = _vm->getStringAddressVar(_vm->VAR_CUSTOMSCALETABLE);
|
2002-04-21 19:38:00 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
/* Setup color decoding variables */
|
2002-05-23 21:22:08 +00:00
|
|
|
num_colors = _vm->getResourceDataSize(akpl);
|
2001-11-26 19:57:57 +00:00
|
|
|
if (num_colors == 32) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.mask = (1 << 3) - 1;
|
|
|
|
v1.shl = 3;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else if (num_colors == 64) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.mask = (1 << 2) - 1;
|
|
|
|
v1.shl = 2;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.mask = (1 << 4) - 1;
|
|
|
|
v1.shl = 4;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
use_scaling = (_scaleX != 0xFF) || (_scaleY != 0xFF);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
cur_x = _actorX;
|
|
|
|
cur_y = _actorY;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
if (use_scaling) {
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
/* Scale direction */
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.scaleXstep = -1;
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_xmoveCur < 0) {
|
|
|
|
_xmoveCur = -_xmoveCur;
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.scaleXstep = 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_mirror) {
|
2001-11-26 19:57:57 +00:00
|
|
|
/* Adjust X position */
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_x = 0x180 - _xmoveCur;
|
2001-11-26 19:57:57 +00:00
|
|
|
j = tmp_x;
|
2003-01-07 17:35:20 +00:00
|
|
|
for (i = 0; i < _xmoveCur; i++) {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[j++] < _scaleX)
|
2002-05-23 00:37:00 +00:00
|
|
|
cur_x -= v1.scaleXstep;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
x_left = x_right = cur_x;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
j = tmp_x;
|
2002-10-22 11:47:45 +00:00
|
|
|
for (i = 0, skip = 0; i < _width; i++) {
|
2001-11-26 19:57:57 +00:00
|
|
|
if (x_right < 0) {
|
|
|
|
skip++;
|
|
|
|
tmp_x = j;
|
|
|
|
}
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[j++] < _scaleX)
|
2001-11-26 19:57:57 +00:00
|
|
|
x_right++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* No mirror */
|
|
|
|
/* Adjust X position */
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_x = 0x180 + _xmoveCur;
|
2001-11-26 19:57:57 +00:00
|
|
|
j = tmp_x;
|
2003-01-07 17:35:20 +00:00
|
|
|
for (i = 0; i < _xmoveCur; i++) {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[j++] < _scaleX)
|
2002-05-23 00:37:00 +00:00
|
|
|
cur_x += v1.scaleXstep;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
x_left = x_right = cur_x;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
j = tmp_x;
|
2002-10-22 11:47:45 +00:00
|
|
|
for (i = 0, skip = 0; i < _width; i++) {
|
2002-05-23 00:37:00 +00:00
|
|
|
if (x_left >= (int)outwidth) {
|
2001-11-26 19:57:57 +00:00
|
|
|
tmp_x = j;
|
|
|
|
skip++;
|
|
|
|
}
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[j--] < _scaleX)
|
2001-11-26 19:57:57 +00:00
|
|
|
x_left--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (skip)
|
|
|
|
skip--;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
step = -1;
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_ymoveCur < 0) {
|
|
|
|
_ymoveCur = -_ymoveCur;
|
2001-11-26 19:57:57 +00:00
|
|
|
step = -step;
|
|
|
|
}
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_y = 0x180 - _ymoveCur;
|
|
|
|
for (i = 0; i < _ymoveCur; i++) {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[tmp_y++] < _scaleY)
|
2002-05-23 00:37:00 +00:00
|
|
|
cur_y -= step;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
y_top = y_bottom = cur_y;
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_y = 0x180 - _ymoveCur;
|
2002-10-22 11:47:45 +00:00
|
|
|
for (i = 0; i < _height; i++) {
|
2003-01-05 23:53:16 +00:00
|
|
|
if (v1.scaletable[tmp_y++] < _scaleY)
|
2001-11-26 19:57:57 +00:00
|
|
|
y_bottom++;
|
|
|
|
}
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_y = 0x180 - _ymoveCur;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
2003-01-07 17:35:20 +00:00
|
|
|
if (!_mirror)
|
|
|
|
_xmoveCur = -_xmoveCur;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
cur_x += _xmoveCur;
|
|
|
|
cur_y += _ymoveCur;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_mirror) {
|
2002-05-23 00:37:00 +00:00
|
|
|
x_left = cur_x;
|
2002-10-22 11:47:45 +00:00
|
|
|
x_right = cur_x + _width;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
2002-05-23 00:37:00 +00:00
|
|
|
x_right = cur_x;
|
2002-10-22 11:47:45 +00:00
|
|
|
x_left = cur_x - _width;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
y_top = cur_y;
|
2002-10-22 11:47:45 +00:00
|
|
|
y_bottom = cur_y + _height;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
tmp_x = 0x180;
|
|
|
|
tmp_y = 0x180;
|
|
|
|
}
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.tmp_x = tmp_x;
|
|
|
|
v1.tmp_y = tmp_y;
|
2002-10-22 11:47:45 +00:00
|
|
|
v1.skip_width = _width;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.scaleXstep = -1;
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_mirror)
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.scaleXstep = -v1.scaleXstep;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
if ((int) y_top >= (int)outheight || y_bottom <= 0)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
if ((int)x_left >= (int)outwidth || x_right <= 0)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.replen = 0;
|
2002-10-22 11:47:45 +00:00
|
|
|
v1.y_pitch = _height * outwidth;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_mirror) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.y_pitch--;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (!use_scaling)
|
2002-05-23 00:37:00 +00:00
|
|
|
skip = -cur_x;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (skip > 0) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.skip_width -= skip;
|
|
|
|
codec1_ignorePakCols(skip);
|
|
|
|
cur_x = 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
2002-05-23 00:37:00 +00:00
|
|
|
skip = x_right - outwidth;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (skip > 0)
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.skip_width -= skip;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.y_pitch++;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (!use_scaling) {
|
2002-05-23 00:37:00 +00:00
|
|
|
skip = x_right - outwidth + 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
if (skip > 0) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.skip_width -= skip;
|
|
|
|
codec1_ignorePakCols(skip);
|
|
|
|
cur_x = outwidth - 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
} else {
|
|
|
|
skip = -1 - x_left;
|
|
|
|
if (skip > 0)
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.skip_width -= skip;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.x = cur_x;
|
|
|
|
v1.y = cur_y;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-10-22 11:47:45 +00:00
|
|
|
if (v1.skip_width <= 0 || _height <= 0)
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
_vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, _dirty_id);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
y_clipping = ((uint) y_bottom > outheight || y_top < 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
if ((uint) y_top > (uint) outheight)
|
2001-11-26 19:57:57 +00:00
|
|
|
y_top = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
if ((uint) y_bottom > (uint) outheight)
|
|
|
|
y_bottom = outheight;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_draw_top > y_top)
|
|
|
|
_draw_top = y_top;
|
|
|
|
if (_draw_bottom < y_bottom)
|
|
|
|
_draw_bottom = y_bottom;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
if (cur_x == -1)
|
2002-07-07 19:31:51 +00:00
|
|
|
cur_x = 0; /* ?? */
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.destptr = outptr + cur_x + cur_y * outwidth;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
masking = false;
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_zbuf) {
|
2002-05-23 21:22:08 +00:00
|
|
|
masking = _vm->isMaskActiveAt(x_left, y_top, x_right, y_bottom,
|
2003-03-06 17:58:13 +00:00
|
|
|
_vm->getResourceAddress(rtBuffer, 9) +
|
|
|
|
_vm->gdi._imgBufOffs[_zbuf] + _vm->_screenStartStrip) != 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.mask_ptr = NULL;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (masking || charsetmask || _shadow_mode) {
|
2002-10-24 06:28:54 +00:00
|
|
|
v1.mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + cur_y * _numStrips + _vm->_screenStartStrip;
|
2003-01-07 17:35:20 +00:00
|
|
|
v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
|
2001-11-26 19:57:57 +00:00
|
|
|
if (!charsetmask && masking) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.mask_ptr += v1.imgbufoffs;
|
|
|
|
v1.imgbufoffs = 0;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
switch (_shadow_mode) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case 1:
|
2002-10-22 12:18:17 +00:00
|
|
|
codec1_spec1();
|
|
|
|
break;
|
2001-11-26 19:57:57 +00:00
|
|
|
case 2:
|
2002-10-22 12:18:17 +00:00
|
|
|
codec1_spec2();
|
|
|
|
break;
|
2001-11-26 19:57:57 +00:00
|
|
|
case 3:
|
2002-10-22 12:18:17 +00:00
|
|
|
codec1_spec3();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
codec1_genericDecode();
|
|
|
|
break;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::codec1_ignorePakCols(int num) {
|
2001-11-26 19:57:57 +00:00
|
|
|
int n;
|
|
|
|
byte repcolor;
|
|
|
|
byte replen;
|
|
|
|
byte *src;
|
|
|
|
|
2002-10-22 11:47:45 +00:00
|
|
|
n = _height;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (num > 1)
|
|
|
|
n *= num;
|
2002-05-23 00:37:00 +00:00
|
|
|
src = srcptr;
|
2001-11-26 19:57:57 +00:00
|
|
|
do {
|
|
|
|
repcolor = *src++;
|
2002-05-23 00:37:00 +00:00
|
|
|
replen = repcolor & v1.mask;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (replen == 0) {
|
2001-11-26 19:57:57 +00:00
|
|
|
replen = *src++;
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
if (!--n) {
|
2002-05-23 00:37:00 +00:00
|
|
|
v1.repcolor = repcolor >> v1.shl;
|
|
|
|
v1.replen = replen;
|
|
|
|
srcptr = src;
|
2001-11-26 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (--replen);
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
void AkosRenderer::codec5() {
|
|
|
|
int32 clip_left, clip_right, clip_top, clip_bottom, maxw, maxh, tmp_x, tmp_y;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (!_mirror) {
|
|
|
|
clip_left = (_actorX - _xmoveCur - _width) + 1;
|
2002-04-24 04:26:09 +00:00
|
|
|
} else {
|
2003-01-07 17:35:20 +00:00
|
|
|
clip_left = _actorX + _xmoveCur - 1;
|
2002-04-22 22:18:24 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
clip_right = (clip_left + _width) - 1;
|
2003-01-07 17:35:20 +00:00
|
|
|
clip_top = _actorY + _ymoveCur;
|
2002-11-06 07:28:39 +00:00
|
|
|
clip_bottom = (clip_top + _height) - 1;
|
|
|
|
maxw = outwidth - 1;
|
|
|
|
maxh = outheight - 1;
|
2002-04-22 22:18:24 +00:00
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
if (clip_left < 0) {
|
|
|
|
clip_left = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_x = clip_right - maxw;
|
|
|
|
if (tmp_x > 0) {
|
|
|
|
clip_right -= tmp_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_y = clip_top;
|
|
|
|
if (tmp_y < 0) {
|
|
|
|
clip_top -= tmp_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_y = clip_bottom - maxh;
|
|
|
|
if (tmp_y > 0) {
|
|
|
|
clip_bottom -= tmp_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((clip_right <= clip_left) || (clip_top >= clip_bottom))
|
2002-10-07 09:20:50 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
_vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
|
2002-04-22 22:18:24 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_draw_top > clip_top)
|
|
|
|
_draw_top = clip_top;
|
|
|
|
if (_draw_bottom < clip_bottom)
|
|
|
|
_draw_bottom = clip_bottom + 1;
|
2002-04-22 16:18:20 +00:00
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
BompDrawData bdd;
|
2002-04-22 16:18:20 +00:00
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
bdd.srcwidth = _width;
|
|
|
|
bdd.srcheight = _height;
|
|
|
|
bdd.out = outptr;
|
|
|
|
bdd.outwidth = outwidth;
|
|
|
|
bdd.outheight = outheight;
|
|
|
|
bdd.dataptr = srcptr;
|
|
|
|
bdd.scale_x = 255;
|
|
|
|
bdd.scale_y = 255;
|
2003-01-07 17:35:20 +00:00
|
|
|
bdd.shadowMode = _shadow_mode;
|
2002-10-07 09:20:50 +00:00
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
_vm->_bompScallingXPtr = NULL;
|
|
|
|
_vm->_bompScallingYPtr = NULL;
|
2002-10-07 09:20:50 +00:00
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
int decode_mode;
|
2002-10-07 09:20:50 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (!_mirror) {
|
|
|
|
bdd.x = (_actorX - _xmoveCur - _width) + 1;
|
2002-11-06 07:28:39 +00:00
|
|
|
decode_mode = 3;
|
|
|
|
} else {
|
2003-01-07 17:35:20 +00:00
|
|
|
bdd.x = _actorX + _xmoveCur;
|
2002-11-06 07:28:39 +00:00
|
|
|
decode_mode = 1;
|
|
|
|
}
|
2002-10-07 09:20:50 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
bdd.y = _actorY + _ymoveCur;
|
2002-10-07 09:20:50 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_zbuf != 0) {
|
|
|
|
_vm->_bompMaskPtr = _vm->getResourceAddress(rtBuffer, 9) + _vm->gdi._imgBufOffs[_zbuf];
|
2002-11-06 14:54:21 +00:00
|
|
|
_vm->drawBomp(&bdd, decode_mode, 1);
|
2002-11-06 07:28:39 +00:00
|
|
|
} else {
|
2002-11-06 14:54:21 +00:00
|
|
|
_vm->drawBomp(&bdd, decode_mode, 0);
|
2002-10-07 09:20:50 +00:00
|
|
|
}
|
2002-11-06 07:28:39 +00:00
|
|
|
|
|
|
|
_vm->_bompActorPalletePtr = NULL;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-10-21 06:01:04 +00:00
|
|
|
void AkosRenderer::akos16SetupBitReader(byte *src) {
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.unk5 = 0;
|
|
|
|
akos16.numbits = 16;
|
2002-10-25 06:57:46 +00:00
|
|
|
akos16.mask = (1 << *src) - 1;
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.shift = *(src);
|
|
|
|
akos16.color = *(src + 1);
|
|
|
|
akos16.bits = (*(src + 2) | *(src + 3) << 8);
|
|
|
|
akos16.dataptr = src + 4;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::akos16PutOnScreen(byte *dest, byte *src, byte transparency, int32 count) {
|
2002-10-21 06:01:04 +00:00
|
|
|
byte tmp_data;
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
if (count == 0)
|
|
|
|
return;
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
switch(_shadow_mode) {
|
2002-10-22 10:37:08 +00:00
|
|
|
case 0:
|
|
|
|
do {
|
2002-10-21 06:01:04 +00:00
|
|
|
tmp_data = *(src++);
|
|
|
|
if (tmp_data != transparency) {
|
|
|
|
*(dest) = tmp_data;
|
|
|
|
}
|
|
|
|
dest++;
|
2002-10-22 10:37:08 +00:00
|
|
|
} while (--count != 0);
|
|
|
|
break;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
case 1:
|
|
|
|
do {
|
2002-10-21 06:01:04 +00:00
|
|
|
tmp_data = *(src++);
|
|
|
|
if (tmp_data != transparency) {
|
|
|
|
if (tmp_data == 13) {
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_data = _shadow_table[*(dest)];
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
*(dest) = tmp_data;
|
|
|
|
}
|
|
|
|
dest++;
|
2002-10-22 10:37:08 +00:00
|
|
|
} while (--count != 0);
|
|
|
|
break;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
case 3:
|
|
|
|
do {
|
2002-10-21 06:01:04 +00:00
|
|
|
tmp_data = *(src++);
|
|
|
|
if (tmp_data != transparency) {
|
2002-10-21 18:49:11 +00:00
|
|
|
if (tmp_data < 8) {
|
2003-01-07 17:35:20 +00:00
|
|
|
tmp_data = _shadow_table[*(dest) + (tmp_data << 8)];
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
*(dest) = tmp_data;
|
|
|
|
}
|
|
|
|
dest++;
|
2002-10-22 10:37:08 +00:00
|
|
|
} while (--count != 0);
|
|
|
|
break;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 15:29:49 +00:00
|
|
|
#define AKOS16_FILL_BITS() \
|
|
|
|
if (akos16.numbits <= 8) { \
|
|
|
|
akos16.bits |= (*akos16.dataptr++) << akos16.numbits; \
|
|
|
|
akos16.numbits += 8; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define AKOS16_EAT_BITS(n) \
|
|
|
|
akos16.numbits -= (n); \
|
|
|
|
akos16.bits >>= (n);
|
2002-10-22 10:37:08 +00:00
|
|
|
|
|
|
|
|
2002-10-21 06:01:04 +00:00
|
|
|
void AkosRenderer::akos16SkipData(int32 numskip) {
|
2002-10-21 18:49:11 +00:00
|
|
|
uint16 bits, tmp_bits;
|
2002-10-22 10:37:08 +00:00
|
|
|
|
|
|
|
while (numskip != 0) {
|
2002-10-22 11:47:45 +00:00
|
|
|
if (akos16.unk5 == 0) {
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
bits = akos16.bits & 3;
|
2002-10-22 10:37:08 +00:00
|
|
|
if (bits & 1) {
|
|
|
|
AKOS16_EAT_BITS(2)
|
|
|
|
if (bits & 2) {
|
2002-10-22 11:47:45 +00:00
|
|
|
tmp_bits = akos16.bits & 7;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_EAT_BITS(3)
|
|
|
|
if (tmp_bits != 4) {
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.color += (tmp_bits - 4);
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.unk5 = 1;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.unk6 = (akos16.bits & 0xff) - 1;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_EAT_BITS(8)
|
|
|
|
AKOS16_FILL_BITS()
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.color = ((byte)akos16.bits) & akos16.mask;
|
2003-03-06 17:58:13 +00:00
|
|
|
AKOS16_EAT_BITS(akos16.shift)
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
|
|
|
AKOS16_EAT_BITS(1);
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
2002-10-22 11:47:45 +00:00
|
|
|
if (--akos16.unk6 == 0) {
|
|
|
|
akos16.unk5 = 0;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
numskip--;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AkosRenderer::akos16DecodeLine(byte *buf, int32 numbytes, int32 dir) {
|
2002-10-21 18:49:11 +00:00
|
|
|
uint16 bits, tmp_bits;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
while (numbytes != 0) {
|
2002-10-22 11:47:45 +00:00
|
|
|
*buf = akos16.color;
|
2002-10-22 10:37:08 +00:00
|
|
|
buf += dir;
|
|
|
|
|
2002-10-22 11:47:45 +00:00
|
|
|
if (akos16.unk5 == 0) {
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
bits = akos16.bits & 3;
|
2002-10-22 10:37:08 +00:00
|
|
|
if (bits & 1) {
|
|
|
|
AKOS16_EAT_BITS(2)
|
|
|
|
if (bits & 2) {
|
2002-10-22 11:47:45 +00:00
|
|
|
tmp_bits = akos16.bits & 7;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_EAT_BITS(3)
|
|
|
|
if (tmp_bits != 4) {
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.color += (tmp_bits - 4);
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.unk5 = 1;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.unk6 = (akos16.bits & 0xff) - 1;
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_EAT_BITS(8)
|
|
|
|
AKOS16_FILL_BITS()
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
|
|
|
AKOS16_FILL_BITS()
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16.color = ((byte)akos16.bits) & akos16.mask;
|
2003-03-28 23:08:36 +00:00
|
|
|
AKOS16_EAT_BITS(akos16.shift)
|
2002-10-22 10:37:08 +00:00
|
|
|
AKOS16_FILL_BITS()
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
|
|
|
AKOS16_EAT_BITS(1);
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
2002-10-22 11:47:45 +00:00
|
|
|
if (--akos16.unk6 == 0) {
|
|
|
|
akos16.unk5 = 0;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-22 10:37:08 +00:00
|
|
|
numbytes--;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::akos16ApplyMask(byte *dest, byte *maskptr, byte bits, int32 count, byte fillwith) {
|
2002-10-21 18:49:11 +00:00
|
|
|
byte tmp;
|
|
|
|
byte tmp_data = *(maskptr++);
|
2002-10-21 06:01:04 +00:00
|
|
|
byte bitpos = 1 << (7 - bits);
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
if (count == 0)
|
|
|
|
return;
|
2003-03-06 17:58:13 +00:00
|
|
|
|
2002-10-21 06:01:04 +00:00
|
|
|
for(;;) {
|
|
|
|
tmp = tmp_data;
|
|
|
|
do {
|
2002-10-22 10:37:08 +00:00
|
|
|
if (tmp & bitpos) {
|
2002-10-21 18:49:11 +00:00
|
|
|
*(dest) = fillwith;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
dest++;
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
if (--count == 0)
|
|
|
|
return;
|
|
|
|
} while ((bitpos>>=1) != 0);
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
bitpos = 0x80;
|
|
|
|
tmp_data = *(maskptr++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::akos16Decompress(byte *dest, int32 pitch, byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency) {
|
|
|
|
byte *tmp_buf = akos16.buffer;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
if (dir < 0) {
|
2002-10-22 07:25:26 +00:00
|
|
|
dest -= (t_width - 1);
|
2002-10-22 09:52:14 +00:00
|
|
|
tmp_buf += (t_width - 1);
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
akos16SetupBitReader(src);
|
|
|
|
|
|
|
|
if (numskip_before != 0) {
|
|
|
|
akos16SkipData(numskip_before);
|
|
|
|
}
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
while (t_height != 0) {
|
2002-10-22 07:25:26 +00:00
|
|
|
akos16DecodeLine(tmp_buf, t_width, dir);
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16PutOnScreen(dest, akos16.buffer, transparency, t_width);
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
if (numskip_after != 0) {
|
|
|
|
akos16SkipData(numskip_after);
|
|
|
|
}
|
|
|
|
dest += pitch;
|
2002-10-22 10:37:08 +00:00
|
|
|
|
|
|
|
t_height--;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void AkosRenderer::akos16DecompressMask(byte *dest, int32 pitch, byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency, byte * maskptr, int32 bitpos_start) {
|
|
|
|
byte *tmp_buf = akos16.buffer;
|
2002-10-22 10:37:08 +00:00
|
|
|
int maskpitch;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
if (dir < 0) {
|
2002-10-22 07:25:26 +00:00
|
|
|
dest -= (t_width - 1);
|
|
|
|
tmp_buf += (t_width - 1);
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
akos16SetupBitReader(src);
|
|
|
|
|
|
|
|
if (numskip_before != 0) {
|
|
|
|
akos16SkipData(numskip_before);
|
|
|
|
}
|
|
|
|
|
2002-11-06 07:28:39 +00:00
|
|
|
maskpitch = _numStrips ;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
while (t_height != 0) {
|
2002-10-22 07:25:26 +00:00
|
|
|
akos16DecodeLine(tmp_buf, t_width, dir);
|
2002-10-22 11:47:45 +00:00
|
|
|
akos16ApplyMask(akos16.buffer, maskptr, (byte)bitpos_start, t_width, transparency);
|
|
|
|
akos16PutOnScreen(dest, akos16.buffer, transparency, t_width);
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
if (numskip_after != 0) {
|
|
|
|
akos16SkipData(numskip_after);
|
|
|
|
}
|
|
|
|
dest += pitch;
|
2002-10-22 10:37:08 +00:00
|
|
|
maskptr += maskpitch;
|
|
|
|
|
|
|
|
t_height--;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AkosRenderer::codec16() {
|
|
|
|
int32 clip_left;
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if(!_mirror) {
|
|
|
|
clip_left = (_actorX - _xmoveCur - _width) + 1;
|
2002-10-22 10:37:08 +00:00
|
|
|
} else {
|
2003-01-07 17:35:20 +00:00
|
|
|
clip_left = _actorX + _xmoveCur;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
int32 clip_top = _ymoveCur + _actorY;
|
2002-10-22 11:47:45 +00:00
|
|
|
int32 clip_right = (clip_left + _width) - 1;
|
|
|
|
int32 clip_bottom = (clip_top + _height) - 1;
|
2002-10-21 06:01:04 +00:00
|
|
|
int32 skip_x = 0;
|
|
|
|
int32 skip_y = 0;
|
2002-10-22 11:47:45 +00:00
|
|
|
int32 cur_x = _width - 1;
|
|
|
|
int32 cur_y = _height - 1;
|
2002-10-21 06:01:04 +00:00
|
|
|
int32 maxw = outwidth - 1;
|
|
|
|
int32 maxh = outheight - 1;
|
|
|
|
int32 tmp_x, tmp_y;
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
/*
|
2002-10-21 06:01:04 +00:00
|
|
|
tmp_x = clip_left;
|
2002-10-22 10:37:08 +00:00
|
|
|
if(tmp_x < 0) {
|
|
|
|
tmp_x = -tmp_x;
|
|
|
|
clip_left -= tmp_x;
|
|
|
|
skip_x = tmp_x;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Modified by ludde
|
2003-03-28 23:08:36 +00:00
|
|
|
if (clip_left < 0) {
|
2002-10-22 10:37:08 +00:00
|
|
|
skip_x = -clip_left;
|
|
|
|
clip_left = 0;
|
|
|
|
}
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
tmp_x = clip_right - maxw;
|
|
|
|
if(tmp_x > 0) {
|
|
|
|
cur_x -= tmp_x;
|
|
|
|
clip_right -= tmp_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_y = clip_top;
|
|
|
|
if(tmp_y < 0) {
|
|
|
|
skip_y -= tmp_y;
|
|
|
|
clip_top -= tmp_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_y = clip_bottom - maxh;
|
|
|
|
if(tmp_y > 0) {
|
|
|
|
cur_y -= tmp_y;
|
|
|
|
clip_bottom -= tmp_y;
|
|
|
|
}
|
|
|
|
|
2003-01-05 23:53:16 +00:00
|
|
|
if ((clip_left >= clip_right) || (clip_top >= clip_bottom))
|
2002-10-21 06:01:04 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
_vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_draw_top > clip_top)
|
|
|
|
_draw_top = clip_top;
|
|
|
|
if (_draw_bottom < clip_bottom)
|
|
|
|
_draw_bottom = clip_bottom + 1;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
|
|
|
int32 width_unk, height_unk;
|
|
|
|
|
|
|
|
height_unk = clip_top;
|
|
|
|
int32 pitch = _vm->_realWidth;
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
int32 /*tmp1, tmp2, tmp3,*/ dir;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (!_mirror) {
|
2002-10-21 18:49:11 +00:00
|
|
|
dir = -1;
|
2002-11-06 07:28:39 +00:00
|
|
|
|
2002-12-27 14:04:25 +00:00
|
|
|
int tmp_skip_x = skip_x;
|
|
|
|
skip_x = _width - 1 - cur_x;
|
|
|
|
cur_x = _width - 1 - tmp_skip_x;
|
|
|
|
width_unk = clip_right;
|
2002-10-22 10:37:08 +00:00
|
|
|
/*
|
2002-10-22 07:25:26 +00:00
|
|
|
tmp1 = width - 1;
|
2002-10-21 18:49:11 +00:00
|
|
|
tmp2 = cur_x;
|
2002-10-22 07:25:26 +00:00
|
|
|
tmp3 = tmp1;
|
|
|
|
cur_x = skip_x;
|
|
|
|
tmp3 -= tmp2;
|
|
|
|
tmp1 -= cur_x;
|
|
|
|
width_unk = clip_right;
|
|
|
|
skip_x = tmp3;
|
2002-12-27 14:04:25 +00:00
|
|
|
cur_x = tmp1;
|
|
|
|
*/
|
2002-10-21 06:01:04 +00:00
|
|
|
} else {
|
|
|
|
dir = 1;
|
|
|
|
width_unk = clip_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_y = cur_y - skip_y;
|
|
|
|
if(tmp_y < 0) {
|
2002-10-21 18:49:11 +00:00
|
|
|
tmp_y = -tmp_y;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
2002-10-22 10:37:08 +00:00
|
|
|
int32 out_height = tmp_y + 1;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2002-10-22 07:25:26 +00:00
|
|
|
cur_x -= skip_x;
|
2002-10-21 06:01:04 +00:00
|
|
|
if(cur_x < 0) {
|
2002-10-21 18:49:11 +00:00
|
|
|
cur_x = -cur_x;
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cur_x++;
|
|
|
|
|
2002-10-22 11:47:45 +00:00
|
|
|
int32 numskip_before = skip_x + (skip_y * _width);
|
|
|
|
int32 numskip_after = _width - cur_x;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte *dest = outptr + width_unk + height_unk * _vm->_realWidth;
|
2002-10-21 06:01:04 +00:00
|
|
|
|
2003-01-07 17:35:20 +00:00
|
|
|
if (_zbuf == 0) {
|
2002-10-22 07:25:26 +00:00
|
|
|
akos16Decompress(dest, pitch, srcptr, cur_x, out_height, dir, numskip_before, numskip_after, 255);
|
2002-10-21 06:01:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte *ptr = _vm->_screenStartStrip + _vm->getResourceAddress(rtBuffer, 9) + _vm->gdi._imgBufOffs[_zbuf];
|
2002-11-06 07:28:39 +00:00
|
|
|
ptr += _numStrips * clip_top + (clip_left / 8);
|
2002-10-22 07:25:26 +00:00
|
|
|
akos16DecompressMask(dest, pitch, srcptr, cur_x, out_height, dir, numskip_before, numskip_after, 255, ptr, clip_left / 8);
|
2002-10-21 06:01:04 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::akos_increaseAnims(byte *akos, Actor *a) {
|
2001-11-26 19:57:57 +00:00
|
|
|
byte *aksq, *akfo;
|
|
|
|
int i;
|
|
|
|
uint size;
|
|
|
|
bool result;
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
aksq = findResourceData(MKID('AKSQ'), akos);
|
|
|
|
akfo = findResourceData(MKID('AKFO'), akos);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
size = getResourceDataSize(akfo) >> 1;
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
result = false;
|
2003-01-06 16:04:01 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a->cost.active[i] != 0)
|
|
|
|
result |= akos_increaseAnim(a, i, aksq, (uint16 *)akfo, size);
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GW(o) ((int16)READ_LE_UINT16(aksq+curpos+(o)))
|
|
|
|
#define GUW(o) READ_LE_UINT16(aksq+curpos+(o))
|
|
|
|
#define GB(o) aksq[curpos+(o)]
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::akos_increaseAnim(Actor *a, int chan, byte *aksq, uint16 *akfo, int numakfo) {
|
2001-11-26 19:57:57 +00:00
|
|
|
byte active;
|
2002-04-11 17:19:16 +00:00
|
|
|
uint old_curpos, curpos, end;
|
2001-11-26 19:57:57 +00:00
|
|
|
uint code;
|
|
|
|
bool flag_value;
|
2002-04-11 17:19:16 +00:00
|
|
|
int tmp, tmp2;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
active = a->cost.active[chan];
|
|
|
|
end = a->cost.end[chan];
|
|
|
|
old_curpos = curpos = a->cost.curpos[chan];
|
|
|
|
flag_value = false;
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
code = aksq[curpos];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code & 0x80)
|
|
|
|
code = (code << 8) | aksq[curpos + 1];
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (active) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case 6:
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (code) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_JumpIfSet:
|
|
|
|
case AKC_AddVar:
|
|
|
|
case AKC_SetVar:
|
|
|
|
case AKC_SkipGE:
|
|
|
|
case AKC_SkipG:
|
|
|
|
case AKC_SkipLE:
|
|
|
|
case AKC_SkipL:
|
|
|
|
case AKC_SkipNE:
|
|
|
|
case AKC_SkipE:
|
|
|
|
curpos += 5;
|
|
|
|
break;
|
|
|
|
case AKC_JumpTable:
|
|
|
|
case AKC_SetActorClip:
|
|
|
|
case AKC_Ignore3:
|
|
|
|
case AKC_Ignore2:
|
|
|
|
case AKC_Ignore:
|
|
|
|
case AKC_StartAnim:
|
2003-03-02 13:07:58 +00:00
|
|
|
case AKC_StartVarAnim:
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_CmdQue3:
|
|
|
|
curpos += 3;
|
|
|
|
break;
|
|
|
|
case AKC_SoundStuff:
|
2003-03-03 00:45:38 +00:00
|
|
|
curpos += 8; // in Putt is 6
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
case AKC_Cmd3:
|
|
|
|
case AKC_SetVarInActor:
|
|
|
|
case AKC_SetDrawOffs:
|
|
|
|
curpos += 6;
|
|
|
|
break;
|
|
|
|
case AKC_ClearFlag:
|
|
|
|
case AKC_HideActor:
|
2003-03-03 00:45:38 +00:00
|
|
|
case AKC_IncVar:
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_CmdQue3Quick:
|
|
|
|
case AKC_Return:
|
2003-01-12 18:35:01 +00:00
|
|
|
case AKC_EndSeq:
|
2001-11-26 19:57:57 +00:00
|
|
|
curpos += 2;
|
|
|
|
break;
|
|
|
|
case AKC_JumpGE:
|
|
|
|
case AKC_JumpG:
|
|
|
|
case AKC_JumpLE:
|
|
|
|
case AKC_JumpL:
|
|
|
|
case AKC_JumpNE:
|
|
|
|
case AKC_JumpE:
|
|
|
|
case AKC_Random:
|
|
|
|
curpos += 7;
|
|
|
|
break;
|
|
|
|
case AKC_Flip:
|
|
|
|
case AKC_Jump:
|
2003-03-03 00:45:38 +00:00
|
|
|
case AKC_StartAnimInActor:
|
2001-11-26 19:57:57 +00:00
|
|
|
curpos += 4;
|
|
|
|
break;
|
|
|
|
case AKC_ComplexChan:
|
|
|
|
curpos += 3;
|
2002-04-11 17:19:16 +00:00
|
|
|
tmp = aksq[curpos - 1];
|
2001-11-26 19:57:57 +00:00
|
|
|
while (--tmp >= 0) {
|
|
|
|
curpos += 4;
|
2002-04-11 17:19:16 +00:00
|
|
|
curpos += (aksq[curpos] & 0x80) ? 2 : 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2003-03-02 12:23:37 +00:00
|
|
|
if ((code & 0xC000) == 0xC000)
|
2001-11-26 19:57:57 +00:00
|
|
|
error("akos_increaseAnim: invalid code %x", code);
|
2002-04-11 17:19:16 +00:00
|
|
|
curpos += (code & 0x8000) ? 2 : 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2002-04-11 17:19:16 +00:00
|
|
|
curpos += (code & 0x8000) ? 2 : 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
if (curpos > end)
|
|
|
|
curpos = a->cost.start[chan];
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (curpos != end)
|
2002-04-11 17:19:16 +00:00
|
|
|
curpos += (code & 0x8000) ? 2 : 1;
|
2001-11-26 19:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
code = aksq[curpos];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code & 0x80)
|
|
|
|
code = (code << 8) | aksq[curpos + 1];
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (flag_value && code != AKC_ClearFlag)
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (code) {
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_StartAnimInActor:
|
2002-12-27 14:04:25 +00:00
|
|
|
akos_queCommand(4, derefActorSafe(a->getAnimVar(GB(2)), "akos_increaseAnim:29"), a->getAnimVar(GB(3)), 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case AKC_Random:
|
2002-12-01 14:57:50 +00:00
|
|
|
a->setAnimVar(GB(6), _rnd.getRandomNumberRng(GW(2), GW(4)));
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
2003-03-03 00:45:38 +00:00
|
|
|
case AKC_JumpGE:
|
|
|
|
case AKC_JumpG:
|
|
|
|
case AKC_JumpLE:
|
|
|
|
case AKC_JumpL:
|
|
|
|
case AKC_JumpNE:
|
|
|
|
case AKC_JumpE:
|
|
|
|
if (akos_compare(a->getAnimVar(GB(4)), GW(5), code - AKC_JumpStart) != 0) {
|
|
|
|
curpos = GUW(2);
|
|
|
|
break;
|
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_IncVar:
|
2002-05-23 00:37:00 +00:00
|
|
|
a->setAnimVar(0, a->getAnimVar(0) + 1);
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_SetVar:
|
2002-05-23 00:37:00 +00:00
|
|
|
a->setAnimVar(GB(4), GW(2));
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_AddVar:
|
2002-05-23 00:37:00 +00:00
|
|
|
a->setAnimVar(GB(4), a->getAnimVar(GB(4)) + GW(2));
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_Flip:
|
|
|
|
a->flip = GW(2) != 0;
|
|
|
|
continue;
|
|
|
|
case AKC_CmdQue3:
|
2002-12-16 21:21:55 +00:00
|
|
|
// tmp = GB(2); // previous
|
|
|
|
tmp = GB(2) - 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
if ((uint) tmp < 8)
|
2001-11-26 19:57:57 +00:00
|
|
|
akos_queCommand(3, a, a->sound[tmp], 0);
|
|
|
|
continue;
|
|
|
|
case AKC_CmdQue3Quick:
|
2002-12-16 21:21:55 +00:00
|
|
|
// akos_queCommand(3, a, a->sound[1], 0); //previous
|
|
|
|
akos_queCommand(3, a, a->sound[0], 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_StartAnim:
|
|
|
|
akos_queCommand(4, a, GB(2), 0);
|
|
|
|
continue;
|
|
|
|
case AKC_StartVarAnim:
|
2002-05-23 00:37:00 +00:00
|
|
|
akos_queCommand(4, a, a->getAnimVar(GB(2)), 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_SetVarInActor:
|
2002-12-27 14:04:25 +00:00
|
|
|
derefActorSafe(a->getAnimVar(GB(2)), "akos_increaseAnim:9")->setAnimVar(GB(3), GW(4));
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_HideActor:
|
|
|
|
akos_queCommand(1, a, 0, 0);
|
|
|
|
continue;
|
|
|
|
case AKC_SetActorClip:
|
|
|
|
akos_queCommand(5, a, GB(2), 0);
|
|
|
|
continue;
|
|
|
|
case AKC_SoundStuff:
|
|
|
|
tmp = GB(2);
|
|
|
|
if (tmp >= 8)
|
|
|
|
continue;
|
|
|
|
tmp2 = GB(4);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (tmp2 < 1 || tmp2 > 3)
|
2001-11-26 19:57:57 +00:00
|
|
|
error("akos_increaseAnim:8 invalid code %d", tmp2);
|
2002-04-11 17:19:16 +00:00
|
|
|
akos_queCommand(tmp2 + 6, a, a->sound[tmp], GB(6));
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
|
|
|
case AKC_SetDrawOffs:
|
|
|
|
akos_queCommand(6, a, GW(2), GW(4));
|
|
|
|
continue;
|
|
|
|
case AKC_JumpTable:
|
2002-04-11 17:19:16 +00:00
|
|
|
if (akfo == NULL)
|
2001-11-26 19:57:57 +00:00
|
|
|
error("akos_increaseAnim: no AKFO table");
|
2002-05-23 00:37:00 +00:00
|
|
|
tmp = a->getAnimVar(GB(2)) - 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (tmp < 0 || tmp >= numakfo - 1)
|
|
|
|
error("akos_increaseAnim: invalid jump value %d", tmp);
|
2001-11-26 19:57:57 +00:00
|
|
|
curpos = READ_LE_UINT16(&akfo[tmp]);
|
|
|
|
break;
|
|
|
|
case AKC_JumpIfSet:
|
2002-05-23 00:37:00 +00:00
|
|
|
if (!a->getAnimVar(GB(4)))
|
2001-11-26 19:57:57 +00:00
|
|
|
continue;
|
2002-05-23 00:37:00 +00:00
|
|
|
a->setAnimVar(GB(4), 0);
|
2001-11-26 19:57:57 +00:00
|
|
|
curpos = GUW(2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AKC_ClearFlag:
|
|
|
|
flag_value = false;
|
|
|
|
continue;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_Jump:
|
|
|
|
curpos = GUW(2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AKC_Return:
|
2003-01-12 18:35:01 +00:00
|
|
|
case AKC_EndSeq:
|
2001-11-26 19:57:57 +00:00
|
|
|
case AKC_ComplexChan:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AKC_Ignore:
|
|
|
|
case AKC_Ignore2:
|
|
|
|
case AKC_Ignore3:
|
|
|
|
continue;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-03-03 00:45:38 +00:00
|
|
|
case AKC_SkipE:
|
|
|
|
case AKC_SkipNE:
|
|
|
|
case AKC_SkipL:
|
|
|
|
case AKC_SkipLE:
|
|
|
|
case AKC_SkipG:
|
|
|
|
case AKC_SkipGE:
|
|
|
|
if (akos_compare(a->getAnimVar(GB(4)), GW(2), code - AKC_SkipStart) == 0)
|
|
|
|
flag_value = true;
|
|
|
|
continue;
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
default:
|
2002-04-11 17:19:16 +00:00
|
|
|
if ((code & 0xC000) == 0xC000)
|
2001-11-26 19:57:57 +00:00
|
|
|
error("Undefined uSweat token %X", code);
|
|
|
|
}
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (1);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
int code2 = aksq[curpos];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (code2 & 0x80)
|
|
|
|
code2 = (code2 << 8) | aksq[curpos + 1];
|
2003-01-12 18:35:01 +00:00
|
|
|
assert((code2 & 0xC000) != 0xC000 || code2 == AKC_ComplexChan || code2 == AKC_Return || code2 == AKC_EndSeq);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
|
|
|
a->cost.curpos[chan] = curpos;
|
|
|
|
|
|
|
|
return curpos != old_curpos;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::akos_queCommand(byte cmd, Actor *a, int param_1, int param_2) {
|
2002-12-16 21:21:55 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case 1:
|
|
|
|
a->putActor(0, 0, 0);
|
|
|
|
break;
|
2003-02-22 10:39:50 +00:00
|
|
|
case 2:
|
|
|
|
warning("unimplemented akos_queCommand(2,%d,%d,%d)", a->number, param_1, param_2);
|
|
|
|
// start script token in actor
|
|
|
|
break;
|
2002-12-16 21:21:55 +00:00
|
|
|
case 3:
|
|
|
|
if (param_1 != 0) {
|
2003-02-22 10:39:50 +00:00
|
|
|
_sound->addSoundToQueue(param_1);
|
2002-12-16 21:21:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2003-02-22 10:39:50 +00:00
|
|
|
a->startAnimActor(param_1);
|
|
|
|
// param_2 ?
|
|
|
|
break;
|
2002-12-16 21:21:55 +00:00
|
|
|
case 5:
|
2003-02-22 10:39:50 +00:00
|
|
|
a->forceClip = param_1;
|
|
|
|
break;
|
2002-12-16 21:21:55 +00:00
|
|
|
case 6:
|
2003-02-22 10:39:50 +00:00
|
|
|
warning("unimplemented akos_queCommand(6,%d,%d,%d)", a->number, param_1, param_2);
|
|
|
|
// a->offs_x = param_1;
|
|
|
|
// a->offs_y = param_2;
|
2002-12-16 21:21:55 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (param_1 != 0) {
|
|
|
|
if (_imuseDigital) {
|
|
|
|
// _imuseDigital->doCommand(12, 0x600, param_1, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
if (param_1 != 0) {
|
|
|
|
if (_imuseDigital) {
|
|
|
|
// _imuseDigital->doCommand(12, 0x700, param_1, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
if (param_1 != 0) {
|
|
|
|
if (_imuseDigital) {
|
|
|
|
// _imuseDigital->doCommand(12, 0x500, param_1, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("akos_queCommand(%d,%d,%d,%d)", cmd, a->number, param_1, param_2);
|
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::akos_compare(int a, int b, byte cmd) {
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
|
|
|
return a == b;
|
|
|
|
case 1:
|
|
|
|
return a != b;
|
|
|
|
case 2:
|
|
|
|
return a < b;
|
|
|
|
case 3:
|
|
|
|
return a <= b;
|
|
|
|
case 4:
|
|
|
|
return a > b;
|
|
|
|
default:
|
|
|
|
return a >= b;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|