2006-02-22 22:40:53 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* cinE Engine is (C) 2004-2005 by CinE Team
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cine/cine.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/unpack.h"
|
|
|
|
#include "cine/various.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
namespace Cine {
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 numElementInPart;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
AnimData *animDataTable;
|
2006-02-27 21:25:59 +00:00
|
|
|
PartBuffer *partBuffer;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
void loadPart(const char *partName) {
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 i;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
memset(partBuffer, 0, sizeof(PartBuffer) * NUM_MAX_PARTDATA);
|
2006-02-22 22:40:53 +00:00
|
|
|
numElementInPart = 0;
|
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
g_cine->_partFileHandle.close();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
checkDataDisk(-1);
|
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
if (!g_cine->_partFileHandle.open(partName))
|
|
|
|
error("loadPart(): Cannot open file %s", partName);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
setMouseCursor(MOUSE_CURSOR_DISK);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
numElementInPart = g_cine->_partFileHandle.readUint16BE();
|
|
|
|
g_cine->_partFileHandle.readUint16BE(); // entry size
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
strcpy(currentPartName, partName);
|
|
|
|
|
|
|
|
for (i = 0; i < numElementInPart; i++) {
|
2007-05-30 18:43:28 +00:00
|
|
|
g_cine->_partFileHandle.read(partBuffer[i].partName, 14);
|
|
|
|
partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE();
|
|
|
|
partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE();
|
|
|
|
partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE();
|
|
|
|
g_cine->_partFileHandle.readUint32BE(); // unused
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2007-05-13 16:07:33 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_FW && g_cine->getPlatform() == Common::kPlatformPC && strcmp(partName, "BASESON.SND") != 0)
|
2006-02-22 22:40:53 +00:00
|
|
|
loadPal(partName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void closePart(void) {
|
2007-05-29 20:22:20 +00:00
|
|
|
// TODO
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
static const char *bundleNamesDOSEN[] = {
|
2006-02-22 22:40:53 +00:00
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCEGOU",
|
|
|
|
"PROCLABY",
|
|
|
|
"PROCS00",
|
|
|
|
"PROCS01",
|
|
|
|
"PROCS02",
|
|
|
|
"PROCS03",
|
|
|
|
"PROCS04",
|
|
|
|
"PROCS06",
|
|
|
|
"PROCS07",
|
|
|
|
"PROCS08",
|
|
|
|
"PROCS10",
|
|
|
|
"PROCS12",
|
|
|
|
"PROCS13",
|
|
|
|
"PROCS15",
|
|
|
|
"PROCS16",
|
|
|
|
"RSC00",
|
|
|
|
"RSC01",
|
|
|
|
"RSC02",
|
|
|
|
"RSC03",
|
|
|
|
"RSC04",
|
|
|
|
"RSC05",
|
|
|
|
"RSC06",
|
|
|
|
"RSC07",
|
|
|
|
"RSC08",
|
|
|
|
"RSC09",
|
|
|
|
"RSC10",
|
|
|
|
"RSC11",
|
|
|
|
"RSC12",
|
|
|
|
"RSC13",
|
|
|
|
"RSC14",
|
|
|
|
"RSC15",
|
|
|
|
"RSC16",
|
|
|
|
"RSC17",
|
|
|
|
"SONS1",
|
|
|
|
"SONS2",
|
|
|
|
"SONS3",
|
|
|
|
"SONS4",
|
|
|
|
"SONS5",
|
|
|
|
"SONS6",
|
|
|
|
"SONS7",
|
|
|
|
"SONS8",
|
|
|
|
"SONS9",
|
2006-10-15 01:06:44 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesDOSUS[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCEGOU",
|
|
|
|
"PROCLABY",
|
|
|
|
"PROCS00",
|
|
|
|
"PROCS01",
|
|
|
|
"PROCS02",
|
|
|
|
"PROCS03",
|
|
|
|
"PROCS04",
|
|
|
|
"PROCS06",
|
|
|
|
"PROCS07",
|
|
|
|
"PROCS08",
|
|
|
|
"PROCS12",
|
|
|
|
"PROCS13",
|
|
|
|
"PROCS15",
|
|
|
|
"PROCS16",
|
|
|
|
"RSC00",
|
|
|
|
"RSC02",
|
|
|
|
"RSC03",
|
|
|
|
"RSC04",
|
|
|
|
"RSC05",
|
|
|
|
"RSC06",
|
|
|
|
"RSC07",
|
|
|
|
"RSC08",
|
|
|
|
"RSC09",
|
|
|
|
"RSC10",
|
|
|
|
"RSC11",
|
|
|
|
"RSC12",
|
|
|
|
"RSC13",
|
|
|
|
"RSC14",
|
|
|
|
"RSC15",
|
|
|
|
"RSC16",
|
|
|
|
"RSC17",
|
|
|
|
"SONS31",
|
|
|
|
"SONS32",
|
|
|
|
"SONS33",
|
|
|
|
"SONS34",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesDOSFR[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCEGOU",
|
|
|
|
"PROCLABY",
|
|
|
|
"PROCS00",
|
|
|
|
"PROCS01",
|
|
|
|
"PROCS02",
|
|
|
|
"PROCS03",
|
|
|
|
"PROCS04",
|
|
|
|
"PROCS06",
|
|
|
|
"PROCS07",
|
|
|
|
"PROCS08",
|
|
|
|
"PROCS10",
|
|
|
|
"PROCS12",
|
|
|
|
"PROCS13",
|
|
|
|
"PROCS15",
|
|
|
|
"PROCS16",
|
|
|
|
"RSC00",
|
|
|
|
"RSC01",
|
|
|
|
"RSC02",
|
|
|
|
"RSC03",
|
|
|
|
"RSC04",
|
|
|
|
"RSC05",
|
|
|
|
"RSC06",
|
|
|
|
"RSC07",
|
|
|
|
"RSC08",
|
|
|
|
"RSC09",
|
|
|
|
"RSC10",
|
|
|
|
"RSC11",
|
|
|
|
"RSC12",
|
|
|
|
"RSC13",
|
|
|
|
"RSC14",
|
|
|
|
"RSC15",
|
|
|
|
"RSC16",
|
|
|
|
"RSC17",
|
|
|
|
"SONS31",
|
2006-03-23 03:15:39 +00:00
|
|
|
"SONS32",
|
|
|
|
"SONS33",
|
2006-10-15 01:06:44 +00:00
|
|
|
"SONS34",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesDOSES[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCS1",
|
|
|
|
"PROCS2",
|
|
|
|
"PROCS3",
|
|
|
|
"PROCS4",
|
|
|
|
"PROCS5",
|
|
|
|
"PROCS6",
|
|
|
|
"SD01A",
|
|
|
|
"SD01B",
|
|
|
|
"SD01C",
|
|
|
|
"SD01D",
|
|
|
|
"SD021",
|
|
|
|
"SD022",
|
|
|
|
"SD03",
|
|
|
|
"SDSONS",
|
|
|
|
"SDSONS2",
|
|
|
|
"SDSONS3",
|
|
|
|
"SINTRO2",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesDOSInt[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCS1",
|
|
|
|
"PROCS2",
|
|
|
|
"PROCS3",
|
|
|
|
"PROCS4",
|
|
|
|
"PROCS5",
|
|
|
|
"PROCS6",
|
|
|
|
"SD01A",
|
|
|
|
"SD01B",
|
|
|
|
"SD01C",
|
|
|
|
"SD01D",
|
|
|
|
"SD021",
|
|
|
|
"SD022",
|
|
|
|
"SD03",
|
|
|
|
"SDS1",
|
|
|
|
"SDS2",
|
|
|
|
"SDS3",
|
|
|
|
"SDS4",
|
|
|
|
"SDS5",
|
|
|
|
"SDS6",
|
|
|
|
"SINTRO2",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesAmiga[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCS0",
|
|
|
|
"PROCS1",
|
|
|
|
"PROCS2",
|
|
|
|
"SAMPLES",
|
|
|
|
"SAMPLES2",
|
|
|
|
"SAMPLES3",
|
|
|
|
"SD01A",
|
|
|
|
"SD01B",
|
|
|
|
"SD01C",
|
|
|
|
"SD01D",
|
|
|
|
"SD02",
|
|
|
|
"SD03",
|
|
|
|
"SDSONS",
|
|
|
|
"SDSONS2",
|
|
|
|
"SDSONS3",
|
|
|
|
"SINTRO2",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesAmigaDemo[] = {
|
|
|
|
"DEMO_OS",
|
|
|
|
"SDSONS",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *bundleNamesAtari[] = {
|
|
|
|
"EGOUBASE",
|
|
|
|
"LABYBASE",
|
|
|
|
"PROCS0",
|
|
|
|
"PROCS1",
|
|
|
|
"PROCS2",
|
|
|
|
"SAMPLES",
|
|
|
|
"SD01A",
|
|
|
|
"SD01B",
|
|
|
|
"SD01C",
|
|
|
|
"SD01D",
|
|
|
|
"SD02",
|
|
|
|
"SD03",
|
|
|
|
"SDSONS",
|
|
|
|
"SDSONS2",
|
|
|
|
"SDSONS3",
|
|
|
|
"SINTRO2",
|
|
|
|
NULL
|
2006-02-22 22:40:53 +00:00
|
|
|
};
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 findFileInBundle(const char *fileName) {
|
|
|
|
uint16 i;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2006-02-22 22:40:53 +00:00
|
|
|
for (i = 0; i < numElementInPart; i++) {
|
2007-05-20 11:48:53 +00:00
|
|
|
if (!scumm_stricmp(fileName, partBuffer[i].partName)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-22 15:50:30 +00:00
|
|
|
const char **bPtr = 0;
|
2006-10-15 01:06:44 +00:00
|
|
|
|
|
|
|
if (g_cine->getPlatform() == Common::kPlatformPC) {
|
|
|
|
switch (g_cine->getLanguage()) {
|
|
|
|
case Common::EN_GRB:
|
|
|
|
bPtr = bundleNamesDOSEN;
|
|
|
|
break;
|
|
|
|
case Common::EN_USA:
|
|
|
|
if (g_cine->getFeatures() & GF_CD)
|
|
|
|
bPtr = bundleNamesDOSUS;
|
|
|
|
else
|
|
|
|
bPtr = bundleNamesDOSInt;
|
|
|
|
break;
|
|
|
|
case Common::DE_DEU:
|
|
|
|
case Common::IT_ITA:
|
|
|
|
bPtr = bundleNamesDOSInt;
|
|
|
|
break;
|
|
|
|
case Common::ES_ESP:
|
|
|
|
if (g_cine->getFeatures() & GF_CD)
|
|
|
|
bPtr = bundleNamesDOSInt;
|
|
|
|
else
|
|
|
|
bPtr = bundleNamesDOSES;
|
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
|
|
|
bPtr = bundleNamesDOSFR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (g_cine->getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
if (g_cine->getFeatures() & GF_DEMO)
|
|
|
|
bPtr = bundleNamesAmigaDemo;
|
|
|
|
else
|
|
|
|
bPtr = bundleNamesAmiga;
|
|
|
|
} else if (g_cine->getPlatform() == Common::kPlatformAtariST) {
|
|
|
|
bPtr = bundleNamesAtari;
|
|
|
|
}
|
|
|
|
|
2007-05-20 11:48:53 +00:00
|
|
|
while (*bPtr) {
|
2006-10-15 01:06:44 +00:00
|
|
|
loadPart(*bPtr);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numElementInPart; i++) {
|
2007-05-20 11:48:53 +00:00
|
|
|
if (!scumm_stricmp(fileName, partBuffer[i].partName)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2006-10-15 01:06:44 +00:00
|
|
|
bPtr++;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < numElementInPart; i++) {
|
2007-05-20 11:48:53 +00:00
|
|
|
if (!scumm_stricmp(fileName, partBuffer[i].partName)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void readFromPart(int16 idx, byte *dataPtr) {
|
2006-03-16 20:29:07 +00:00
|
|
|
setMouseCursor(MOUSE_CURSOR_DISK);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
g_cine->_partFileHandle.seek(partBuffer[idx].offset, SEEK_SET);
|
|
|
|
g_cine->_partFileHandle.read(dataPtr, partBuffer[idx].packedSize);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte *readBundleFile(int16 foundFileIdx) {
|
|
|
|
byte *dataPtr;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-05-26 09:36:41 +00:00
|
|
|
dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-25 18:16:40 +00:00
|
|
|
if (partBuffer[foundFileIdx].unpackedSize != partBuffer[foundFileIdx].packedSize) {
|
2006-03-23 03:45:52 +00:00
|
|
|
byte *unpackBuffer;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize);
|
2006-02-22 22:40:53 +00:00
|
|
|
readFromPart(foundFileIdx, unpackBuffer);
|
2006-02-25 18:26:16 +00:00
|
|
|
delphineUnpack(dataPtr, unpackBuffer, partBuffer[foundFileIdx].packedSize);
|
2006-02-22 22:40:53 +00:00
|
|
|
free(unpackBuffer);
|
|
|
|
} else {
|
|
|
|
readFromPart(foundFileIdx, dataPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dataPtr;
|
|
|
|
}
|
2006-02-25 00:26:14 +00:00
|
|
|
|
2007-05-20 11:48:53 +00:00
|
|
|
byte *readBundleSoundFile(const char *entryName, uint32 *size) {
|
2007-05-13 16:07:33 +00:00
|
|
|
int16 index;
|
|
|
|
byte *data = 0;
|
|
|
|
char previousPartName[15] = "";
|
|
|
|
|
|
|
|
if (g_cine->getGameType() == Cine::GType_FW) {
|
|
|
|
strcpy(previousPartName, currentPartName);
|
|
|
|
loadPart("BASESON.SND");
|
|
|
|
}
|
|
|
|
index = findFileInBundle((const char *)entryName);
|
|
|
|
if (index != -1) {
|
|
|
|
data = readBundleFile(index);
|
2007-05-20 11:48:53 +00:00
|
|
|
if (size) {
|
|
|
|
*size = partBuffer[index].unpackedSize;
|
|
|
|
}
|
2007-05-13 16:07:33 +00:00
|
|
|
}
|
|
|
|
if (g_cine->getGameType() == Cine::GType_FW) {
|
|
|
|
loadPart(previousPartName);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte *readFile(const char *filename) {
|
2006-03-23 03:15:39 +00:00
|
|
|
Common::File in;
|
|
|
|
|
|
|
|
in.open(filename);
|
|
|
|
|
|
|
|
if (!in.isOpen())
|
|
|
|
error("readFile(): Cannot open file %s", filename);
|
|
|
|
|
|
|
|
uint32 size = in.size();
|
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
byte *dataPtr = (byte *)malloc(size);
|
2006-03-23 03:15:39 +00:00
|
|
|
in.read(dataPtr, size);
|
|
|
|
|
|
|
|
return dataPtr;
|
|
|
|
}
|
|
|
|
|
2007-05-13 16:07:33 +00:00
|
|
|
void checkDataDisk(int16 param) {
|
|
|
|
}
|
|
|
|
|
2006-11-23 06:47:41 +00:00
|
|
|
void dumpBundle(const char *fileName) {
|
|
|
|
char tmpPart[15];
|
|
|
|
|
|
|
|
strcpy(tmpPart, currentPartName);
|
|
|
|
|
|
|
|
loadPart(fileName);
|
|
|
|
for (int i = 0; i < numElementInPart; i++) {
|
|
|
|
byte *data = readBundleFile(i);
|
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
debug(0, "%s", partBuffer[i].partName);
|
|
|
|
|
2006-11-23 06:47:41 +00:00
|
|
|
Common::File out;
|
2007-05-30 18:43:28 +00:00
|
|
|
if (out.open(Common::String("dumps/") + partBuffer[i].partName, Common::File::kFileWriteMode)) {
|
|
|
|
out.write(data, partBuffer[i].unpackedSize);
|
|
|
|
out.close();
|
|
|
|
}
|
2006-11-23 06:47:41 +00:00
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
free(data);
|
2006-11-23 06:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
loadPart(tmpPart);
|
|
|
|
}
|
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
} // End of namespace Cine
|