[Scummvm-git-logs] scummvm master -> 3291a9761cf43e67fe0d085ac63fd89b46367765

sev- sev at scummvm.org
Tue Nov 8 23:42:41 CET 2016


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
25a2333394 DIRECTOR: Split out cast-related classes into separate file
3291a9761c DIRECTOR: Implement D4 CASt member parsing stub


Commit: 25a233339439ed2cdf6b52f82c57f1adaa59e0bc
    https://github.com/scummvm/scummvm/commit/25a233339439ed2cdf6b52f82c57f1adaa59e0bc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-11-08T21:51:51+01:00

Commit Message:
DIRECTOR: Split out cast-related classes into separate file

Changed paths:
  A engines/director/cast.cpp
  A engines/director/cast.h
    engines/director/frame.cpp
    engines/director/lingo/lingo-the.cpp
    engines/director/module.mk
    engines/director/score.cpp
    engines/director/score.h
    engines/director/sprite.cpp



diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
new file mode 100644
index 0000000..e0d0603
--- /dev/null
+++ b/engines/director/cast.cpp
@@ -0,0 +1,94 @@
+/* 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.
+ *
+ * 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.
+ *
+ */
+
+#include "common/array.h"
+#include "common/hashmap.h"
+
+#include "director/cast.h"
+#include "director/score.h"
+
+namespace Director {
+
+BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) {
+	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();
+	}
+	modified = 0;
+}
+
+TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) {
+	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();
+
+	int t = stream.readUint32();
+	assert(t == 0); // So far we saw only 0 here
+
+	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("Unproxessed text cast flags: %x", flags & 0xf8);
+
+	// TODO: FIXME: guesswork
+	fontId = stream.readByte();
+	fontSize = stream.readByte();
+
+	modified = 0;
+}
+
+ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) {
+	/*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();
+	modified = 0;
+}
+
+} // End of namespace Director
diff --git a/engines/director/cast.h b/engines/director/cast.h
new file mode 100644
index 0000000..96ad879
--- /dev/null
+++ b/engines/director/cast.h
@@ -0,0 +1,155 @@
+/* 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.
+ *
+ * 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.
+ *
+ */
+
+#ifndef DIRECTOR_CAST_H
+#define DIRECTOR_CAST_H
+
+#include "common/rect.h"
+#include "common/substream.h"
+
+namespace Director {
+
+enum CastType {
+	kCastBitmap = 1,
+	kCastFilmLoop = 2,
+	kCastText = 3,
+	kCastPalette = 4,
+	kCastPicture = 5,
+	kCastSound = 6,
+	kCastButton = 7,
+	kCastShape = 8,
+	kCastMovie = 9,
+	kCastDigitalVideo = 10,
+	kCastScript = 11
+};
+
+struct Cast {
+	CastType type;
+	Common::Rect initialRect;
+	byte modified;
+};
+
+struct BitmapCast : Cast {
+	BitmapCast(Common::SeekableSubReadStreamEndian &stream);
+
+	Common::Rect boundingRect;
+	uint16 regX;
+	uint16 regY;
+	uint8 flags;
+	uint16 someFlaggyThing;
+	uint16 unk1, unk2;
+};
+
+enum ShapeType {
+	kShapeRectangle,
+	kShapeRoundRect,
+	kShapeOval,
+	kShapeLine
+};
+
+struct ShapeCast : Cast {
+	ShapeCast(Common::SeekableSubReadStreamEndian &stream);
+
+	ShapeType shapeType;
+	uint16 pattern;
+	byte fgCol;
+	byte bgCol;
+	byte fillType;
+	byte lineThickness;
+	byte lineDirection;
+};
+
+enum TextType {
+	kTextTypeAdjustToFit,
+	kTextTypeScrolling,
+	kTextTypeFixed
+};
+
+enum TextAlignType {
+	kTextAlignRight = -1,
+	kTextAlignLeft,
+	kTextAlignCenter
+};
+
+enum TextFlag {
+	kTextFlagEditable,
+	kTextFlagAutoTab,
+	kTextFlagDoNotWrap
+};
+
+enum SizeType {
+	kSizeNone,
+	kSizeSmallest,
+	kSizeSmall,
+	kSizeMedium,
+	kSizeLarge,
+	kSizeLargest
+};
+
+struct TextCast : Cast {
+	TextCast(Common::SeekableSubReadStreamEndian &stream);
+
+	SizeType borderSize;
+	SizeType gutterSize;
+	SizeType boxShadow;
+
+	byte flags1;
+	uint32 fontId;
+	uint16 fontSize;
+	TextType textType;
+	TextAlignType textAlign;
+	SizeType textShadow;
+	Common::Array<TextFlag> textFlags;
+	int16 palinfo1, palinfo2, palinfo3;
+};
+
+enum ButtonType {
+	kTypeButton,
+	kTypeCheckBox,
+	kTypeRadio
+};
+
+struct ButtonCast : TextCast {
+	ButtonCast(Common::SeekableSubReadStreamEndian &stream) : TextCast(stream) {
+		buttonType = static_cast<ButtonType>(stream.readUint16BE());
+	}
+
+	ButtonType buttonType;
+};
+
+struct CastInfo {
+	Common::String script;
+	Common::String name;
+	Common::String directory;
+	Common::String fileName;
+	Common::String type;
+};
+
+struct Label {
+	Common::String name;
+	uint16 number;
+	Label(Common::String name1, uint16 number1) { name = name1; number = number1; }
+};
+
+} // End of namespace Director
+
+#endif
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index b840239..6464943 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -27,6 +27,7 @@
 #include "image/bmp.h"
 
 #include "director/director.h"
+#include "director/cast.h"
 #include "director/frame.h"
 #include "director/images.h"
 #include "director/archive.h"
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index a8633f1..2707466 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "director/lingo/lingo.h"
+#include "director/cast.h"
 #include "director/sprite.h"
 
 namespace Director {
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 1ea3615..38e3cfe 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/director
 
 MODULE_OBJS = \
 	archive.o \
+	cast.o \
 	detection.o \
 	director.o \
 	frame.o \
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 98d25cf..407a671 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -31,6 +31,7 @@
 #include "graphics/macgui/macfontmanager.h"
 #include "graphics/macgui/macwindowmanager.h"
 
+#include "director/cast.h"
 #include "director/score.h"
 #include "director/frame.h"
 #include "director/archive.h"
@@ -829,69 +830,6 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) {
 	}
 }
 
-BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) {
-	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();
-	}
-	modified = 0;
-}
-
-TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) {
-	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();
-
-	int t = stream.readUint32();
-	assert(t == 0); // So far we saw only 0 here
-
-	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("Unproxessed text cast flags: %x", flags & 0xf8);
-
-	// TODO: FIXME: guesswork
-	fontId = stream.readByte();
-	fontSize = stream.readByte();
-
-	modified = 0;
-}
-
-ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) {
-	/*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();
-	modified = 0;
-}
-
 Common::Rect Score::readRect(Common::SeekableSubReadStreamEndian &stream) {
 	Common::Rect *rect = new Common::Rect();
 	rect->top = stream.readUint16();
diff --git a/engines/director/score.h b/engines/director/score.h
index a60f2d7..ca148af 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -34,26 +34,14 @@ namespace Graphics {
 namespace Director {
 
 class Archive;
+struct CastInfo;
 class DirectorEngine;
 class DirectorSound;
 class Frame;
+struct Label;
 class Lingo;
 class Sprite;
 
-enum CastType {
-	kCastBitmap = 1,
-	kCastFilmLoop = 2,
-	kCastText = 3,
-	kCastPalette = 4,
-	kCastPicture = 5,
-	kCastSound = 6,
-	kCastButton = 7,
-	kCastShape = 8,
-	kCastMovie = 9,
-	kCastDigitalVideo = 10,
-	kCastScript = 11
-};
-
 enum ScriptType {
 	kMovieScript = 0,
 	kSpriteScript = 1,
@@ -62,114 +50,6 @@ enum ScriptType {
 	kMaxScriptType = 2
 };
 
-struct Cast {
-	CastType type;
-	Common::Rect initialRect;
-	byte modified;
-};
-
-struct BitmapCast : Cast {
-	BitmapCast(Common::SeekableSubReadStreamEndian &stream);
-
-	Common::Rect boundingRect;
-	uint16 regX;
-	uint16 regY;
-	uint8 flags;
-	uint16 someFlaggyThing;
-	uint16 unk1, unk2;
-};
-
-enum ShapeType {
-	kShapeRectangle,
-	kShapeRoundRect,
-	kShapeOval,
-	kShapeLine
-};
-
-struct ShapeCast : Cast {
-	ShapeCast(Common::SeekableSubReadStreamEndian &stream);
-
-	ShapeType shapeType;
-	uint16 pattern;
-	byte fgCol;
-	byte bgCol;
-	byte fillType;
-	byte lineThickness;
-	byte lineDirection;
-};
-
-enum TextType {
-	kTextTypeAdjustToFit,
-	kTextTypeScrolling,
-	kTextTypeFixed
-};
-
-enum TextAlignType {
-	kTextAlignRight = -1,
-	kTextAlignLeft,
-	kTextAlignCenter
-};
-
-enum TextFlag {
-	kTextFlagEditable,
-	kTextFlagAutoTab,
-	kTextFlagDoNotWrap
-};
-
-enum SizeType {
-	kSizeNone,
-	kSizeSmallest,
-	kSizeSmall,
-	kSizeMedium,
-	kSizeLarge,
-	kSizeLargest
-};
-
-struct TextCast : Cast {
-	TextCast(Common::SeekableSubReadStreamEndian &stream);
-
-	SizeType borderSize;
-	SizeType gutterSize;
-	SizeType boxShadow;
-
-	byte flags1;
-	uint32 fontId;
-	uint16 fontSize;
-	TextType textType;
-	TextAlignType textAlign;
-	SizeType textShadow;
-	Common::Array<TextFlag> textFlags;
-	int16 palinfo1, palinfo2, palinfo3;
-};
-
-enum ButtonType {
-	kTypeButton,
-	kTypeCheckBox,
-	kTypeRadio
-};
-
-struct ButtonCast : TextCast {
-	ButtonCast(Common::SeekableSubReadStreamEndian &stream) : TextCast(stream) {
-		buttonType = static_cast<ButtonType>(stream.readUint16BE());
-	}
-
-	ButtonType buttonType;
-};
-
-struct CastInfo {
-	Common::String script;
-	Common::String name;
-	Common::String directory;
-	Common::String fileName;
-	Common::String type;
-};
-
-struct Label {
-	Common::String name;
-	uint16 number;
-	Label(Common::String name1, uint16 number1) { name = name1; number = number1; }
-};
-
 class Score {
 public:
 	Score(DirectorEngine *vm, Archive *);
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index ccbe8e3..a59313a 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "director/director.h"
+#include "director/cast.h"
 #include "director/score.h"
 #include "director/sprite.h"
 


Commit: 3291a9761cf43e67fe0d085ac63fd89b46367765
    https://github.com/scummvm/scummvm/commit/3291a9761cf43e67fe0d085ac63fd89b46367765
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-11-08T23:41:43+01:00

Commit Message:
DIRECTOR: Implement D4 CASt member parsing stub

Changed paths:
    engines/director/cast.cpp
    engines/director/cast.h
    engines/director/resource.cpp
    engines/director/score.cpp
    engines/director/score.h



diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index e0d0603..2e4e2c9 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -28,66 +28,103 @@
 
 namespace Director {
 
-BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) {
-	flags = stream.readByte();
-	someFlaggyThing = stream.readUint16();
-	initialRect = Score::readRect(stream);
-	boundingRect = Score::readRect(stream);
-	regY = stream.readUint16();
-	regX = stream.readUint16();
-	unk1 = unk2 = 0;
+BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, 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();
+		if (someFlaggyThing & 0x8000) {
+			unk1 = stream.readUint16();
+			unk2 = stream.readUint16();
+		}
+	} else {
+		initialRect = Score::readRect(stream);
+		boundingRect = Score::readRect(stream);
+		regX = 0; // FIXME: HACK
+		regY = 0; // FIXME: HACK
 	}
 	modified = 0;
 }
 
-TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) {
-	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();
+TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) {
+	if (version < 4) {
+		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();
 
-	int t = stream.readUint32();
-	assert(t == 0); // So far we saw only 0 here
+		int t = stream.readUint32();
+		assert(t == 0); // So far we saw only 0 here
 
-	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("Unproxessed text cast flags: %x", flags & 0xf8);
+		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("Unproxessed text cast flags: %x", flags & 0xf8);
 
-	// TODO: FIXME: guesswork
-	fontId = stream.readByte();
-	fontSize = stream.readByte();
+		// TODO: FIXME: guesswork
+		fontId = stream.readByte();
+		fontSize = stream.readByte();
+	} else {
+		initialRect = Score::readRect(stream);
+		//boundingRect = Score::readRect(stream);
+	}
+
+	modified = 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 {
+		initialRect = Score::readRect(stream);
+		//boundingRect = Score::readRect(stream);
+	}
+	modified = 0;
+}
 
+ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextCast(stream, version) {
+	if (version < 4) {
+		buttonType = static_cast<ButtonType>(stream.readUint16BE());
+	} else {
+		initialRect = Score::readRect(stream);
+		//boundingRect = Score::readRect(stream);
+	}
 	modified = 0;
 }
 
-ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) {
-	/*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();
+ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) {
+	if (version < 4) {
+		error("Unhandled Script cast");
+	} else {
+		initialRect = Score::readRect(stream);
+		//boundingRect = Score::readRect(stream);
+	}
 	modified = 0;
 }
 
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 96ad879..82651a7 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -49,7 +49,7 @@ struct Cast {
 };
 
 struct BitmapCast : Cast {
-	BitmapCast(Common::SeekableSubReadStreamEndian &stream);
+	BitmapCast(Common::ReadStreamEndian &stream, uint16 version = 2);
 
 	Common::Rect boundingRect;
 	uint16 regX;
@@ -67,7 +67,7 @@ enum ShapeType {
 };
 
 struct ShapeCast : Cast {
-	ShapeCast(Common::SeekableSubReadStreamEndian &stream);
+	ShapeCast(Common::ReadStreamEndian &stream, uint16 version = 2);
 
 	ShapeType shapeType;
 	uint16 pattern;
@@ -106,7 +106,7 @@ enum SizeType {
 };
 
 struct TextCast : Cast {
-	TextCast(Common::SeekableSubReadStreamEndian &stream);
+	TextCast(Common::ReadStreamEndian &stream, uint16 version = 2);
 
 	SizeType borderSize;
 	SizeType gutterSize;
@@ -129,13 +129,17 @@ enum ButtonType {
 };
 
 struct ButtonCast : TextCast {
-	ButtonCast(Common::SeekableSubReadStreamEndian &stream) : TextCast(stream) {
-		buttonType = static_cast<ButtonType>(stream.readUint16BE());
-	}
+	ButtonCast(Common::ReadStreamEndian &stream, uint16 version = 2);
 
 	ButtonType buttonType;
 };
 
+struct ScriptCast : Cast {
+	ScriptCast(Common::ReadStreamEndian &stream, uint16 version = 2);
+};
+
+
+
 struct CastInfo {
 	Common::String script;
 	Common::String name;
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index bcf5db6..54ab219 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -212,7 +212,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 	castScore->loadConfig(*shardcst->getResource(MKTAG('V','W','C','F'), 1024));
 
 	if (getVersion() < 4)
-		castScore->loadCastDataD2(*shardcst->getResource(MKTAG('V','W','C','R'), 1024));
+		castScore->loadCastDataVWCR(*shardcst->getResource(MKTAG('V','W','C','R'), 1024));
 
 	Common::Array<uint16> cast = shardcst->getResourceIDList(MKTAG('C','A','S','t'));
 	if (cast.size() > 0) {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 407a671..f2cd673 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -193,7 +193,7 @@ void Score::loadArchive() {
 
 	if (_vm->getVersion() < 4) {
 		assert(_movieArchive->hasResource(MKTAG('V','W','C','R'), 1024));
-		loadCastDataD2(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024));
+		loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024));
 	}
 
 	if (_movieArchive->hasResource(MKTAG('V','W','A','C'), 1024)) {
@@ -348,8 +348,8 @@ void Score::readVersion(uint32 rid) {
 	debug("Version: %d.%d", _versionMajor, _versionMinor);
 }
 
-void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) {
-	debugC(1, kDebugLoading, "Score::loadCastData(). start: %d, end: %d", _castArrayStart, _castArrayEnd);
+void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) {
+	debugC(1, kDebugLoading, "Score::loadCastDataVWCR(). start: %d, end: %d", _castArrayStart, _castArrayEnd);
 
 	for (uint16 id = _castArrayStart; id <= _castArrayEnd; id++) {
 		byte size = stream.readByte();
@@ -376,7 +376,7 @@ void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) {
 			_casts[id]->type = kCastButton;
 			break;
 		default:
-			warning("Unhandled cast type: %d", castType);
+			warning("Score::loadCastDataVWCR(): Unhandled cast type: %d", castType);
 			stream.skip(size - 1);
 			break;
 		}
@@ -393,17 +393,17 @@ void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) {
 	}
 }
 
-void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 castId) {
+void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id) {
 	// d4+ variant
 	if (stream.size() == 0)
 		return;
 
 	if (stream.size() < 26) {
-		warning("CAST data id %d is too small", castId);
+		warning("CAST data id %d is too small", id);
 		return;
 	}
 
-	debugC(3, kDebugLoading, "CASt: id: %d", castId);
+	debugC(3, kDebugLoading, "CASt: id: %d", id);
 
 	if (debugChannelSet(5, kDebugLoading))
 		stream.hexdump(stream.size());
@@ -428,43 +428,52 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 cas
 		blob[0] = blob[1] = blob[2] = 0;
 	}
 
-	debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d", castId, castType, size1, size2, size2, size3);
+	debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d", id, castType, size1, size2, size2, size3);
+
+	byte *data = (byte *)malloc(size1 + 16);
+	stream.read(data, size1 + 16);
+
+	Common::MemoryReadStreamEndian castStream(data, size1 + 16, stream.isBE());
 
-#if 0
 	switch (castType) {
 	case kCastBitmap:
-		_casts[id] = new BitmapCast(stream);
+		warning("CASt: Bitmap");
+		Common::hexdump(data, size1 + 16);
+		_casts[id] = new BitmapCast(castStream, _vm->getVersion());
 		_casts[id]->type = kCastBitmap;
 		break;
 	case kCastText:
-		_casts[id] = new TextCast(stream);
+		warning("CASt: Text");
+		Common::hexdump(data, size1 + 16);
+		_casts[id] = new TextCast(castStream, _vm->getVersion());
 		_casts[id]->type = kCastText;
 		break;
 	case kCastShape:
-		_casts[id] = new ShapeCast(stream);
+		warning("CASt: Shape");
+		Common::hexdump(data, size1 + 16);
+
+		_casts[id] = new ShapeCast(castStream, _vm->getVersion());
 		_casts[id]->type = kCastShape;
 		break;
 	case kCastButton:
-		_casts[id] = new ButtonCast(stream);
+		warning("CASt: Button");
+		Common::hexdump(data, size1 + 16);
+
+		_casts[id] = new ButtonCast(castStream, _vm->getVersion());
 		_casts[id]->type = kCastButton;
 		break;
+	case kCastScript:
+		warning("CASt: Script");
+		Common::hexdump(data, size1 + 16);
+
+		_casts[id] = new ScriptCast(castStream, _vm->getVersion());
+		_casts[id]->type = kCastScript;
+		break;
 	default:
-		warning("Unhandled cast type: %d", castType);
-		stream.skip(size - 1);
+		warning("Score::loadCastData(): Unhandled cast type: %d", castType);
 		break;
 	}
-#endif
-
-	Score::readRect(stream);
-	Score::readRect(stream);
-
-	//member.initialRect = readRect(data)
-	//member.boundingRect = readRect(data)
-	//member.regX = 0 // FIXME: HACK
-	//member.regY = 0 // FIXME: HACK
 
-	byte *data = (byte *)malloc(size1);
-	stream.read(data, size1);
 	free(data);
 
 	if (size2) {
@@ -488,7 +497,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 cas
 		ci->fileName = castStrings[3];
 		ci->type = castStrings[4];
 
-		_castsInfo[castId] = ci;
+		_castsInfo[id] = ci;
 	}
 
 	if (size3)
@@ -794,7 +803,10 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn
 		Common::String entryString;
 
 		for (uint j = entries[i]; j < entries[i + 1]; j++)
-			entryString += data[j];
+			if (data[j] == '\r')
+				entryString += '\n';
+			else
+				entryString += data[j];
 
 		strings.push_back(entryString);
 	}
@@ -830,7 +842,7 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) {
 	}
 }
 
-Common::Rect Score::readRect(Common::SeekableSubReadStreamEndian &stream) {
+Common::Rect Score::readRect(Common::ReadStreamEndian &stream) {
 	Common::Rect *rect = new Common::Rect();
 	rect->top = stream.readUint16();
 	rect->left = stream.readUint16();
diff --git a/engines/director/score.h b/engines/director/score.h
index ca148af..9f60883 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -55,7 +55,7 @@ public:
 	Score(DirectorEngine *vm, Archive *);
 	~Score();
 
-	static Common::Rect readRect(Common::SeekableSubReadStreamEndian &stream);
+	static Common::Rect readRect(Common::ReadStreamEndian &stream);
 	static int compareLabels(const void *a, const void *b);
 	void loadArchive();
 	void setStartToLabel(Common::String label);
@@ -66,7 +66,7 @@ public:
 	void processEvents();
 	Archive *getArchive() const { return _movieArchive; };
 	void loadConfig(Common::SeekableSubReadStreamEndian &stream);
-	void loadCastDataD2(Common::SeekableSubReadStreamEndian &stream);
+	void loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream);
 	void loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id);
 	void setCurrentFrame(uint16 frameId) { _currentFrame = frameId; }
 	int getCurrentFrame() { return _currentFrame; }





More information about the Scummvm-git-logs mailing list