2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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-02-22 22:40:53 +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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-03-29 15:59:37 +00:00
|
|
|
#include "common/endian.h"
|
2006-05-26 09:36:41 +00:00
|
|
|
#include "common/stream.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
#include "cine/cine.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/various.h"
|
2008-04-07 20:24:40 +00:00
|
|
|
#include "cine/bg.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 bgVar0;
|
2007-12-13 12:33:31 +00:00
|
|
|
byte *additionalBgTable[9];
|
|
|
|
byte currentAdditionalBgIdx = 0, currentAdditionalBgIdx2 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte loadCt(const char *ctName) {
|
2006-02-25 18:16:40 +00:00
|
|
|
uint16 header[32];
|
2007-05-29 21:06:07 +00:00
|
|
|
byte *ptr, *dataPtr;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-06-08 19:29:48 +00:00
|
|
|
if (currentCtName != ctName)
|
|
|
|
strcpy(currentCtName, ctName);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-05-29 21:06:07 +00:00
|
|
|
ptr = dataPtr = readBundleFile(findFileInBundle(ctName));
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2006-03-16 20:29:07 +00:00
|
|
|
uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
if (bpp == 8) {
|
2008-04-07 20:24:40 +00:00
|
|
|
ctColorMode = 1;
|
2008-04-21 20:51:17 +00:00
|
|
|
memcpy(newPalette, ptr, 256 * 3);
|
2006-03-16 20:29:07 +00:00
|
|
|
ptr += 3 * 256;
|
2008-04-07 20:24:40 +00:00
|
|
|
memcpy(page3Raw, ptr, 320 * 200);
|
2006-03-16 20:29:07 +00:00
|
|
|
} else {
|
2008-04-07 20:24:40 +00:00
|
|
|
ctColorMode = 0;
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
tempPalette[i] = READ_BE_UINT16(ptr);
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
gfxResetRawPage(page3Raw);
|
|
|
|
gfxConvertSpriteToRaw(page3Raw, ptr, 160, 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
loadRelatedPalette(ctName);
|
|
|
|
|
2006-03-23 03:17:47 +00:00
|
|
|
assert(strstr(ctName, ".NEO"));
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-05-26 09:36:41 +00:00
|
|
|
Common::MemoryReadStream readS(ptr, 32);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2006-05-26 09:36:41 +00:00
|
|
|
header[i] = readS.readUint16BE();
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-06 20:57:58 +00:00
|
|
|
gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 21:06:07 +00:00
|
|
|
free(dataPtr);
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
void loadBgHigh(const char *currentPtr) {
|
2008-04-07 20:24:40 +00:00
|
|
|
memcpy(newPalette, currentPtr, 256 * 3);
|
2006-02-22 22:40:53 +00:00
|
|
|
currentPtr += 256 * 3;
|
|
|
|
|
|
|
|
memcpy(page2Raw, currentPtr, 320 * 200);
|
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
newColorMode = 2;
|
|
|
|
bgColorMode = 1;
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte loadBg(const char *bgName) {
|
2007-05-29 21:06:07 +00:00
|
|
|
byte *ptr, *dataPtr;
|
|
|
|
|
2007-06-08 19:29:48 +00:00
|
|
|
if (currentBgName[0] != bgName)
|
|
|
|
strcpy(currentBgName[0], bgName);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte fileIdx = findFileInBundle(bgName);
|
2007-05-29 21:06:07 +00:00
|
|
|
ptr = dataPtr = readBundleFile(fileIdx);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
if (bpp == 8) {
|
|
|
|
loadBgHigh((const char *)ptr);
|
|
|
|
} else {
|
2008-04-07 20:24:40 +00:00
|
|
|
newColorMode = 1;
|
|
|
|
bgColorMode = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2006-04-07 01:04:09 +00:00
|
|
|
tempPalette[i] = READ_BE_UINT16(ptr);
|
|
|
|
ptr += 2;
|
2006-03-16 20:29:07 +00:00
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-09 13:41:59 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_FW) {
|
|
|
|
loadRelatedPalette(bgName);
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
gfxResetRawPage(page2Raw);
|
|
|
|
gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2007-05-29 21:06:07 +00:00
|
|
|
free(dataPtr);
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
void addBackground(const char *bgName, uint16 bgIdx) {
|
2007-05-29 21:06:07 +00:00
|
|
|
byte *ptr, *dataPtr;
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
strcpy(currentBgName[bgIdx], bgName);
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte fileIdx = findFileInBundle(bgName);
|
2007-05-29 21:06:07 +00:00
|
|
|
ptr = dataPtr = readBundleFile(fileIdx);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
additionalBgTable[bgIdx] = (byte *) malloc(320 * 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
|
2008-04-07 20:24:40 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
if (bpp == 8) {
|
2008-04-07 20:24:40 +00:00
|
|
|
bgColorMode = 1;
|
2008-04-21 20:51:17 +00:00
|
|
|
memcpy(newPalette, ptr, 256 * 3);
|
2006-03-16 20:29:07 +00:00
|
|
|
ptr += 3 * 256;
|
|
|
|
memcpy(additionalBgTable[bgIdx], ptr, 320 * 200);
|
|
|
|
} else {
|
2008-04-07 20:24:40 +00:00
|
|
|
bgColorMode = 0;
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
tempPalette[i] = READ_BE_UINT16(ptr);
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr, 160, 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2007-05-29 21:06:07 +00:00
|
|
|
free(dataPtr);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2006-02-25 00:26:14 +00:00
|
|
|
|
|
|
|
} // End of namespace Cine
|