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.
|
2005-04-05 15:53:16 +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
|
2005-04-05 15:53:16 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-03-29 15:59:37 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/game.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"
|
|
|
|
#include "gob/util.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/dataio.h"
|
|
|
|
#include "gob/inter.h"
|
|
|
|
#include "gob/parse.h"
|
|
|
|
#include "gob/draw.h"
|
|
|
|
#include "gob/mult.h"
|
2008-12-03 22:14:47 +00:00
|
|
|
#include "gob/videoplayer.h"
|
2008-05-08 00:47:23 +00:00
|
|
|
#include "gob/sound/sound.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Game::Game(GobEngine *vm) : _vm(vm) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_extTable = 0;
|
|
|
|
_totFileData = 0;
|
|
|
|
_totResourceTable = 0;
|
|
|
|
_imFileData = 0;
|
|
|
|
_extHandle = 0;
|
2008-12-11 21:57:47 +00:00
|
|
|
_lomHandle = -1;
|
2006-01-07 22:28:54 +00:00
|
|
|
_collisionAreas = 0;
|
|
|
|
_shouldPushColls = 0;
|
2007-02-12 14:37:27 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_captureCount = 0;
|
|
|
|
|
2007-02-12 14:37:27 +00:00
|
|
|
_foundTotLoc = false;
|
2006-01-07 22:28:54 +00:00
|
|
|
_totTextData = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_collStackSize = 0;
|
2006-02-03 07:30:29 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_collStack[i] = 0;
|
|
|
|
_collStackElemSizes[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_curTotFile[0] = 0;
|
|
|
|
_curExtFile[0] = 0;
|
|
|
|
_totToLoad[0] = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_startTimeKey = 0;
|
|
|
|
_mouseButtons = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_lastCollKey = 0;
|
|
|
|
_lastCollAreaIndex = 0;
|
|
|
|
_lastCollId = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_activeCollResId = 0;
|
|
|
|
_activeCollIndex = 0;
|
|
|
|
_handleMouse = 0;
|
|
|
|
_forceHandleMouse = 0;
|
2007-04-09 18:29:51 +00:00
|
|
|
_menuLevel = 0;
|
2007-04-16 05:04:41 +00:00
|
|
|
_noScroll = true;
|
2007-05-30 10:20:21 +00:00
|
|
|
_preventScroll = false;
|
2007-04-17 09:40:10 +00:00
|
|
|
_scrollHandleMouse = false;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2008-12-17 13:07:56 +00:00
|
|
|
_noCd = false;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_tempStr[0] = 0;
|
|
|
|
_curImaFile[0] = 0;
|
|
|
|
_collStr[0] = 0;
|
2006-04-13 20:56:22 +00:00
|
|
|
|
|
|
|
_backupedCount = 0;
|
|
|
|
_curBackupPos = 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
2007-04-02 11:05:09 +00:00
|
|
|
_cursorHotspotXArray[i] = 0;
|
|
|
|
_cursorHotspotYArray[i] = 0;
|
2006-04-13 20:56:22 +00:00
|
|
|
_totTextDataArray[i] = 0;
|
|
|
|
_totFileDataArray[i] = 0;
|
|
|
|
_totResourceTableArray[i] = 0;
|
|
|
|
_extTableArray[i] = 0;
|
|
|
|
_extHandleArray[i] = 0;
|
|
|
|
_imFileDataArray[i] = 0;
|
|
|
|
_variablesArray[i] = 0;
|
|
|
|
_curTotFileArray[i][0] = 0;
|
|
|
|
}
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-05-31 08:44:14 +00:00
|
|
|
Game::~Game() {
|
2008-12-12 00:10:39 +00:00
|
|
|
delete[] _vm->_game->_totFileData;
|
|
|
|
if (_vm->_game->_totTextData) {
|
|
|
|
if (_vm->_game->_totTextData->items)
|
|
|
|
delete[] _vm->_game->_totTextData->items;
|
|
|
|
delete _vm->_game->_totTextData;
|
|
|
|
}
|
|
|
|
if (_vm->_game->_totResourceTable) {
|
|
|
|
delete[] _vm->_game->_totResourceTable->items;
|
|
|
|
delete _vm->_game->_totResourceTable;
|
|
|
|
}
|
2006-05-31 08:44:14 +00:00
|
|
|
}
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *Game::loadExtData(int16 itemId, int16 *pResWidth,
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 *pResHeight, uint32 *dataSize) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 commonHandle;
|
|
|
|
int16 itemsCount;
|
|
|
|
int32 offset;
|
|
|
|
uint32 size;
|
2007-01-06 11:17:20 +00:00
|
|
|
uint32 realSize;
|
2006-01-03 23:14:39 +00:00
|
|
|
ExtItem *item;
|
2007-03-20 14:51:57 +00:00
|
|
|
bool isPacked;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 handle;
|
|
|
|
int32 tableSize;
|
|
|
|
char path[20];
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *dataBuf;
|
|
|
|
byte *packedBuf;
|
|
|
|
byte *dataPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
itemId -= 30000;
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_extTable == 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
commonHandle = -1;
|
2006-01-07 22:28:54 +00:00
|
|
|
itemsCount = _extTable->itemsCount;
|
|
|
|
item = &_extTable->items[itemId];
|
2005-04-05 15:07:40 +00:00
|
|
|
tableSize = szGame_ExtTable + szGame_ExtItem * itemsCount;
|
|
|
|
|
|
|
|
offset = item->offset;
|
|
|
|
size = item->size;
|
2007-04-15 15:40:24 +00:00
|
|
|
isPacked = (item->width & 0x8000) != 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-07-25 04:52:12 +00:00
|
|
|
if ((pResWidth != 0) && (pResHeight != 0)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
*pResWidth = item->width & 0x7FFF;
|
2007-07-25 04:52:12 +00:00
|
|
|
|
|
|
|
if (*pResWidth & 0x4000)
|
|
|
|
size += 1 << 16;
|
|
|
|
if (*pResWidth & 0x2000)
|
|
|
|
size += 2 << 16;
|
|
|
|
if (*pResWidth & 0x1000)
|
|
|
|
size += 4 << 16;
|
|
|
|
|
|
|
|
*pResWidth &= 0xFFF;
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
*pResHeight = item->height;
|
2007-03-20 14:51:57 +00:00
|
|
|
debugC(7, kDebugFileIO, "loadExtData(%d, %d, %d)",
|
|
|
|
itemId, *pResWidth, *pResHeight);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-01-13 15:35:02 +00:00
|
|
|
debugC(7, kDebugFileIO, "loadExtData(%d, 0, 0)", itemId);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
if (item->height == 0)
|
2007-03-20 14:51:57 +00:00
|
|
|
size += (item->width & 0x7FFF) << 16;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-01-13 15:35:02 +00:00
|
|
|
debugC(7, kDebugFileIO, "size: %d off: %d", size, offset);
|
2007-03-20 14:51:57 +00:00
|
|
|
if (offset < 0) {
|
2005-04-05 15:07:40 +00:00
|
|
|
offset = -(offset + 1);
|
|
|
|
tableSize = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeData(_extHandle);
|
2005-04-05 15:07:40 +00:00
|
|
|
strcpy(path, "commun.ex1");
|
2007-03-20 14:51:57 +00:00
|
|
|
path[strlen(path) - 1] = *(_totFileData + 0x3C) + '0';
|
|
|
|
commonHandle = _vm->_dataIO->openData(path);
|
2005-04-05 15:07:40 +00:00
|
|
|
handle = commonHandle;
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
|
|
|
handle = _extHandle;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
DataStream *stream = _vm->_dataIO->openAsStream(handle);
|
|
|
|
|
2007-01-13 15:35:02 +00:00
|
|
|
debugC(7, kDebugFileIO, "off: %d size: %d", offset, tableSize);
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->seek(offset + tableSize);
|
2007-01-06 11:17:20 +00:00
|
|
|
realSize = size;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (isPacked)
|
2007-04-02 11:05:09 +00:00
|
|
|
dataBuf = new byte[size + 2];
|
2005-04-05 15:07:40 +00:00
|
|
|
else
|
2007-04-02 11:05:09 +00:00
|
|
|
dataBuf = new byte[size];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
dataPtr = dataBuf;
|
|
|
|
while (size > 32000) {
|
|
|
|
// BUG: huge->far conversion. Need normalization?
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->read(dataPtr, 32000);
|
2005-04-05 15:07:40 +00:00
|
|
|
size -= 32000;
|
|
|
|
dataPtr += 32000;
|
|
|
|
}
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->read(dataPtr, size);
|
|
|
|
|
|
|
|
delete stream;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (commonHandle != -1) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeData(commonHandle);
|
|
|
|
_extHandle = _vm->_dataIO->openData(_curExtFile);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (isPacked) {
|
2005-04-05 15:07:40 +00:00
|
|
|
packedBuf = dataBuf;
|
2007-01-06 11:17:20 +00:00
|
|
|
realSize = READ_LE_UINT32(packedBuf);
|
2007-04-02 11:05:09 +00:00
|
|
|
dataBuf = new byte[realSize];
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->unpackData(packedBuf, dataBuf);
|
2006-01-29 02:27:10 +00:00
|
|
|
delete[] packedBuf;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-01-06 11:17:20 +00:00
|
|
|
if (dataSize)
|
|
|
|
*dataSize = realSize;
|
2005-04-05 15:07:40 +00:00
|
|
|
return dataBuf;
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::freeCollision(int16 id) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 250; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_collisionAreas[i].id == id)
|
2007-05-01 14:49:13 +00:00
|
|
|
_collisionAreas[i].left = 0xFFFF;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::capturePush(int16 left, int16 top, int16 width, int16 height) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 right;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_captureCount == 20)
|
2009-05-31 10:02:16 +00:00
|
|
|
error("Game::capturePush(): Capture stack overflow");
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_captureStack[_captureCount].left = left;
|
|
|
|
_captureStack[_captureCount].top = top;
|
|
|
|
_captureStack[_captureCount].right = left + width;
|
|
|
|
_captureStack[_captureCount].bottom = top + height;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteTop = top;
|
|
|
|
_vm->_draw->_spriteBottom = height;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
right = left + width - 1;
|
2007-03-20 14:51:57 +00:00
|
|
|
left &= 0xFFF0;
|
|
|
|
right |= 0xF;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->initSpriteSurf(30 + _captureCount, right - left + 1, height, 0);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_sourceSurface = 21;
|
|
|
|
_vm->_draw->_destSurface = 30 + _captureCount;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteLeft = left;
|
|
|
|
_vm->_draw->_spriteRight = right - left + 1;
|
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
|
|
|
_vm->_draw->_transparency = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(0);
|
2006-01-07 22:28:54 +00:00
|
|
|
_captureCount++;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::capturePop(char doDraw) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_captureCount <= 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_captureCount--;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (doDraw) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_destSpriteX = _captureStack[_captureCount].left;
|
|
|
|
_vm->_draw->_destSpriteY = _captureStack[_captureCount].top;
|
|
|
|
_vm->_draw->_spriteRight =
|
|
|
|
_captureStack[_captureCount].width();
|
|
|
|
_vm->_draw->_spriteBottom =
|
|
|
|
_captureStack[_captureCount].height();
|
|
|
|
|
|
|
|
_vm->_draw->_transparency = 0;
|
|
|
|
_vm->_draw->_sourceSurface = 30 + _captureCount;
|
|
|
|
_vm->_draw->_destSurface = 21;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_spriteLeft = _vm->_draw->_destSpriteX & 0xF;
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteTop = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(0);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->freeSprite(30 + _captureCount);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2008-12-12 00:10:39 +00:00
|
|
|
byte *Game::loadTotResource(int16 id,
|
|
|
|
int16 *dataSize, int16 *width, int16 *height) {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
TotResItem *itemPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int32 offset;
|
|
|
|
|
2008-12-12 00:10:39 +00:00
|
|
|
if (id >= _vm->_game->_totResourceTable->itemsCount) {
|
|
|
|
warning("Trying to load non-existent TOT resource (%s, %d/%d)",
|
|
|
|
_curTotFile, id, _totResourceTable->itemsCount - 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
itemPtr = &_totResourceTable->items[id];
|
2005-04-05 15:07:40 +00:00
|
|
|
offset = itemPtr->offset;
|
2008-12-12 00:10:39 +00:00
|
|
|
|
2007-01-06 11:17:20 +00:00
|
|
|
if (dataSize)
|
|
|
|
*dataSize = itemPtr->size;
|
2008-12-12 00:10:39 +00:00
|
|
|
if (width)
|
|
|
|
*width = itemPtr->width;
|
|
|
|
if (height)
|
|
|
|
*height = itemPtr->height;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (offset < 0) {
|
|
|
|
offset = (-offset - 1) * 4;
|
|
|
|
return _imFileData + (int32) READ_LE_UINT32(_imFileData + offset);
|
|
|
|
} else
|
2006-06-13 08:10:54 +00:00
|
|
|
return _totResourceTable->dataPtr + szGame_TotResTable +
|
2006-01-07 22:28:54 +00:00
|
|
|
szGame_TotResItem * _totResourceTable->itemsCount + offset;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::freeSoundSlot(int16 slot) {
|
2005-04-05 15:07:40 +00:00
|
|
|
if (slot == -1)
|
2006-01-03 23:14:39 +00:00
|
|
|
slot = _vm->_parse->parseValExpr();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->sampleFree(_vm->_sound->sampleGetBySlot(slot));
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-04-13 07:48:26 +00:00
|
|
|
void Game::evaluateScroll(int16 x, int16 y) {
|
2007-05-30 10:20:21 +00:00
|
|
|
if (_preventScroll || !_scrollHandleMouse || (_menuLevel > 0))
|
2007-04-13 07:48:26 +00:00
|
|
|
return;
|
|
|
|
|
2008-05-04 01:02:27 +00:00
|
|
|
if (_noScroll ||
|
|
|
|
((_vm->_global->_videoMode != 0x14) && (_vm->_global->_videoMode != 0x18)))
|
2007-04-13 07:48:26 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ((x == 0) && (_vm->_draw->_scrollOffsetX > 0)) {
|
|
|
|
uint16 off;
|
|
|
|
|
|
|
|
off = MIN(_vm->_draw->_cursorWidth, _vm->_draw->_scrollOffsetX);
|
|
|
|
off = MAX(off / 2, 1);
|
|
|
|
_vm->_draw->_scrollOffsetX -= off;
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2007-04-19 13:51:57 +00:00
|
|
|
} else if ((y == 0) && (_vm->_draw->_scrollOffsetY > 0)) {
|
|
|
|
uint16 off;
|
|
|
|
|
|
|
|
off = MIN(_vm->_draw->_cursorHeight, _vm->_draw->_scrollOffsetY);
|
|
|
|
off = MAX(off / 2, 1);
|
|
|
|
_vm->_draw->_scrollOffsetY -= off;
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2007-04-13 07:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 cursorRight = x + _vm->_draw->_cursorWidth;
|
2007-07-24 23:24:40 +00:00
|
|
|
int16 screenRight = _vm->_draw->_scrollOffsetX + _vm->_width;
|
2007-04-19 13:51:57 +00:00
|
|
|
int16 cursorBottom = y + _vm->_draw->_cursorHeight;
|
2007-07-24 23:24:40 +00:00
|
|
|
int16 screenBottom = _vm->_draw->_scrollOffsetY + _vm->_height;
|
2007-04-13 07:48:26 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
if ((cursorRight >= _vm->_width) &&
|
|
|
|
(screenRight < _vm->_video->_surfWidth)) {
|
2007-04-13 07:48:26 +00:00
|
|
|
uint16 off;
|
|
|
|
|
|
|
|
off = MIN(_vm->_draw->_cursorWidth,
|
|
|
|
(int16) (_vm->_video->_surfWidth - screenRight));
|
|
|
|
off = MAX(off / 2, 1);
|
|
|
|
|
|
|
|
_vm->_draw->_scrollOffsetX += off;
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2007-04-13 07:48:26 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_util->setMousePos(_vm->_width - _vm->_draw->_cursorWidth, y);
|
|
|
|
} else if ((cursorBottom >= (_vm->_height - _vm->_video->_splitHeight2)) &&
|
2007-04-19 13:51:57 +00:00
|
|
|
(screenBottom < _vm->_video->_surfHeight)) {
|
|
|
|
uint16 off;
|
|
|
|
|
|
|
|
off = MIN(_vm->_draw->_cursorHeight,
|
|
|
|
(int16) (_vm->_video->_surfHeight - screenBottom));
|
|
|
|
off = MAX(off / 2, 1);
|
|
|
|
|
|
|
|
_vm->_draw->_scrollOffsetY += off;
|
2008-12-04 18:38:55 +00:00
|
|
|
_vm->_video->dirtyRectsAll();
|
2007-04-19 13:51:57 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
_vm->_util->setMousePos(x, _vm->_height - _vm->_video->_splitHeight2 -
|
2007-04-19 13:51:57 +00:00
|
|
|
_vm->_draw->_cursorHeight);
|
2007-04-13 07:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_util->setScrollOffset();
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
|
|
|
|
int16 *pButtons, char handleMouse) {
|
|
|
|
|
2007-04-13 07:48:26 +00:00
|
|
|
_vm->_util->processInput(true);
|
2007-02-05 14:08:50 +00:00
|
|
|
|
2008-05-28 21:15:11 +00:00
|
|
|
if (_vm->_mult->_multData && _vm->_inter->_variables &&
|
2007-02-05 14:08:50 +00:00
|
|
|
(VAR(58) != 0)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_vm->_mult->_multData->frameStart != (int) VAR(58) - 1)
|
2007-02-05 14:08:50 +00:00
|
|
|
_vm->_mult->_multData->frameStart++;
|
|
|
|
else
|
|
|
|
_vm->_mult->_multData->frameStart = 0;
|
|
|
|
|
|
|
|
_vm->_mult->playMult(_vm->_mult->_multData->frameStart + VAR(57),
|
|
|
|
_vm->_mult->_multData->frameStart + VAR(57), 1, handleMouse);
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_vm->_inter->_soundEndTimeKey != 0) &&
|
|
|
|
(_vm->_util->getTimeKey() >= _vm->_inter->_soundEndTimeKey)) {
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->blasterStop(_vm->_inter->_soundStopVal);
|
2007-02-05 14:08:50 +00:00
|
|
|
_vm->_inter->_soundEndTimeKey = 0;
|
|
|
|
}
|
|
|
|
|
2007-07-30 15:53:38 +00:00
|
|
|
if (pMouseX && pMouseY && pButtons) {
|
|
|
|
_vm->_util->getMouseState(pMouseX, pMouseY, pButtons);
|
2007-02-05 14:08:50 +00:00
|
|
|
|
2007-07-30 15:53:38 +00:00
|
|
|
if (*pButtons == 3)
|
|
|
|
*pButtons = 0;
|
|
|
|
}
|
2007-02-05 14:08:50 +00:00
|
|
|
|
|
|
|
return _vm->_util->checkKey();
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 Game::adjustKey(int16 key) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (key <= 0x60 || key >= 0x7B)
|
2005-04-05 15:07:40 +00:00
|
|
|
return key;
|
|
|
|
|
|
|
|
return key - 0x20;
|
|
|
|
}
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
int32 Game::loadTotFile(const char *path) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 handle;
|
2006-11-21 13:28:45 +00:00
|
|
|
int32 size;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2008-12-11 21:57:47 +00:00
|
|
|
_lomHandle = -1;
|
|
|
|
|
2006-11-21 13:28:45 +00:00
|
|
|
size = -1;
|
2007-03-20 14:51:57 +00:00
|
|
|
handle = _vm->_dataIO->openData(path);
|
2005-04-05 15:07:40 +00:00
|
|
|
if (handle >= 0) {
|
2008-12-11 21:57:47 +00:00
|
|
|
|
|
|
|
if (!scumm_stricmp(path + strlen(path) - 3, "LOM")) {
|
|
|
|
warning("Urban Stub: loadTotFile %s", path);
|
|
|
|
|
|
|
|
_lomHandle = handle;
|
|
|
|
|
|
|
|
DataStream *stream = _vm->_dataIO->openAsStream(handle);
|
|
|
|
|
|
|
|
stream->seek(48);
|
|
|
|
size = stream->readUint32LE();
|
|
|
|
stream->seek(0);
|
|
|
|
|
|
|
|
_totFileData = new byte[size];
|
|
|
|
stream->read(_totFileData, size);
|
|
|
|
|
|
|
|
delete stream;
|
|
|
|
} else {
|
|
|
|
_vm->_dataIO->closeData(handle);
|
|
|
|
size = _vm->_dataIO->getDataSize(path);
|
|
|
|
_totFileData = _vm->_dataIO->getData(path);
|
|
|
|
}
|
|
|
|
|
2008-12-03 22:14:47 +00:00
|
|
|
} else {
|
|
|
|
Common::MemoryReadStream *videoExtraData = _vm->_vidPlayer->getExtraData(path);
|
|
|
|
|
|
|
|
if (videoExtraData) {
|
|
|
|
warning("Found \"%s\" in video file", path);
|
|
|
|
|
|
|
|
size = videoExtraData->size();
|
|
|
|
_totFileData = new byte[size];
|
|
|
|
videoExtraData->read(_totFileData, size);
|
|
|
|
delete videoExtraData;
|
|
|
|
} else
|
|
|
|
_totFileData = 0;
|
|
|
|
}
|
2006-11-21 13:28:45 +00:00
|
|
|
|
|
|
|
return size;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::loadExtTable(void) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 count;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
// Function is correct. [sev]
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_extHandle = _vm->_dataIO->openData(_curExtFile);
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_extHandle < 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
DataStream *stream = _vm->_dataIO->openAsStream(_extHandle);
|
|
|
|
count = stream->readUint16LE();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->seek(0);
|
2006-01-29 02:27:10 +00:00
|
|
|
_extTable = new ExtTable;
|
|
|
|
_extTable->items = 0;
|
|
|
|
if (count)
|
|
|
|
_extTable->items = new ExtItem[count];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-07-31 01:43:32 +00:00
|
|
|
_extTable->itemsCount = stream->readUint16LE();
|
|
|
|
_extTable->unknown = stream->readByte();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2007-07-31 01:43:32 +00:00
|
|
|
_extTable->items[i].offset = stream->readUint32LE();
|
|
|
|
_extTable->items[i].size = stream->readUint16LE();
|
|
|
|
_extTable->items[i].width = stream->readUint16LE();
|
|
|
|
_extTable->items[i].height = stream->readUint16LE();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2007-07-31 01:43:32 +00:00
|
|
|
|
|
|
|
delete stream;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::loadImFile(void) {
|
2005-04-05 15:07:40 +00:00
|
|
|
char path[20];
|
|
|
|
int16 handle;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_totFileData[0x3D] != 0) && (_totFileData[0x3B] == 0))
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
strcpy(path, "commun.im1");
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_totFileData[0x3B] != 0)
|
|
|
|
path[strlen(path) - 1] = '0' + _totFileData[0x3B];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
handle = _vm->_dataIO->openData(path);
|
2005-04-05 15:07:40 +00:00
|
|
|
if (handle < 0)
|
|
|
|
return;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeData(handle);
|
|
|
|
_imFileData = _vm->_dataIO->getData(path);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Game::start(void) {
|
2006-01-29 02:27:10 +00:00
|
|
|
_collisionAreas = new Collision[250];
|
2006-11-14 14:58:41 +00:00
|
|
|
memset(_collisionAreas, 0, 250 * sizeof(Collision));
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
prepareStart();
|
2006-06-29 12:55:57 +00:00
|
|
|
playTot(-2);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
delete[] _collisionAreas;
|
2006-11-20 13:03:30 +00:00
|
|
|
_vm->_draw->closeScreen();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < SPRITES_COUNT; i++)
|
|
|
|
_vm->_draw->freeSprite(i);
|
|
|
|
_vm->_draw->_scummvmCursor = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 20:56:22 +00:00
|
|
|
// flagbits: 0 = freeInterVariables, 1 = skipPlay
|
2007-04-02 11:05:09 +00:00
|
|
|
void Game::totSub(int8 flags, const char *newTotFile) {
|
2006-04-13 20:56:22 +00:00
|
|
|
int8 curBackupPos;
|
|
|
|
|
|
|
|
if (_backupedCount >= 5)
|
|
|
|
return;
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
_cursorHotspotXArray[_backupedCount] = _vm->_draw->_cursorHotspotXVar;
|
|
|
|
_cursorHotspotYArray[_backupedCount] = _vm->_draw->_cursorHotspotYVar;
|
2006-04-13 20:56:22 +00:00
|
|
|
_totTextDataArray[_backupedCount] = _totTextData;
|
|
|
|
_totFileDataArray[_backupedCount] = _totFileData;
|
|
|
|
_totResourceTableArray[_backupedCount] = _totResourceTable;
|
|
|
|
_extTableArray[_backupedCount] = _extTable;
|
|
|
|
_extHandleArray[_backupedCount] = _extHandle;
|
|
|
|
_imFileDataArray[_backupedCount] = _imFileData;
|
2008-05-28 21:15:11 +00:00
|
|
|
_variablesArray[_backupedCount] = _vm->_inter->_variables;
|
2006-04-13 20:56:22 +00:00
|
|
|
strcpy(_curTotFileArray[_backupedCount], _curTotFile);
|
|
|
|
|
|
|
|
curBackupPos = _curBackupPos;
|
|
|
|
_backupedCount++;
|
|
|
|
_curBackupPos = _backupedCount;
|
|
|
|
|
|
|
|
_totTextData = 0;
|
|
|
|
_totFileData = 0;
|
|
|
|
_totResourceTable = 0;
|
2008-05-28 21:15:11 +00:00
|
|
|
if (flags & 1)
|
|
|
|
_vm->_inter->_variables = 0;
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
strncpy0(_curTotFile, newTotFile, 9);
|
2009-04-21 21:44:37 +00:00
|
|
|
// if (_vm->getGameType() == kGameTypeGeisha)
|
|
|
|
// strcat(_curTotFile, ".0OT");
|
|
|
|
// else
|
2006-04-13 20:56:22 +00:00
|
|
|
strcat(_curTotFile, ".TOT");
|
|
|
|
|
|
|
|
if (_vm->_inter->_terminate != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pushCollisions(0);
|
|
|
|
|
|
|
|
if (flags & 2)
|
|
|
|
playTot(-1);
|
|
|
|
else
|
|
|
|
playTot(0);
|
|
|
|
|
|
|
|
if (_vm->_inter->_terminate != 2)
|
|
|
|
_vm->_inter->_terminate = 0;
|
|
|
|
|
2006-05-01 12:43:50 +00:00
|
|
|
popCollisions();
|
2006-04-13 20:56:22 +00:00
|
|
|
|
2008-05-28 21:15:11 +00:00
|
|
|
if ((flags & 1) && _vm->_inter->_variables) {
|
|
|
|
_vm->_inter->delocateVars();
|
2006-11-27 14:19:30 +00:00
|
|
|
}
|
2006-04-13 20:56:22 +00:00
|
|
|
|
|
|
|
_backupedCount--;
|
|
|
|
_curBackupPos = curBackupPos;
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_backupedCount];
|
|
|
|
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_backupedCount];
|
2006-04-13 20:56:22 +00:00
|
|
|
_totTextData = _totTextDataArray[_backupedCount];
|
|
|
|
_totFileData = _totFileDataArray[_backupedCount];
|
|
|
|
_totResourceTable = _totResourceTableArray[_backupedCount];
|
|
|
|
_extTable = _extTableArray[_backupedCount];
|
|
|
|
_extHandle = _extHandleArray[_backupedCount];
|
|
|
|
_imFileData = _imFileDataArray[_backupedCount];
|
2008-05-28 21:15:11 +00:00
|
|
|
_vm->_inter->_variables = _variablesArray[_backupedCount];
|
2006-04-13 20:56:22 +00:00
|
|
|
strcpy(_curTotFile, _curTotFileArray[_backupedCount]);
|
|
|
|
strcpy(_curExtFile, _curTotFile);
|
2007-03-20 14:51:57 +00:00
|
|
|
_curExtFile[strlen(_curExtFile) - 4] = '\0';
|
2006-04-13 20:56:22 +00:00
|
|
|
strcat(_curExtFile, ".EXT");
|
|
|
|
}
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
void Game::switchTotSub(int16 index, int16 skipPlay) {
|
|
|
|
int16 backupedCount;
|
|
|
|
int16 curBackupPos;
|
|
|
|
|
|
|
|
if ((_backupedCount - index) < 1)
|
|
|
|
return;
|
|
|
|
|
2007-05-30 10:20:21 +00:00
|
|
|
int16 newPos = _curBackupPos - index - ((index >= 0) ? 1 : 0);
|
|
|
|
// WORKAROUND: Some versions don't make the MOVEMENT menu item unselectable
|
|
|
|
// in the dreamland screen, resulting in a crash when it's clicked.
|
2007-07-24 23:24:40 +00:00
|
|
|
if ((_vm->getGameType() == kGameTypeGob2) && (index == -1) && (skipPlay == 7) &&
|
2007-05-30 10:20:21 +00:00
|
|
|
!scumm_stricmp(_curTotFileArray[newPos], "gob06.tot"))
|
|
|
|
return;
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
curBackupPos = _curBackupPos;
|
|
|
|
backupedCount = _backupedCount;
|
|
|
|
if (_curBackupPos == _backupedCount) {
|
2007-04-02 11:05:09 +00:00
|
|
|
_cursorHotspotXArray[_backupedCount] = _vm->_draw->_cursorHotspotXVar;
|
|
|
|
_cursorHotspotYArray[_backupedCount] = _vm->_draw->_cursorHotspotYVar;
|
2006-05-11 19:43:30 +00:00
|
|
|
_totTextDataArray[_backupedCount] = _totTextData;
|
|
|
|
_totFileDataArray[_backupedCount] = _totFileData;
|
|
|
|
_totResourceTableArray[_backupedCount] = _totResourceTable;
|
|
|
|
_extTableArray[_backupedCount] = _extTable;
|
|
|
|
_extHandleArray[_backupedCount] = _extHandle;
|
|
|
|
_imFileDataArray[_backupedCount] = _imFileData;
|
2008-05-28 21:15:11 +00:00
|
|
|
_variablesArray[_backupedCount] = _vm->_inter->_variables;
|
2006-05-11 19:43:30 +00:00
|
|
|
strcpy(_curTotFileArray[_backupedCount], _curTotFile);
|
|
|
|
_backupedCount++;
|
|
|
|
}
|
|
|
|
_curBackupPos -= index;
|
|
|
|
if (index >= 0)
|
|
|
|
_curBackupPos--;
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_curBackupPos];
|
|
|
|
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_curBackupPos];
|
2006-05-11 19:43:30 +00:00
|
|
|
_totTextData = _totTextDataArray[_curBackupPos];
|
|
|
|
_totFileData = _totFileDataArray[_curBackupPos];
|
|
|
|
_totResourceTable = _totResourceTableArray[_curBackupPos];
|
2006-11-14 14:58:41 +00:00
|
|
|
_imFileData = _imFileDataArray[_curBackupPos];
|
2006-05-11 19:43:30 +00:00
|
|
|
_extTable = _extTableArray[_curBackupPos];
|
|
|
|
_extHandle = _extHandleArray[_curBackupPos];
|
2008-05-28 21:15:11 +00:00
|
|
|
_vm->_inter->_variables = _variablesArray[_curBackupPos];
|
2006-05-11 19:43:30 +00:00
|
|
|
strcpy(_curTotFile, _curTotFileArray[_curBackupPos]);
|
|
|
|
strcpy(_curExtFile, _curTotFile);
|
2007-03-20 14:51:57 +00:00
|
|
|
_curExtFile[strlen(_curExtFile) - 4] = '\0';
|
2006-05-11 19:43:30 +00:00
|
|
|
strcat(_curExtFile, ".EXT");
|
|
|
|
|
|
|
|
if (_vm->_inter->_terminate != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_game->pushCollisions(0);
|
|
|
|
_vm->_game->playTot(skipPlay);
|
|
|
|
|
|
|
|
if (_vm->_inter->_terminate != 2)
|
|
|
|
_vm->_inter->_terminate = 0;
|
|
|
|
|
|
|
|
_vm->_game->popCollisions();
|
|
|
|
|
|
|
|
_curBackupPos = curBackupPos;
|
|
|
|
_backupedCount = backupedCount;
|
2007-04-02 11:05:09 +00:00
|
|
|
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_curBackupPos];
|
|
|
|
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_curBackupPos];
|
2006-05-11 19:43:30 +00:00
|
|
|
_totTextData = _totTextDataArray[_curBackupPos];
|
|
|
|
_totFileData = _totFileDataArray[_curBackupPos];
|
|
|
|
_totResourceTable = _totResourceTableArray[_curBackupPos];
|
|
|
|
_extTable = _extTableArray[_curBackupPos];
|
|
|
|
_extHandle = _extHandleArray[_curBackupPos];
|
|
|
|
_imFileData = _imFileDataArray[_curBackupPos];
|
2008-05-28 21:15:11 +00:00
|
|
|
_vm->_inter->_variables = _variablesArray[_curBackupPos];
|
2006-05-11 19:43:30 +00:00
|
|
|
strcpy(_curTotFile, _curTotFileArray[_curBackupPos]);
|
|
|
|
strcpy(_curExtFile, _curTotFile);
|
2007-03-20 14:51:57 +00:00
|
|
|
_curExtFile[strlen(_curExtFile) - 4] = '\0';
|
2006-05-11 19:43:30 +00:00
|
|
|
strcat(_curExtFile, ".EXT");
|
|
|
|
}
|
|
|
|
|
2006-05-01 12:43:50 +00:00
|
|
|
int16 Game::openLocTextFile(char *locTextFile, int language) {
|
|
|
|
int n;
|
2006-04-18 09:59:18 +00:00
|
|
|
|
2006-05-01 12:43:50 +00:00
|
|
|
n = strlen(locTextFile);
|
|
|
|
if (n < 4)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
locTextFile[n - 4] = 0;
|
|
|
|
switch (language) {
|
2006-04-18 09:59:18 +00:00
|
|
|
case 0:
|
|
|
|
strcat(locTextFile, ".dat");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
strcat(locTextFile, ".all");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
strcat(locTextFile, ".esp");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
strcat(locTextFile, ".ita");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
strcat(locTextFile, ".usa");
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
strcat(locTextFile, ".ndl");
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
strcat(locTextFile, ".kor");
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
strcat(locTextFile, ".isr");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
strcat(locTextFile, ".ang");
|
|
|
|
break;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
return _vm->_dataIO->openData(locTextFile);
|
2006-05-01 12:43:50 +00:00
|
|
|
}
|
|
|
|
|
2007-07-25 20:36:14 +00:00
|
|
|
byte *Game::loadLocTexts(int32 *dataSize) {
|
2006-05-01 12:43:50 +00:00
|
|
|
char locTextFile[20];
|
|
|
|
int16 handle;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
strcpy(locTextFile, _curTotFile);
|
|
|
|
|
2007-02-12 14:37:27 +00:00
|
|
|
handle = openLocTextFile(locTextFile, _vm->_global->_languageWanted);
|
|
|
|
if (handle >= 0) {
|
2007-07-27 13:05:24 +00:00
|
|
|
|
2007-02-12 14:37:27 +00:00
|
|
|
_foundTotLoc = true;
|
|
|
|
_vm->_global->_language = _vm->_global->_languageWanted;
|
2007-07-27 13:05:24 +00:00
|
|
|
|
|
|
|
} else if (!_foundTotLoc) {
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
if (_vm->_global->_languageWanted == 2) {
|
|
|
|
handle = openLocTextFile(locTextFile, 5);
|
|
|
|
if (handle >= 0) {
|
|
|
|
_vm->_global->_language = 5;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
} else if (_vm->_global->_languageWanted == 5) {
|
|
|
|
handle = openLocTextFile(locTextFile, 2);
|
2006-08-12 09:16:08 +00:00
|
|
|
if (handle >= 0) {
|
2007-07-27 13:05:24 +00:00
|
|
|
_vm->_global->_language = 2;
|
|
|
|
found = true;
|
2006-08-12 09:16:08 +00:00
|
|
|
}
|
2006-05-01 12:43:50 +00:00
|
|
|
}
|
2007-07-27 13:05:24 +00:00
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
handle = openLocTextFile(locTextFile, i);
|
|
|
|
if (handle >= 0) {
|
|
|
|
_vm->_global->_language = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-01 12:43:50 +00:00
|
|
|
}
|
2007-07-27 13:05:24 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
debugC(1, kDebugFileIO, "Using language %d for %s",
|
|
|
|
_vm->_global->_language, _curTotFile);
|
2006-04-18 09:59:18 +00:00
|
|
|
|
|
|
|
if (handle >= 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeData(handle);
|
2007-07-25 20:36:14 +00:00
|
|
|
|
|
|
|
if (dataSize)
|
|
|
|
*dataSize = _vm->_dataIO->getDataSize(locTextFile);
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return _vm->_dataIO->getData(locTextFile);
|
2006-04-18 09:59:18 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-14 02:09:03 +00:00
|
|
|
void Game::setCollisions(byte arg_0) {
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *savedIP;
|
2007-05-01 14:49:13 +00:00
|
|
|
uint16 left;
|
|
|
|
uint16 top;
|
|
|
|
uint16 width;
|
|
|
|
uint16 height;
|
2006-05-01 12:43:50 +00:00
|
|
|
Collision *collArea;
|
|
|
|
|
2007-05-01 14:49:13 +00:00
|
|
|
for (collArea = _collisionAreas; collArea->left != 0xFFFF; collArea++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (((collArea->id & 0xC000) != 0x8000) || (collArea->funcSub == 0))
|
2006-05-01 12:43:50 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
savedIP = _vm->_global->_inter_execPtr;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_inter_execPtr = _totFileData + collArea->funcSub;
|
2006-05-01 12:43:50 +00:00
|
|
|
left = _vm->_parse->parseValExpr();
|
|
|
|
top = _vm->_parse->parseValExpr();
|
|
|
|
width = _vm->_parse->parseValExpr();
|
|
|
|
height = _vm->_parse->parseValExpr();
|
2007-05-01 14:49:13 +00:00
|
|
|
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) &&
|
|
|
|
(left != 0xFFFF)) {
|
2006-05-01 12:43:50 +00:00
|
|
|
left += _vm->_draw->_backDeltaX;
|
|
|
|
top += _vm->_draw->_backDeltaY;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_vm->_draw->_needAdjust != 2) {
|
2006-05-01 12:43:50 +00:00
|
|
|
_vm->_draw->adjustCoords(0, &left, &top);
|
|
|
|
if ((collArea->flags & 0x0F) < 3)
|
|
|
|
_vm->_draw->adjustCoords(2, &width, &height);
|
|
|
|
else {
|
|
|
|
height &= 0xFFFE;
|
|
|
|
_vm->_draw->adjustCoords(2, 0, &height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
collArea->left = left;
|
|
|
|
collArea->top = top;
|
|
|
|
collArea->right = left + width - 1;
|
|
|
|
collArea->bottom = top + height - 1;
|
|
|
|
_vm->_global->_inter_execPtr = savedIP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-07 13:08:17 +00:00
|
|
|
void Game::collSub(uint16 offset) {
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *savedIP;
|
2006-05-01 12:43:50 +00:00
|
|
|
int16 collStackSize;
|
|
|
|
|
|
|
|
savedIP = _vm->_global->_inter_execPtr;
|
|
|
|
_vm->_global->_inter_execPtr = _totFileData + offset;
|
|
|
|
|
|
|
|
_shouldPushColls = 1;
|
|
|
|
collStackSize = _collStackSize;
|
|
|
|
|
|
|
|
_vm->_inter->funcBlock(0);
|
|
|
|
|
|
|
|
if (collStackSize != _collStackSize)
|
|
|
|
popCollisions();
|
|
|
|
|
|
|
|
_shouldPushColls = 0;
|
|
|
|
_vm->_global->_inter_execPtr = savedIP;
|
|
|
|
setCollisions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Game::collAreaSub(int16 index, int8 enter) {
|
|
|
|
uint16 collId;
|
|
|
|
|
|
|
|
collId = _collisionAreas[index].id & 0xF000;
|
|
|
|
|
2006-11-14 15:39:11 +00:00
|
|
|
if ((collId == 0xA000) || (collId == 0x9000)) {
|
2006-11-14 14:58:41 +00:00
|
|
|
if (enter == 0)
|
|
|
|
WRITE_VAR(17, _collisionAreas[index].id & 0x0FFF);
|
|
|
|
else
|
|
|
|
WRITE_VAR(17, -(_collisionAreas[index].id & 0x0FFF));
|
|
|
|
}
|
|
|
|
|
2006-05-01 12:43:50 +00:00
|
|
|
if (enter != 0) {
|
|
|
|
if (_collisionAreas[index].funcEnter != 0)
|
|
|
|
collSub(_collisionAreas[index].funcEnter);
|
|
|
|
} else {
|
|
|
|
if (_collisionAreas[index].funcLeave != 0)
|
|
|
|
collSub(_collisionAreas[index].funcLeave);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
} // End of namespace Gob
|