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.
|
2002-08-29 16:57:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-08-29 16:57:43 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-09-13 23:29:38 +00:00
|
|
|
*
|
2002-08-29 16:57:43 +00:00
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-04-10 12:59:17 +00:00
|
|
|
|
2006-03-03 15:16:02 +00:00
|
|
|
#include "scumm/file.h"
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v2.h"
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/resource.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine_v2::readClassicIndexFile() {
|
2003-06-02 18:15:09 +00:00
|
|
|
int i;
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_MANIAC) {
|
2007-02-25 07:23:52 +00:00
|
|
|
if (_game.version == 0) {
|
2005-05-17 23:56:21 +00:00
|
|
|
_numGlobalObjects = 256;
|
|
|
|
_numRooms = 55;
|
|
|
|
_numCostumes = 25;
|
|
|
|
_numScripts = 160;
|
|
|
|
_numSounds = 70;
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.platform == Common::kPlatformNES) {
|
2005-03-27 21:21:05 +00:00
|
|
|
_numGlobalObjects = 775;
|
2005-05-17 23:56:21 +00:00
|
|
|
_numRooms = 55;
|
2005-03-13 23:18:59 +00:00
|
|
|
|
2005-04-10 09:58:37 +00:00
|
|
|
// costumes 25-36 are special. see v1MMNEScostTables[] in costume.cpp
|
|
|
|
// costumes 37-76 are room graphics resources
|
|
|
|
// costume 77 is a character set translation table
|
|
|
|
// costume 78 is a preposition list
|
|
|
|
// costume 79 is unused but allocated, so the total is a nice even number :)
|
|
|
|
_numCostumes = 80;
|
2005-05-17 23:56:21 +00:00
|
|
|
_numScripts = 200;
|
|
|
|
_numSounds = 100;
|
|
|
|
} else {
|
|
|
|
_numGlobalObjects = 800;
|
|
|
|
_numRooms = 55;
|
2005-03-13 23:18:59 +00:00
|
|
|
_numCostumes = 35;
|
2005-05-17 23:56:21 +00:00
|
|
|
_numScripts = 200;
|
|
|
|
_numSounds = 100;
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.id == GID_ZAK) {
|
|
|
|
if (_game.platform == Common::kPlatformC64) {
|
2005-05-17 23:56:21 +00:00
|
|
|
_numGlobalObjects = 775;
|
|
|
|
_numRooms = 59;
|
|
|
|
_numCostumes = 38;
|
|
|
|
_numScripts = 155;
|
|
|
|
_numSounds = 127;
|
|
|
|
} else {
|
|
|
|
_numGlobalObjects = 775;
|
|
|
|
_numRooms = 61;
|
|
|
|
_numCostumes = 37;
|
|
|
|
_numScripts = 155;
|
|
|
|
_numSounds = 120;
|
|
|
|
}
|
2003-06-02 17:32:13 +00:00
|
|
|
}
|
|
|
|
|
2005-03-30 21:59:12 +00:00
|
|
|
_fileHandle->seek(0, SEEK_SET);
|
2003-06-02 17:32:13 +00:00
|
|
|
|
2005-04-03 23:53:34 +00:00
|
|
|
readMAXS(0);
|
2005-04-10 00:51:47 +00:00
|
|
|
allocateArrays();
|
2003-06-02 17:32:13 +00:00
|
|
|
|
2005-03-30 21:59:12 +00:00
|
|
|
_fileHandle->readUint16LE(); /* version magic number */
|
2003-06-02 18:15:09 +00:00
|
|
|
for (i = 0; i != _numGlobalObjects; i++) {
|
2005-03-30 21:59:12 +00:00
|
|
|
byte tmp = _fileHandle->readByte();
|
2003-06-02 17:32:13 +00:00
|
|
|
_objectOwnerTable[i] = tmp & OF_OWNER_MASK;
|
|
|
|
_objectStateTable[i] = tmp >> OF_STATE_SHL;
|
|
|
|
}
|
2003-06-02 18:15:09 +00:00
|
|
|
|
|
|
|
for (i = 0; i < _numRooms; i++) {
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->roomno[rtRoom][i] = i;
|
2003-06-04 12:48:50 +00:00
|
|
|
}
|
2005-03-30 21:59:12 +00:00
|
|
|
_fileHandle->seek(_numRooms, SEEK_CUR);
|
2003-06-04 12:48:50 +00:00
|
|
|
for (i = 0; i < _numRooms; i++) {
|
2007-04-01 15:58:34 +00:00
|
|
|
_res->roomoffs[rtRoom][i] = _fileHandle->readUint16LE();
|
|
|
|
if (_res->roomoffs[rtRoom][i] == 0xFFFF)
|
2007-04-15 15:40:24 +00:00
|
|
|
_res->roomoffs[rtRoom][i] = (uint32)RES_INVALID_OFFSET;
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _numCostumes; i++) {
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->roomno[rtCostume][i] = _fileHandle->readByte();
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < _numCostumes; i++) {
|
2007-04-01 15:58:34 +00:00
|
|
|
_res->roomoffs[rtCostume][i] = _fileHandle->readUint16LE();
|
|
|
|
if (_res->roomoffs[rtCostume][i] == 0xFFFF)
|
2007-04-15 15:40:24 +00:00
|
|
|
_res->roomoffs[rtCostume][i] = (uint32)RES_INVALID_OFFSET;
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _numScripts; i++) {
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->roomno[rtScript][i] = _fileHandle->readByte();
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < _numScripts; i++) {
|
2007-04-01 15:58:34 +00:00
|
|
|
_res->roomoffs[rtScript][i] = _fileHandle->readUint16LE();
|
|
|
|
if (_res->roomoffs[rtScript][i] == 0xFFFF)
|
2007-04-15 15:40:24 +00:00
|
|
|
_res->roomoffs[rtScript][i] = (uint32)RES_INVALID_OFFSET;
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _numSounds; i++) {
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->roomno[rtSound][i] = _fileHandle->readByte();
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < _numSounds; i++) {
|
2007-04-01 15:58:34 +00:00
|
|
|
_res->roomoffs[rtSound][i] = _fileHandle->readUint16LE();
|
|
|
|
if (_res->roomoffs[rtSound][i] == 0xFFFF)
|
2007-04-15 15:40:24 +00:00
|
|
|
_res->roomoffs[rtSound][i] = (uint32)RES_INVALID_OFFSET;
|
2003-06-02 18:15:09 +00:00
|
|
|
}
|
2003-05-29 08:05:20 +00:00
|
|
|
}
|
2002-08-29 16:57:43 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine_v2::readEnhancedIndexFile() {
|
2003-08-14 02:28:19 +00:00
|
|
|
|
2005-03-30 21:59:12 +00:00
|
|
|
_numGlobalObjects = _fileHandle->readUint16LE();
|
2005-04-10 00:51:47 +00:00
|
|
|
_fileHandle->seek(_numGlobalObjects, SEEK_CUR);
|
2005-03-30 21:59:12 +00:00
|
|
|
_numRooms = _fileHandle->readByte();
|
|
|
|
_fileHandle->seek(_numRooms * 3, SEEK_CUR);
|
|
|
|
_numCostumes = _fileHandle->readByte();
|
|
|
|
_fileHandle->seek(_numCostumes * 3, SEEK_CUR);
|
|
|
|
_numScripts = _fileHandle->readByte();
|
|
|
|
_fileHandle->seek(_numScripts * 3, SEEK_CUR);
|
|
|
|
_numSounds = _fileHandle->readByte();
|
2002-08-29 16:57:43 +00:00
|
|
|
|
2009-07-29 21:39:00 +00:00
|
|
|
_fileHandle->clearErr();
|
2005-03-30 21:59:12 +00:00
|
|
|
_fileHandle->seek(0, SEEK_SET);
|
2002-08-29 16:57:43 +00:00
|
|
|
|
2005-04-03 23:53:34 +00:00
|
|
|
readMAXS(0);
|
2005-04-10 00:51:47 +00:00
|
|
|
allocateArrays();
|
2002-09-24 15:46:09 +00:00
|
|
|
|
2005-03-30 21:59:12 +00:00
|
|
|
_fileHandle->readUint16LE(); /* version magic number */
|
2005-04-10 00:51:47 +00:00
|
|
|
readGlobalObjects();
|
2007-02-24 19:29:40 +00:00
|
|
|
readResTypeList(rtRoom);
|
|
|
|
readResTypeList(rtCostume);
|
|
|
|
readResTypeList(rtScript);
|
|
|
|
readResTypeList(rtSound);
|
2005-04-10 00:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v2::readGlobalObjects() {
|
|
|
|
int i;
|
2005-03-30 21:59:12 +00:00
|
|
|
int num = _fileHandle->readUint16LE();
|
2003-04-20 20:58:00 +00:00
|
|
|
assert(num == _numGlobalObjects);
|
2005-04-10 00:51:47 +00:00
|
|
|
|
|
|
|
for (i = 0; i != num; i++) {
|
2005-03-30 21:59:12 +00:00
|
|
|
byte tmp = _fileHandle->readByte();
|
2003-04-20 21:09:43 +00:00
|
|
|
_objectOwnerTable[i] = tmp & OF_OWNER_MASK;
|
|
|
|
_objectStateTable[i] = tmp >> OF_STATE_SHL;
|
2003-04-20 20:58:00 +00:00
|
|
|
}
|
2003-05-29 08:05:20 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine_v2::readIndexFile() {
|
2003-05-29 08:05:20 +00:00
|
|
|
int magic = 0;
|
|
|
|
debug(9, "readIndexFile()");
|
|
|
|
|
|
|
|
closeRoom();
|
|
|
|
openRoom(0);
|
|
|
|
|
2005-03-30 21:59:12 +00:00
|
|
|
magic = _fileHandle->readUint16LE();
|
2003-05-29 08:05:20 +00:00
|
|
|
|
2004-10-22 10:25:56 +00:00
|
|
|
switch (magic) {
|
2003-05-29 08:05:20 +00:00
|
|
|
case 0x0100:
|
2003-09-06 03:48:08 +00:00
|
|
|
printf("Enhanced V2 game detected\n");
|
2006-05-28 12:12:30 +00:00
|
|
|
assert(_game.version == 2);
|
2005-07-30 21:11:48 +00:00
|
|
|
readEnhancedIndexFile();
|
2003-05-29 08:05:20 +00:00
|
|
|
break;
|
|
|
|
case 0x0A31:
|
2003-09-06 03:48:08 +00:00
|
|
|
printf("Classic V1 game detected\n");
|
2006-05-28 12:12:30 +00:00
|
|
|
assert(_game.version == 1);
|
2003-05-29 08:05:20 +00:00
|
|
|
readClassicIndexFile();
|
|
|
|
break;
|
2003-08-14 11:40:50 +00:00
|
|
|
case 0x4643:
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(_game.platform == Common::kPlatformNES))
|
2005-03-15 17:56:50 +00:00
|
|
|
error("Use maniac target");
|
2003-09-06 03:48:08 +00:00
|
|
|
printf("NES V1 game detected\n");
|
2006-05-28 12:12:30 +00:00
|
|
|
assert(_game.version == 1);
|
2003-08-14 11:40:50 +00:00
|
|
|
readClassicIndexFile();
|
|
|
|
break;
|
2005-05-17 23:56:21 +00:00
|
|
|
case 0x132:
|
|
|
|
printf("C64 V1 game detected\n");
|
2008-11-29 18:01:16 +00:00
|
|
|
if (_game.id == GID_MANIAC) {
|
2006-05-29 12:45:11 +00:00
|
|
|
assert(_game.version == 0);
|
2008-11-29 18:01:16 +00:00
|
|
|
} else {
|
2006-05-29 12:45:11 +00:00
|
|
|
assert(_game.version == 1);
|
2008-11-29 18:01:16 +00:00
|
|
|
}
|
2005-05-17 23:56:21 +00:00
|
|
|
readClassicIndexFile();
|
|
|
|
break;
|
2007-02-25 06:21:57 +00:00
|
|
|
case 0x032:
|
|
|
|
printf("Apple II V1 game detected\n");
|
|
|
|
assert(_game.version == 0);
|
|
|
|
readClassicIndexFile();
|
|
|
|
break;
|
2003-05-29 08:05:20 +00:00
|
|
|
default:
|
|
|
|
error("Unknown magic id (0x%X) - this version is unsupported", magic);
|
|
|
|
break;
|
|
|
|
}
|
2002-08-29 16:57:43 +00:00
|
|
|
|
2002-12-22 21:58:16 +00:00
|
|
|
closeRoom();
|
2002-08-29 16:57:43 +00:00
|
|
|
}
|
2003-03-07 21:38:46 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine_v2::loadCharset(int num) {
|
2003-09-06 03:36:54 +00:00
|
|
|
// Stub, V2 font resources are hardcoded into the engine.
|
2003-04-20 16:37:43 +00:00
|
|
|
}
|
2003-10-03 18:33:57 +00:00
|
|
|
|
|
|
|
} // End of namespace Scumm
|