示例#1
0
byte loadCtFW(const char *ctName) {
	debugC(1, kCineDebugCollision, "loadCtFW(\"%s\")", ctName);
	uint16 header[32];
	byte *ptr, *dataPtr;

	int16 foundFileIdx = findFileInBundle(ctName);
	if (foundFileIdx == -1) {
		warning("loadCtFW: Unable to find collision data file '%s'", ctName);
		// FIXME: Rework this function's return value policy and return an appropriate value here.
		// The return value isn't yet used for anything so currently it doesn't really matter.
		return 0;
	}

	if (currentCtName != ctName)
		strcpy(currentCtName, ctName);

	ptr = dataPtr = readBundleFile(foundFileIdx);

	loadRelatedPalette(ctName);

	assert(strstr(ctName, ".NEO"));

	Common::MemoryReadStream readS(ptr, 32);

	for (int i = 0; i < 16; i++) {
		header[i] = readS.readUint16BE();
	}

	gfxConvertSpriteToRaw(collisionPage, ptr + 0x80, 160, 200);

	free(dataPtr);
	return 0;
}
示例#2
0
byte loadCtOS(const char *ctName) {
	debugC(1, kCineDebugCollision, "loadCtOS(\"%s\")", ctName);
	byte *ptr, *dataPtr;

	int16 foundFileIdx = findFileInBundle(ctName);
	if (foundFileIdx == -1) {
		warning("loadCtOS: Unable to find collision data file '%s'", ctName);
		// FIXME: Rework this function's return value policy and return an appropriate value here.
		// The return value isn't yet used for anything so currently it doesn't really matter.
		return 0;
	}

	if (currentCtName != ctName)
		strcpy(currentCtName, ctName);

	ptr = dataPtr = readBundleFile(foundFileIdx);

	uint16 bpp = READ_BE_UINT16(ptr);
	ptr += 2;

	if (bpp == 8) {
		renderer->loadCt256(ptr, ctName);
	} else {
		gfxConvertSpriteToRaw(collisionPage, ptr + 32, 160, 200);
		renderer->loadCt16(ptr, ctName);
	}

	free(dataPtr);
	return 0;
}
示例#3
0
byte loadCt(const char *ctName) {
	uint16 header[32];

	strcpy(currentCtName, ctName);

	byte *ptr = readBundleFile(findFileInBundle(ctName));

	if (gameType == Cine::GID_OS) {
		uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
		if (bpp == 8) {
			ptr += 3 * 256;
			loadCtHigh(ptr);
		} else {
			ptr += 32;
			gfxResetRawPage(page3Raw);
			gfxConvertSpriteToRaw(page3Raw, ptr, 160, 200);
		}
	} else {
		loadRelatedPalette(ctName);

		assert(strstr(ctName, ".NEO"));

		Common::MemoryReadStream readS(ptr, 32);

		for (int i = 0; i < 16; i++) {
			header[i] = readS.readUint16BE();
		}

		gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200);
	}

	return 0;
}
示例#4
0
void loadRel(char *pRelName) {
	uint16 numEntry;
	uint16 i;
	byte *ptr;

	checkDataDisk(-1);

	for (i = 0; i < NUM_MAX_REL; i++) {
		if (relTable[i].data) {
			free(relTable[i].data);
			relTable[i].data = NULL;
			relTable[i].size = 0;
		}
	}

	ptr = readBundleFile(findFileInBundle(pRelName));

	setMouseCursor(MOUSE_CURSOR_DISK);

	numEntry = READ_BE_UINT16(ptr); ptr += 2;

	assert(numEntry <= NUM_MAX_REL);

	for (i = 0; i < numEntry; i++) {
		relTable[i].size = READ_BE_UINT16(ptr); ptr += 2;
		relTable[i].obj1Param1 = READ_BE_UINT16(ptr); ptr += 2;
		relTable[i].obj1Param2 = READ_BE_UINT16(ptr); ptr += 2;
		relTable[i].obj2Param = READ_BE_UINT16(ptr); ptr += 2;
	}

	for (i = 0; i < numEntry; i++) {
		if (relTable[i].size) {
			relTable[i].data = (byte *)malloc(relTable[i].size);

			assert(relTable[i].data);

			memcpy(relTable[i].data, ptr, relTable[i].size);
			ptr += relTable[i].size;
		}
	}

#ifdef DUMP_SCRIPTS

	{
		uint16 s;
		char buffer[256];

		for (s = 0; s < numEntry; s++) {
			if (relTable[s].size) {
				sprintf(buffer, "%s_%03d.txt", pRelName, s);

				decompileScript(relTable[s].data, NULL, relTable[s].size, s);
				dumpScript(buffer);
			}
		}
	}
#endif
}
示例#5
0
/*! \todo Is script size of 0 valid?
 * \todo Fix script dump code
 */
void loadRel(char *pRelName) {
	uint16 numEntry;
	uint16 i;
	uint16 size, p1, p2, p3;
	byte *ptr, *dataPtr;

	checkDataDisk(-1);

	objectScripts.clear();
	relTable.clear();

	ptr = dataPtr = readBundleFile(findFileInBundle(pRelName));

	setMouseCursor(MOUSE_CURSOR_DISK);

	numEntry = READ_BE_UINT16(ptr); ptr += 2;

	for (i = 0; i < numEntry; i++) {
		size = READ_BE_UINT16(ptr); ptr += 2;
		p1 = READ_BE_UINT16(ptr); ptr += 2;
		p2 = READ_BE_UINT16(ptr); ptr += 2;
		p3 = READ_BE_UINT16(ptr); ptr += 2;
		RawObjectScriptPtr tmp(new RawObjectScript(size, p1, p2, p3));
		assert(tmp);
		relTable.push_back(tmp);
	}

	for (i = 0; i < numEntry; i++) {
		size = relTable[i]->_size;
		// TODO: delete the test?
		if (size) {
			relTable[i]->setData(*scriptInfo, ptr);
			ptr += size;
		}
	}

	free(dataPtr);

#ifdef DUMP_SCRIPTS

	{
		uint16 s;
		char buffer[256];

		for (s = 0; s < numEntry; s++) {
			if (relTable[s]->_size) {
				sprintf(buffer, "%s_%03d.txt", pRelName, s);

				decompileScript((const byte *)relTable[s]->getString(0), relTable[s]->_size, s);
				dumpScript(buffer);
			}
		}
	}
#endif
}
示例#6
0
void addBackground(const char *bgName, uint16 bgIdx) {
	byte *ptr, *dataPtr;

	byte fileIdx = findFileInBundle(bgName);
	ptr = dataPtr = readBundleFile(fileIdx);

	uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;

	if (bpp == 8) {
		renderer->loadBg256(ptr, bgName, bgIdx);
	} else {
		renderer->loadBg16(ptr, bgName, bgIdx);
	}
	free(dataPtr);
}
示例#7
0
void addBackground(const char *bgName, uint16 bgIdx) {
	strcpy(currentBgName[bgIdx], bgName);

	byte fileIdx = findFileInBundle(bgName);
	byte *ptr = readBundleFile(fileIdx);

	additionalBgTable[bgIdx] = (byte *) malloc(320 * 200);

	uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
	if (bpp == 8) {
		ptr += 3 * 256;
		memcpy(additionalBgTable[bgIdx], ptr, 320 * 200);
	} else {
		ptr += 32;
		gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr, 160, 200);
	}
}
示例#8
0
文件: object.cpp 项目: 33d/scummvm
void loadObject(char *pObjectName) {
	debug(5, "loadObject(\"%s\")", pObjectName);
	uint16 numEntry;
	uint16 entrySize;
	uint16 i;
	byte *ptr, *dataPtr;

	checkDataDisk(-1);

	ptr = dataPtr = readBundleFile(findFileInBundle(pObjectName));

	setMouseCursor(MOUSE_CURSOR_DISK);

	numEntry = READ_BE_UINT16(ptr); ptr += 2;

	entrySize = READ_BE_UINT16(ptr); ptr += 2;

	assert(numEntry <= NUM_MAX_OBJECT);

	for (i = 0; i < numEntry; i++) {
		if (g_cine->_objectTable[i].costume != -2 && g_cine->_objectTable[i].costume != -3) { // flag is keep?
			Common::MemoryReadStream readS(ptr, entrySize);

			g_cine->_objectTable[i].x = readS.readSint16BE();
			g_cine->_objectTable[i].y = readS.readSint16BE();
			g_cine->_objectTable[i].mask = readS.readUint16BE();
			g_cine->_objectTable[i].frame = readS.readSint16BE();
			g_cine->_objectTable[i].costume = readS.readSint16BE();
			readS.read(g_cine->_objectTable[i].name, 20);
			g_cine->_objectTable[i].part = readS.readUint16BE();
		}
		ptr += entrySize;
	}

	if (!strcmp(pObjectName, "INTRO.OBJ")) {
		for (i = 0; i < 10; i++) {
			g_cine->_objectTable[i].costume = 0;
		}
	}

	free(dataPtr);
}
示例#9
0
byte loadBg(const char *bgName) {
	byte *ptr, *dataPtr;

	byte fileIdx = findFileInBundle(bgName);
	ptr = dataPtr = readBundleFile(fileIdx);

	uint16 bpp = READ_BE_UINT16(ptr);
	ptr += 2;

	if (bpp == 8) {
		renderer->loadBg256(ptr, bgName);
	} else {
		if (g_cine->getGameType() == Cine::GType_FW) {
			loadRelatedPalette(bgName);
		}

		renderer->loadBg16(ptr, bgName);
	}
	free(dataPtr);
	return 0;
}
示例#10
0
文件: msg.cpp 项目: 33d/scummvm
void loadMsg(char *pMsgName) {
	uint32 sourceSize;

	checkDataDisk(-1);
	g_cine->_messageTable.clear();
	byte *dataPtr = readBundleFile(findFileInBundle(pMsgName), &sourceSize);

	setMouseCursor(MOUSE_CURSOR_DISK);

	uint count = READ_BE_UINT16(dataPtr);
	uint messageLenPos = 2;
	uint messageDataPos = messageLenPos + 2 * count;

	// Read in the messages
	for (uint i = 0; i < count; i++) {
		// Read message's length
		uint messageLen = READ_BE_UINT16(dataPtr + messageLenPos);
		messageLenPos += 2;

		// Store the read message.
		// This code works around input data that has empty strings residing outside the input
		// buffer (e.g. message indexes 58-254 in BATEAU.MSG in PROCS08 in Operation Stealth).
		if (messageDataPos < sourceSize) {
			g_cine->_messageTable.push_back((const char *)(dataPtr + messageDataPos));
		} else {
			if (messageLen > 0) { // Only warn about overflowing non-empty strings
				warning("loadMsg(%s): message (%d. / %d) is overflowing the input buffer. Replacing it with an empty string", pMsgName, i + 1, count);
			} else {
				debugC(5, kCineDebugPart, "loadMsg(%s): empty message (%d. / %d) resides outside input buffer", pMsgName, i + 1, count);
			}
			// Message resides outside the input buffer so we replace it with an empty string
			g_cine->_messageTable.push_back("");
		}
		// Jump to the next message
		messageDataPos += messageLen;
	}

	free(dataPtr);
}
示例#11
0
byte loadBg(const char *bgName) {
	strcpy(currentBgName[0], bgName);

	byte fileIdx = findFileInBundle(bgName);
	byte *ptr = readBundleFile(fileIdx);

	uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
	if (bpp == 8) {
		loadBgHigh((const char *)ptr);
	} else {
		colorMode256 = 0;

		for (int i = 0; i < 16; i++) {
			tempPalette[i] = READ_BE_UINT16(ptr);
			ptr += 2;
		}

		loadRelatedPalette(bgName);

		gfxResetRawPage(page2Raw);
		gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200);
	}
	return 0;
}
示例#12
0
/**
 * @todo Is script size of 0 valid?
 * @todo Fix script dump code
 * @return Was the loading successful?
 */
bool loadPrc(const char *pPrcName) {
	byte i;
	uint16 numScripts;
	byte *scriptPtr, *dataPtr;

	assert(pPrcName);

	g_cine->_globalScripts.clear();
	g_cine->_scriptTable.clear();

	// This is copy protection. Used to hang the machine
	if (!scumm_stricmp(pPrcName, COPY_PROT_FAIL_PRC_NAME)) {
		Common::Event event;
		event.type = Common::EVENT_RTL;
		g_system->getEventManager()->pushEvent(event);
		return false;
	}

	checkDataDisk(-1);
	if ((g_cine->getGameType() == Cine::GType_FW) &&
		(!scumm_stricmp(pPrcName, BOOT_PRC_NAME) || !scumm_stricmp(pPrcName, "demo.prc"))) {
		scriptPtr = dataPtr = readFile(pPrcName, (g_cine->getFeatures() & GF_CRYPTED_BOOT_PRC) != 0);
	} else {
		scriptPtr = dataPtr = readBundleFile(findFileInBundle(pPrcName));
	}

	assert(scriptPtr);

	setMouseCursor(MOUSE_CURSOR_DISK);

	numScripts = READ_BE_UINT16(scriptPtr);
	scriptPtr += 2;
	assert(numScripts <= NUM_MAX_SCRIPT);

	for (i = 0; i < numScripts; i++) {
		RawScriptPtr tmp(new RawScript(READ_BE_UINT16(scriptPtr)));
		scriptPtr += 2;
		assert(tmp);
		g_cine->_scriptTable.push_back(tmp);
	}

	for (i = 0; i < numScripts; i++) {
		uint16 size = g_cine->_scriptTable[i]->_size;
		// TODO: delete the test?
		if (size) {
			g_cine->_scriptTable[i]->setData(*scriptInfo, scriptPtr);
			scriptPtr += size;
		}
	}

	free(dataPtr);

#ifdef DUMP_SCRIPTS

	{
		uint16 s;
		char buffer[256];

		for (s = 0; s < numScripts; s++) {
			if (scriptTable[s]->_size) {
				sprintf(buffer, "%s_%03d.txt", pPrcName, s);

				decompileScript((const byte *)scriptTable[s]->getString(0), scriptTable[s]->_size, s);
				dumpScript(buffer);
			}
		}
	}
#endif

	return true;
}