Esempio n. 1
0
Common::Array<Opcode> Database::loadOpcodes(Common::ReadStreamEndian &s) {
	Common::Array<Opcode> script;

	while (1) {
		Opcode opcode;
		uint16 code = s.readUint16();

		opcode.op = code & 0xff;
		uint8 count = code >> 8;
		if (count == 0 && opcode.op == 0)
			break;

		// The v1.0 executables use a slightly different opcode set
		// Since it's a simple conversion, we'll handle that here
		if ((_executableVersion->flags & kFlagVersion10) && opcode.op >= 122)
			opcode.op++;

		for (int i = 0; i < count; i++) {
			int16 value = s.readSint16();
			opcode.args.push_back(value);
		}

		script.push_back(opcode);
	}

	return script;
}
Esempio n. 2
0
ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
	if (version < 4) {
		/*byte flags = */ stream.readByte();
		/*unk1 = */ stream.readByte();
		shapeType = static_cast<ShapeType>(stream.readByte());
		initialRect = Score::readRect(stream);
		pattern = stream.readUint16BE();
		fgCol = stream.readByte();
		bgCol = stream.readByte();
		fillType = stream.readByte();
		lineThickness = stream.readByte();
		lineDirection = stream.readByte();
	} else {
		stream.readByte();
		stream.readByte();

		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);

		shapeType = kShapeRectangle;
		pattern = 0;
		fgCol = bgCol = 0;
		fillType = 0;
		lineThickness = 1;
		lineDirection = 0;
	}
	modified = 0;
}
Esempio n. 3
0
ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextCast(stream, version) {
	if (version < 4) {
		buttonType = static_cast<ButtonType>(stream.readUint16BE());
	} else {
		stream.readByte();
		stream.readByte();

		// This has already been populated in the super TextCast constructor
		//initialRect = Score::readRect(stream);
		//boundingRect = Score::readRect(stream);

		buttonType = static_cast<ButtonType>(stream.readUint16BE());
	}
	modified = 0;
}
Esempio n. 4
0
HotSpot Database::loadHotspot(Common::ReadStreamEndian &s) {
	HotSpot hotspot;

	hotspot.condition = s.readUint16();

	if (hotspot.condition == 0)
		return hotspot;

	if (hotspot.condition != -1) {
		hotspot.rects = loadRects(s);
		hotspot.cursor = s.readUint16();
	}

	hotspot.script = loadOpcodes(s);

	return hotspot;
}
Esempio n. 5
0
CondScript Database::loadCondScript(Common::ReadStreamEndian &s)
{
	CondScript script;
	script.condition = s.readUint16();
	if(!script.condition)
		return script;

	script.script = loadOpcodes(s);

	return script;
}
Esempio n. 6
0
ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) {
	if (version < 4) {
		error("Unhandled Script cast");
	} else if (version == 4) {
		stream.readByte();
		stream.readByte();

		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);

		id = stream.readUint32();

		debugC(4, kDebugLoading, "CASt: Script id: %d", id);

		stream.readByte(); // There should be no more data
		assert(stream.eos());
	} else if (version > 4) {
		stream.readByte();
		stream.readByte();

		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);

		id = stream.readUint32();

		debugC(4, kDebugLoading, "CASt: Script id: %d", id);

		// WIP need to complete this!
	}
	modified = 0;
}
Esempio n. 7
0
Common::Array<PolarRect> Database::loadRects(Common::ReadStreamEndian &s) {
	Common::Array<PolarRect> rects;

	bool lastRect = false;
	do {
		PolarRect rect;
		rect.centerPitch = s.readUint16();
		rect.centerHeading = s.readUint16();
		rect.width = s.readUint16();
		rect.height = s.readUint16();

		if (rect.width < 0) {
			rect.width = -rect.width;
		} else {
			lastRect = true;
		}

		rects.push_back(rect);
	} while (!lastRect);

	return rects;
}
Esempio n. 8
0
RoomData Database::loadRoomDescription(Common::ReadStreamEndian &s) {
	RoomData room;

	if (_vm->getPlatform() == Common::kPlatformPS2) {
		room.id = s.readUint32LE(); s.readUint32LE();
		s.read(&room.name, 8);
		room.scriptsOffset = s.readUint32LE(); s.readUint32LE();
		room.ambSoundsOffset = s.readUint32LE(); s.readUint32LE();
		room.unkOffset = s.readUint32LE(); // not 64-bit -- otherwise roomUnk5 is incorrect
		room.roomUnk4 = s.readUint32LE();
		room.roomUnk5 = s.readUint32LE();
	} else {
		room.id = s.readUint32();
		s.read(&room.name, 8);
		room.scriptsOffset = s.readUint32();
		room.ambSoundsOffset = s.readUint32();
		room.unkOffset = s.readUint32();
		room.roomUnk4 = s.readUint32();
		room.roomUnk5 = s.readUint32();
	}

	if (room.scriptsOffset != 0)
		room.scriptsOffset -= _executableVersion->baseOffset;

	if (room.ambSoundsOffset != 0)
		room.ambSoundsOffset -= _executableVersion->baseOffset;

	if (room.unkOffset != 0)
		room.unkOffset -= _executableVersion->baseOffset;

	return room;
}
Esempio n. 9
0
Common::Array<AgeData> Database::loadAges(Common::ReadStreamEndian &s)
{
	Common::Array<AgeData> ages;

	for (uint i = 0; i < 10; i++) {
		AgeData age;

		if (_vm->getPlatform() == Common::kPlatformPS2) {
			// Really 64-bit values
			age.id = s.readUint32LE();
			s.readUint32LE();
			age.disk = s.readUint32LE();
			s.readUint32LE();
			age.roomCount = s.readUint32LE();
			s.readUint32LE();
			age.roomsOffset = s.readUint32LE() - _executableVersion->baseOffset;
			s.readUint32LE();
			age.labelId = s.readUint32LE();
			s.readUint32LE();
		} else {
			age.id = s.readUint32();
			age.disk = s.readUint32();
			age.roomCount = s.readUint32();
			age.roomsOffset = s.readUint32() - _executableVersion->baseOffset;
			age.labelId = s.readUint32();
		}

		ages.push_back(age);
	}

	return ages;
}
Esempio n. 10
0
TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) {
	borderSize = kSizeNone;
	gutterSize = kSizeNone;
	boxShadow = kSizeNone;

	flags1 = 0;
	fontId = 0;
	fontSize = 12;
	textType = kTextTypeFixed;
	textAlign = kTextAlignLeft;
	textShadow = kSizeNone;
	textSlant = 0;
	palinfo1 = palinfo2 = palinfo3 = 0;

	if (version <= 3) {
		flags1 = stream.readByte();
		borderSize = static_cast<SizeType>(stream.readByte());
		gutterSize = static_cast<SizeType>(stream.readByte());
		boxShadow = static_cast<SizeType>(stream.readByte());
		textType = static_cast<TextType>(stream.readByte());
		textAlign = static_cast<TextAlignType>(stream.readUint16());
		palinfo1 = stream.readUint16();
		palinfo2 = stream.readUint16();
		palinfo3 = stream.readUint16();

		if (version == 2) {
			int t = stream.readUint16();
			if (t != 0) { // In D2 there are values
				warning("TextCast: t: %x", t);
			}

			initialRect = Score::readRect(stream);
			stream.readUint16();
		} else {
			int t = stream.readUint32();
			if (t != 0) { // In D2 there are values
				warning("TextCast: t: %x", t);
			}

			initialRect = Score::readRect(stream); 
		}

		textShadow = static_cast<SizeType>(stream.readByte());
		byte flags = stream.readByte();
		if (flags & 0x1)
			textFlags.push_back(kTextFlagEditable);
		if (flags & 0x2)
			textFlags.push_back(kTextFlagAutoTab);
		if (flags & 0x4)
			textFlags.push_back(kTextFlagDoNotWrap);
		if (flags & 0xf8)
			warning("Unprocessed text cast flags: %x", flags & 0xf8);

		// TODO: FIXME: guesswork
		fontId = stream.readByte();
		fontSize = stream.readByte();
		textSlant = 0;
	} else if (version == 4) {
		borderSize = static_cast<SizeType>(stream.readByte());
		gutterSize = static_cast<SizeType>(stream.readByte());
		boxShadow = static_cast<SizeType>(stream.readByte());
		textType = static_cast<TextType>(stream.readByte());
		textAlign = static_cast<TextAlignType>(stream.readSint16()); // this is because 'right' is -1? or should that be 255?
		stream.readUint16();
		stream.readUint16();
		stream.readUint16();
		stream.readUint16();

		fontId = 1; // this is in STXT

		initialRect = Score::readRect(stream);
		stream.readUint16();
		textShadow = static_cast<SizeType>(stream.readByte());
		byte flags = stream.readByte();

		if (flags)
			warning("Unprocessed text cast flags: %x", flags);

		fontSize = stream.readUint16();
		textSlant = 0;
	} else {
		fontId = 1;
		fontSize = 12;

		stream.readUint32();
		stream.readUint32(); 
		stream.readUint32();
		stream.readUint32();
		uint16 skip = stream.readUint16();
		for (int i = 0; i < skip; i++) 
			stream.readUint32();

		stream.readUint32();
		stream.readUint32();
		stream.readUint32();
		stream.readUint32();
		stream.readUint32();
		stream.readUint32();

		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);

		stream.readUint32();
		stream.readUint16();
		stream.readUint16();
	}

	modified = 0;

	cachedMacText = new CachedMacText(this, version);
	// TODO Destroy me
}
Esempio n. 11
0
BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint32 castTag, uint16 version) {
	if (version < 4) {
		flags = stream.readByte();
		someFlaggyThing = stream.readUint16();
		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);
		regY = stream.readUint16();
		regX = stream.readUint16();
		unk1 = unk2 = 0;

		if (someFlaggyThing & 0x8000) {
			unk1 = stream.readUint16();
			unk2 = stream.readUint16();
		}
	} else if (version == 4) {
		stream.readByte();
		stream.readByte();

		flags = 0;
		someFlaggyThing = 0;
		unk1 = unk2 = 0;

		initialRect = Score::readRect(stream);
		boundingRect = Score::readRect(stream);
		regX = stream.readUint16();
		regY = stream.readUint16();

		bitsPerPixel = stream.readUint16();
		if (bitsPerPixel == 0)
			bitsPerPixel = 1;

		int tail = 0;

		while (!stream.eos()) {
			stream.readByte();
			tail++;
		}

		warning("BitmapCast: %d bytes left", tail);
	} else if (version == 5) {
		uint16 count = stream.readUint16();
		for (uint16 cc = 0; cc < count; cc++)
			stream.readUint32();

		uint32 stringLength = stream.readUint32();
		for (uint32 s = 0; s < stringLength; s++)
			stream.readByte();

		/*uint16 width =*/ stream.readUint16LE(); //maybe?
		initialRect = Score::readRect(stream);

		/*uint32 somethingElse =*/ stream.readUint32();
		boundingRect = Score::readRect(stream);

		bitsPerPixel = stream.readUint16();

		regX = 0;
		regY = 0;

		stream.readUint32();
	}
	modified = 0;
	tag = castTag;
}