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
|
|
|
|
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"
|
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/parse.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);
|
|
|
|
|
|
|
|
OPCODEFUNC(0x18, o2_addCollision);
|
|
|
|
OPCODEFUNC(0x19, o2_freeCollision);
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
void Inter_v2::checkSwitchTable(byte **ppExec) {
|
2007-02-06 14:42:05 +00:00
|
|
|
byte cmd;
|
|
|
|
int16 len;
|
|
|
|
int32 value;
|
|
|
|
bool found;
|
|
|
|
|
|
|
|
found = false;
|
|
|
|
*ppExec = 0;
|
|
|
|
|
|
|
|
cmd = *_vm->_global->_inter_execPtr;
|
|
|
|
|
|
|
|
value = _vm->_parse->parseVarIndex();
|
|
|
|
|
|
|
|
switch (cmd) {
|
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;
|
|
|
|
|
|
|
|
len = (int8) *_vm->_global->_inter_execPtr++;
|
|
|
|
while (len != -5) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
2007-02-06 14:42:05 +00:00
|
|
|
cmd = *_vm->_global->_inter_execPtr;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
switch (cmd) {
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT32:
|
2007-02-06 14:42:05 +00:00
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
if (!found &&
|
2007-03-20 14:51:57 +00:00
|
|
|
(value ==
|
|
|
|
(int32) (READ_LE_UINT32(_vm->_global->_inter_execPtr))))
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
|
|
|
_vm->_global->_inter_execPtr += 5;
|
|
|
|
break;
|
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT16:
|
2007-02-06 14:42:05 +00:00
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
if (!found &&
|
2007-03-20 14:51:57 +00:00
|
|
|
(value ==
|
|
|
|
(int16) (READ_LE_UINT16(_vm->_global->_inter_execPtr))))
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
|
|
|
_vm->_global->_inter_execPtr += 3;
|
|
|
|
break;
|
|
|
|
|
2009-06-15 23:09:23 +00:00
|
|
|
case TYPE_IMM_INT8:
|
2007-02-06 14:42:05 +00:00
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
if (!found && (value == (int8) *_vm->_global->_inter_execPtr))
|
|
|
|
found = true;
|
2007-03-02 11:37:42 +00:00
|
|
|
_vm->_global->_inter_execPtr += 2;
|
2007-02-06 14:42:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (!found) {
|
|
|
|
evalExpr(0);
|
2009-06-15 23:11:08 +00:00
|
|
|
if (value == _vm->_parse->_resultInt)
|
2007-02-06 14:42:05 +00:00
|
|
|
found = true;
|
|
|
|
} else
|
|
|
|
_vm->_parse->skipExpr(99);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
if (found && !*ppExec)
|
2007-02-06 14:42:05 +00:00
|
|
|
*ppExec = _vm->_global->_inter_execPtr;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr +=
|
|
|
|
READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
|
2007-02-06 14:42:05 +00:00
|
|
|
len = (int8) *_vm->_global->_inter_execPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*_vm->_global->_inter_execPtr >> 4) != 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_global->_inter_execPtr++;
|
2007-04-02 11:05:09 +00:00
|
|
|
if (!*ppExec)
|
2007-02-06 14:42:05 +00:00
|
|
|
*ppExec = _vm->_global->_inter_execPtr;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr +=
|
|
|
|
READ_LE_UINT16(_vm->_global->_inter_execPtr + 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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
checkEscape = load16();
|
|
|
|
|
|
|
|
_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() {
|
|
|
|
uint16 index = load16();
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
expr = _vm->_parse->parseValExpr();
|
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() {
|
|
|
|
_vm->_mult->multSub(_vm->_parse->parseValExpr());
|
|
|
|
}
|
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;
|
|
|
|
int16 posXVar;
|
|
|
|
int16 posYVar;
|
|
|
|
int16 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;
|
|
|
|
|
|
|
|
_vm->_mult->_animLeft = load16();
|
|
|
|
_vm->_mult->_animTop = load16();
|
|
|
|
_vm->_mult->_animWidth = load16();
|
|
|
|
_vm->_mult->_animHeight = load16();
|
|
|
|
_vm->_mult->_objCount = load16();
|
|
|
|
posXVar = _vm->_parse->parseVarIndex();
|
|
|
|
posYVar = _vm->_parse->parseVarIndex();
|
|
|
|
animDataVar = _vm->_parse->parseVarIndex();
|
|
|
|
|
|
|
|
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 =
|
2009-05-31 02:15:43 +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))) {
|
|
|
|
_vm->_draw->freeSprite(22);
|
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) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->initSpriteSurf(22, _vm->_mult->_animWidth,
|
|
|
|
_vm->_mult->_animHeight, 0);
|
|
|
|
_vm->_mult->_animSurf = _vm->_draw->_spritesArray[22];
|
|
|
|
if (_terminate)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_draw->adjustCoords(1,
|
|
|
|
&_vm->_mult->_animWidth, &_vm->_mult->_animHeight);
|
|
|
|
_vm->_draw->_sourceSurface = 21;
|
|
|
|
_vm->_draw->_destSurface = 22;
|
|
|
|
_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
|
|
|
|
|
|
|
objIndex = _vm->_parse->parseValExpr();
|
|
|
|
val = _vm->_parse->parseValExpr();
|
|
|
|
*_vm->_mult->_objects[objIndex].pPosX = val;
|
|
|
|
val = _vm->_parse->parseValExpr();
|
|
|
|
*_vm->_mult->_objects[objIndex].pPosY = val;
|
|
|
|
|
|
|
|
debugC(4, kDebugGameFlow, "Loading mult object %d", objIndex);
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
multData = (byte *) _vm->_mult->_objects[objIndex].pAnimData;
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 11; i++) {
|
|
|
|
if (*_vm->_global->_inter_execPtr != 99)
|
|
|
|
multData[i] = _vm->_parse->parseValExpr();
|
|
|
|
else
|
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
_vm->_vidPlayer->slotClose(obj.videoSlot - 1);
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
index = _vm->_parse->parseValExpr();
|
|
|
|
layer = _vm->_parse->parseValExpr();
|
|
|
|
_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() {
|
|
|
|
_vm->_scenery->_curStatic = _vm->_parse->parseValExpr();
|
|
|
|
_vm->_scenery->_curStaticLayer = _vm->_parse->parseValExpr();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
2009-06-15 23:11:29 +00:00
|
|
|
_vm->_sound->cdPlay(_vm->_parse->_resultStr);
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
2009-06-15 23:11:29 +00:00
|
|
|
strncpy0(path, _vm->_parse->_resultStr, 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);
|
|
|
|
|
|
|
|
varPos = _vm->_parse->parseVarIndex();
|
|
|
|
varName = _vm->_parse->parseVarIndex();
|
|
|
|
|
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() {
|
|
|
|
int16 i = load16();
|
|
|
|
|
|
|
|
_vm->_draw->_fontToSprite[i].sprite = *_vm->_global->_inter_execPtr;
|
|
|
|
_vm->_global->_inter_execPtr += 2;
|
|
|
|
_vm->_draw->_fontToSprite[i].base = *_vm->_global->_inter_execPtr;
|
|
|
|
_vm->_global->_inter_execPtr += 2;
|
|
|
|
_vm->_draw->_fontToSprite[i].width = *_vm->_global->_inter_execPtr;
|
|
|
|
_vm->_global->_inter_execPtr += 2;
|
|
|
|
_vm->_draw->_fontToSprite[i].height = *_vm->_global->_inter_execPtr;
|
|
|
|
_vm->_global->_inter_execPtr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Inter_v2::o2_totSub() {
|
|
|
|
char totFile[14];
|
|
|
|
byte length;
|
|
|
|
int flags;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
length = *_vm->_global->_inter_execPtr++;
|
|
|
|
if ((length & 0x7F) > 13)
|
|
|
|
error("Length in o2_totSub is greater than 13 (%d)", length);
|
|
|
|
|
|
|
|
if (length & 0x80) {
|
|
|
|
evalExpr(0);
|
2009-06-15 23:11:29 +00:00
|
|
|
strcpy(totFile, _vm->_parse->_resultStr);
|
2007-01-28 13:19:17 +00:00
|
|
|
} else {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (i = 0; i < length; i++)
|
2007-04-02 11:05:09 +00:00
|
|
|
totFile[i] = (char) *_vm->_global->_inter_execPtr++;
|
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
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
flags = *_vm->_global->_inter_execPtr++;
|
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;
|
|
|
|
|
|
|
|
index = load16();
|
|
|
|
skipPlay = load16();
|
|
|
|
|
|
|
|
_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;
|
|
|
|
|
|
|
|
count = *_vm->_global->_inter_execPtr++;
|
2008-12-18 02:48:15 +00:00
|
|
|
for (int i = 0; i < count; i++, _varStackPos++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((*_vm->_global->_inter_execPtr == 25) ||
|
|
|
|
(*_vm->_global->_inter_execPtr == 28)) {
|
|
|
|
|
2006-11-20 13:03:30 +00:00
|
|
|
varOff = _vm->_parse->parseVarIndex();
|
|
|
|
_vm->_global->_inter_execPtr++;
|
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 {
|
2008-12-18 16:38:28 +00:00
|
|
|
if (evalExpr(&varOff) != 20)
|
2009-06-15 23:11:08 +00:00
|
|
|
_vm->_parse->_resultInt = 0;
|
2008-05-28 21:15:11 +00:00
|
|
|
|
2009-06-15 23:11:08 +00:00
|
|
|
memcpy(_varStack + _varStackPos, &_vm->_parse->_resultInt, 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
|
|
|
|
|
|
|
count = *_vm->_global->_inter_execPtr++;
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2006-11-20 13:03:30 +00:00
|
|
|
varOff = _vm->_parse->parseVarIndex();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
destX = _vm->_parse->parseValExpr();
|
|
|
|
destY = _vm->_parse->parseValExpr();
|
2006-05-11 19:43:30 +00:00
|
|
|
index = _vm->_parse->parseValExpr();
|
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;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
varX = _vm->_parse->parseVarIndex();
|
|
|
|
varY = _vm->_parse->parseVarIndex();
|
2006-06-07 18:49:20 +00:00
|
|
|
index = _vm->_parse->parseValExpr();
|
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() {
|
|
|
|
int16 index = _vm->_parse->parseValExpr();
|
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
|
|
|
|
|
|
|
index = _vm->_parse->parseValExpr();
|
2007-03-20 14:51:57 +00:00
|
|
|
state = _vm->_parse->parseValExpr();
|
|
|
|
type = _vm->_parse->parseValExpr();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
index = _vm->_parse->parseValExpr();
|
|
|
|
x = _vm->_parse->parseValExpr();
|
|
|
|
y = _vm->_parse->parseValExpr();
|
|
|
|
state = _vm->_parse->parseValExpr();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
offY = load16();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
width = _vm->_parse->parseValExpr();
|
|
|
|
height = _vm->_parse->parseValExpr();
|
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
|
|
|
|
2007-04-09 14:00:23 +00:00
|
|
|
startX = CLIP((int) _vm->_parse->parseValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfWidth - _vm->_width);
|
2007-04-09 14:00:23 +00:00
|
|
|
startY = CLIP((int) _vm->_parse->parseValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfHeight - _vm->_height);
|
2007-04-09 14:00:23 +00:00
|
|
|
endX = CLIP((int) _vm->_parse->parseValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfWidth - _vm->_width);
|
2007-04-09 14:00:23 +00:00
|
|
|
endY = CLIP((int) _vm->_parse->parseValExpr(), 0,
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_video->_surfHeight - _vm->_height);
|
2007-03-20 14:51:57 +00:00
|
|
|
stepX = _vm->_parse->parseValExpr();
|
|
|
|
stepY = _vm->_parse->parseValExpr();
|
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
|
|
|
|
2008-05-26 22:02:20 +00:00
|
|
|
offsetX = _vm->_parse->parseValExpr();
|
|
|
|
offsetY = _vm->_parse->parseValExpr();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2008-05-26 22:02:20 +00:00
|
|
|
if (offsetX == -1) {
|
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];
|
|
|
|
int16 x, y;
|
|
|
|
int16 startFrame;
|
|
|
|
int16 lastFrame;
|
|
|
|
int16 breakKey;
|
|
|
|
int16 flags;
|
|
|
|
int16 palStart;
|
|
|
|
int16 palEnd;
|
|
|
|
uint16 palCmd;
|
|
|
|
bool close;
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
2009-06-15 23:11:29 +00:00
|
|
|
_vm->_parse->_resultStr[8] = 0;
|
|
|
|
strncpy0(imd, _vm->_parse->_resultStr, 127);
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
x = _vm->_parse->parseValExpr();
|
|
|
|
y = _vm->_parse->parseValExpr();
|
|
|
|
startFrame = _vm->_parse->parseValExpr();
|
|
|
|
lastFrame = _vm->_parse->parseValExpr();
|
|
|
|
breakKey = _vm->_parse->parseValExpr();
|
|
|
|
flags = _vm->_parse->parseValExpr();
|
|
|
|
palStart = _vm->_parse->parseValExpr();
|
|
|
|
palEnd = _vm->_parse->parseValExpr();
|
|
|
|
palCmd = 1 << (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, "
|
2009-06-15 23:11:29 +00:00
|
|
|
"paletteCmd %d (%d - %d), flags %X", _vm->_parse->_resultStr, x, y,
|
2008-05-17 19:23:44 +00:00
|
|
|
startFrame, lastFrame, palCmd, palStart, palEnd, flags);
|
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
if ((imd[0] != 0) && !_vm->_vidPlayer->primaryOpen(imd, x, y, flags)) {
|
2008-05-28 21:15:11 +00:00
|
|
|
WRITE_VAR(11, (uint32) -1);
|
2007-03-20 14:51:57 +00:00
|
|
|
return;
|
2007-03-29 17:55:39 +00:00
|
|
|
}
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
close = (lastFrame == -1);
|
2007-03-29 17:55:39 +00:00
|
|
|
if (startFrame == -2) {
|
|
|
|
startFrame = lastFrame = 0;
|
|
|
|
close = false;
|
|
|
|
}
|
2006-02-02 21:12:00 +00:00
|
|
|
|
2007-07-30 15:53:38 +00:00
|
|
|
if (startFrame >= 0) {
|
|
|
|
_vm->_game->_preventScroll = true;
|
2008-04-27 03:19:19 +00:00
|
|
|
_vm->_vidPlayer->primaryPlay(startFrame, lastFrame, breakKey, palCmd, palStart, palEnd, 0);
|
2007-07-30 15:53:38 +00:00
|
|
|
_vm->_game->_preventScroll = false;
|
2006-02-02 21:12:00 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (close)
|
2008-04-27 03:19:19 +00:00
|
|
|
_vm->_vidPlayer->primaryClose();
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
|
|
|
varX = _vm->_parse->parseVarIndex();
|
|
|
|
varY = _vm->_parse->parseVarIndex();
|
|
|
|
varFrames = _vm->_parse->parseVarIndex();
|
|
|
|
varWidth = _vm->_parse->parseVarIndex();
|
|
|
|
varHeight = _vm->_parse->parseVarIndex();
|
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-15 23:11:29 +00:00
|
|
|
(!scumm_stricmp(_vm->_parse->_resultStr, "noixroule")))
|
|
|
|
strcpy(_vm->_parse->_resultStr, "noixroul");
|
2008-05-25 13:02:23 +00:00
|
|
|
|
2009-06-15 23:11:29 +00:00
|
|
|
_vm->_vidPlayer->writeVideoInfo(_vm->_parse->_resultStr, 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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
2009-06-15 23:11:29 +00:00
|
|
|
strncpy0(fileName, _vm->_parse->_resultStr, 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-15 23:09:37 +00:00
|
|
|
byte destType = *_vm->_global->_inter_execPtr;
|
2009-06-15 23:08:28 +00:00
|
|
|
int16 dest = _vm->_parse->parseVarIndex();
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2009-06-15 23:08:28 +00:00
|
|
|
byte loopCount;
|
2007-03-20 14:51:57 +00:00
|
|
|
if (*_vm->_global->_inter_execPtr == 99) {
|
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
loopCount = *_vm->_global->_inter_execPtr++;
|
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-15 23:09:37 +00:00
|
|
|
int16 srcType = 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-15 23:11:08 +00:00
|
|
|
WRITE_VARO_UINT8(dest + i, _vm->_parse->_resultInt);
|
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-15 23:11:08 +00:00
|
|
|
WRITE_VARO_UINT16(dest + i * 2, _vm->_parse->_resultInt);
|
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-15 23:11:08 +00:00
|
|
|
WRITE_VAR_OFFSET(dest + i * 4, _vm->_parse->_resultInt);
|
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-15 23:11:08 +00:00
|
|
|
WRITE_VARO_UINT16(dest + i * 4, _vm->_parse->_resultInt);
|
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-15 23:11:29 +00:00
|
|
|
WRITE_VARO_STR(dest, _vm->_parse->_resultStr);
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
|
|
|
|
_vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
|
|
|
|
|
|
|
|
_vm->_draw->_backColor = _vm->_parse->parseValExpr();
|
|
|
|
_vm->_draw->_frontColor = _vm->_parse->parseValExpr();
|
|
|
|
_vm->_draw->_fontIndex = _vm->_parse->parseValExpr();
|
|
|
|
_vm->_draw->_destSurface = 21;
|
|
|
|
_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 {
|
2007-04-02 11:05:09 +00:00
|
|
|
for (i = 0; (((char) *_vm->_global->_inter_execPtr) != '.') &&
|
|
|
|
(*_vm->_global->_inter_execPtr != 200);
|
2007-03-20 14:51:57 +00:00
|
|
|
i++, _vm->_global->_inter_execPtr++) {
|
2007-04-02 11:05:09 +00:00
|
|
|
buf[i] = (char) *_vm->_global->_inter_execPtr;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-16 20:25:59 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
if (*_vm->_global->_inter_execPtr != 200) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
switch (*_vm->_global->_inter_execPtr) {
|
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",
|
|
|
|
(int8) READ_VARO_UINT8(_vm->_parse->parseVarIndex()));
|
|
|
|
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",
|
|
|
|
(int16) READ_VARO_UINT16(_vm->_parse->parseVarIndex()));
|
|
|
|
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",
|
|
|
|
VAR_OFFSET(_vm->_parse->parseVarIndex()));
|
|
|
|
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",
|
|
|
|
GET_VARO_STR(_vm->_parse->parseVarIndex()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_vm->_global->_inter_execPtr++;
|
|
|
|
} 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);
|
2007-04-02 11:05:09 +00:00
|
|
|
} while (*_vm->_global->_inter_execPtr != 200);
|
2006-02-24 21:58:03 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr++;
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
index = load16();
|
|
|
|
if (index > 0) {
|
|
|
|
index--;
|
|
|
|
_animPalLowIndex[index] = _vm->_parse->parseValExpr();
|
|
|
|
_animPalHighIndex[index] = _vm->_parse->parseValExpr();
|
|
|
|
_animPalDir[index] = 1;
|
|
|
|
} else if (index == 0) {
|
|
|
|
memset(_animPalDir, 0, 8 * sizeof(int16));
|
|
|
|
_vm->_parse->parseValExpr();
|
|
|
|
_vm->_parse->parseValExpr();
|
|
|
|
} else {
|
|
|
|
index = -index - 1;
|
|
|
|
_animPalLowIndex[index] = _vm->_parse->parseValExpr();
|
|
|
|
_animPalHighIndex[index] = _vm->_parse->parseValExpr();
|
|
|
|
_animPalDir[index] = -1;
|
|
|
|
}
|
|
|
|
return false;
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-07-26 01:01:00 +00:00
|
|
|
bool Inter_v2::o2_addCollision(OpFuncParams ¶ms) {
|
|
|
|
int16 id;
|
|
|
|
int16 left, top, width, height;
|
|
|
|
int16 flags;
|
|
|
|
int16 key;
|
|
|
|
int16 funcSub;
|
|
|
|
|
|
|
|
id = _vm->_parse->parseValExpr();
|
|
|
|
funcSub = _vm->_global->_inter_execPtr - _vm->_game->_totFileData;
|
|
|
|
left = _vm->_parse->parseValExpr();
|
|
|
|
top = _vm->_parse->parseValExpr();
|
|
|
|
width = _vm->_parse->parseValExpr();
|
|
|
|
height = _vm->_parse->parseValExpr();
|
|
|
|
flags = _vm->_parse->parseValExpr();
|
|
|
|
key = load16();
|
|
|
|
|
|
|
|
if (key == 0)
|
|
|
|
key = ABS(id) + 41960;
|
|
|
|
|
|
|
|
_vm->_draw->adjustCoords(0, &left, &top);
|
|
|
|
_vm->_draw->adjustCoords(2, &width, &height);
|
|
|
|
|
|
|
|
if (left < 0) {
|
|
|
|
width += left;
|
|
|
|
left = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (top < 0) {
|
|
|
|
height += top;
|
|
|
|
top = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 index;
|
|
|
|
if (id < 0)
|
|
|
|
index = _vm->_game->addNewCollision(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
|
|
|
|
left + width + 3, top + height + 3, flags, key, 0, 0);
|
|
|
|
else
|
|
|
|
index = _vm->_game->addNewCollision(0xE000 + id, left, top,
|
|
|
|
left + width - 1, top + height - 1, flags, key, 0, 0);
|
|
|
|
|
|
|
|
_vm->_game->_collisionAreas[index].funcSub = funcSub;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Inter_v2::o2_freeCollision(OpFuncParams ¶ms) {
|
|
|
|
int16 id;
|
|
|
|
|
|
|
|
id = _vm->_parse->parseValExpr();
|
|
|
|
if (id == -2) {
|
|
|
|
for (int i = 0; i < 150; i++) {
|
|
|
|
if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xD000)
|
|
|
|
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
|
|
|
}
|
|
|
|
} else if (id == -1) {
|
|
|
|
for (int i = 0; i < 150; i++) {
|
|
|
|
if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xE000)
|
|
|
|
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
_vm->_game->freeCollision(0xE000 + id);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
_vm->_global->_inter_execPtr += 4;
|
|
|
|
uint16 resVar = (uint16) load16();
|
|
|
|
_vm->_global->_inter_execPtr += 4;
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
cmd = load16();
|
2009-06-19 09:43:01 +00:00
|
|
|
|
|
|
|
gobParams.paramCount = load16();
|
|
|
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
expr = _vm->_parse->parseValExpr();
|
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) {
|
|
|
|
int16 freeVar;
|
|
|
|
int16 maxFreeVar;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
freeVar = _vm->_parse->parseVarIndex();
|
|
|
|
maxFreeVar = _vm->_parse->parseVarIndex();
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// HACK
|
|
|
|
WRITE_VAR_OFFSET(freeVar, 1000000);
|
|
|
|
WRITE_VAR_OFFSET(maxFreeVar, 1000000);
|
|
|
|
WRITE_VAR(16, READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4);
|
|
|
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
|
|
|
varOff = _vm->_parse->parseVarIndex();
|
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-06-15 23:11:29 +00:00
|
|
|
mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_resultStr);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeNone) {
|
2009-06-15 23:11:29 +00:00
|
|
|
handle = _vm->_dataIO->openData(_vm->_parse->_resultStr);
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (handle >= 0) {
|
|
|
|
_vm->_dataIO->closeData(handle);
|
2009-06-15 23:11:29 +00:00
|
|
|
size = _vm->_dataIO->getDataSize(_vm->_parse->_resultStr);
|
2007-04-05 16:04:59 +00:00
|
|
|
} else
|
2009-06-15 23:11:29 +00:00
|
|
|
warning("File \"%s\" not found", _vm->_parse->_resultStr);
|
2008-05-10 20:59:43 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeSave)
|
2009-06-15 23:11:29 +00:00
|
|
|
size = _vm->_saveLoad->getSize(_vm->_parse->_resultStr);
|
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-06-15 23:11:29 +00:00
|
|
|
_vm->_parse->_resultStr, 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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
|
|
|
dataVar = _vm->_parse->parseVarIndex();
|
|
|
|
size = _vm->_parse->parseValExpr();
|
|
|
|
evalExpr(0);
|
2009-06-15 23:11:08 +00:00
|
|
|
offset = _vm->_parse->_resultInt;
|
2007-04-15 13:41:54 +00:00
|
|
|
retSize = 0;
|
2007-01-29 17:04:37 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)",
|
2009-06-15 23:11:29 +00:00
|
|
|
_vm->_parse->_resultStr, dataVar, size, offset);
|
2007-04-02 11:05:09 +00:00
|
|
|
|
2009-06-15 23:11:29 +00:00
|
|
|
mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_resultStr);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeSave) {
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 1);
|
2009-06-15 23:11:29 +00:00
|
|
|
if (_vm->_saveLoad->load(_vm->_parse->_resultStr, dataVar, size, offset))
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 0);
|
2007-03-20 14:51:57 +00:00
|
|
|
return false;
|
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-06-15 23:11:29 +00:00
|
|
|
_vm->_parse->_resultStr);
|
2007-03-20 14:51:57 +00:00
|
|
|
return false ;
|
|
|
|
} else if (size == 0) {
|
|
|
|
dataVar = 0;
|
|
|
|
size = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
|
|
|
|
}
|
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-06-15 23:11:29 +00:00
|
|
|
if (_vm->_parse->_resultStr[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-06-15 23:11:29 +00:00
|
|
|
handle = _vm->_dataIO->openData(_vm->_parse->_resultStr);
|
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
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
evalExpr(0);
|
|
|
|
dataVar = _vm->_parse->parseVarIndex();
|
|
|
|
size = _vm->_parse->parseValExpr();
|
|
|
|
evalExpr(0);
|
2009-06-15 23:11:08 +00:00
|
|
|
offset = _vm->_parse->_resultInt;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)",
|
2009-06-15 23:11:29 +00:00
|
|
|
_vm->_parse->_resultStr, dataVar, size, offset);
|
2007-04-02 11:05:09 +00:00
|
|
|
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 1);
|
|
|
|
|
2009-06-15 23:11:29 +00:00
|
|
|
mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_resultStr);
|
2008-05-10 20:59:43 +00:00
|
|
|
if (mode == SaveLoad::kSaveModeSave) {
|
2009-06-15 23:11:29 +00:00
|
|
|
if (_vm->_saveLoad->save(_vm->_parse->_resultStr, dataVar, size, offset))
|
2007-04-08 00:08:26 +00:00
|
|
|
WRITE_VAR(1, 0);
|
2008-05-10 20:59:43 +00:00
|
|
|
} else if (mode == SaveLoad::kSaveModeNone)
|
2009-06-15 23:11:29 +00:00
|
|
|
warning("Attempted to write to file \"%s\"", _vm->_parse->_resultStr);
|
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];
|
|
|
|
|
|
|
|
varName = load16();
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
varName = load16();
|
|
|
|
|
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) {
|
|
|
|
load16();
|
|
|
|
|
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) {
|
|
|
|
load16();
|
|
|
|
|
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) {
|
2007-04-15 15:40:24 +00:00
|
|
|
_vm->_goblin->_gob1NoTurn = VAR(load16()) != 0;
|
|
|
|
_vm->_goblin->_gob2NoTurn = VAR(load16()) != 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->_gob1RelaxTimeVar = load16();
|
|
|
|
_vm->_goblin->_gob2RelaxTimeVar = load16();
|
2007-04-15 15:40:24 +00:00
|
|
|
_vm->_goblin->_gob1Busy = VAR(load16()) != 0;
|
|
|
|
_vm->_goblin->_gob2Busy = VAR(load16()) != 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;
|
|
|
|
SoundSource source;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
slot = _vm->_parse->parseValExpr();
|
|
|
|
if (slot < 0) {
|
|
|
|
type = SOUND_ADL;
|
|
|
|
slot = -slot;
|
|
|
|
}
|
|
|
|
id = load16();
|
|
|
|
} else {
|
|
|
|
id = load16();
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
source = SOUND_FILE;
|
2006-05-01 12:43:50 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
strncpy0(sndfile, (const char *) _vm->_global->_inter_execPtr, 9);
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr += 9;
|
|
|
|
|
|
|
|
if (type == SOUND_ADL)
|
|
|
|
strcat(sndfile, ".ADL");
|
|
|
|
else
|
|
|
|
strcat(sndfile, ".SND");
|
|
|
|
|
|
|
|
dataPtr = (byte *) _vm->_dataIO->getData(sndfile);
|
|
|
|
if (dataPtr)
|
|
|
|
dataSize = _vm->_dataIO->getDataSize(sndfile);
|
|
|
|
} else if (id >= 30000) {
|
|
|
|
source = SOUND_EXT;
|
|
|
|
|
|
|
|
dataPtr = (byte *) _vm->_game->loadExtData(id, 0, 0, &dataSize);
|
|
|
|
} else {
|
|
|
|
int16 totSize;
|
|
|
|
|
|
|
|
source = SOUND_TOT;
|
|
|
|
|
|
|
|
dataPtr = (byte *) _vm->_game->loadTotResource(id, &totSize);
|
|
|
|
dataSize = (uint32) ((int32) totSize);
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (dataPtr) {
|
2008-05-08 00:47:23 +00:00
|
|
|
sample->load(type, source, dataPtr, dataSize);
|
|
|
|
sample->_id = id;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-05-01 12:43:50 +00:00
|
|
|
|
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
|