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.
|
2006-01-05 16:06:55 +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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-01-05 16:06:55 +00:00
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2006-01-05 16:06:55 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-04-13 20:56:22 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
2008-07-08 00:16:55 +00:00
|
|
|
|
2009-08-02 13:54:06 +00:00
|
|
|
#include "gui/message.h"
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "sound/mixer.h"
|
|
|
|
#include "sound/mods/infogrames.h"
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2006-01-05 16:06:55 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/inter.h"
|
2009-05-21 17:12:33 +00:00
|
|
|
#include "gob/helper.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/global.h"
|
2006-01-05 16:06:55 +00:00
|
|
|
#include "gob/util.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/dataio.h"
|
2006-01-05 16:06:55 +00:00
|
|
|
#include "gob/draw.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/game.h"
|
2009-06-22 16:30:35 +00:00
|
|
|
#include "gob/expression.h"
|
2009-06-22 10:13:37 +00:00
|
|
|
#include "gob/script.h"
|
2009-06-24 21:49:37 +00:00
|
|
|
#include "gob/resources.h"
|
2009-07-05 11:27:54 +00:00
|
|
|
#include "gob/hotspots.h"
|
2006-01-05 16:06:55 +00:00
|
|
|
#include "gob/goblin.h"
|
2006-05-11 19:43:30 +00:00
|
|
|
#include "gob/map.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/mult.h"
|
|
|
|
#include "gob/scenery.h"
|
|
|
|
#include "gob/video.h"
|
2009-05-31 02:15:43 +00:00
|
|
|
#include "gob/save/saveload.h"
|
2007-07-30 15:53:38 +00:00
|
|
|
#include "gob/videoplayer.h"
|
2008-05-08 00:47:23 +00:00
|
|
|
#include "gob/sound/sound.h"
|
2006-01-05 16:06:55 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2009-06-17 04:16:21 +00:00
|
|
|
#define OPCODEVER Inter_v2
|
|
|
|
#define OPCODEDRAW(i, x) _opcodesDraw[i]._OPCODEDRAW(OPCODEVER, x)
|
|
|
|
#define OPCODEFUNC(i, x) _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x)
|
2009-06-17 04:16:51 +00:00
|
|
|
#define OPCODEGOB(i, x) _opcodesGob[i]._OPCODEGOB(OPCODEVER, x)
|
2006-01-10 11:30:23 +00:00
|
|
|
|
2006-01-05 16:06:55 +00:00
|
|
|
Inter_v2::Inter_v2(GobEngine *vm) : Inter_v1(vm) {
|
|
|
|
}
|
|
|
|
|
2009-06-17 04:15:45 +00:00
|
|
|
void Inter_v2::setupOpcodesDraw() {
|
|
|
|
Inter_v1::setupOpcodesDraw();
|
|
|
|
|
|
|
|
OPCODEDRAW(0x01, o2_playMult);
|
|
|
|
OPCODEDRAW(0x02, o2_freeMultKeys);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x0A, o2_setRenderFlags);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x13, o2_multSub);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x14, o2_initMult);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x17, o2_loadMultObject);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x1C, o2_renderStatic);
|
|
|
|
OPCODEDRAW(0x1D, o2_loadCurLayer);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x20, o2_playCDTrack);
|
|
|
|
OPCODEDRAW(0x21, o2_waitCDTrackEnd);
|
|
|
|
OPCODEDRAW(0x22, o2_stopCD);
|
|
|
|
OPCODEDRAW(0x23, o2_readLIC);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x24, o2_freeLIC);
|
|
|
|
OPCODEDRAW(0x25, o2_getCDTrackPos);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x30, o2_loadFontToSprite);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x40, o2_totSub);
|
|
|
|
OPCODEDRAW(0x41, o2_switchTotSub);
|
|
|
|
OPCODEDRAW(0x42, o2_pushVars);
|
|
|
|
OPCODEDRAW(0x43, o2_popVars);
|
2006-01-05 16:06:55 +00:00
|
|
|
|
2009-06-17 04:15:45 +00:00
|
|
|
OPCODEDRAW(0x50, o2_loadMapObjects);
|
|
|
|
OPCODEDRAW(0x51, o2_freeGoblins);
|
|
|
|
OPCODEDRAW(0x52, o2_moveGoblin);
|
|
|
|
OPCODEDRAW(0x53, o2_writeGoblinPos);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x54, o2_stopGoblin);
|
|
|
|
OPCODEDRAW(0x55, o2_setGoblinState);
|
|
|
|
OPCODEDRAW(0x56, o2_placeGoblin);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x80, o2_initScreen);
|
|
|
|
OPCODEDRAW(0x81, o2_scroll);
|
|
|
|
OPCODEDRAW(0x82, o2_setScrollOffset);
|
|
|
|
OPCODEDRAW(0x83, o2_playImd);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x84, o2_getImdInfo);
|
|
|
|
OPCODEDRAW(0x85, o2_openItk);
|
|
|
|
OPCODEDRAW(0x86, o2_closeItk);
|
|
|
|
OPCODEDRAW(0x87, o2_setImdFrontSurf);
|
|
|
|
|
|
|
|
OPCODEDRAW(0x88, o2_resetImdFrontSurf);
|
|
|
|
}
|
|
|
|
|
2009-06-17 04:16:21 +00:00
|
|
|
void Inter_v2::setupOpcodesFunc() {
|
|
|
|
Inter_v1::setupOpcodesFunc();
|
|
|
|
|
|
|
|
OPCODEFUNC(0x09, o2_assign);
|
|
|
|
|
|
|
|
OPCODEFUNC(0x11, o2_printText);
|
|
|
|
|
|
|
|
OPCODEFUNC(0x17, o2_animPalInit);
|
|
|
|
|
2009-07-05 21:39:55 +00:00
|
|
|
OPCODEFUNC(0x18, o2_addHotspot);
|
|
|
|
OPCODEFUNC(0x19, o2_removeHotspot);
|
2009-06-17 04:16:21 +00:00
|
|
|
|
|
|
|
OPCODEFUNC(0x25, o2_goblinFunc);
|
2006-01-05 16:06:55 +00:00
|
|
|
|
2009-06-17 04:16:21 +00:00
|
|
|
OPCODEFUNC(0x39, o2_stopSound);
|
|
|
|
OPCODEFUNC(0x3A, o2_loadSound);
|
|
|
|
|
|
|
|
OPCODEFUNC(0x3E, o2_getFreeMem);
|
|
|
|
OPCODEFUNC(0x3F, o2_checkData);
|
|
|
|
|
|
|
|
OPCODEFUNC(0x4D, o2_readData);
|
|
|
|
OPCODEFUNC(0x4E, o2_writeData);
|
|
|
|
}
|
|
|
|
|
2009-06-17 04:16:51 +00:00
|
|
|
void Inter_v2::setupOpcodesGob() {
|
|
|
|
OPCODEGOB( 0, o2_loadInfogramesIns);
|
|
|
|
OPCODEGOB( 1, o2_startInfogrames);
|
|
|
|
OPCODEGOB( 2, o2_stopInfogrames);
|
2006-01-10 11:30:23 +00:00
|
|
|
|
2009-06-17 04:16:51 +00:00
|
|
|
OPCODEGOB( 10, o2_playInfogrames);
|
2006-01-10 11:30:23 +00:00
|
|
|
|
2009-06-17 04:16:51 +00:00
|
|
|
OPCODEGOB(100, o2_handleGoblins);
|
2006-01-10 11:30:23 +00:00
|
|
|
|
2009-06-17 04:16:51 +00:00
|
|
|
OPCODEGOB(500, o2_playProtracker);
|
|
|
|
OPCODEGOB(501, o2_stopProtracker);
|
2006-01-10 11:30:23 +00:00
|
|
|
}
|
2006-01-05 16:06:55 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
void Inter_v2::checkSwitchTable(uint32 &offset) {
|
|
|
|
byte type;
|
2007-02-06 14:42:05 +00:00
|
|
|
int16 len;
|
|
|
|
int32 value;
|
|
|
|
bool found;
|
|
|
|
|
|
|
|
found = false;
|
2009-06-22 10:13:37 +00:00
|
|
|
offset = 0;
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
type = _vm->_game->_script->peekByte();
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-08-24 22:37:09 +00:00
|
|
|
value = (uint16) _vm->_game->_script->readVarIndex();
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
switch (type) {
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT8:
|
|
|
|
case TYPE_ARRAY_INT8:
|
2007-02-06 14:42:05 +00:00
|
|
|
value = (int8) READ_VARO_UINT8(value);
|
|
|
|
break;
|
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT32:
|
|
|
|
case TYPE_ARRAY_INT32:
|
2007-02-06 14:42:05 +00:00
|
|
|
value = READ_VARO_UINT32(value);
|
|
|
|
break;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-02-06 14:42:05 +00:00
|
|
|
default:
|
2007-04-05 13:37:20 +00:00
|
|
|
value = (int16) READ_VARO_UINT16(value);
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_terminate)
|
|
|
|
return;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
len = _vm->_game->_script->readInt8();
|
2007-02-06 14:42:05 +00:00
|
|
|
while (len != -5) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
type = _vm->_game->_script->peekByte();
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
switch (type) {
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT32:
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
2007-02-06 14:42:05 +00:00
|
|
|
if (!found &&
|
2009-06-22 10:13:37 +00:00
|
|
|
(value == _vm->_game->_script->peekInt32()))
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(5);
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT16:
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
2007-02-06 14:42:05 +00:00
|
|
|
if (!found &&
|
2009-06-22 10:13:37 +00:00
|
|
|
(value == _vm->_game->_script->peekInt16()))
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(3);
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT8:
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
if (!found && (value == _vm->_game->_script->peekInt8()))
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(2);
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (!found) {
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
if (value == _vm->_game->_script->getResultInt())
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
|
|
|
} else
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skipExpr(99);
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
if (found && (offset == 0))
|
|
|
|
offset = _vm->_game->_script->pos();
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
|
|
|
|
len = _vm->_game->_script->readInt8();
|
2007-02-06 14:42:05 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
if ((_vm->_game->_script->peekByte() >> 4) != 4)
|
2007-02-06 14:42:05 +00:00
|
|
|
return;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
if (offset == 0)
|
|
|
|
offset = _vm->_game->_script->pos();
|
2007-02-06 14:42:05 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
|
2007-02-06 14:42:05 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_playMult() {
|
|
|
|
int16 checkEscape;
|
2006-05-01 16:04:53 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
checkEscape = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
_vm->_mult->setMultData(checkEscape >> 1);
|
|
|
|
_vm->_mult->playMult(VAR(57), -1, checkEscape & 0x1, 0);
|
2006-05-01 16:04:53 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
void Inter_v2::o2_freeMultKeys() {
|
2009-06-22 10:13:37 +00:00
|
|
|
uint16 index = _vm->_game->_script->readUint16();
|
2007-07-24 06:11:38 +00:00
|
|
|
|
|
|
|
if (!_vm->_mult->hasMultData(index))
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_mult->setMultData(index);
|
|
|
|
_vm->_mult->freeMultKeys();
|
|
|
|
_vm->_mult->zeroMultData(index);
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_setRenderFlags() {
|
|
|
|
int16 expr;
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
expr = _vm->_game->_script->readValExpr();
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (expr & 0x8000) {
|
|
|
|
_vm->_draw->_renderFlags |= expr & 0x3FFF;
|
2007-04-05 16:04:59 +00:00
|
|
|
} else {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (expr & 0x4000)
|
|
|
|
_vm->_draw->_renderFlags &= expr & 0x3FFF;
|
|
|
|
else
|
|
|
|
_vm->_draw->_renderFlags = expr;
|
|
|
|
}
|
|
|
|
}
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_multSub() {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_mult->multSub(_vm->_game->_script->readValExpr());
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_initMult() {
|
|
|
|
int16 oldAnimHeight;
|
|
|
|
int16 oldAnimWidth;
|
|
|
|
int16 oldObjCount;
|
2009-08-24 22:37:09 +00:00
|
|
|
uint16 posXVar;
|
|
|
|
uint16 posYVar;
|
|
|
|
uint16 animDataVar;
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
oldAnimWidth = _vm->_mult->_animWidth;
|
|
|
|
oldAnimHeight = _vm->_mult->_animHeight;
|
|
|
|
oldObjCount = _vm->_mult->_objCount;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_mult->_animLeft = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_mult->_animTop = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_mult->_animWidth = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_mult->_animHeight = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_mult->_objCount = _vm->_game->_script->readInt16();
|
|
|
|
posXVar = _vm->_game->_script->readVarIndex();
|
|
|
|
posYVar = _vm->_game->_script->readVarIndex();
|
|
|
|
animDataVar = _vm->_game->_script->readVarIndex();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (_vm->_mult->_objects && (oldObjCount != _vm->_mult->_objCount)) {
|
|
|
|
warning("Initializing new objects without having "
|
|
|
|
"cleaned up the old ones at first");
|
2008-05-04 02:26:25 +00:00
|
|
|
|
|
|
|
_vm->_mult->clearObjectVideos();
|
|
|
|
|
2008-07-12 15:21:38 +00:00
|
|
|
for (int i = 0; i < _vm->_mult->_objCount; i++) {
|
|
|
|
delete _vm->_mult->_objects[i].pPosX;
|
|
|
|
delete _vm->_mult->_objects[i].pPosY;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _vm->_mult->_objects;
|
|
|
|
delete[] _vm->_mult->_renderObjs;
|
|
|
|
delete[] _vm->_mult->_orderArray;
|
2008-07-12 15:21:38 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_mult->_objects = 0;
|
|
|
|
_vm->_mult->_renderObjs = 0;
|
|
|
|
_vm->_mult->_orderArray = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_vm->_mult->_objects == 0) {
|
|
|
|
_vm->_mult->_renderObjs = new Mult::Mult_Object*[_vm->_mult->_objCount];
|
|
|
|
memset(_vm->_mult->_renderObjs, 0,
|
|
|
|
_vm->_mult->_objCount * sizeof(Mult::Mult_Object*));
|
|
|
|
|
|
|
|
if (_terminate)
|
|
|
|
return;
|
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
_vm->_mult->_orderArray = new int8[_vm->_mult->_objCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_vm->_mult->_orderArray, 0, _vm->_mult->_objCount * sizeof(int8));
|
|
|
|
_vm->_mult->_objects = new Mult::Mult_Object[_vm->_mult->_objCount];
|
|
|
|
memset(_vm->_mult->_objects, 0,
|
|
|
|
_vm->_mult->_objCount * sizeof(Mult::Mult_Object));
|
|
|
|
|
|
|
|
for (int i = 0; i < _vm->_mult->_objCount; i++) {
|
2008-05-28 21:15:11 +00:00
|
|
|
uint32 offPosX = i * 4 + (posXVar / 4) * 4;
|
|
|
|
uint32 offPosY = i * 4 + (posYVar / 4) * 4;
|
|
|
|
uint32 offAnim = animDataVar + i * 4 * _vm->_global->_inter_animDataSize;
|
|
|
|
|
2008-07-12 15:21:38 +00:00
|
|
|
_vm->_mult->_objects[i].pPosX = new VariableReference(*_vm->_inter->_variables, offPosX);
|
|
|
|
_vm->_mult->_objects[i].pPosY = new VariableReference(*_vm->_inter->_variables, offPosY);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
_vm->_mult->_objects[i].pAnimData =
|
2010-05-17 22:46:53 +00:00
|
|
|
(Mult::Mult_AnimData *)_variables->getAddressOff8(offAnim);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
_vm->_mult->_objects[i].pAnimData->isStatic = 1;
|
|
|
|
_vm->_mult->_objects[i].tick = 0;
|
|
|
|
_vm->_mult->_objects[i].lastLeft = -1;
|
|
|
|
_vm->_mult->_objects[i].lastRight = -1;
|
|
|
|
_vm->_mult->_objects[i].lastTop = -1;
|
|
|
|
_vm->_mult->_objects[i].lastBottom = -1;
|
|
|
|
_vm->_mult->_objects[i].goblinX = 1;
|
|
|
|
_vm->_mult->_objects[i].goblinY = 1;
|
2006-08-12 09:16:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_vm->_mult->_animSurf &&
|
|
|
|
((oldAnimWidth != _vm->_mult->_animWidth) ||
|
|
|
|
(oldAnimHeight != _vm->_mult->_animHeight))) {
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->freeSprite(Draw::kAnimSurface);
|
2009-06-06 20:03:13 +00:00
|
|
|
_vm->_mult->_animSurf.reset();
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_draw->adjustCoords(0,
|
|
|
|
&_vm->_mult->_animWidth, &_vm->_mult->_animHeight);
|
2009-06-06 20:03:13 +00:00
|
|
|
if (!_vm->_mult->_animSurf) {
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->initSpriteSurf(Draw::kAnimSurface, _vm->_mult->_animWidth,
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_mult->_animHeight, 0);
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_mult->_animSurf = _vm->_draw->_spritesArray[Draw::kAnimSurface];
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_terminate)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_draw->adjustCoords(1,
|
|
|
|
&_vm->_mult->_animWidth, &_vm->_mult->_animHeight);
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_sourceSurface = Draw::kBackSurface;
|
|
|
|
_vm->_draw->_destSurface = Draw::kAnimSurface;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_spriteLeft = _vm->_mult->_animLeft;
|
|
|
|
_vm->_draw->_spriteTop = _vm->_mult->_animTop;
|
|
|
|
_vm->_draw->_spriteRight = _vm->_mult->_animWidth;
|
|
|
|
_vm->_draw->_spriteBottom = _vm->_mult->_animHeight;
|
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
|
|
|
_vm->_draw->spriteOperation(0);
|
|
|
|
|
|
|
|
debugC(4, kDebugGraphics, "o2_initMult: x = %d, y = %d, w = %d, h = %d",
|
|
|
|
_vm->_mult->_animLeft, _vm->_mult->_animTop,
|
|
|
|
_vm->_mult->_animWidth, _vm->_mult->_animHeight);
|
|
|
|
debugC(4, kDebugGraphics, " _vm->_mult->_objCount = %d, "
|
|
|
|
"animation data size = %d", _vm->_mult->_objCount,
|
|
|
|
_vm->_global->_inter_animDataSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_loadMultObject() {
|
|
|
|
int16 val;
|
|
|
|
int16 objIndex;
|
|
|
|
int16 animation;
|
|
|
|
int16 layer;
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *multData;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
objIndex = _vm->_game->_script->readValExpr();
|
|
|
|
val = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
*_vm->_mult->_objects[objIndex].pPosX = val;
|
2009-06-22 10:13:37 +00:00
|
|
|
val = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
*_vm->_mult->_objects[objIndex].pPosY = val;
|
|
|
|
|
|
|
|
debugC(4, kDebugGameFlow, "Loading mult object %d", objIndex);
|
|
|
|
|
2010-05-17 22:46:53 +00:00
|
|
|
multData = (byte *)_vm->_mult->_objects[objIndex].pAnimData;
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 11; i++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
if (_vm->_game->_script->peekByte() != 99)
|
|
|
|
multData[i] = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
else
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Mult::Mult_Object &obj = _vm->_mult->_objects[objIndex];
|
|
|
|
Mult::Mult_AnimData &objAnim = *(obj.pAnimData);
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
if ((objAnim.animType == 100) && (objIndex < _vm->_goblin->_gobsCount)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
val = *(obj.pPosX) % 256;
|
|
|
|
obj.destX = val;
|
|
|
|
obj.gobDestX = val;
|
|
|
|
obj.goblinX = val;
|
|
|
|
|
|
|
|
val = *(obj.pPosY) % 256;
|
|
|
|
obj.destY = val;
|
|
|
|
obj.gobDestY = val;
|
|
|
|
obj.goblinY = val;
|
|
|
|
|
|
|
|
*(obj.pPosX) *= _vm->_map->_tilesWidth;
|
|
|
|
|
|
|
|
layer = objAnim.layer;
|
|
|
|
animation = obj.goblinStates[layer][0].animation;
|
|
|
|
objAnim.framesLeft = objAnim.maxFrame;
|
|
|
|
objAnim.nextState = -1;
|
|
|
|
objAnim.newState = -1;
|
|
|
|
objAnim.pathExistence = 0;
|
|
|
|
objAnim.isBusy = 0;
|
|
|
|
objAnim.state = layer;
|
|
|
|
objAnim.layer = obj.goblinStates[objAnim.state][0].layer;
|
|
|
|
objAnim.animation = animation;
|
|
|
|
_vm->_scenery->updateAnim(layer, 0, animation, 0,
|
|
|
|
*(obj.pPosX), *(obj.pPosY), 0);
|
|
|
|
|
|
|
|
if (!_vm->_map->_bigTiles)
|
|
|
|
*(obj.pPosY) = (obj.goblinY + 1) * _vm->_map->_tilesHeight
|
|
|
|
- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
|
|
|
|
else
|
|
|
|
*(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
|
|
|
|
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) -
|
|
|
|
((obj.goblinY + 1) / 2);
|
|
|
|
*(obj.pPosX) = obj.goblinX * _vm->_map->_tilesWidth;
|
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
} else if ((objAnim.animType == 101) && (objIndex < _vm->_goblin->_gobsCount)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
layer = objAnim.layer;
|
|
|
|
animation = obj.goblinStates[layer][0].animation;
|
|
|
|
objAnim.nextState = -1;
|
|
|
|
objAnim.newState = -1;
|
|
|
|
objAnim.state = layer;
|
|
|
|
objAnim.layer = obj.goblinStates[objAnim.state][0].layer;
|
|
|
|
objAnim.animation = animation;
|
|
|
|
|
|
|
|
if ((*(obj.pPosX) == 1000) && (*(obj.pPosY) == 1000)) {
|
|
|
|
Scenery::AnimLayer *animLayer =
|
|
|
|
_vm->_scenery->getAnimLayer(animation, objAnim.layer);
|
|
|
|
|
|
|
|
*(obj.pPosX) = animLayer->posX;
|
|
|
|
*(obj.pPosY) = animLayer->posY;
|
2006-08-12 09:16:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->updateAnim(layer, 0, animation, 0,
|
|
|
|
*(obj.pPosX), *(obj.pPosY), 0);
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
} else if ((objAnim.animType != 100) && (objAnim.animType != 101)) {
|
|
|
|
|
2008-07-12 15:21:38 +00:00
|
|
|
if ((((int32) *(obj.pPosX)) == -1234) && (((int32) *(obj.pPosY)) == -4321)) {
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
if (obj.videoSlot > 0)
|
2010-08-08 00:55:27 +00:00
|
|
|
_vm->_vidPlayer->closeVideo(obj.videoSlot - 1);
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
obj.videoSlot = 0;
|
|
|
|
obj.lastLeft = -1;
|
|
|
|
obj.lastTop = -1;
|
|
|
|
obj.lastBottom = -1;
|
|
|
|
obj.lastRight = -1;
|
|
|
|
}
|
|
|
|
|
2006-08-12 09:16:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_renderStatic() {
|
|
|
|
int16 layer;
|
|
|
|
int16 index;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = _vm->_game->_script->readValExpr();
|
|
|
|
layer = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->renderStatic(index, layer);
|
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_loadCurLayer() {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_scenery->_curStatic = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_scenery->_curStaticLayer = _vm->_game->_script->readValExpr();
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_playCDTrack() {
|
|
|
|
if (!(_vm->_draw->_renderFlags & RENDERFLAG_NOBLITINVALIDATED))
|
|
|
|
_vm->_draw->blitInvalidated();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_sound->cdPlay(_vm->_game->_script->getResultStr());
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_waitCDTrackEnd() {
|
2008-05-17 19:01:00 +00:00
|
|
|
debugC(1, kDebugSound, "CDROM: Waiting for playback to end");
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
while (_vm->_sound->cdGetTrackPos() >= 0)
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_util->longDelay(1);
|
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_stopCD() {
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->cdStop();
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_readLIC() {
|
|
|
|
char path[40];
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
strncpy0(path, _vm->_game->_script->getResultStr(), 35);
|
2007-03-20 14:51:57 +00:00
|
|
|
strcat(path, ".LIC");
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->cdLoadLIC(path);
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_freeLIC() {
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->cdUnloadLIC();
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2007-01-28 13:19:17 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_getCDTrackPos() {
|
|
|
|
int16 varPos;
|
|
|
|
int16 varName;
|
|
|
|
|
|
|
|
_vm->_util->longDelay(1);
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
varPos = _vm->_game->_script->readVarIndex();
|
|
|
|
varName = _vm->_game->_script->readVarIndex();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
WRITE_VAR_OFFSET(varPos, _vm->_sound->cdGetTrackPos(GET_VARO_STR(varName)));
|
|
|
|
WRITE_VARO_STR(varName, _vm->_sound->cdGetCurrentTrack());
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_loadFontToSprite() {
|
2009-06-22 10:13:37 +00:00
|
|
|
int16 i = _vm->_game->_script->readInt16();
|
|
|
|
|
|
|
|
_vm->_draw->_fontToSprite[i].sprite = _vm->_game->_script->readByte();
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
_vm->_draw->_fontToSprite[i].base = _vm->_game->_script->readByte();
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
_vm->_draw->_fontToSprite[i].width = _vm->_game->_script->readByte();
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
_vm->_draw->_fontToSprite[i].height = _vm->_game->_script->readByte();
|
|
|
|
_vm->_game->_script->skip(1);
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_totSub() {
|
|
|
|
char totFile[14];
|
|
|
|
byte length;
|
|
|
|
int flags;
|
|
|
|
int i;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
length = _vm->_game->_script->readByte();
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((length & 0x7F) > 13)
|
|
|
|
error("Length in o2_totSub is greater than 13 (%d)", length);
|
|
|
|
|
|
|
|
if (length & 0x80) {
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
strcpy(totFile, _vm->_game->_script->getResultStr());
|
2007-01-28 13:19:17 +00:00
|
|
|
} else {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (i = 0; i < length; i++)
|
2009-06-22 10:13:37 +00:00
|
|
|
totFile[i] = _vm->_game->_script->readChar();
|
2007-03-20 14:51:57 +00:00
|
|
|
totFile[i] = 0;
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// WORKAROUND: There is a race condition in the script when opening the notepad
|
|
|
|
if (!scumm_stricmp(totFile, "edit"))
|
|
|
|
_vm->_util->forceMouseUp();
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
// WORKAROUND: For some reason, the variable indicating which TOT to load next
|
|
|
|
// is overwritten in the guard house card game in Woodruff
|
|
|
|
if ((_vm->getGameType() == kGameTypeWoodruff) && !scumm_stricmp(totFile, "6"))
|
|
|
|
strcpy(totFile, "EMAP2011");
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
flags = _vm->_game->_script->readByte();
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_game->totSub(flags, totFile);
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_switchTotSub() {
|
|
|
|
int16 index;
|
|
|
|
int16 skipPlay;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = _vm->_game->_script->readInt16();
|
|
|
|
skipPlay = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
_vm->_game->switchTotSub(index, skipPlay);
|
|
|
|
}
|
|
|
|
|
2008-12-18 02:48:15 +00:00
|
|
|
void Inter_v2::o2_pushVars() {
|
2006-11-20 13:03:30 +00:00
|
|
|
byte count;
|
|
|
|
int16 varOff;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
count = _vm->_game->_script->readByte();
|
2008-12-18 02:48:15 +00:00
|
|
|
for (int i = 0; i < count; i++, _varStackPos++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
if ((_vm->_game->_script->peekByte() == 25) ||
|
|
|
|
(_vm->_game->_script->peekByte() == 28)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
varOff = _vm->_game->_script->readVarIndex();
|
|
|
|
_vm->_game->_script->skip(1);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-05-31 02:15:43 +00:00
|
|
|
_variables->copyTo(varOff, _varStack + _varStackPos, _vm->_global->_inter_animDataSize * 4);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-12-18 02:48:15 +00:00
|
|
|
_varStackPos += _vm->_global->_inter_animDataSize * 4;
|
|
|
|
_varStack[_varStackPos] = _vm->_global->_inter_animDataSize * 4;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2006-11-20 13:03:30 +00:00
|
|
|
} else {
|
2009-06-22 10:13:37 +00:00
|
|
|
int32 n = _vm->_game->_script->getResultInt();
|
2009-06-22 10:11:25 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
if (_vm->_game->_script->evalExpr(&varOff) != 20)
|
2009-06-22 10:11:25 +00:00
|
|
|
n = 0;
|
2008-05-28 21:15:11 +00:00
|
|
|
|
2009-06-22 10:11:25 +00:00
|
|
|
memcpy(_varStack + _varStackPos, &n, 4);
|
2008-12-18 02:48:15 +00:00
|
|
|
_varStackPos += 4;
|
|
|
|
_varStack[_varStackPos] = 4;
|
2006-11-20 13:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-18 02:48:15 +00:00
|
|
|
void Inter_v2::o2_popVars() {
|
2006-11-20 13:03:30 +00:00
|
|
|
byte count;
|
|
|
|
int16 varOff;
|
2009-05-31 02:15:43 +00:00
|
|
|
int16 size;
|
2006-11-20 13:03:30 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
count = _vm->_game->_script->readByte();
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
varOff = _vm->_game->_script->readVarIndex();
|
2009-05-31 02:15:43 +00:00
|
|
|
size = _varStack[--_varStackPos];
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-05-31 02:15:43 +00:00
|
|
|
_varStackPos -= size;
|
|
|
|
_variables->copyFrom(varOff, _varStack + _varStackPos, size);
|
2006-11-20 13:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_loadMapObjects() {
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_map->loadMapObjects(0);
|
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_freeGoblins() {
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->freeObjects();
|
|
|
|
}
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_moveGoblin() {
|
|
|
|
int16 destX, destY;
|
2006-05-11 19:43:30 +00:00
|
|
|
int16 index;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
destX = _vm->_game->_script->readValExpr();
|
|
|
|
destY = _vm->_game->_script->readValExpr();
|
|
|
|
index = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->move(destX, destY, index);
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_writeGoblinPos() {
|
|
|
|
int16 varX, varY;
|
2006-06-07 18:49:20 +00:00
|
|
|
int16 index;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
varX = _vm->_game->_script->readVarIndex();
|
|
|
|
varY = _vm->_game->_script->readVarIndex();
|
|
|
|
index = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR_OFFSET(varX, _vm->_mult->_objects[index].goblinX);
|
|
|
|
WRITE_VAR_OFFSET(varY, _vm->_mult->_objects[index].goblinY);
|
2006-05-29 18:24:52 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_stopGoblin() {
|
2009-06-22 10:13:37 +00:00
|
|
|
int16 index = _vm->_game->_script->readValExpr();
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_mult->_objects[index].pAnimData->pathExistence = 4;
|
2006-05-01 16:04:53 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_setGoblinState() {
|
2006-04-14 18:18:46 +00:00
|
|
|
int16 index;
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 state;
|
|
|
|
int16 type;
|
|
|
|
int16 layer;
|
|
|
|
int16 animation;
|
|
|
|
int16 deltaX, deltaY;
|
|
|
|
int16 deltaWidth, deltaHeight;
|
2006-04-14 18:18:46 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = _vm->_game->_script->readValExpr();
|
|
|
|
state = _vm->_game->_script->readValExpr();
|
|
|
|
type = _vm->_game->_script->readValExpr();
|
2006-04-14 18:18:46 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
Mult::Mult_Object &obj = _vm->_mult->_objects[index];
|
|
|
|
Mult::Mult_AnimData &objAnim = *(obj.pAnimData);
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
objAnim.stateType = type;
|
|
|
|
if (!obj.goblinStates[state])
|
|
|
|
return;
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
Scenery::AnimLayer *animLayer;
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
objAnim.frame = 0;
|
|
|
|
layer = obj.goblinStates[state][0].layer;
|
|
|
|
animation = obj.goblinStates[state][0].animation;
|
|
|
|
objAnim.state = state;
|
|
|
|
objAnim.layer = layer;
|
|
|
|
objAnim.animation = animation;
|
|
|
|
|
|
|
|
animLayer = _vm->_scenery->getAnimLayer(animation, layer);
|
|
|
|
*(obj.pPosX) = animLayer->posX;
|
|
|
|
*(obj.pPosY) = animLayer->posY;
|
|
|
|
objAnim.isPaused = 0;
|
|
|
|
objAnim.isStatic = 0;
|
|
|
|
objAnim.newCycle = animLayer->framesCount;
|
|
|
|
break;
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2007-03-20 14:51:57 +00:00
|
|
|
case 6:
|
|
|
|
layer = obj.goblinStates[objAnim.state][0].layer;
|
|
|
|
animation = obj.goblinStates[objAnim.state][0].animation;
|
|
|
|
_vm->_scenery->updateAnim(layer, 0, animation, 0,
|
|
|
|
*(obj.pPosX), *(obj.pPosY), 0);
|
|
|
|
|
|
|
|
deltaHeight = _vm->_scenery->_animBottom - _vm->_scenery->_animTop;
|
|
|
|
deltaWidth = _vm->_scenery->_animRight - _vm->_scenery->_animLeft;
|
|
|
|
|
|
|
|
animLayer =
|
|
|
|
_vm->_scenery->getAnimLayer(objAnim.animation, objAnim.layer);
|
|
|
|
deltaX = animLayer->animDeltaX;
|
|
|
|
deltaY = animLayer->animDeltaY;
|
|
|
|
|
|
|
|
layer = obj.goblinStates[state][0].layer;
|
|
|
|
animation = obj.goblinStates[state][0].animation;
|
|
|
|
objAnim.state = state;
|
|
|
|
objAnim.layer = layer;
|
|
|
|
objAnim.animation = animation;
|
|
|
|
objAnim.frame = 0;
|
|
|
|
objAnim.isPaused = 0;
|
|
|
|
objAnim.isStatic = 0;
|
|
|
|
|
|
|
|
animLayer = _vm->_scenery->getAnimLayer(animation, layer);
|
|
|
|
objAnim.newCycle = animLayer->framesCount;
|
|
|
|
|
|
|
|
_vm->_scenery->updateAnim(layer, 0, animation, 0,
|
|
|
|
*(obj.pPosX), *(obj.pPosY), 0);
|
|
|
|
|
|
|
|
deltaHeight -= _vm->_scenery->_animBottom - _vm->_scenery->_animTop;
|
|
|
|
deltaWidth -= _vm->_scenery->_animRight - _vm->_scenery->_animLeft;
|
|
|
|
*(obj.pPosX) += deltaWidth + deltaX;
|
|
|
|
*(obj.pPosY) += deltaHeight + deltaY;
|
|
|
|
break;
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
case 11:
|
|
|
|
layer = obj.goblinStates[state][0].layer;
|
|
|
|
animation = obj.goblinStates[state][0].animation;
|
|
|
|
objAnim.state = state;
|
|
|
|
objAnim.layer = layer;
|
|
|
|
objAnim.animation = animation;
|
|
|
|
objAnim.frame = 0;
|
|
|
|
objAnim.isPaused = 0;
|
|
|
|
objAnim.isStatic = 0;
|
|
|
|
|
|
|
|
animLayer = _vm->_scenery->getAnimLayer(animation, layer);
|
|
|
|
objAnim.newCycle = animLayer->framesCount;
|
|
|
|
_vm->_scenery->updateAnim(layer, 0, animation, 0,
|
|
|
|
*(obj.pPosX), *(obj.pPosY), 0);
|
|
|
|
|
|
|
|
if (_vm->_map->_bigTiles)
|
|
|
|
*(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
|
|
|
|
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) -
|
|
|
|
((obj.goblinY + 1) / 2);
|
|
|
|
else
|
|
|
|
*(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
|
|
|
|
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
|
|
|
|
*(obj.pPosX) = obj.goblinX * _vm->_map->_tilesWidth;
|
|
|
|
break;
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_placeGoblin() {
|
|
|
|
int16 index;
|
|
|
|
int16 x, y;
|
|
|
|
int16 state;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = _vm->_game->_script->readValExpr();
|
|
|
|
x = _vm->_game->_script->readValExpr();
|
|
|
|
y = _vm->_game->_script->readValExpr();
|
|
|
|
state = _vm->_game->_script->readValExpr();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->placeObject(0, 0, index, x, y, state);
|
2006-11-19 17:52:52 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_initScreen() {
|
|
|
|
int16 offY;
|
|
|
|
int16 videoMode;
|
|
|
|
int16 width, height;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
offY = _vm->_game->_script->readInt16();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
videoMode = offY & 0xFF;
|
|
|
|
offY = (offY >> 8) & 0xFF;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
width = _vm->_game->_script->readValExpr();
|
|
|
|
height = _vm->_game->_script->readValExpr();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2008-05-03 20:08:46 +00:00
|
|
|
_vm->_video->clearScreen();
|
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
// Lost in Time switches to 640x400x16 when showing the title screen
|
|
|
|
if (_vm->getGameType() == kGameTypeLostInTime) {
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
if (videoMode == 0x10) {
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
width = _vm->_width = 640;
|
|
|
|
height = _vm->_height = 400;
|
|
|
|
_vm->_global->_colorCount = 16;
|
2008-05-03 20:08:46 +00:00
|
|
|
|
|
|
|
_vm->_video->setSize(true);
|
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
} else if (_vm->_global->_videoMode == 0x10) {
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
if (width == -1)
|
|
|
|
width = 320;
|
|
|
|
if (height == -1)
|
|
|
|
height = 200;
|
|
|
|
|
|
|
|
_vm->_width = 320;
|
|
|
|
_vm->_height = 200;
|
|
|
|
_vm->_global->_colorCount = 256;
|
2008-05-03 20:08:46 +00:00
|
|
|
|
|
|
|
_vm->_video->setSize(false);
|
|
|
|
|
2007-08-03 17:51:36 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-03 15:18:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_fakeVideoMode = videoMode;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Some versions require this
|
2007-08-03 17:51:36 +00:00
|
|
|
if (videoMode == 0xD)
|
2007-07-24 23:24:40 +00:00
|
|
|
videoMode = _vm->_mode;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((videoMode == _vm->_global->_videoMode) && (width == -1))
|
|
|
|
return;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (width > 0)
|
|
|
|
_vm->_video->_surfWidth = width;
|
|
|
|
if (height > 0)
|
|
|
|
_vm->_video->_surfHeight = height;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-05-17 23:55:04 +00:00
|
|
|
_vm->_video->_splitHeight1 = MIN<int16>(_vm->_height, _vm->_video->_surfHeight - offY);
|
|
|
|
_vm->_video->_splitHeight2 = offY;
|
|
|
|
_vm->_video->_splitStart = _vm->_video->_surfHeight - offY;
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2008-05-17 23:55:04 +00:00
|
|
|
_vm->_video->_screenDeltaX = 0;
|
|
|
|
_vm->_video->_screenDeltaY = 0;
|
2008-05-13 23:22:31 +00:00
|
|
|
|
2008-05-17 23:55:04 +00:00
|
|
|
_vm->_global->_mouseMinX = 0;
|
|
|
|
_vm->_global->_mouseMinY = 0;
|
|
|
|
_vm->_global->_mouseMaxX = _vm->_width;
|
|
|
|
_vm->_global->_mouseMaxY = _vm->_height - _vm->_video->_splitHeight2 - 1;
|
2007-04-05 13:37:20 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->closeScreen();
|
|
|
|
_vm->_util->clearPalette();
|
|
|
|
memset(_vm->_global->_redPalette, 0, 256);
|
|
|
|
memset(_vm->_global->_greenPalette, 0, 256);
|
|
|
|
memset(_vm->_global->_bluePalette, 0, 256);
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_videoMode = videoMode;
|
|
|
|
_vm->_video->initPrimary(videoMode);
|
|
|
|
WRITE_VAR(15, _vm->_global->_fakeVideoMode);
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_setAllPalette = true;
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_util->setMousePos(_vm->_global->_inter_mouseX,
|
|
|
|
_vm->_global->_inter_mouseY);
|
|
|
|
_vm->_util->clearPalette();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->initScreen();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_util->setScrollOffset();
|
2006-11-19 17:52:52 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_scroll() {
|
|
|
|
int16 startX;
|
|
|
|
int16 startY;
|
|
|
|
int16 endX;
|
|
|
|
int16 endY;
|
|
|
|
int16 stepX;
|
|
|
|
int16 stepY;
|
|
|
|
int16 curX;
|
|
|
|
int16 curY;
|
2006-06-29 12:55:57 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
startX = CLIP((int) _vm->_game->_script->readValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfWidth - _vm->_width);
|
2009-06-22 10:13:37 +00:00
|
|
|
startY = CLIP((int) _vm->_game->_script->readValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfHeight - _vm->_height);
|
2009-06-22 10:13:37 +00:00
|
|
|
endX = CLIP((int) _vm->_game->_script->readValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfWidth - _vm->_width);
|
2009-06-22 10:13:37 +00:00
|
|
|
endY = CLIP((int) _vm->_game->_script->readValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfHeight - _vm->_height);
|
2009-06-22 10:13:37 +00:00
|
|
|
stepX = _vm->_game->_script->readValExpr();
|
|
|
|
stepY = _vm->_game->_script->readValExpr();
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
curX = startX;
|
|
|
|
curY = startY;
|
2008-09-30 12:27:38 +00:00
|
|
|
while (!_vm->shouldQuit() && ((curX != endX) || (curY != endY))) {
|
2007-03-20 14:51:57 +00:00
|
|
|
curX = stepX > 0 ? MIN(curX + stepX, (int) endX) :
|
|
|
|
MAX(curX + stepX, (int) endX);
|
|
|
|
curY = stepY > 0 ? MIN(curY + stepY, (int) endY) :
|
|
|
|
MAX(curY + stepY, (int) endY);
|
2006-11-19 17:52:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_scrollOffsetX = curX;
|
|
|
|
_vm->_draw->_scrollOffsetY = curY;
|
|
|
|
_vm->_util->setScrollOffset();
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2006-11-19 17:52:52 +00:00
|
|
|
}
|
2006-06-01 12:18:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_setScrollOffset() {
|
2008-05-26 22:02:20 +00:00
|
|
|
int16 offsetX, offsetY;
|
2006-06-01 12:18:12 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
offsetX = _vm->_game->_script->readValExpr();
|
|
|
|
offsetY = _vm->_game->_script->readValExpr();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2008-05-26 22:02:20 +00:00
|
|
|
if (offsetX == -1) {
|
2009-08-08 21:43:07 +00:00
|
|
|
_vm->_game->_preventScroll = !_vm->_game->_preventScroll;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR(2, _vm->_draw->_scrollOffsetX);
|
|
|
|
WRITE_VAR(3, _vm->_draw->_scrollOffsetY);
|
2006-05-11 19:43:30 +00:00
|
|
|
} else {
|
2008-05-26 22:02:20 +00:00
|
|
|
int16 screenW = _vm->_video->_surfWidth;
|
|
|
|
int16 screenH = _vm->_video->_surfHeight;
|
|
|
|
|
|
|
|
if (screenW > _vm->_width)
|
|
|
|
screenW -= _vm->_width;
|
|
|
|
if (screenH > _vm->_height)
|
|
|
|
screenH -= _vm->_height;
|
|
|
|
|
|
|
|
_vm->_draw->_scrollOffsetX = CLIP<int16>(offsetX, 0, screenW);
|
|
|
|
_vm->_draw->_scrollOffsetY = CLIP<int16>(offsetY, 0, screenH);
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2006-12-18 20:38:31 +00:00
|
|
|
}
|
2008-05-26 22:02:20 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_util->setScrollOffset();
|
|
|
|
_noBusyWait = true;
|
2006-12-18 20:38:31 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_playImd() {
|
|
|
|
char imd[128];
|
|
|
|
bool close;
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->getResultStr()[8] = 0;
|
|
|
|
strncpy0(imd, _vm->_game->_script->getResultStr(), 127);
|
|
|
|
|
2010-08-08 00:41:22 +00:00
|
|
|
VideoPlayer::Properties props;
|
|
|
|
|
|
|
|
props.x = _vm->_game->_script->readValExpr();
|
|
|
|
props.y = _vm->_game->_script->readValExpr();
|
|
|
|
props.startFrame = _vm->_game->_script->readValExpr();
|
|
|
|
props.lastFrame = _vm->_game->_script->readValExpr();
|
|
|
|
props.breakKey = _vm->_game->_script->readValExpr();
|
|
|
|
props.flags = _vm->_game->_script->readValExpr();
|
|
|
|
props.palStart = _vm->_game->_script->readValExpr();
|
|
|
|
props.palEnd = _vm->_game->_script->readValExpr();
|
|
|
|
props.palCmd = 1 << (props.flags & 0x3F);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-05-17 19:23:44 +00:00
|
|
|
debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "
|
2010-08-08 00:41:22 +00:00
|
|
|
"paletteCmd %d (%d - %d), flags %X", imd,
|
|
|
|
props.x, props.y, props.startFrame, props.lastFrame,
|
|
|
|
props.palCmd, props.palStart, props.palEnd, props.flags);
|
2008-05-17 19:23:44 +00:00
|
|
|
|
2010-08-08 00:47:54 +00:00
|
|
|
int slot = 0;
|
|
|
|
if (imd[0] != 0) {
|
|
|
|
_vm->_vidPlayer->evaluateFlags(props);
|
|
|
|
if ((slot = _vm->_vidPlayer->openVideo(true, imd, props)) < 0) {
|
|
|
|
WRITE_VAR(11, (uint32) -1);
|
|
|
|
return;
|
|
|
|
}
|
2007-03-29 17:55:39 +00:00
|
|
|
}
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2010-08-08 00:41:22 +00:00
|
|
|
close = (props.lastFrame == -1);
|
|
|
|
if (props.startFrame == -2) {
|
|
|
|
props.startFrame = 0;
|
|
|
|
props.lastFrame = 0;
|
2007-03-29 17:55:39 +00:00
|
|
|
close = false;
|
|
|
|
}
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2010-08-08 00:41:22 +00:00
|
|
|
if (props.startFrame >= 0)
|
|
|
|
_vm->_vidPlayer->play(slot, props);
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (close)
|
2010-08-08 00:41:22 +00:00
|
|
|
_vm->_vidPlayer->closeVideo(slot);
|
2006-02-02 21:12:00 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_getImdInfo() {
|
|
|
|
int16 varX, varY;
|
|
|
|
int16 varFrames;
|
|
|
|
int16 varWidth, varHeight;
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2010-08-08 00:41:22 +00:00
|
|
|
varX = _vm->_game->_script->readVarIndex();
|
|
|
|
varY = _vm->_game->_script->readVarIndex();
|
2009-06-22 10:13:37 +00:00
|
|
|
varFrames = _vm->_game->_script->readVarIndex();
|
2010-08-08 00:41:22 +00:00
|
|
|
varWidth = _vm->_game->_script->readVarIndex();
|
2009-06-22 10:13:37 +00:00
|
|
|
varHeight = _vm->_game->_script->readVarIndex();
|
2007-07-30 15:53:38 +00:00
|
|
|
|
2008-05-25 13:02:23 +00:00
|
|
|
// WORKAROUND: The nut rolling animation in the administration center
|
|
|
|
// in Woodruff is called "noixroul", but the scripts think it's "noixroule".
|
|
|
|
if ((_vm->getGameType() == kGameTypeWoodruff) &&
|
2009-06-22 10:13:37 +00:00
|
|
|
(!scumm_stricmp(_vm->_game->_script->getResultStr(), "noixroule")))
|
|
|
|
strcpy(_vm->_game->_script->getResultStr(), "noixroul");
|
2008-05-25 13:02:23 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_vidPlayer->writeVideoInfo(_vm->_game->_script->getResultStr(), varX, varY,
|
2007-07-30 15:53:38 +00:00
|
|
|
varFrames, varWidth, varHeight);
|
2006-02-02 21:12:00 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_openItk() {
|
|
|
|
char fileName[32];
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
strncpy0(fileName, _vm->_game->_script->getResultStr(), 27);
|
2007-08-13 14:04:50 +00:00
|
|
|
if (!strchr(fileName, '.'))
|
|
|
|
strcat(fileName, ".ITK");
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->openDataFile(fileName, true);
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_closeItk() {
|
|
|
|
_vm->_dataIO->closeDataFile(true);
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_setImdFrontSurf() {
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_resetImdFrontSurf() {
|
|
|
|
}
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-06 23:39:58 +00:00
|
|
|
bool Inter_v2::o2_assign(OpFuncParams ¶ms) {
|
2009-06-22 10:13:37 +00:00
|
|
|
byte destType = _vm->_game->_script->peekByte();
|
|
|
|
int16 dest = _vm->_game->_script->readVarIndex();
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:08:28 +00:00
|
|
|
byte loopCount;
|
2009-06-22 10:13:37 +00:00
|
|
|
if (_vm->_game->_script->peekByte() == 99) {
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
loopCount = _vm->_game->_script->readByte();
|
2007-04-05 16:04:59 +00:00
|
|
|
} else
|
2007-03-20 14:51:57 +00:00
|
|
|
loopCount = 1;
|
2007-03-02 11:37:42 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < loopCount; i++) {
|
2009-06-15 23:08:28 +00:00
|
|
|
int16 result;
|
2009-06-22 10:29:32 +00:00
|
|
|
int16 srcType = _vm->_game->_script->evalExpr(&result);
|
2009-06-15 23:08:28 +00:00
|
|
|
|
2009-06-15 23:09:37 +00:00
|
|
|
switch (destType) {
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT8:
|
|
|
|
case TYPE_ARRAY_INT8:
|
2009-06-22 10:13:37 +00:00
|
|
|
WRITE_VARO_UINT8(dest + i, _vm->_game->_script->getResultInt());
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT16:
|
|
|
|
case TYPE_ARRAY_INT16:
|
2009-06-22 10:13:37 +00:00
|
|
|
WRITE_VARO_UINT16(dest + i * 2, _vm->_game->_script->getResultInt());
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT32:
|
|
|
|
case TYPE_ARRAY_INT32:
|
2009-06-22 10:13:37 +00:00
|
|
|
WRITE_VAR_OFFSET(dest + i * 4, _vm->_game->_script->getResultInt());
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT32_AS_INT16:
|
2009-06-22 10:13:37 +00:00
|
|
|
WRITE_VARO_UINT16(dest + i * 4, _vm->_game->_script->getResultInt());
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_STR:
|
|
|
|
case TYPE_ARRAY_STR:
|
2009-06-15 23:09:37 +00:00
|
|
|
if (srcType == TYPE_IMM_INT16)
|
2009-06-15 23:08:28 +00:00
|
|
|
WRITE_VARO_UINT8(dest, result);
|
2007-03-20 14:51:57 +00:00
|
|
|
else
|
2009-06-22 10:13:37 +00:00
|
|
|
WRITE_VARO_STR(dest, _vm->_game->_script->getResultStr());
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-02-16 20:25:59 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
2006-02-16 20:25:59 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_printText(OpFuncParams ¶ms) {
|
|
|
|
char buf[60];
|
|
|
|
int i;
|
2006-07-08 16:37:23 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
|
|
|
|
_vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_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;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_textToPrint = buf;
|
|
|
|
_vm->_draw->_transparency = 0;
|
|
|
|
|
|
|
|
if (_vm->_draw->_backColor == 16) {
|
|
|
|
_vm->_draw->_backColor = 0;
|
|
|
|
_vm->_draw->_transparency = 1;
|
2006-07-08 16:37:23 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
do {
|
2009-06-22 10:13:37 +00:00
|
|
|
for (i = 0; (_vm->_game->_script->peekChar() != '.') &&
|
|
|
|
(_vm->_game->_script->peekByte() != 200); i++) {
|
|
|
|
buf[i] = _vm->_game->_script->readChar();
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
if (_vm->_game->_script->peekByte() != 200) {
|
|
|
|
_vm->_game->_script->skip(1);
|
|
|
|
switch (_vm->_game->_script->peekByte()) {
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT8:
|
|
|
|
case TYPE_ARRAY_INT8:
|
2007-03-20 14:51:57 +00:00
|
|
|
sprintf(buf + i, "%d",
|
2009-06-22 10:13:37 +00:00
|
|
|
(int8) READ_VARO_UINT8(_vm->_game->_script->readVarIndex()));
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT16:
|
|
|
|
case TYPE_VAR_INT32_AS_INT16:
|
|
|
|
case TYPE_ARRAY_INT16:
|
2007-03-20 14:51:57 +00:00
|
|
|
sprintf(buf + i, "%d",
|
2009-06-22 10:13:37 +00:00
|
|
|
(int16) READ_VARO_UINT16(_vm->_game->_script->readVarIndex()));
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_INT32:
|
|
|
|
case TYPE_ARRAY_INT32:
|
2007-03-20 14:51:57 +00:00
|
|
|
sprintf(buf + i, "%d",
|
2009-06-22 10:13:37 +00:00
|
|
|
VAR_OFFSET(_vm->_game->_script->readVarIndex()));
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_VAR_STR:
|
|
|
|
case TYPE_ARRAY_STR:
|
2007-03-20 14:51:57 +00:00
|
|
|
sprintf(buf + i, "%s",
|
2009-06-22 10:13:37 +00:00
|
|
|
GET_VARO_STR(_vm->_game->_script->readVarIndex()));
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
|
|
|
buf[i] = 0;
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_PRINTTEXT);
|
2009-06-22 10:13:37 +00:00
|
|
|
} while (_vm->_game->_script->peekByte() != 200);
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(1);
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_animPalInit(OpFuncParams ¶ms) {
|
|
|
|
int16 index;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
if (index > 0) {
|
|
|
|
index--;
|
2009-06-22 10:13:37 +00:00
|
|
|
_animPalLowIndex[index] = _vm->_game->_script->readValExpr();
|
|
|
|
_animPalHighIndex[index] = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
_animPalDir[index] = 1;
|
|
|
|
} else if (index == 0) {
|
|
|
|
memset(_animPalDir, 0, 8 * sizeof(int16));
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->readValExpr();
|
|
|
|
_vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
} else {
|
|
|
|
index = -index - 1;
|
2009-06-22 10:13:37 +00:00
|
|
|
_animPalLowIndex[index] = _vm->_game->_script->readValExpr();
|
|
|
|
_animPalHighIndex[index] = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
_animPalDir[index] = -1;
|
|
|
|
}
|
|
|
|
return false;
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 21:39:55 +00:00
|
|
|
bool Inter_v2::o2_addHotspot(OpFuncParams ¶ms) {
|
2009-07-05 11:27:54 +00:00
|
|
|
int16 id = _vm->_game->_script->readValExpr();
|
|
|
|
uint16 funcPos = _vm->_game->_script->pos();
|
|
|
|
int16 left = _vm->_game->_script->readValExpr();
|
|
|
|
int16 top = _vm->_game->_script->readValExpr();
|
|
|
|
uint16 width = _vm->_game->_script->readValExpr();
|
|
|
|
uint16 height = _vm->_game->_script->readValExpr();
|
|
|
|
uint16 flags = _vm->_game->_script->readValExpr();
|
|
|
|
uint16 key = _vm->_game->_script->readInt16();
|
2007-07-26 01:01:00 +00:00
|
|
|
|
|
|
|
if (key == 0)
|
|
|
|
key = ABS(id) + 41960;
|
|
|
|
|
|
|
|
if (left < 0) {
|
|
|
|
width += left;
|
2009-07-05 11:27:54 +00:00
|
|
|
left = 0;
|
2007-07-26 01:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (top < 0) {
|
|
|
|
height += top;
|
2009-07-05 11:27:54 +00:00
|
|
|
top = 0;
|
2007-07-26 01:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 index;
|
|
|
|
if (id < 0)
|
2009-07-05 11:27:54 +00:00
|
|
|
index = _vm->_game->_hotspots->add(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
|
|
|
|
left + width + 3, top + height + 3, flags, key, 0, 0, funcPos);
|
2007-07-26 01:01:00 +00:00
|
|
|
else
|
2009-07-05 11:27:54 +00:00
|
|
|
index = _vm->_game->_hotspots->add(0xE000 + id, left, top,
|
|
|
|
left + width - 1, top + height - 1, flags, key, 0, 0, funcPos);
|
2007-07-26 01:01:00 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-05 21:39:55 +00:00
|
|
|
bool Inter_v2::o2_removeHotspot(OpFuncParams ¶ms) {
|
2009-07-05 11:27:54 +00:00
|
|
|
int16 id = _vm->_game->_script->readValExpr();
|
2009-07-05 21:40:51 +00:00
|
|
|
uint8 stateType1 = Hotspots::kStateFilledDisabled | Hotspots::kStateType1;
|
|
|
|
uint8 stateType2 = Hotspots::kStateFilledDisabled | Hotspots::kStateType2;
|
2007-07-26 01:01:00 +00:00
|
|
|
|
2009-07-05 21:40:51 +00:00
|
|
|
if (id == -2)
|
|
|
|
_vm->_game->_hotspots->removeState(stateType1);
|
2009-07-05 11:27:54 +00:00
|
|
|
else if (id == -1)
|
2009-07-05 21:40:51 +00:00
|
|
|
_vm->_game->_hotspots->removeState(stateType2);
|
2009-07-05 11:27:54 +00:00
|
|
|
else
|
2009-07-05 21:40:51 +00:00
|
|
|
_vm->_game->_hotspots->remove((stateType2 << 12) + id);
|
2007-07-26 01:01:00 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_goblinFunc(OpFuncParams ¶ms) {
|
2008-03-02 23:57:29 +00:00
|
|
|
// TODO: In Inca 2, this is the big SpaceShoot0rz()-Opcode.
|
|
|
|
// It's not yet implemented, so we fudge our way through
|
|
|
|
// and pretend we've won.
|
|
|
|
if (_vm->getGameType() == kGameTypeInca2) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(4);
|
|
|
|
uint16 resVar = _vm->_game->_script->readUint16();
|
|
|
|
_vm->_game->_script->skip(4);
|
2008-03-02 23:57:29 +00:00
|
|
|
|
|
|
|
WRITE_VAR(resVar, 1);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
OpGobParams gobParams;
|
|
|
|
int16 cmd;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
cmd = _vm->_game->_script->readInt16();
|
2009-06-19 09:43:01 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
gobParams.paramCount = _vm->_game->_script->readInt16();
|
2009-06-19 09:43:01 +00:00
|
|
|
gobParams.extraData = cmd;
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (cmd != 101)
|
2009-06-17 04:16:51 +00:00
|
|
|
executeOpcodeGob(cmd, gobParams);
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
2006-02-16 20:25:59 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_stopSound(OpFuncParams ¶ms) {
|
|
|
|
int16 expr;
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
expr = _vm->_game->_script->readValExpr();
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (expr < 0) {
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->adlibStop();
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->blasterStop(expr);
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_soundEndTimeKey = 0;
|
|
|
|
return false;
|
|
|
|
}
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_loadSound(OpFuncParams ¶ms) {
|
|
|
|
loadSound(0);
|
|
|
|
return false;
|
|
|
|
}
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_getFreeMem(OpFuncParams ¶ms) {
|
2009-08-24 22:37:09 +00:00
|
|
|
uint16 freeVar;
|
|
|
|
uint16 maxFreeVar;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-08-24 22:37:09 +00:00
|
|
|
freeVar = _vm->_game->_script->readVarIndex();
|
2009-06-22 10:13:37 +00:00
|
|
|
maxFreeVar = _vm->_game->_script->readVarIndex();
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// HACK
|
2009-08-24 22:37:09 +00:00
|
|
|
WRITE_VAR_OFFSET(freeVar , 1000000);
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR_OFFSET(maxFreeVar, 1000000);
|
2009-06-23 01:20:05 +00:00
|
|
|
WRITE_VAR(16, _vm->_game->_script->getVariablesCount() * 4);
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-02-12 12:53:28 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_checkData(OpFuncParams ¶ms) {
|
|
|
|
int16 handle;
|
|
|
|
int16 varOff;
|
|
|
|
int32 size;
|
2008-05-10 20:59:43 +00:00
|
|
|
SaveLoad::SaveMode mode;
|
2007-02-12 12:53:28 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
varOff = _vm->_game->_script->readVarIndex();
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-04-05 16:04:59 +00:00
|
|
|
size = -1;
|
2007-03-20 14:51:57 +00:00
|
|
|
handle = 1;
|
2007-04-08 00:08:26 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
char *file = _vm->_game->_script->getResultStr();
|
|
|
|
|
|
|
|
// WORKAROUND: For some reason, the variable indicating which TOT to load next
|
2009-08-10 20:57:26 +00:00
|
|
|
// is overwritten in the guard house card game in Woodruff.
|
2009-07-18 13:05:36 +00:00
|
|
|
if ((_vm->getGameType() == kGameTypeWoodruff) && !scumm_stricmp(file, "6.TOT"))
|
|
|
|
strcpy(file, "EMAP2011.TOT");
|
|
|
|
|
|
|
|
mode = _vm->_saveLoad->getSaveMode(file);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeNone) {
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
if (_vm->_dataIO->existData(file))
|
|
|
|
size = _vm->_dataIO->getDataSize(file);
|
2009-06-22 10:12:33 +00:00
|
|
|
else
|
2009-07-18 13:05:36 +00:00
|
|
|
warning("File \"%s\" not found", file);
|
2009-06-22 10:12:33 +00:00
|
|
|
|
2008-05-10 20:59:43 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeSave)
|
2009-07-18 13:05:36 +00:00
|
|
|
size = _vm->_saveLoad->getSize(file);
|
2008-12-13 13:18:16 +00:00
|
|
|
else if (mode == SaveLoad::kSaveModeExists)
|
|
|
|
size = 23;
|
2007-04-08 00:08:26 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (size == -1)
|
|
|
|
handle = -1;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-04-08 00:08:26 +00:00
|
|
|
debugC(2, kDebugFileIO, "Requested size of file \"%s\": %d",
|
2009-07-18 13:05:36 +00:00
|
|
|
file, size);
|
2007-04-08 00:08:26 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR_OFFSET(varOff, handle);
|
|
|
|
WRITE_VAR(16, (uint32) size);
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_readData(OpFuncParams ¶ms) {
|
|
|
|
int32 retSize;
|
|
|
|
int32 size;
|
|
|
|
int32 offset;
|
|
|
|
int16 dataVar;
|
|
|
|
int16 handle;
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *buf;
|
2008-05-10 20:59:43 +00:00
|
|
|
SaveLoad::SaveMode mode;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
dataVar = _vm->_game->_script->readVarIndex();
|
|
|
|
size = _vm->_game->_script->readValExpr();
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
offset = _vm->_game->_script->getResultInt();
|
2007-04-15 13:41:54 +00:00
|
|
|
retSize = 0;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
char *file = _vm->_game->_script->getResultStr();
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)",
|
2009-07-18 13:05:36 +00:00
|
|
|
file, dataVar, size, offset);
|
2007-04-02 11:05:09 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
mode = _vm->_saveLoad->getSaveMode(file);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeSave) {
|
2009-08-02 13:54:06 +00:00
|
|
|
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 1);
|
2009-08-02 13:54:06 +00:00
|
|
|
|
|
|
|
if (!_vm->_saveLoad->load(file, dataVar, size, offset)) {
|
|
|
|
|
|
|
|
GUI::MessageDialog dialog("Failed to load game state from file.");
|
|
|
|
dialog.runModal();
|
|
|
|
|
|
|
|
} else
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 0);
|
2009-08-02 13:54:06 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
2009-08-02 13:54:06 +00:00
|
|
|
|
2008-05-10 20:59:43 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeIgnore)
|
|
|
|
return false;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (size < 0) {
|
|
|
|
warning("Attempted to read a raw sprite from file \"%s\"",
|
2009-07-18 13:05:36 +00:00
|
|
|
file);
|
2007-03-20 14:51:57 +00:00
|
|
|
return false ;
|
|
|
|
} else if (size == 0) {
|
|
|
|
dataVar = 0;
|
2009-06-23 01:20:05 +00:00
|
|
|
size = _vm->_game->_script->getVariablesCount() * 4;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-05-31 02:15:43 +00:00
|
|
|
buf = _variables->getAddressOff8(dataVar);
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
if (file[0] == 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR(1, size);
|
|
|
|
return false;
|
2007-01-29 17:04:37 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR(1, 1);
|
2009-07-18 13:05:36 +00:00
|
|
|
handle = _vm->_dataIO->openData(file);
|
2007-01-31 13:17:50 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (handle < 0)
|
|
|
|
return false;
|
2007-01-31 13:17:50 +00:00
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
DataStream *stream = _vm->_dataIO->openAsStream(handle, true);
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->animateCursor(4);
|
|
|
|
if (offset < 0)
|
2009-03-05 20:37:53 +00:00
|
|
|
stream->seek(offset + 1, SEEK_END);
|
2007-03-20 14:51:57 +00:00
|
|
|
else
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->seek(offset);
|
2007-01-31 13:17:50 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (((dataVar >> 2) == 59) && (size == 4)) {
|
2007-07-31 01:43:32 +00:00
|
|
|
WRITE_VAR(59, stream->readUint32LE());
|
2007-03-20 14:51:57 +00:00
|
|
|
// The scripts in some versions divide through 256^3 then,
|
|
|
|
// effectively doing a LE->BE conversion
|
2008-05-08 00:47:23 +00:00
|
|
|
if ((_vm->getPlatform() != Common::kPlatformPC) && (VAR(59) < 256))
|
2007-03-20 14:51:57 +00:00
|
|
|
WRITE_VAR(59, SWAP_BYTES_32(VAR(59)));
|
|
|
|
} else
|
2007-07-31 01:43:32 +00:00
|
|
|
retSize = stream->read(buf, size);
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (retSize == size)
|
|
|
|
WRITE_VAR(1, 0);
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
delete stream;
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
2006-04-13 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool Inter_v2::o2_writeData(OpFuncParams ¶ms) {
|
|
|
|
int32 offset;
|
|
|
|
int32 size;
|
|
|
|
int16 dataVar;
|
2008-05-10 20:59:43 +00:00
|
|
|
SaveLoad::SaveMode mode;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
dataVar = _vm->_game->_script->readVarIndex();
|
|
|
|
size = _vm->_game->_script->readValExpr();
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
offset = _vm->_game->_script->getResultInt();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
char *file = _vm->_game->_script->getResultStr();
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)",
|
2009-07-18 13:05:36 +00:00
|
|
|
file, dataVar, size, offset);
|
2007-04-02 11:05:09 +00:00
|
|
|
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 1);
|
|
|
|
|
2009-07-18 13:05:36 +00:00
|
|
|
mode = _vm->_saveLoad->getSaveMode(file);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeSave) {
|
2009-08-02 13:54:06 +00:00
|
|
|
|
|
|
|
if (!_vm->_saveLoad->save(file, dataVar, size, offset)) {
|
|
|
|
|
|
|
|
GUI::MessageDialog dialog("Failed to save game state to file.");
|
|
|
|
dialog.runModal();
|
|
|
|
|
|
|
|
} else
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 0);
|
2009-08-02 13:54:06 +00:00
|
|
|
|
2008-05-10 20:59:43 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeNone)
|
2009-07-18 13:05:36 +00:00
|
|
|
warning("Attempted to write to file \"%s\"", file);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
2007-01-25 14:18:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_loadInfogramesIns(OpGobParams ¶ms) {
|
2007-02-12 12:53:28 +00:00
|
|
|
int16 varName;
|
|
|
|
char fileName[20];
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
varName = _vm->_game->_script->readInt16();
|
2007-02-12 12:53:28 +00:00
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
strncpy0(fileName, GET_VAR_STR(varName), 15);
|
2007-02-12 12:53:28 +00:00
|
|
|
strcat(fileName, ".INS");
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->infogramesLoadInstruments(fileName);
|
2007-02-12 12:53:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_playInfogrames(OpGobParams ¶ms) {
|
2007-01-25 14:18:12 +00:00
|
|
|
int16 varName;
|
|
|
|
char fileName[20];
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
varName = _vm->_game->_script->readInt16();
|
2007-01-25 14:18:12 +00:00
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
strncpy0(fileName, GET_VAR_STR(varName), 15);
|
2007-01-25 14:18:12 +00:00
|
|
|
strcat(fileName, ".DUM");
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->infogramesLoadSong(fileName);
|
|
|
|
_vm->_sound->infogramesPlay();
|
2007-01-25 14:18:12 +00:00
|
|
|
}
|
|
|
|
|
2007-04-05 15:38:30 +00:00
|
|
|
void Inter_v2::o2_startInfogrames(OpGobParams ¶ms) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->readInt16();
|
2007-04-05 15:38:30 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->infogramesPlay();
|
2007-04-05 15:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_stopInfogrames(OpGobParams ¶ms) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->readInt16();
|
2007-04-05 15:38:30 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->infogramesStop();
|
2007-04-05 15:38:30 +00:00
|
|
|
}
|
|
|
|
|
2009-03-19 23:42:19 +00:00
|
|
|
void Inter_v2::o2_playProtracker(OpGobParams ¶ms) {
|
|
|
|
_vm->_sound->protrackerPlay("mod.babayaga");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_stopProtracker(OpGobParams ¶ms) {
|
|
|
|
_vm->_sound->protrackerStop();
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::o2_handleGoblins(OpGobParams ¶ms) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_goblin->_gob1NoTurn = VAR(_vm->_game->_script->readInt16()) != 0;
|
|
|
|
_vm->_goblin->_gob2NoTurn = VAR(_vm->_game->_script->readInt16()) != 0;
|
|
|
|
_vm->_goblin->_gob1RelaxTimeVar = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_goblin->_gob2RelaxTimeVar = _vm->_game->_script->readInt16();
|
|
|
|
_vm->_goblin->_gob1Busy = VAR(_vm->_game->_script->readInt16()) != 0;
|
|
|
|
_vm->_goblin->_gob2Busy = VAR(_vm->_game->_script->readInt16()) != 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->handleGoblins();
|
2006-12-19 07:38:33 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 Inter_v2::loadSound(int16 search) {
|
|
|
|
byte *dataPtr;
|
|
|
|
int16 id;
|
|
|
|
int16 slot;
|
2007-04-09 20:17:10 +00:00
|
|
|
uint16 slotIdMask;
|
2007-03-20 14:51:57 +00:00
|
|
|
uint32 dataSize;
|
|
|
|
SoundType type;
|
|
|
|
|
|
|
|
type = SOUND_SND;
|
2007-04-09 20:17:10 +00:00
|
|
|
slotIdMask = 0;
|
2007-04-15 13:41:54 +00:00
|
|
|
dataSize = 0;
|
2007-04-09 20:17:10 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!search) {
|
2009-06-22 10:13:37 +00:00
|
|
|
slot = _vm->_game->_script->readValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
if (slot < 0) {
|
|
|
|
type = SOUND_ADL;
|
|
|
|
slot = -slot;
|
|
|
|
}
|
2009-06-22 10:13:37 +00:00
|
|
|
id = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
} else {
|
2009-06-22 10:13:37 +00:00
|
|
|
id = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
for (slot = 0; slot < Sound::kSoundsCount; slot++)
|
|
|
|
if (_vm->_sound->sampleGetBySlot(slot)->isId(id)) {
|
2007-04-09 20:17:10 +00:00
|
|
|
slotIdMask = 0x8000;
|
2007-04-02 11:05:09 +00:00
|
|
|
break;
|
2007-04-09 20:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
if (slot == Sound::kSoundsCount) {
|
|
|
|
for (slot = (Sound::kSoundsCount - 1); slot >= 0; slot--) {
|
|
|
|
if (_vm->_sound->sampleGetBySlot(slot)->empty())
|
2007-04-09 20:17:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-02 11:05:09 +00:00
|
|
|
|
2007-04-09 20:17:10 +00:00
|
|
|
if (slot == -1) {
|
|
|
|
warning("Inter_v2::loadSound(): No free slot to load sound "
|
|
|
|
"(id = %d)", id);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-04-02 11:05:09 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
SoundDesc *sample = _vm->_sound->sampleGetBySlot(slot);
|
|
|
|
|
|
|
|
_vm->_sound->sampleFree(sample, true, slot);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (id == -1) {
|
|
|
|
char sndfile[14];
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
strncpy0(sndfile, _vm->_game->_script->readString(9), 9);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (type == SOUND_ADL)
|
|
|
|
strcat(sndfile, ".ADL");
|
|
|
|
else
|
|
|
|
strcat(sndfile, ".SND");
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
dataPtr = _vm->_dataIO->getData(sndfile);
|
|
|
|
dataSize = _vm->_dataIO->getDataSize(sndfile);
|
|
|
|
if (!dataPtr)
|
|
|
|
return 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
if (!sample->load(type, dataPtr, dataSize)) {
|
|
|
|
delete[] dataPtr;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
sample->_id = id;
|
|
|
|
return slot | slotIdMask;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
Resource *resource = _vm->_game->_resources->getResource(id);
|
|
|
|
if (!resource)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!sample->load(type, resource)) {
|
|
|
|
delete resource;
|
|
|
|
return 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-05-01 12:43:50 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
sample->_id = id;
|
2007-04-09 20:17:10 +00:00
|
|
|
return slot | slotIdMask;
|
2006-05-01 12:43:50 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Inter_v2::animPalette() {
|
2006-05-11 19:43:30 +00:00
|
|
|
int16 i;
|
|
|
|
int16 j;
|
|
|
|
Video::Color col;
|
|
|
|
bool first;
|
|
|
|
|
|
|
|
first = true;
|
|
|
|
for (j = 0; j < 8; j ++) {
|
|
|
|
if (_animPalDir[j] == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (first) {
|
2007-03-29 17:55:39 +00:00
|
|
|
_vm->_video->waitRetrace();
|
2006-05-11 19:43:30 +00:00
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_animPalDir[j] == -1) {
|
|
|
|
col = _vm->_global->_pPaletteDesc->vgaPal[_animPalLowIndex[j]];
|
|
|
|
|
|
|
|
for (i = _animPalLowIndex[j]; i < _animPalHighIndex[j]; i++)
|
2007-02-04 15:45:15 +00:00
|
|
|
_vm->_draw->_vgaPalette[i] = _vm->_draw->_vgaPalette[i + 1];
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal[_animPalHighIndex[j]] = col;
|
|
|
|
} else {
|
|
|
|
col = _vm->_global->_pPaletteDesc->vgaPal[_animPalHighIndex[j]];
|
|
|
|
for (i = _animPalHighIndex[j]; i > _animPalLowIndex[j]; i--)
|
2007-02-01 10:42:27 +00:00
|
|
|
_vm->_draw->_vgaPalette[i] = _vm->_draw->_vgaPalette[i - 1];
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal[_animPalLowIndex[j]] = col;
|
|
|
|
}
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->_vgaPalette;
|
|
|
|
}
|
|
|
|
if (!first)
|
|
|
|
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
|
|
|
|
}
|
|
|
|
|
2006-01-05 16:06:55 +00:00
|
|
|
} // End of namespace Gob
|