2009-08-13 09:59:44 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2009-08-13 09:59:44 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2009-08-13 09:59:44 +00:00
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/endian.h"
|
2010-10-15 13:54:23 +00:00
|
|
|
#include "common/str.h"
|
2011-06-13 21:19:18 +00:00
|
|
|
#include "common/translation.h"
|
2009-08-13 09:59:44 +00:00
|
|
|
|
2009-08-20 12:32:59 +00:00
|
|
|
#include "gui/message.h"
|
|
|
|
|
2009-08-13 09:59:44 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/inter.h"
|
|
|
|
#include "gob/global.h"
|
|
|
|
#include "gob/util.h"
|
|
|
|
#include "gob/dataio.h"
|
|
|
|
#include "gob/draw.h"
|
|
|
|
#include "gob/game.h"
|
2009-09-09 20:10:16 +00:00
|
|
|
#include "gob/expression.h"
|
2009-08-13 09:59:44 +00:00
|
|
|
#include "gob/script.h"
|
2009-08-27 10:39:04 +00:00
|
|
|
#include "gob/hotspots.h"
|
2009-08-13 09:59:44 +00:00
|
|
|
#include "gob/palanim.h"
|
2009-09-04 20:50:16 +00:00
|
|
|
#include "gob/scenery.h"
|
2009-08-13 09:59:44 +00:00
|
|
|
#include "gob/video.h"
|
|
|
|
#include "gob/videoplayer.h"
|
|
|
|
#include "gob/save/saveload.h"
|
|
|
|
#include "gob/sound/sound.h"
|
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
#define OPCODEVER Inter_Playtoons
|
|
|
|
#define OPCODEDRAW(i, x) _opcodesDraw[i]._OPCODEDRAW(OPCODEVER, x)
|
|
|
|
#define OPCODEFUNC(i, x) _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x)
|
|
|
|
#define OPCODEGOB(i, x) _opcodesGob[i]._OPCODEGOB(OPCODEVER, x)
|
|
|
|
|
|
|
|
Inter_Playtoons::Inter_Playtoons(GobEngine *vm) : Inter_v6(vm) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_Playtoons::setupOpcodesDraw() {
|
|
|
|
Inter_v6::setupOpcodesDraw();
|
|
|
|
|
|
|
|
// In the code, the Draw codes 0x00 to 0x06 and 0x13 are replaced by an engrish
|
|
|
|
// error message. As it's useless, they are simply cleared.
|
|
|
|
CLEAROPCODEDRAW(0x00);
|
|
|
|
CLEAROPCODEDRAW(0x01);
|
|
|
|
CLEAROPCODEDRAW(0x02);
|
|
|
|
CLEAROPCODEDRAW(0x03);
|
|
|
|
CLEAROPCODEDRAW(0x04);
|
|
|
|
CLEAROPCODEDRAW(0x05);
|
|
|
|
CLEAROPCODEDRAW(0x06);
|
|
|
|
CLEAROPCODEDRAW(0x13);
|
|
|
|
|
|
|
|
CLEAROPCODEDRAW(0x21);
|
|
|
|
CLEAROPCODEDRAW(0x22);
|
|
|
|
CLEAROPCODEDRAW(0x24);
|
|
|
|
|
2011-02-04 15:55:20 +00:00
|
|
|
OPCODEDRAW(0x17, oPlaytoons_loadMultObject);
|
2009-09-04 20:50:16 +00:00
|
|
|
OPCODEDRAW(0x19, oPlaytoons_getObjAnimSize);
|
2009-08-13 09:59:44 +00:00
|
|
|
OPCODEDRAW(0x20, oPlaytoons_CD_20_23);
|
|
|
|
OPCODEDRAW(0x23, oPlaytoons_CD_20_23);
|
|
|
|
OPCODEDRAW(0x25, oPlaytoons_CD_25);
|
2009-08-30 23:39:25 +00:00
|
|
|
OPCODEDRAW(0x60, oPlaytoons_copyFile);
|
2009-08-17 09:50:35 +00:00
|
|
|
OPCODEDRAW(0x85, oPlaytoons_openItk);
|
2009-08-13 09:59:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_Playtoons::setupOpcodesFunc() {
|
|
|
|
Inter_v6::setupOpcodesFunc();
|
|
|
|
|
2009-08-27 10:39:04 +00:00
|
|
|
CLEAROPCODEFUNC(0x3D);
|
2009-09-09 20:10:16 +00:00
|
|
|
OPCODEFUNC(0x0B, oPlaytoons_printText);
|
2009-08-28 21:08:59 +00:00
|
|
|
OPCODEFUNC(0x1B, oPlaytoons_F_1B);
|
2009-09-15 12:15:22 +00:00
|
|
|
OPCODEFUNC(0x24, oPlaytoons_putPixel);
|
2009-08-28 21:08:59 +00:00
|
|
|
OPCODEFUNC(0x27, oPlaytoons_freeSprite);
|
2009-08-13 09:59:44 +00:00
|
|
|
OPCODEFUNC(0x3F, oPlaytoons_checkData);
|
2009-08-20 12:32:59 +00:00
|
|
|
OPCODEFUNC(0x4D, oPlaytoons_readData);
|
2009-08-13 09:59:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_Playtoons::setupOpcodesGob() {
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_printText(OpFuncParams ¶ms) {
|
2009-09-09 20:10:16 +00:00
|
|
|
char buf[60];
|
|
|
|
int i;
|
|
|
|
int16 oldTransparency;
|
|
|
|
|
|
|
|
_vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
|
|
|
|
|
|
|
|
_vm->_draw->_backColor = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->_frontColor = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->_fontIndex = _vm->_game->_script->readValExpr();
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2009-09-09 20:10:16 +00:00
|
|
|
_vm->_draw->_textToPrint = buf;
|
|
|
|
_vm->_draw->_transparency = 0;
|
|
|
|
|
|
|
|
if (_vm->_draw->_backColor == 16) {
|
|
|
|
_vm->_draw->_backColor = 0;
|
|
|
|
_vm->_draw->_transparency = 1;
|
|
|
|
}
|
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
// colMod is read from conf file (_off_=xxx).
|
|
|
|
// in Playtoons, it's not present in the conf file, thus always equal to the default value (0).
|
2009-09-09 20:10:16 +00:00
|
|
|
// Maybe used in ADIs...
|
2010-01-25 01:39:44 +00:00
|
|
|
// if (!_vm->_draw->_transparency)
|
2009-09-09 20:10:16 +00:00
|
|
|
// _vm->_draw->_backColor += colMod;
|
|
|
|
// _vm->_draw->_frontColor += colMod;
|
|
|
|
|
|
|
|
oldTransparency = _vm->_draw->_transparency;
|
|
|
|
do {
|
|
|
|
for (i = 0; (_vm->_game->_script->peekChar() != '.') &&
|
|
|
|
(_vm->_game->_script->peekByte() != 200); i++) {
|
|
|
|
buf[i] = _vm->_game->_script->readChar();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_vm->_game->_script->peekByte() != 200) {
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
switch (_vm->_game->_script->peekByte()) {
|
|
|
|
case TYPE_VAR_INT8:
|
|
|
|
case TYPE_ARRAY_INT8:
|
|
|
|
sprintf(buf + i, "%d",
|
|
|
|
(int8) READ_VARO_UINT8(_vm->_game->_script->readVarIndex()));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_VAR_INT16:
|
|
|
|
case TYPE_VAR_INT32_AS_INT16:
|
|
|
|
case TYPE_ARRAY_INT16:
|
|
|
|
sprintf(buf + i, "%d",
|
|
|
|
(int16) READ_VARO_UINT16(_vm->_game->_script->readVarIndex()));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_VAR_INT32:
|
|
|
|
case TYPE_ARRAY_INT32:
|
|
|
|
sprintf(buf + i, "%d",
|
2011-11-03 15:49:57 +00:00
|
|
|
(int32)VAR_OFFSET(_vm->_game->_script->readVarIndex()));
|
2009-09-09 20:10:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_VAR_STR:
|
|
|
|
case TYPE_ARRAY_STR:
|
|
|
|
sprintf(buf + i, "%s",
|
|
|
|
GET_VARO_STR(_vm->_game->_script->readVarIndex()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
} else
|
|
|
|
buf[i] = 0;
|
|
|
|
|
|
|
|
if (_vm->_game->_script->peekByte() == 200) {
|
|
|
|
_vm->_draw->_spriteBottom = _vm->_draw->_fonts[_vm->_draw->_fontIndex]->getCharHeight();
|
|
|
|
_vm->_draw->_spriteRight = _vm->_draw->stringLength(_vm->_draw->_textToPrint, _vm->_draw->_fontIndex);
|
|
|
|
_vm->_draw->adjustCoords(1, &_vm->_draw->_spriteBottom, &_vm->_draw->_spriteRight);
|
|
|
|
if (_vm->_draw->_transparency == 0) {
|
|
|
|
_vm->_draw->spriteOperation(DRAW_FILLRECT);
|
|
|
|
_vm->_draw->_transparency = 1;
|
|
|
|
}
|
|
|
|
_vm->_draw->spriteOperation(DRAW_PRINTTEXT);
|
|
|
|
_vm->_draw->_transparency = oldTransparency;
|
|
|
|
i = 0;
|
2010-01-25 01:39:44 +00:00
|
|
|
} else
|
2009-09-09 20:10:16 +00:00
|
|
|
i = strlen(buf);
|
|
|
|
} while (_vm->_game->_script->peekByte() != 200);
|
|
|
|
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_F_1B(OpFuncParams ¶ms) {
|
2009-09-15 12:15:22 +00:00
|
|
|
_vm->_game->_hotspots->oPlaytoons_F_1B();
|
|
|
|
}
|
2009-08-20 12:32:59 +00:00
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_putPixel(OpFuncParams ¶ms) {
|
2009-09-15 12:15:22 +00:00
|
|
|
_vm->_draw->_destSurface = _vm->_game->_script->readInt16();
|
2009-08-20 12:32:59 +00:00
|
|
|
|
2009-09-15 12:15:22 +00:00
|
|
|
_vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
|
2009-08-20 12:32:59 +00:00
|
|
|
|
2010-04-27 20:47:06 +00:00
|
|
|
_vm->_game->_script->readExpr(99, 0);
|
2009-09-15 12:15:22 +00:00
|
|
|
|
|
|
|
//unk_var is always set to 0 in Playtoons
|
|
|
|
_vm->_draw->_frontColor = _vm->_game->_script->getResultInt() & 0xFFFF; // + unk_var;
|
|
|
|
|
|
|
|
_vm->_draw->_pattern = _vm->_game->_script->getResultInt()>>16;
|
|
|
|
|
|
|
|
_vm->_draw->spriteOperation(DRAW_PUTPIXEL);
|
2009-08-20 12:32:59 +00:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_freeSprite(OpFuncParams ¶ms) {
|
2009-08-28 21:08:59 +00:00
|
|
|
int16 index;
|
|
|
|
if (_vm->_game->_script->peekByte(1) == 0)
|
|
|
|
index = _vm->_game->_script->readInt16();
|
|
|
|
else
|
|
|
|
index = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->freeSprite(index);
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_checkData(OpFuncParams ¶ms) {
|
2011-01-29 22:49:15 +00:00
|
|
|
Common::String file = getFile(_vm->_game->_script->evalString());
|
2009-08-13 09:59:44 +00:00
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
uint16 varOff = _vm->_game->_script->readVarIndex();
|
2009-08-13 09:59:44 +00:00
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
int32 size = -1;
|
|
|
|
int16 handle = 1;
|
2011-01-29 22:49:15 +00:00
|
|
|
SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file.c_str());
|
2009-08-13 09:59:44 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeNone) {
|
2010-10-31 20:07:14 +00:00
|
|
|
size = _vm->_dataIO->fileSize(file);
|
|
|
|
if (size == -1)
|
2011-01-29 22:49:15 +00:00
|
|
|
warning("File \"%s\" not found", file.c_str());
|
2010-10-31 20:07:14 +00:00
|
|
|
|
2009-08-13 09:59:44 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeSave)
|
2011-01-29 22:49:15 +00:00
|
|
|
size = _vm->_saveLoad->getSize(file.c_str());
|
2009-08-13 09:59:44 +00:00
|
|
|
else if (mode == SaveLoad::kSaveModeExists)
|
|
|
|
size = 23;
|
|
|
|
|
|
|
|
if (size == -1)
|
|
|
|
handle = -1;
|
|
|
|
|
|
|
|
debugC(2, kDebugFileIO, "Requested size of file \"%s\": %d",
|
2011-01-29 22:49:15 +00:00
|
|
|
file.c_str(), size);
|
2009-08-13 09:59:44 +00:00
|
|
|
|
|
|
|
WRITE_VAR_OFFSET(varOff, handle);
|
|
|
|
WRITE_VAR(16, (uint32) size);
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_readData(OpFuncParams ¶ms) {
|
2011-01-29 22:49:15 +00:00
|
|
|
Common::String file = getFile(_vm->_game->_script->evalString());
|
2009-08-20 12:32:59 +00:00
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
uint16 dataVar = _vm->_game->_script->readVarIndex();
|
|
|
|
int32 size = _vm->_game->_script->readValExpr();
|
|
|
|
int32 offset = _vm->_game->_script->evalInt();
|
|
|
|
int32 retSize = 0;
|
2009-08-20 12:32:59 +00:00
|
|
|
|
|
|
|
debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)",
|
2011-01-29 22:49:15 +00:00
|
|
|
file.c_str(), dataVar, size, offset);
|
2009-08-20 12:32:59 +00:00
|
|
|
|
2011-01-29 22:49:15 +00:00
|
|
|
SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file.c_str());
|
2009-08-20 12:32:59 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeSave) {
|
|
|
|
|
|
|
|
WRITE_VAR(1, 1);
|
|
|
|
|
2011-01-29 22:49:15 +00:00
|
|
|
if (!_vm->_saveLoad->load(file.c_str(), dataVar, size, offset)) {
|
2011-06-13 21:19:18 +00:00
|
|
|
GUI::MessageDialog dialog(_("Failed to load game state from file."));
|
2009-08-20 12:32:59 +00:00
|
|
|
dialog.runModal();
|
|
|
|
} else
|
|
|
|
WRITE_VAR(1, 0);
|
|
|
|
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2009-08-20 12:32:59 +00:00
|
|
|
|
|
|
|
} else if (mode == SaveLoad::kSaveModeIgnore)
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2009-08-20 12:32:59 +00:00
|
|
|
|
|
|
|
if (size < 0) {
|
2011-01-30 00:03:12 +00:00
|
|
|
if (readSprite(file, dataVar, size, offset))
|
|
|
|
WRITE_VAR(1, 0);
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2009-08-20 12:32:59 +00:00
|
|
|
} else if (size == 0) {
|
|
|
|
dataVar = 0;
|
|
|
|
size = _vm->_game->_script->getVariablesCount() * 4;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
byte *buf = _variables->getAddressOff8(dataVar);
|
2009-08-20 12:32:59 +00:00
|
|
|
|
|
|
|
if (file[0] == 0) {
|
|
|
|
WRITE_VAR(1, size);
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2009-08-20 12:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WRITE_VAR(1, 1);
|
2010-10-31 20:07:14 +00:00
|
|
|
Common::SeekableReadStream *stream = _vm->_dataIO->getFile(file);
|
|
|
|
if (!stream)
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2009-08-20 12:32:59 +00:00
|
|
|
|
|
|
|
_vm->_draw->animateCursor(4);
|
2011-01-18 04:19:33 +00:00
|
|
|
if (offset > stream->size()) {
|
|
|
|
warning("oPlaytoons_readData: File \"%s\", Offset (%d) > file size (%d)",
|
2011-01-29 22:49:15 +00:00
|
|
|
file.c_str(), offset, stream->size());
|
2011-01-18 04:19:33 +00:00
|
|
|
delete stream;
|
2011-01-29 22:44:06 +00:00
|
|
|
return;
|
2011-01-18 04:19:33 +00:00
|
|
|
}
|
|
|
|
|
2009-08-20 12:32:59 +00:00
|
|
|
if (offset < 0)
|
|
|
|
stream->seek(offset + 1, SEEK_END);
|
|
|
|
else
|
|
|
|
stream->seek(offset);
|
|
|
|
|
|
|
|
if (((dataVar >> 2) == 59) && (size == 4)) {
|
|
|
|
WRITE_VAR(59, stream->readUint32LE());
|
|
|
|
// The scripts in some versions divide through 256^3 then,
|
|
|
|
// effectively doing a LE->BE conversion
|
2013-05-02 22:26:58 +00:00
|
|
|
if ((_vm->getPlatform() != Common::kPlatformDOS) && (VAR(59) < 256))
|
2009-08-20 12:32:59 +00:00
|
|
|
WRITE_VAR(59, SWAP_BYTES_32(VAR(59)));
|
|
|
|
} else
|
|
|
|
retSize = stream->read(buf, size);
|
|
|
|
|
|
|
|
if (retSize == size)
|
|
|
|
WRITE_VAR(1, 0);
|
|
|
|
|
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
|
2011-02-04 15:55:20 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_loadMultObject() {
|
|
|
|
assert(_vm->_mult->_objects);
|
|
|
|
|
|
|
|
uint16 objIndex = _vm->_game->_script->readValExpr();
|
|
|
|
|
|
|
|
debugC(4, kDebugGameFlow, "Loading mult object %d", objIndex);
|
|
|
|
|
|
|
|
Mult::Mult_Object &obj = _vm->_mult->_objects[objIndex];
|
|
|
|
Mult::Mult_AnimData &objAnim = *(obj.pAnimData);
|
|
|
|
|
|
|
|
*obj.pPosX = _vm->_game->_script->readValExpr();
|
|
|
|
*obj.pPosY = _vm->_game->_script->readValExpr();
|
|
|
|
|
|
|
|
byte *multData = (byte *) &objAnim;
|
|
|
|
for (int i = 0; i < 11; i++) {
|
|
|
|
if (_vm->_game->_script->peekByte() != 99)
|
|
|
|
multData[i] = _vm->_game->_script->readValExpr();
|
|
|
|
else
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((int32)*obj.pPosX != -1234) || ((int32)*obj.pPosY == -4321))
|
|
|
|
return;
|
|
|
|
|
|
|
|
warning("Stub: oPlaytoons_loadMultObject: pPosX == -1234, pPosY == -4321");
|
|
|
|
}
|
|
|
|
|
2009-09-04 20:50:16 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_getObjAnimSize() {
|
|
|
|
int16 objIndex;
|
|
|
|
uint16 readVar[4];
|
2011-02-04 15:54:52 +00:00
|
|
|
uint16 types[4];
|
2009-09-04 20:50:16 +00:00
|
|
|
Mult::Mult_AnimData animData;
|
|
|
|
|
|
|
|
_vm->_game->_script->evalExpr(&objIndex);
|
|
|
|
|
2011-02-04 15:54:52 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
readVar[i] = _vm->_game->_script->readVarIndex(0, &types[0]);
|
2009-09-04 20:50:16 +00:00
|
|
|
|
|
|
|
if (objIndex == -1) {
|
|
|
|
warning("oPlaytoons_getObjAnimSize case -1 not implemented");
|
|
|
|
return;
|
|
|
|
}
|
2011-02-04 15:54:52 +00:00
|
|
|
|
2009-09-04 20:50:16 +00:00
|
|
|
if (objIndex == -2) {
|
2011-02-04 15:54:52 +00:00
|
|
|
bool doBreak = false;
|
|
|
|
for (int i = 0; i < 3; i++)
|
2011-02-04 16:16:07 +00:00
|
|
|
storeValue(readVar[i], types[i], (uint32) -1);
|
2011-02-04 15:54:52 +00:00
|
|
|
|
|
|
|
for (int i = readValue(readVar[3], types[3]); i < _vm->_mult->_objCount; i++) {
|
|
|
|
if (_vm->_mult->_objects[i].pAnimData->isStatic != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
byte *data = (byte *)_vm->_mult->_objects[i].pAnimData;
|
|
|
|
|
|
|
|
for (int j = 1; j < 39; j += 2) {
|
|
|
|
int32 value1 = READ_VARO_UINT32(readVar[3] + j * 4);
|
|
|
|
int32 value2 = READ_VARO_UINT32(readVar[3] + (j + 1) * 4);
|
|
|
|
if (value1 == -1) {
|
|
|
|
doBreak = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value1 >= 0) {
|
|
|
|
if ((int8)data[value1] != value2)
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if ((int8)data[-value1] == value2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doBreak) {
|
|
|
|
storeValue(readVar[0], types[0], i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-04 20:50:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-09-29 22:43:30 +00:00
|
|
|
|
2009-09-04 20:50:16 +00:00
|
|
|
if ((objIndex < 0) || (objIndex >= _vm->_mult->_objCount)) {
|
|
|
|
warning("oPlaytoons_getObjAnimSize(): objIndex = %d (%d)", objIndex, _vm->_mult->_objCount);
|
|
|
|
_vm->_scenery->_toRedrawLeft = 0;
|
|
|
|
_vm->_scenery->_toRedrawTop = 0;
|
|
|
|
_vm->_scenery->_toRedrawRight = 0;
|
|
|
|
_vm->_scenery->_toRedrawBottom = 0;
|
|
|
|
} else {
|
|
|
|
animData = *(_vm->_mult->_objects[objIndex].pAnimData);
|
|
|
|
if (animData.isStatic == 0)
|
|
|
|
_vm->_scenery->updateAnim(animData.layer, animData.frame,
|
|
|
|
animData.animation, 0, *(_vm->_mult->_objects[objIndex].pPosX),
|
|
|
|
*(_vm->_mult->_objects[objIndex].pPosY), 0);
|
|
|
|
|
|
|
|
_vm->_scenery->_toRedrawLeft = MAX<int16>(_vm->_scenery->_toRedrawLeft, 0);
|
|
|
|
_vm->_scenery->_toRedrawTop = MAX<int16>(_vm->_scenery->_toRedrawTop , 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
WRITE_VAR_OFFSET(readVar[0], _vm->_scenery->_toRedrawLeft);
|
|
|
|
WRITE_VAR_OFFSET(readVar[1], _vm->_scenery->_toRedrawTop);
|
|
|
|
WRITE_VAR_OFFSET(readVar[2], _vm->_scenery->_toRedrawRight);
|
|
|
|
WRITE_VAR_OFFSET(readVar[3], _vm->_scenery->_toRedrawBottom);
|
|
|
|
}
|
|
|
|
|
2009-08-13 09:59:44 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_CD_20_23() {
|
|
|
|
_vm->_game->_script->evalExpr(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_Playtoons::oPlaytoons_CD_25() {
|
|
|
|
_vm->_game->_script->readVarIndex();
|
|
|
|
_vm->_game->_script->readVarIndex();
|
|
|
|
}
|
|
|
|
|
2009-08-30 23:39:25 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_copyFile() {
|
2011-01-30 00:03:35 +00:00
|
|
|
Common::String path1 = _vm->_game->_script->evalString();
|
|
|
|
Common::String path2 = _vm->_game->_script->evalString();
|
|
|
|
|
|
|
|
Common::String file1 = getFile(path1.c_str());
|
|
|
|
Common::String file2 = getFile(path2.c_str());
|
|
|
|
|
|
|
|
if (file1.equalsIgnoreCase(file2)) {
|
|
|
|
warning("oPlaytoons_copyFile(): \"%s\" == \"%s\"", path1.c_str(), path2.c_str());
|
|
|
|
return;
|
|
|
|
}
|
2009-08-30 23:39:25 +00:00
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
warning("Playtoons Stub: copy file from \"%s\" to \"%s\"", file1.c_str(), file2.c_str());
|
2009-08-30 23:39:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-17 09:50:35 +00:00
|
|
|
void Inter_Playtoons::oPlaytoons_openItk() {
|
2011-01-29 22:49:15 +00:00
|
|
|
Common::String file = getFile(_vm->_game->_script->evalString());
|
2011-01-29 22:47:53 +00:00
|
|
|
if (!file.contains('.'))
|
|
|
|
file += ".ITK";
|
2009-08-17 09:57:09 +00:00
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
_vm->_dataIO->openArchive(file, false);
|
2009-08-17 09:50:35 +00:00
|
|
|
}
|
2009-08-13 09:59:44 +00:00
|
|
|
|
2011-01-29 22:49:15 +00:00
|
|
|
Common::String Inter_Playtoons::getFile(const char *path) {
|
|
|
|
const char *orig = path;
|
|
|
|
|
|
|
|
if (!strncmp(path, "@:\\", 3))
|
|
|
|
path += 3;
|
|
|
|
else if (!strncmp(path, "<ME>", 4))
|
|
|
|
path += 4;
|
|
|
|
else if (!strncmp(path, "<CD>", 4))
|
|
|
|
path += 4;
|
|
|
|
else if (!strncmp(path, "<STK>", 5))
|
|
|
|
path += 5;
|
|
|
|
else if (!strncmp(path, "<ALLCD>", 7))
|
|
|
|
path += 7;
|
|
|
|
|
|
|
|
const char *backslash = strrchr(path, '\\');
|
|
|
|
if (backslash)
|
|
|
|
path = backslash + 1;
|
|
|
|
|
|
|
|
if (orig != path)
|
|
|
|
debugC(2, kDebugFileIO, "Inter_Playtoons::getFile(): Evaluating path"
|
|
|
|
"\"%s\" to \"%s\"", orig, path);
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2011-01-30 13:14:54 +00:00
|
|
|
bool Inter_Playtoons::readSprite(Common::String file, int32 dataVar,
|
2011-01-30 00:03:12 +00:00
|
|
|
int32 size, int32 offset) {
|
|
|
|
|
2011-01-30 13:14:54 +00:00
|
|
|
// WORKAROUND: Adibou copies TEMP.CSA to TEMP01.CSA, which isn't yet implemented
|
|
|
|
if (file.equalsIgnoreCase("TEMP01.CSA"))
|
|
|
|
file = "TEMP.CSA";
|
|
|
|
|
2011-01-30 00:03:12 +00:00
|
|
|
bool palette = false;
|
|
|
|
if (size < -1000) {
|
|
|
|
palette = true;
|
|
|
|
size += 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = -size - 1;
|
2011-02-02 16:49:20 +00:00
|
|
|
if ((index < 0) || (index >= Draw::kSpriteCount) || !_vm->_draw->_spritesArray[index]) {
|
2011-01-30 00:03:12 +00:00
|
|
|
warning("No such sprite");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfacePtr sprite = _vm->_draw->_spritesArray[index];
|
|
|
|
if (sprite->getBPP() != 1) {
|
|
|
|
warning("bpp != 1");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *stream = _vm->_dataIO->getFile(file);
|
|
|
|
if (!stream) {
|
|
|
|
warning("No such file \"%s\"", file.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 spriteSize = sprite->getWidth() * sprite->getHeight();
|
|
|
|
int32 dataSize = stream->size();
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
dataSize -= 768;
|
|
|
|
|
|
|
|
int32 readSize = MIN(spriteSize, dataSize);
|
|
|
|
if (readSize <= 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream->read(sprite->getData(), readSize);
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
stream->read((byte *)_vm->_global->_pPaletteDesc->vgaPal, 768);
|
|
|
|
|
|
|
|
delete stream;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-13 09:59:44 +00:00
|
|
|
} // End of namespace Gob
|