ScummVM API documentation
data.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MTROPOLIS_DATA_H
23 #define MTROPOLIS_DATA_H
24 
25 #include "common/array.h"
26 #include "common/data-io.h"
27 #include "common/endian.h"
28 #include "common/error.h"
29 #include "common/hashmap.h"
30 #include "common/hash-str.h"
31 #include "common/ptr.h"
32 #include "common/stream.h"
33 #include "common/rect.h"
34 #include "common/xpfloat.h"
35 
36 #include "mtropolis/core.h"
37 
38 // This contains defs related to parsing of mTropolis stored data into structured data objects.
39 // This is separated from asset construction for a number of reasons, mainly that data parsing has
40 // several quirky parses, and there are a lot of fields where, due to platform-specific byte
41 // swaps, we know the size of the value but don't know what it means.
42 
43 namespace MTropolis {
44 
45 class PlugIn;
46 
47 namespace Data {
48 
49 enum DataFormat {
50  kDataFormatUnknown,
51 
52  kDataFormatMacintosh,
53  kDataFormatWindows,
54 };
55 
56 } // End of namespace Data
57 
58 } // End of namespace MTropolis
59 
60 namespace Common {
61 
62 template<>
63 struct DataFormatTraits<MTropolis::Data::DataFormat> {
64  static inline bool isLittleEndian(MTropolis::Data::DataFormat dataFormat) {
65  return dataFormat != MTropolis::Data::kDataFormatMacintosh;
66  }
67 };
68 
69 template<>
70 struct DataIO<MTropolis::Data::DataFormat, Common::XPFloat> {
71  static const uint kMaxSize = 10;
72 
73  static inline uint computeSize(MTropolis::Data::DataFormat dataFormat) {
74  if (dataFormat == MTropolis::Data::kDataFormatMacintosh)
75  return 10;
76  else if (dataFormat == MTropolis::Data::kDataFormatWindows)
77  return 8;
78  else
79  return 0;
80  }
81 
82  static inline void encode(MTropolis::Data::DataFormat dataFormat, byte *data, const Common::XPFloat &value) {
83  if (dataFormat == MTropolis::Data::kDataFormatMacintosh) {
84  DataIO<MTropolis::Data::DataFormat, uint16>::encode(dataFormat, data + 0, value.signAndExponent);
85  DataIO<MTropolis::Data::DataFormat, uint64>::encode(dataFormat, data + 2, value.mantissa);
86  } else if (dataFormat == MTropolis::Data::kDataFormatWindows) {
87  uint64 doubleBits = 0;
88  bool overflowed = false;
89  value.toDoubleBitsSafe(doubleBits, overflowed);
90  DataIO<MTropolis::Data::DataFormat, uint64>::encode(dataFormat, data, doubleBits);
91  }
92  }
93 
94  static inline void decode(MTropolis::Data::DataFormat dataFormat, const byte *data, Common::XPFloat &value) {
95  if (dataFormat == MTropolis::Data::kDataFormatMacintosh) {
96  DataIO<MTropolis::Data::DataFormat, uint16>::decode(dataFormat, data + 0, value.signAndExponent);
97  DataIO<MTropolis::Data::DataFormat, uint64>::decode(dataFormat, data + 2, value.mantissa);
98  } else if (dataFormat == MTropolis::Data::kDataFormatWindows) {
99  uint64 doubleBits = 0;
100  DataIO<MTropolis::Data::DataFormat, uint64>::decode(dataFormat, data, doubleBits);
101  value = value.fromDoubleBits(doubleBits);
102  }
103  }
104 };
105 
106 } // End of namespace Common
107 
108 
109 namespace MTropolis {
110 
111 class PlugIn;
112 
113 namespace Data {
114 
115 struct PlugInModifier;
116 struct PlugInModifierData;
117 
118 // Project format and data format are 2 separate things.
119 //
120 // A cross-platform project can be booted in either Mac or Win mode and contains
121 // separate scene streams for Mac and Win. Which one is loaded depends on what the
122 // game platform is loaded as.
123 //
124 // The following table describes the behavior:
125 //
126 // Project type | ProjectFormat | Catalog and asset data format | Scene data format |
127 // ------------------------------------------------------------------------------------------|
128 // Mac | Macintosh | Macintosh | Macintosh |
129 // Win | Windows | Windows | Windows |
130 // Cross-Platform as Mac | Neutral | Windows | Macintosh |
131 // Cross-Platform as Win | Neutral | Windows | Windows |
132 
133 enum ProjectFormat {
134  kProjectFormatUnknown,
135 
136  kProjectFormatMacintosh,
137  kProjectFormatWindows,
138  kProjectFormatNeutral,
139 };
140 
141 enum DataReadErrorCode {
142  kDataReadErrorNone = 0,
143 
144  kDataReadErrorUnsupportedRevision,
145  kDataReadErrorReadFailed,
146  kDataReadErrorUnrecognized,
147  kDataReadErrorPlugInNotFound,
148 };
149 
150 enum ModifierFlags {
151  kModifierFlagLast = 0x2,
152 };
153 
154 enum TextAlignmentCode {
155  kTextAlignmentCodeLeft = 0,
156  kTextAlignmentCodeCenter = 1,
157  kTextAlignmentCodeRight = 0xffff,
158 };
159 
160 
161 namespace DataObjectTypes {
162 
163 enum DataObjectType : uint {
164  kUnknown = 0,
165 
166  kProjectLabelMap = 0x22,
167  kProjectCatalog = 0x3e8,
168  kStreamHeader = 0x3e9,
169  kProjectHeader = 0x3ea,
170  kPresentationSettings = 0x3ec,
171 
172  kAssetCatalog = 0xd,
173  kGlobalObjectInfo = 0x17,
174  kUnknown19 = 0x19,
175  kUnknown2B = 0x2b,
176 
177  kProjectStructuralDef = 0x2,
178  kSectionStructuralDef = 0x3,
179  kSubsectionStructuralDef = 0x21,
180 
181  kGraphicElement = 0x8,
182  kMovieElement = 0x5,
183  kMToonElement = 0x6,
184  kImageElement = 0x7,
185  kSoundElement = 0xa,
186  kTextLabelElement = 0x15,
187 
188  kAVIMovieElement = 0x25,
189  kAliasModifier = 0x27,
190  kChangeSceneModifier = 0x136,
191  kReturnModifier = 0x140,
192  kSoundEffectModifier = 0x1a4,
193  kSimpleMotionModifier = 0x1fe,
194  kDragMotionModifier = 0x208,
195  kPathMotionModifierV1 = 0x21c,
196  kPathMotionModifierV2 = 0x21b,
197  kVectorMotionModifier = 0x226,
198  kSceneTransitionModifier = 0x26c,
199  kElementTransitionModifier = 0x276,
200  kSharedSceneModifier = 0x29a,
201  kIfMessengerModifier = 0x2bc,
202  kBehaviorModifier = 0x2c6,
203  kMessengerModifier = 0x2da,
204  kSetModifier = 0x2df,
205  kTimerMessengerModifier = 0x2e4,
206  kCollisionDetectionMessengerModifier = 0x2ee,
207  kBoundaryDetectionMessengerModifier = 0x2f8,
208  kKeyboardMessengerModifier = 0x302,
209  kTextStyleModifier = 0x32a,
210  kGraphicModifier = 0x334,
211  kImageEffectModifier = 0x384,
212  kMiniscriptModifier = 0x3c0,
213  kCursorModifierV1 = 0x3ca,
214  kGradientModifier = 0x4b0, // NYI
215  kColorTableModifier = 0x4c4,
216  kSoundFadeModifier = 0x4ce,
217  kSaveAndRestoreModifier = 0x4d8,
218 
219  kCompoundVariableModifier = 0x2c7,
220  kBooleanVariableModifier = 0x321,
221  kIntegerVariableModifier = 0x322,
222  kIntegerRangeVariableModifier = 0x324,
223  kVectorVariableModifier = 0x327,
224  kPointVariableModifier = 0x326,
225  kFloatingPointVariableModifier = 0x328,
226  kStringVariableModifier = 0x329,
227  kObjectReferenceVariableModifierV1 = 0x33e,
228  kDebris = 0xfffffffe, // Deleted modifier in alias list
229  kPlugInModifier = 0xffffffff,
230 
231  kMovieAsset = 0x10,
232  kAudioAsset = 0x11,
233  kColorTableAsset = 0x1e,
234  kImageAsset = 0xe,
235  kMToonAsset = 0xf,
236  kTextAsset = 0x1f,
237  kAVIMovieAsset = 0x24,
238 
239  kAssetDataChunk = 0xffff,
240 };
241 
242 bool isValidSceneRootElement(DataObjectType type);
243 bool isVisualElement(DataObjectType type);
244 bool isNonVisualElement(DataObjectType type);
245 bool isStructural(DataObjectType type);
246 bool isElement(DataObjectType type);
247 bool isModifier(DataObjectType type);
248 bool isAsset(DataObjectType type);
249 
250 } // End of namespace DataObjectTypes
251 
252 namespace StructuralFlags {
253  enum StructuralFlags {
254  kHasModifiers = 0x1,
255  kHasChildren = 0x4,
256  kNoMoreSiblings = 0x8,
257  };
258 } // End of namespace StructuralFlags
259 
260 
261 class DataReader {
262 public:
263  DataReader(int64 globalPosition, Common::SeekableReadStream &stream, DataFormat dataFormat, RuntimeVersion runtimeVersion, bool autoDetectVersion);
264 
265  bool readU8(uint8 &value);
266  bool readU16(uint16 &value);
267  bool readU32(uint32 &value);
268  bool readU64(uint64 &value);
269  bool readS8(int8 &value);
270  bool readS16(int16 &value);
271  bool readS32(int32 &value);
272  bool readS64(int64 &value);
273  bool readF32(float &value);
274  bool readF64(double &value);
275  bool readPlatformFloat(Common::XPFloat &value);
276 
277  template<class... T>
278  bool readMultiple(T &...values);
279 
280  bool read(void *dest, size_t size);
281 
282  // Reads a terminated string where "length" is the number of characters including a null terminator
283  bool readTerminatedStr(Common::String &value, size_t length);
284 
285  bool readNonTerminatedStr(Common::String &value, size_t length);
286 
287  template<size_t TSize>
288  bool readChars(char (&arr)[TSize]);
289 
290  template<size_t TSize>
291  bool readBytes(uint8 (&arr)[TSize]);
292 
293  bool seek(int64 pos);
294  bool skip(size_t count);
295 
296  int64 tell() const;
297  inline int64 tellGlobal() const { return _globalPosition + tell(); }
298 
299  DataFormat getDataFormat() const;
300 
301  void setPermitDamagedStrings(bool permit);
302 
303  bool isVersionAutoDetect() const;
304  RuntimeVersion getRuntimeVersion() const;
305  void setRuntimeVersion(RuntimeVersion runtimeVersion);
306 
307 private:
308  bool checkErrorAndReset();
309 
311  DataFormat _dataFormat;
312  int64 _globalPosition;
313 
314  bool _permitDamagedStrings;
315 
316  RuntimeVersion _runtimeVersion; // NOTE: May change during parsing if auto-detecting
317  bool _autoDetect;
318 };
319 
320 template<class... T>
321 bool DataReader::readMultiple(T &...values) {
322  byte buffer[Common::DataMultipleIO<DataFormat, T...>::kMaxSize];
323  const uint actualSize = Common::DataMultipleIO<DataFormat, T...>::computeSize(_dataFormat);
324 
325  if (!read(buffer, actualSize))
326  return false;
327 
328  Common::DataMultipleIO<DataFormat, T...>::decode(_dataFormat, buffer, values...);
329  return true;
330 }
331 
332 struct Rect {
333  Rect();
334 
335  bool load(DataReader &reader);
336 
337  bool toScummVMRect(Common::Rect &outRect) const;
338  bool toScummVMRectUnchecked(Common::Rect &outRect) const;
339 
340  int16 top;
341  int16 left;
342  int16 bottom;
343  int16 right;
344 };
345 
346 struct Point {
347  Point();
348 
349  bool load(DataReader &reader);
350  bool toScummVMPoint(Common::Point &outPoint) const;
351 
352  int16 x;
353  int16 y;
354 };
355 
356 struct Event {
357  Event();
358 
359  bool load(DataReader &reader);
360 
361  uint32 eventID;
362  uint32 eventInfo;
363 };
364 
365 struct ColorRGB16 {
366  ColorRGB16();
367 
368  bool load(DataReader &reader);
369 
370  uint16 red;
371  uint16 green;
372  uint16 blue;
373 };
374 
375 struct IntRange {
376  IntRange();
377 
378  bool load(DataReader &reader);
379 
380  int32 min;
381  int32 max;
382 };
383 
385  bool load(DataReader &reader);
386 
387  Common::XPFloat angleRadians;
388  Common::XPFloat magnitude;
389 };
390 
391 struct XPFloatPOD {
392  uint16 signAndExponent;
393  uint64 mantissa;
394 
395  bool load(DataReader &reader);
396  Common::XPFloat toXPFloat() const;
397 };
398 
399 struct Label {
400  bool load(DataReader &reader);
401 
402  uint32 superGroupID;
403  uint32 labelID;
404 };
405 
407  bool load(DataReader &reader);
408 
409  int32 value;
410  int32 scale;
411  int32 base;
412 };
413 
414 
415 // mTropolis uses two separate type-tagged value formats.
416 //
417 // InternalTypeTaggedValue is used by internal modifiers for messenger payloads and set modifiers
418 // and seems to match Miniscript ops too.
419 // InternalTypeTaggedValue is always 46 bytes in size and stores string data elsewhere in the containing structure.
420 //
421 // PlugInTypeTaggedValue is used by plug-ins and is fully self-contained.
422 //
423 // If you change something here, remember to update DynamicValue::load
425  enum TypeCode {
426  kNull = 0x00,
427  kInteger = 0x01,
428  kString = 0x0d, // String data is stored externally from the value
429  kPoint = 0x10,
430  kIntegerRange = 0x11,
431  kFloat = 0x15,
432  kBool = 0x1a,
433  kIncomingData = 0x1b,
434  kVariableReference = 0x1c,
435  kLabel = 0x1d,
436  };
437 
439  uint32 unknown;
440  uint32 guid;
441  };
442 
443  union ValueUnion {
444  ValueUnion();
445 
446  uint8 asBool;
447  XPFloatPOD asFloat;
448  int32 asInteger;
449  IntRange asIntegerRange;
450  VariableReference asVariableReference;
451  Label asLabel;
452  Point asPoint;
453 
454  template<class T>
455  void constructField(T ValueUnion::*fieldPtr);
456  };
457 
460 
461  uint16 type;
462  ValueUnion value;
463 
464  bool load(DataReader &reader);
465 };
466 
468  enum TypeCode {
469  kNull = 0x00,
470  kInteger = 0x01,
471  kUniversalTime = 0x09,
472  kPoint = 0xa,
473  kIntegerRange = 0xb,
474  kFloat = 0xf,
475  kBoolean = 0x14,
476  kEvent = 0x17,
477  kLabel = 0x64,
478  kString = 0x66,
479  kRGBColor = 0x6c,
480  kIncomingData = 0x6e,
481  kVariableReference = 0x73, // Has extra data
482  };
483 
484  union ValueUnion {
485  ValueUnion();
486  ~ValueUnion();
487 
488  int32 asInt;
489  Point asPoint;
490  UniversalTime asUniversalTime;
491  ColorRGB16 asColor;
492  IntRange asIntRange;
493  XPFloatPOD asFloat;
494  uint16 asBoolean;
495  Event asEvent;
496  Label asLabel;
497  uint32 asVarRefGUID;
498  Common::String asString;
499 
500  template<class T>
501  void constructField(T ValueUnion::*fieldPtr);
502 
503  template<class T>
504  void destructField(T ValueUnion::*fieldPtr);
505  };
506 
509 
510  uint16 type;
511  ValueUnion value;
512 
513  Common::Array<uint8> extraData;
514 
515  bool load(DataReader &reader);
516 };
517 
519 
520 public:
521  DataObject();
522  virtual ~DataObject();
523  DataReadErrorCode load(DataObjectTypes::DataObjectType type, uint16 revision, DataReader &reader);
524 
525  uint16 getRevision() const;
526  DataObjectTypes::DataObjectType getType() const;
527 
528 protected:
529  virtual DataReadErrorCode load(DataReader &reader) = 0;
530 
531  DataObjectTypes::DataObjectType _type;
532  uint16 _revision;
533 };
534 
535 struct ProjectHeader : public DataObject {
536  ProjectHeader();
537 
538  uint32 persistFlags;
539  uint32 sizeIncludingTag;
540  uint16 unknown1;
541  uint32 catalogFilePosition;
542 
543 protected:
544  DataReadErrorCode load(DataReader &reader) override;
545 };
546 
547 struct ProjectLabelMap : public DataObject {
548  ProjectLabelMap();
549  ~ProjectLabelMap();
550 
551  struct LabelTree {
552  LabelTree();
553  ~LabelTree();
554 
555  enum : uint {
556  kExpandedInEditor = 0x80000000,
557  };
558 
559  uint32 nameLength;
560  uint32 isGroup;
561  uint32 id;
562  uint32 unknown1;
563  uint32 flags;
564 
565  Common::String name;
566 
567  uint32 numChildren;
568  LabelTree *children;
569  };
570 
571  struct SuperGroup {
572  SuperGroup();
573  ~SuperGroup();
574 
575  uint32 nameLength;
576  uint32 id;
577  uint32 unknown2;
578  Common::String name;
579 
580  uint32 numChildren;
581  LabelTree *tree;
582  };
583 
584  uint32 persistFlags;
585  uint32 unknown1; // Always 0x16
586  uint32 numSuperGroups;
587  uint32 nextAvailableID;
588 
589  SuperGroup *superGroups;
590 
591 private:
592  static DataReadErrorCode loadSuperGroup(SuperGroup &sg, DataReader &reader);
593  static DataReadErrorCode loadLabelTree(LabelTree &lt, DataReader &reader);
594 
595  DataReadErrorCode load(DataReader &reader) override;
596 };
597 
600 
601  uint32 persistFlags;
602  uint32 sizeIncludingTag;
603  uint8 unknown1[2];
604  Point dimensions;
605  uint16 bitsPerPixel;
606  uint16 unknown4;
607 
608 protected:
609  DataReadErrorCode load(DataReader &reader) override;
610 };
611 
612 struct AssetCatalog : public DataObject {
613  enum {
614  kFlag1Deleted = 1,
615  kFlag1LimitOnePerSegment = 2,
616  };
617 
620 
621  uint32 assetType;
622  uint32 flags2;
623  };
624 
625  struct AssetInfo {
626  AssetInfo();
627 
628  uint32 flags1;
629  uint16 nameLength;
630  uint16 alwaysZero;
631  uint32 streamID;
632  uint32 filePosition; // Contains a static value in Obsidian
633 
634  AssetInfoRev4Fields rev4Fields;
635 
636  Common::String name;
637  };
638 
639  AssetCatalog();
640 
641  uint32 persistFlags;
642  uint32 totalNameSizePlus22;
643  uint8 unknown1[4];
644  uint32 numAssets;
645  bool haveRev4Fields;
646 
648 
649 protected:
650  DataReadErrorCode load(DataReader &reader) override;
651 };
652 
653 struct Unknown19 : public DataObject {
654  Unknown19();
655 
656  uint32 persistFlags;
657  uint32 sizeIncludingTag;
658  uint8 unknown1[2];
659 
660 protected:
661  DataReadErrorCode load(DataReader &reader) override;
662 };
663 
664 struct Unknown2B : public DataObject {
665  Unknown2B();
666 
667  uint32 persistFlags;
668  uint32 sizeIncludingTag;
669 
670 protected:
671  DataReadErrorCode load(DataReader &reader) override;
672 };
673 
674 struct StructuralDef : public DataObject {
675  StructuralDef();
676 
677  uint32 structuralFlags;
678 };
679 
682 
683  uint32 unknown1; // Seems to always be 0x16 or 0x9
684  uint32 sizeIncludingTag;
685  uint32 guid;
686  uint32 otherFlags;
687  uint16 lengthOfName;
688 
689  Common::String name;
690 
691 protected:
692  DataReadErrorCode load(DataReader &reader) override;
693 };
694 
697 
698  uint32 sizeIncludingTag;
699  uint32 guid;
700  uint16 lengthOfName;
701  uint32 otherFlags;
702  uint16 unknown4;
703  uint16 sectionID;
704  uint32 segmentID;
705 
706  Common::String name;
707 
708 protected:
709  DataReadErrorCode load(DataReader &reader) override;
710 };
711 
714 
715  uint32 structuralFlags;
716  uint32 sizeIncludingTag;
717  uint32 guid;
718  uint16 lengthOfName;
719  uint32 otherFlags;
720  uint16 sectionID;
721 
722  Common::String name;
723 
724 protected:
725  DataReadErrorCode load(DataReader &reader) override;
726 };
727 
728 namespace ElementFlags {
729 
730 enum ElementFlags {
731  kNotDirectToScreen = 0x00001000,
732  kHidden = 0x00008000,
733  kPaused = 0x00010000,
734  kExpandedInEditor = 0x00800000,
735  kCacheBitmap = 0x02000000,
736  kSelectedInEditor = 0x10000000,
737 };
738 
739 } // End of namespace ElementFlags
740 
741 namespace AnimationFlags {
742 
743 enum AnimationFlags {
744  kAlternate = 0x10000000,
745  kLoop = 0x08000000,
746  kPlayEveryFrame = 0x02000000,
747 };
748 
749 } // End of namespace AnimationFlags
750 
751 namespace SceneTransitionTypes {
752 
753 enum SceneTransitionType {
754  kNone = 0,
755  kPatternDissolve = 0x0406,
756  kRandomDissolve = 0x0410, // No steps
757  kFade = 0x041a,
758  kSlide = 0x03e8, // Directional
759  kPush = 0x03f2, // Directional
760  kZoom = 0x03fc,
761  kWipe = 0x0424, // Directional
762 };
763 
764 } // End of namespace SceneTransitionTypes
765 
766 namespace SceneTransitionDirections {
767 
768 enum SceneTransitionDirection {
769  kUp = 0x384,
770  kDown = 0x385,
771  kLeft = 0x386,
772  kRight = 0x387,
773 };
774 
775 } // End of namespace SceneTransitionDirections
776 
777 struct GraphicElement : public StructuralDef {
778  GraphicElement();
779 
780  // Possible element flags: NotDirectToScreen, CacheBitmap, Hidden
781  uint32 sizeIncludingTag;
782  uint32 guid;
783  uint16 lengthOfName;
784  uint32 elementFlags;
785  uint16 layer;
786  uint16 sectionID;
787  Rect rect1;
788  Rect rect2;
789  uint32 streamLocator; // 1-based index, sometimes observed with 0x10000000 flag set, not sure of the meaning
790  uint8 unknown11[4];
791 
792  Common::String name;
793 
794 protected:
795  DataReadErrorCode load(DataReader &reader) override;
796 };
797 
798 struct ImageElement : public StructuralDef {
799  ImageElement();
800 
801  // Possible element flags: NotDirectToScreen, CacheBitmap, Hidden
802  uint32 sizeIncludingTag;
803  uint32 guid;
804  uint16 lengthOfName;
805  uint32 elementFlags;
806  uint16 layer;
807  uint16 sectionID;
808  Rect rect1;
809  Rect rect2;
810  uint32 imageAssetID;
811  uint32 streamLocator;
812  uint8 unknown7[4];
813 
814  Common::String name;
815 
816 protected:
817  DataReadErrorCode load(DataReader &reader) override;
818 };
819 
822 
823  // Possible element flags: NotDirectToScreen, CacheBitmap, Hidden
824  uint32 sizeIncludingTag;
825  uint32 guid;
826  uint16 lengthOfName;
827  uint32 elementFlags;
828  uint16 layer;
829  uint16 sectionID;
830  Rect rect1;
831  Rect rect2;
832  uint32 assetID;
833 
834  struct MacPart {
835  uint8 unknown2[30];
836  };
837 
838  struct WinPart {
839  uint8 unknown3[2];
840  uint8 unknown4[8];
841  };
842 
843  union PlatformPart {
844  MacPart mac;
845  WinPart win;
846  };
847 
848  bool haveMacPart;
849  bool haveWinPart;
850  PlatformPart platform;
851 
852  Common::String name;
853 
854 protected:
855  DataReadErrorCode load(DataReader &reader) override;
856 };
857 
858 struct SoundElement : public StructuralDef {
859  enum SoundFlags : uint {
860  kPaused = 0x40000000,
861  kLoop = 0x80000000,
862  };
863 
864  SoundElement();
865 
866  // Possible element flags: Loop, Paused
867  uint32 sizeIncludingTag;
868  uint32 guid;
869  uint16 lengthOfName;
870  uint32 elementFlags;
871  uint32 soundFlags;
872  uint16 unknown2;
873  uint8 unknown3[2];
874  uint16 rightVolume;
875  uint16 leftVolume;
876  int16 balance;
877  uint32 assetID;
878  uint8 unknown5[8];
879 
880  Common::String name;
881 
882 protected:
883  DataReadErrorCode load(DataReader &reader) override;
884 };
885 
886 struct MovieElement : public StructuralDef {
887  explicit MovieElement(bool avi);
888 
889  // Possible flags: NotDirectToScreen, CacheBitmap, Hidden, Loop, Loop + Alternate, Paused
890  uint32 sizeIncludingTag;
891  uint32 guid;
892  uint16 lengthOfName;
893  uint32 elementFlags;
894  uint16 layer;
895  uint8 unknown3[44];
896  uint16 sectionID;
897  uint8 unknown5[2];
898  Rect rect1;
899  Rect rect2;
900  uint32 assetID;
901  uint32 unknown7;
902  uint16 volume;
903  uint32 animationFlags;
904  uint8 unknown10[4];
905  uint8 unknown11[4];
906  uint32 streamLocator;
907  uint8 unknown13[4];
908 
909  Common::String name;
910 
911  bool isAVI;
912 
913 protected:
914  DataReadErrorCode load(DataReader &reader) override;
915 };
916 
917 struct MToonElement : public StructuralDef {
918  MToonElement();
919 
920  // Possible flags: NotDirectToScreen, CacheBitmap, Hidden, Loop, Paused, PlayEveryFrame (inverted as "Maintain Rate")
921  uint32 sizeIncludingTag;
922  uint32 guid;
923  uint16 lengthOfName;
924  uint32 elementFlags;
925  uint16 layer;
926  uint32 animationFlags;
927  uint8 unknown4[4];
928  uint16 sectionID;
929  Rect rect1;
930  Rect rect2;
931  uint32 assetID;
932  uint32 rateTimes100000;
933  uint32 streamLocator;
934  uint32 unknown6;
935 
936  Common::String name;
937 
938 protected:
939  DataReadErrorCode load(DataReader &reader) override;
940 };
941 
942 struct GlobalObjectInfo : public DataObject {
944 
945  uint32 persistFlags;
946  uint32 sizeIncludingTag;
947  uint16 numGlobalModifiers;
948  uint8 unknown1[4];
949 
950 protected:
951  DataReadErrorCode load(DataReader &reader) override;
952 };
953 
954 class ProjectCatalog : public DataObject {
955 public:
956  struct StreamDesc {
957  StreamDesc();
958 
959  char streamType[25];
960  uint16 segmentIndexPlusOne;
961  uint32 winSize;
962  uint32 winPos;
963  uint32 macSize;
964  uint32 macPos;
965  };
966 
967  struct SegmentDesc {
968  SegmentDesc();
969 
970  uint32 segmentID;
971  Common::String label;
972  Common::String exportedPath;
973  };
974 
975  ProjectCatalog();
976 
977  uint32 persistFlags;
978  uint32 sizeOfStreamAndSegmentDescs;
979  uint16 unknown1;
980  uint16 unknown2;
981  uint32 unknown3;
982 
985 
986 protected:
987  DataReadErrorCode load(DataReader &reader) override;
988 };
989 
990 struct StreamHeader : public DataObject {
991  StreamHeader();
992 
993  uint32 marker;
994  uint32 sizeIncludingTag;
995  char name[17];
996  uint8 projectID[2];
997  uint8 unknown1[4]; // Seems to be consistent across builds
998  uint16 unknown2; // 0
999 
1000 protected:
1001  DataReadErrorCode load(DataReader &reader) override;
1002 };
1003 
1004 struct BehaviorModifier : public DataObject {
1005  enum BehaviorFlags {
1006  kBehaviorFlagSwitchable = 1,
1007  };
1008 
1009  BehaviorModifier();
1010 
1011  uint32 modifierFlags;
1012  uint32 sizeIncludingTag;
1013  uint8 unknown2[2];
1014  uint32 guid;
1015  uint32 unknown4;
1016  uint16 unknown5;
1017  uint32 unknown6;
1018  uint32 unknown8; // revision 2 only.
1019  Point editorLayoutPosition;
1020  uint16 lengthOfName;
1021  uint16 numChildren;
1022  uint32 behaviorFlags;
1023  Event enableWhen;
1024  Event disableWhen;
1025  uint8 unknown7[2];
1026 
1027  Common::String name;
1028 
1029 protected:
1030  DataReadErrorCode load(DataReader &reader) override;
1031 };
1032 
1034  struct LocalRef {
1035  LocalRef();
1036 
1037  uint32 guid;
1038  uint8 lengthOfName;
1039  uint8 unknown2;
1040 
1041  Common::String name;
1042  };
1043 
1044  struct Attribute {
1045  Attribute();
1046 
1047  uint8 lengthOfName;
1048  uint8 unknown3;
1049 
1050  Common::String name;
1051  };
1052 
1054 
1055  uint32 unknown1;
1056  uint32 sizeOfInstructions;
1057  uint32 numOfInstructions;
1058  uint32 numLocalRefs;
1059  uint32 numAttributes;
1060 
1061  Common::Array<uint8> bytecode;
1062  Common::Array<LocalRef> localRefs;
1063  Common::Array<Attribute> attributes;
1064 
1065  DataFormat dataFormat;
1066 
1067  bool load(DataReader &reader);
1068 };
1069 
1070 // Header used for most modifiers, but not all
1073 
1074  uint32 modifierFlags;
1075  uint32 sizeIncludingTag;
1076  uint32 guid;
1077  uint8 unknown3[6];
1078  uint32 unknown4;
1079  uint32 unknown5; // V2 header only
1080  Point editorLayoutPosition;
1081  uint16 lengthOfName;
1082 
1083  Common::String name;
1084 
1085  bool load(DataReader &reader, bool isV2);
1086 };
1087 
1090 
1091  TypicalModifierHeader modHeader;
1092  Event enableWhen;
1093  uint8 unknown6[11];
1094  uint8 unknown7;
1095 
1096  MiniscriptProgram program;
1097 
1098 protected:
1099  DataReadErrorCode load(DataReader &reader) override;
1100 };
1101 
1104 
1105  TypicalModifierHeader modHeader;
1106  Event applyWhen;
1107  uint32 unknown1;
1108  uint8 unknown2[4];
1109  uint32 assetID;
1110 
1111 protected:
1112  DataReadErrorCode load(DataReader &reader) override;
1113 };
1114 
1117 
1118  TypicalModifierHeader modHeader;
1119  uint8 unknown1[4];
1120  Event enableWhen;
1121  Event disableWhen;
1122  uint16 fadeToVolume;
1123  uint8 codedDuration[4];
1124  uint8 unknown2[18];
1125 
1126 protected:
1127  DataReadErrorCode load(DataReader &reader) override;
1128 };
1129 
1132 
1133  TypicalModifierHeader modHeader;
1134  uint8 unknown1[4];
1135  Event saveWhen;
1136  Event restoreWhen;
1137  InternalTypeTaggedValue saveOrRestoreValue;
1138 
1139  uint8 unknown5[8];
1140 
1141  uint8 lengthOfFilePath;
1142  uint8 lengthOfFileName;
1143  uint8 lengthOfVariableName;
1144  uint8 lengthOfVariableString;
1145 
1146  Common::String varName;
1147  Common::String varString;
1148  Common::String filePath;
1149  Common::String fileName;
1150 
1151 protected:
1152  DataReadErrorCode load(DataReader &reader) override;
1153 };
1154 
1155 enum MessageFlags : uint {
1156  kMessageFlagNoRelay = 0x20000000,
1157  kMessageFlagNoCascade = 0x40000000,
1158  kMessageFlagNoImmediate = 0x80000000,
1159 };
1160 
1161 
1164 
1165  TypicalModifierHeader modHeader;
1166 
1167  uint32 messageFlags;
1168  Event send;
1169  Event when;
1170  uint16 unknown14;
1171  uint32 destination;
1172  uint8 unknown11[10];
1174  uint8 withSourceLength;
1175  uint8 withStringLength;
1176 
1177  Common::String withSource;
1178  Common::String withString;
1179 
1180 protected:
1181  DataReadErrorCode load(DataReader &reader) override;
1182 };
1183 
1184 struct SetModifier : public DataObject {
1185  SetModifier();
1186 
1187  TypicalModifierHeader modHeader;
1188 
1189  uint8 unknown1[4];
1190  Event executeWhen;
1191  InternalTypeTaggedValue source;
1192  InternalTypeTaggedValue target;
1193  uint8 unknown3;
1194  uint8 sourceNameLength;
1195  uint8 targetNameLength;
1196  uint8 sourceStringLength;
1197  uint8 targetStringLength;
1198  uint8 unknown4;
1199 
1200  Common::String sourceName;
1201  Common::String targetName;
1202  Common::String sourceString;
1203  Common::String targetString;
1204 
1205 protected:
1206  DataReadErrorCode load(DataReader &reader) override;
1207 };
1208 
1209 struct AliasModifier : public DataObject {
1210  AliasModifier();
1211 
1212  uint32 modifierFlags;
1213  uint32 sizeIncludingTag;
1214  uint16 aliasIndexPlusOne;
1215  uint32 unknown1;
1216  uint32 unknown2;
1217  uint32 unknown3;
1218  uint32 lengthOfName;
1219  uint32 guid;
1220  Point editorLayoutPosition;
1221 
1222  Common::String name;
1223 
1224  bool haveGUID;
1225 
1226 protected:
1227  DataReadErrorCode load(DataReader &reader) override;
1228 };
1229 
1231  enum ChangeSceneFlags : uint {
1232  kChangeSceneFlagNextScene = 0x80000000,
1233  kChangeSceneFlagPrevScene = 0x40000000,
1234  kChangeSceneFlagSpecificScene = 0x20000000,
1235  kChangeSceneFlagAddToReturnList = 0x10000000,
1236  kChangeSceneFlagAddToDestList = 0x08000000,
1237  kChangeSceneFlagWrapAround = 0x04000000,
1238  };
1239 
1241 
1242  TypicalModifierHeader modHeader;
1243  uint32 changeSceneFlags;
1244  Event executeWhen;
1245  uint32 targetSectionGUID;
1246  uint32 targetSubsectionGUID;
1247  uint32 targetSceneGUID;
1248 
1249 protected:
1250  DataReadErrorCode load(DataReader &reader) override;
1251 };
1252 
1255 
1256  static const uint32 kSpecialAssetIDSystemBeep = 0xffffffffu;
1257 
1258  TypicalModifierHeader modHeader;
1259  uint8 unknown1[4];
1260  Event executeWhen;
1261  Event terminateWhen;
1262  uint32 unknown2;
1263  uint8 unknown3[4];
1264  uint32 assetID;
1265  uint8 unknown5[4];
1266 
1267 protected:
1268  DataReadErrorCode load(DataReader &reader) override;
1269 };
1270 
1274 
1275  uint32 messageFlags;
1276  Event send;
1277  uint16 unknown11;
1278  uint32 destination;
1279  uint8 unknown13[10];
1281  uint8 withSourceLength;
1282  uint8 withStringLength;
1283 
1284  Common::String withSource;
1285  Common::String withString;
1286 
1287  bool load(DataReader &reader);
1288  };
1289 
1290  struct PointDef {
1291  PointDef();
1292 
1293  enum FrameFlags {
1294  kFrameFlagPlaySequentially = 1,
1295  };
1296 
1297  Point point;
1298  uint32 frame;
1299  uint32 frameFlags;
1300 
1301  PointDefMessageSpec messageSpec;
1302 
1303  bool load(DataReader &reader, bool haveMessageSpec);
1304  };
1305 
1306  enum Flags {
1307  kFlagReverse = 0x00100000,
1308  kFlagLoop = 0x10000000,
1309  kFlagAlternate = 0x02000000,
1310  kFlagStartAtBeginning = 0x08000000,
1311  };
1312 
1313  explicit PathMotionModifier(uint version);
1314 
1315  TypicalModifierHeader modHeader;
1316  uint32 flags;
1317 
1318  Event executeWhen;
1319  Event terminateWhen;
1320 
1321  uint8 unknown2[2];
1322  uint16 numPoints;
1323  uint8 unknown3[4];
1324  uint32 frameDurationTimes10Million;
1325  uint8 unknown5[4];
1326  uint32 unknown6;
1327 
1328  bool havePointDefMessageSpecs;
1329 
1330  Common::Array<PointDef> points;
1331 
1332 protected:
1333  DataReadErrorCode load(DataReader &reader) override;
1334 };
1335 
1338 
1339  TypicalModifierHeader modHeader;
1340 
1341  Event executeWhen;
1342  Event terminateWhen;
1343  uint16 motionType;
1344  uint16 directionFlags;
1345  uint16 steps;
1346  uint32 delayMSecTimes4800;
1347  uint8 unknown1[4];
1348 
1349 protected:
1350  DataReadErrorCode load(DataReader &reader) override;
1351 };
1352 
1355 
1356  TypicalModifierHeader modHeader;
1357 
1358  Event enableWhen;
1359  Event disableWhen;
1360 
1361  struct WinPart {
1362  uint8 unknown2;
1363  uint8 constrainHorizontal;
1364  uint8 constrainVertical;
1365  uint8 constrainToParent;
1366  };
1367 
1368  struct MacPart {
1369  uint8 flags;
1370  uint8 unknown3;
1371 
1372  enum Flags {
1373  kConstrainToParent = 0x10,
1374  kConstrainVertical = 0x20,
1375  kConstrainHorizontal = 0x40,
1376  };
1377  };
1378 
1380  WinPart win;
1381  MacPart mac;
1382  };
1383 
1384  PlatformPart platform;
1385 
1386  bool haveMacPart;
1387  bool haveWinPart;
1388  Rect constraintMargin;
1389  uint16 unknown1;
1390 
1391 protected:
1392  DataReadErrorCode load(DataReader &reader) override;
1393 };
1394 
1397 
1398  TypicalModifierHeader modHeader;
1399 
1400  Event enableWhen;
1401  Event disableWhen;
1403  uint16 unknown1;
1404  uint8 vecSourceLength;
1405  uint8 vecStringLength;
1406 
1407  Common::String vecSource;
1408  Common::String vecString;
1409 
1410 protected:
1411  DataReadErrorCode load(DataReader &reader) override;
1412 };
1413 
1416 
1417  TypicalModifierHeader modHeader;
1418 
1419  Event enableWhen;
1420  Event disableWhen;
1421  uint16 transitionType;
1422  uint16 direction;
1423  uint16 unknown3;
1424  uint16 steps;
1425  uint32 duration;
1426  uint8 unknown5[2];
1427 
1428 protected:
1429  DataReadErrorCode load(DataReader &reader) override;
1430 };
1431 
1434 
1435  enum TransitionType {
1436  kTransitionTypeRectangularIris = 0x03e8,
1437  kTransitionTypeOvalIris = 0x03f2,
1438  kTransitionTypeZoom = 0x044c,
1439  kTransitionTypeFade = 0x2328,
1440  };
1441 
1442  enum RevealType {
1443  kRevealTypeReveal = 0,
1444  kRevealTypeConceal = 1,
1445  };
1446 
1447  TypicalModifierHeader modHeader;
1448 
1449  Event enableWhen;
1450  Event disableWhen;
1451  uint16 revealType;
1452  uint16 transitionType;
1453  uint16 unknown3;
1454  uint16 unknown4;
1455  uint16 steps;
1456  uint16 rate;
1457 
1458 protected:
1459  DataReadErrorCode load(DataReader &reader) override;
1460 };
1461 
1464 
1465  TypicalModifierHeader modHeader;
1466 
1467  uint8 unknown1[4];
1468  Event executeWhen;
1469  uint32 sectionGUID;
1470  uint32 subsectionGUID;
1471  uint32 sceneGUID;
1472 
1473 protected:
1474  DataReadErrorCode load(DataReader &reader) override;
1475 };
1476 
1479 
1480  TypicalModifierHeader modHeader;
1481 
1482  uint32 messageFlags;
1483  Event send;
1484  Event when;
1485  uint16 unknown6;
1486  uint32 destination;
1487  uint8 unknown7[10];
1489  uint8 unknown9[10];
1490  uint8 withSourceLength;
1491  uint8 withStringLength;
1492  MiniscriptProgram program;
1493 
1494  Common::String withSource;
1495  Common::String withString;
1496 
1497 protected:
1498  DataReadErrorCode load(DataReader &reader) override;
1499 };
1500 
1503 
1504  TypicalModifierHeader modHeader;
1505 
1506  enum TimerFlags {
1507  kTimerFlagLooping = 0x10000000,
1508  };
1509 
1510  uint32 messageAndTimerFlags;
1511  Event executeWhen;
1512  Event send;
1513  Event terminateWhen;
1514  uint16 unknown2;
1515  uint32 destination;
1516  uint8 unknown4[10];
1518  uint8 unknown5;
1519  uint8 minutes;
1520  uint8 seconds;
1521  uint8 hundredthsOfSeconds;
1522  uint32 unknown6;
1523  uint32 unknown7;
1524  uint8 unknown8[10];
1525  uint8 withSourceLength;
1526  uint8 withStringLength;
1527 
1528  Common::String withSource;
1529  Common::String withString;
1530 
1531 protected:
1532  DataReadErrorCode load(DataReader &reader) override;
1533 };
1534 
1537 
1538  enum Flags {
1539  kDetectTopEdge = 0x1000,
1540  kDetectBottomEdge = 0x0800,
1541  kDetectLeftEdge = 0x0400,
1542  kDetectRightEdge = 0x0200,
1543  kDetectExiting = 0x0100, // Off = once exited
1544  kWhileDetected = 0x0080, // Off = on first detected
1545  };
1546 
1547  TypicalModifierHeader modHeader;
1548  uint16 messageFlagsHigh;
1549  Event enableWhen;
1550  Event disableWhen;
1551  Event send;
1552  uint16 unknown2;
1553  uint32 destination;
1554  uint8 unknown3[10];
1556  uint8 withSourceLength;
1557  uint8 withStringLength;
1558 
1559  Common::String withSource;
1560  Common::String withString;
1561 
1562 protected:
1563  DataReadErrorCode load(DataReader &reader) override;
1564 };
1565 
1568 
1569  enum ModifierFlags {
1570  kDetectLayerInFront = 0x10000000,
1571  kDetectLayerBehind = 0x08000000,
1572  kSendToCollidingElement = 0x02000000,
1573  kSendToOnlyFirstCollidingElement = 0x00200000,
1574 
1575  kDetectionModeMask = 0x01c00000,
1576  kDetectionModeFirstContact = 0x01400000,
1577  kDetectionModeWhileInContact = 0x01000000,
1578  kDetectionModeExiting = 0x00800000,
1579 
1580  kNoCollideWithParent = 0x00100000,
1581  };
1582 
1583  TypicalModifierHeader modHeader;
1584  uint32 messageAndModifierFlags;
1585  Event enableWhen;
1586  Event disableWhen;
1587  Event send;
1588  uint16 unknown2;
1589  uint32 destination;
1590  uint8 unknown3[10];
1592  uint8 withSourceLength;
1593  uint8 withStringLength;
1594 
1595  Common::String withSource;
1596  Common::String withString;
1597 
1598 protected:
1599  DataReadErrorCode load(DataReader &reader) override;
1600 };
1601 
1603  enum KeyStateFlags {
1604  kOnDown = 0x10000000,
1605  kOnUp = 0x4000000,
1606  kOnRepeat = 0x8000000,
1607 
1608  kKeyStateMask = (kOnDown | kOnUp | kOnRepeat),
1609  };
1610 
1611  enum KeyModifiers {
1612  kControl = 0x1000,
1613  kCommand = 0x0100,
1614  kOption = 0x0800,
1615  };
1616 
1617  enum KeyCodes {
1618  kAny = 0x00,
1619  kHome = 0x01,
1620  kEnter = 0x03,
1621  kEnd = 0x04,
1622  kHelp = 0x05,
1623  kBackspace = 0x08,
1624  kTab = 0x09,
1625  kPageUp = 0x0b,
1626  kPageDown = 0x0c,
1627  kReturn = 0x0d,
1628  kEscape = 0x1b,
1629  kArrowLeft = 0x1c,
1630  kArrowRight = 0x1d,
1631  kArrowUp = 0x1e,
1632  kArrowDown = 0x1f,
1633  kDelete = 0x7f,
1634  };
1635 
1637 
1638  TypicalModifierHeader modHeader;
1639  uint32 messageFlagsAndKeyStates;
1640  uint16 unknown2;
1641  uint16 keyModifiers;
1642  uint8 keycode;
1643  uint8 unknown4[7];
1644  Event message;
1645  uint16 unknown7;
1646  uint32 destination;
1647  uint8 unknown9[10];
1649  uint8 withSourceLength;
1650  uint8 withStringLength;
1651 
1652  Common::String withSource;
1653  Common::String withString;
1654 
1655 protected:
1656  DataReadErrorCode load(DataReader &reader) override;
1657 };
1658 
1661 
1662  TypicalModifierHeader modHeader;
1663 
1664  uint8 unknown1[4];
1665  uint16 macFontID;
1666  uint8 flags;
1667  uint8 unknown2;
1668  uint16 size;
1669  ColorRGB16 textColor; // Appears to not actually be used
1670  ColorRGB16 backgroundColor; // Appears to not actually be used
1671  uint16 alignment;
1672  uint16 unknown3;
1673  Event applyWhen;
1674  Event removeWhen;
1675  uint16 lengthOfFontFamilyName;
1676 
1677  Common::String fontFamilyName;
1678 
1679 protected:
1680  DataReadErrorCode load(DataReader &reader) override;
1681 };
1682 
1683 struct GraphicModifier : public DataObject {
1684  GraphicModifier();
1685 
1686  TypicalModifierHeader modHeader;
1687 
1688  uint16 unknown1;
1689  Event applyWhen;
1690  Event removeWhen;
1691  uint8 unknown2[2];
1692  uint16 inkMode;
1693  uint16 shape;
1694 
1695  struct MacPart {
1696  uint8 unknown4_1[6];
1697  uint8 unknown4_2[26];
1698  };
1699 
1700  struct WinPart {
1701  uint8 unknown5_1[4];
1702  uint8 unknown5_2[22];
1703  };
1704 
1706  MacPart mac;
1707  WinPart win;
1708  };
1709 
1710  bool haveMacPart;
1711  bool haveWinPart;
1712  PlatformPart platform;
1713 
1714  ColorRGB16 foreColor;
1715  ColorRGB16 backColor;
1716  uint16 borderSize;
1717  ColorRGB16 borderColor;
1718  uint16 shadowSize;
1719  ColorRGB16 shadowColor;
1720 
1721  uint16 numPolygonPoints;
1722  uint8 unknown6[8];
1723 
1724  Common::Array<Point> polyPoints;
1725 
1726 protected:
1727  DataReadErrorCode load(DataReader &reader) override;
1728 };
1729 
1732 
1733  enum Types {
1734  kTypeInvert = 1,
1735  kTypeSelectedBevels = 2,
1736  kTypeDeselectedBevels = 3,
1737  kTypeToneDown = 4,
1738  kTypeToneUp = 5,
1739  };
1740 
1741  TypicalModifierHeader modHeader;
1742 
1743  uint32 flags;
1744  uint16 type;
1745  Event applyWhen;
1746  Event removeWhen;
1747  uint16 bevelWidth;
1748  uint16 toneAmount;
1749  uint8 unknown2[2];
1750 
1751 protected:
1752  DataReadErrorCode load(DataReader &reader) override;
1753 };
1754 
1755 struct ReturnModifier : public DataObject {
1756  ReturnModifier();
1757 
1758  TypicalModifierHeader modHeader;
1759 
1760  Event executeWhen;
1761  uint16 unknown1;
1762 
1763 protected:
1764  DataReadErrorCode load(DataReader &reader) override;
1765 };
1766 
1767 struct CursorModifierV1 : public DataObject {
1768  CursorModifierV1();
1769 
1770  struct MacOnlyPart {
1771  MacOnlyPart();
1772 
1773  Event applyWhen;
1774  uint32 unknown1;
1775  uint16 unknown2;
1776  uint32 cursorIndex;
1777  };
1778 
1779  TypicalModifierHeader modHeader;
1780 
1781  bool hasMacOnlyPart;
1782  MacOnlyPart macOnlyPart;
1783 
1784 protected:
1785  DataReadErrorCode load(DataReader &reader) override;
1786 };
1787 
1790 
1791  // This doesn't follow the usual modifier header layout
1792  uint32 modifierFlags;
1793  uint32 sizeIncludingTag;
1794  uint8 unknown1[2]; // Extra field
1795  uint32 guid;
1796  uint8 unknown4[6];
1797  uint32 unknown5;
1798  Point editorLayoutPosition;
1799  uint16 lengthOfName;
1800  uint16 numChildren;
1801  uint8 unknown7[4];
1802 
1803  Common::String name;
1804 
1805 protected:
1806  DataReadErrorCode load(DataReader &reader) override;
1807 };
1808 
1811 
1812  TypicalModifierHeader modHeader;
1813  uint8 value;
1814  uint8 unknown5;
1815 
1816 protected:
1817  DataReadErrorCode load(DataReader &reader) override;
1818 };
1819 
1822 
1823  TypicalModifierHeader modHeader;
1824  uint8 unknown1[4];
1825  int32 value;
1826 
1827 protected:
1828  DataReadErrorCode load(DataReader &reader) override;
1829 };
1830 
1833 
1834  TypicalModifierHeader modHeader;
1835  uint8 unknown1[4];
1836  IntRange range;
1837 
1838 protected:
1839  DataReadErrorCode load(DataReader &reader) override;
1840 };
1841 
1844 
1845  TypicalModifierHeader modHeader;
1846  uint8 unknown1[4];
1847  XPFloatVector vector;
1848 
1849 protected:
1850  DataReadErrorCode load(DataReader &reader) override;
1851 };
1852 
1855 
1856  TypicalModifierHeader modHeader;
1857 
1858  uint8 unknown5[4];
1859  Point value;
1860 
1861 protected:
1862  DataReadErrorCode load(DataReader &reader) override;
1863 };
1864 
1867 
1868  TypicalModifierHeader modHeader;
1869  uint8 unknown1[4];
1870  Common::XPFloat value;
1871 
1872 protected:
1873  DataReadErrorCode load(DataReader &reader) override;
1874 };
1875 
1878 
1879  TypicalModifierHeader modHeader;
1880  uint32 lengthOfString;
1881  uint8 unknown1[4];
1882  Common::String value;
1883 
1884 protected:
1885  DataReadErrorCode load(DataReader &reader) override;
1886 };
1887 
1890 
1891  TypicalModifierHeader modHeader;
1892  uint32 unknown1;
1893  Event setToSourcesParentWhen;
1894 
1895 protected:
1896  DataReadErrorCode load(DataReader &reader) override;
1897 };
1898 
1900  virtual ~PlugInModifierData();
1901  virtual DataReadErrorCode load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) = 0;
1902 };
1903 
1904 struct PlugInModifier : public DataObject {
1905  PlugInModifier();
1906 
1907  uint32 modifierFlags;
1908  uint32 codedSize; // Total size on Mac but (size + (name length * 255)) on Windows for some reason
1909  char modifierName[17];
1910  uint32 guid;
1911  uint8 unknown2[6];
1912  uint16 plugInRevision;
1913  uint32 unknown4;
1914  Point editorLayoutPosition;
1915  uint16 lengthOfName;
1916 
1917  Common::String name;
1918 
1919  uint32 subObjectSize;
1920 
1922 
1923 protected:
1924  DataReadErrorCode load(DataReader &reader) override;
1925 };
1926 
1927 struct Debris : public DataObject {
1928  Debris();
1929 
1930  uint32 persistFlags;
1931  uint32 sizeIncludingTag;
1932 
1933 protected:
1934  DataReadErrorCode load(DataReader &reader) override;
1935 };
1936 
1937 struct ColorTableAsset : public DataObject {
1938  ColorTableAsset();
1939 
1940  uint32 persistFlags;
1941  uint32 sizeIncludingTag;
1942  uint8 unknown1[4];
1943  uint32 assetID;
1944  uint32 unknown2; // Usually zero-fill but sometimes contains 0xb
1945 
1946  ColorRGB16 colors[256];
1947 
1948 protected:
1949  DataReadErrorCode load(DataReader &reader) override;
1950 };
1951 
1952 struct MovieAsset : public DataObject {
1953  struct MacPart {
1954  uint8 unknown5_1[66];
1955  uint8 unknown6[12];
1956  uint8 unknown8[4];
1957  };
1958 
1959  struct WinPart {
1960  uint8 unknown3_1[32];
1961  uint8 unknown4[12];
1962  uint8 unknown7[12];
1963  };
1964 
1966  MacPart mac;
1967  WinPart win;
1968  };
1969 
1970  MovieAsset();
1971 
1972  uint32 persistFlags;
1973  uint32 assetAndDataCombinedSize;
1974  uint8 unknown1[4];
1975  uint32 assetID;
1976  uint8 unknown1_1[4];
1977  uint16 extFileNameLength;
1978 
1979  uint32 movieDataPos;
1980  uint32 moovAtomPos;
1981  uint32 movieDataSize;
1982 
1983  bool haveMacPart;
1984  bool haveWinPart;
1985  PlatformPart platform;
1986 
1987  Common::String extFileName;
1988 
1989 protected:
1990  DataReadErrorCode load(DataReader &reader) override;
1991 };
1992 
1993 struct AVIMovieAsset : public DataObject {
1994  AVIMovieAsset();
1995 
1996  uint8 unknown1[12];
1997  uint32 assetID;
1998  uint8 unknown2[4];
1999  uint16 extFileNameLength;
2000  uint8 unknown3[60];
2001 
2002  Common::String extFileName;
2003 
2004 protected:
2005  DataReadErrorCode load(DataReader &reader) override;
2006 };
2007 
2008 struct AudioAsset : public DataObject {
2009  struct MacPart {
2010  uint8 unknown4[4];
2011  uint8 unknown5[5];
2012  uint8 unknown6[3];
2013  uint8 unknown8[20];
2014  };
2015 
2016  struct WinPart {
2017  uint8 unknown9[3];
2018  uint8 unknown10[3];
2019  uint8 unknown11[18];
2020  uint8 unknown12_1[2];
2021  };
2022 
2024  MacPart mac;
2025  WinPart win;
2026  };
2027 
2028  struct CuePoint {
2029  uint8 unknown13[2];
2030  uint32 unknown14;
2031  uint32 position;
2032  uint32 cuePointID;
2033  };
2034 
2035  AudioAsset();
2036 
2037  uint32 persistFlags;
2038  uint32 assetAndDataCombinedSize;
2039  uint8 unknown2[4];
2040  uint32 assetID;
2041  uint8 unknown3[20];
2042  uint16 sampleRate1;
2043  uint8 bitsPerSample;
2044  uint8 encoding1;
2045  uint8 channels;
2046  uint8 codedDuration[4];
2047  uint16 sampleRate2;
2048  uint32 cuePointDataSize;
2049  uint16 numCuePoints;
2050  uint8 unknown14[4];
2051  uint32 filePosition;
2052  uint32 size;
2053 
2054  Common::Array<CuePoint> cuePoints;
2055 
2056  bool haveMacPart;
2057  bool haveWinPart;
2058  bool isBigEndian;
2059  PlatformPart platform;
2060 
2061 protected:
2062  DataReadErrorCode load(DataReader &reader) override;
2063 };
2064 
2065 struct ImageAsset : public DataObject {
2066  struct MacPart {
2067  uint8 unknown7[44];
2068  };
2069 
2070  struct WinPart {
2071  uint8 unknown8[10];
2072  };
2073 
2075  WinPart win;
2076  MacPart mac;
2077  };
2078 
2079  ImageAsset();
2080 
2081  uint32 persistFlags;
2082  uint32 unknown1;
2083  uint8 unknown2[4];
2084  uint32 assetID;
2085  uint32 unknown3;
2086 
2087  Rect rect1;
2088  uint32 hdpiFixed;
2089  uint32 vdpiFixed;
2090  uint16 bitsPerPixel;
2091  uint8 unknown4[2];
2092  uint8 unknown5[4];
2093  uint8 unknown6[8];
2094  Rect rect2;
2095  uint32 filePosition;
2096  uint32 size;
2097 
2098  bool haveMacPart;
2099  bool haveWinPart;
2100  PlatformPart platform;
2101 
2102 protected:
2103  DataReadErrorCode load(DataReader &reader) override;
2104 };
2105 
2106 struct MToonAsset : public DataObject {
2107  struct MacPart {
2108  uint8 unknown10[88];
2109  };
2110 
2111  struct WinPart {
2112  uint8 unknown11[54];
2113  };
2114 
2116  MacPart mac;
2117  WinPart win;
2118  };
2119 
2120  struct FrameDef {
2121  struct MacPart {
2122  uint8 unknown17[4];
2123  };
2124 
2125  struct WinPart {
2126  uint8 unknown18[2];
2127  };
2128 
2130  MacPart mac;
2131  WinPart win;
2132  };
2133 
2134  FrameDef();
2135 
2136  uint8 unknown12[4];
2137  Rect rect1;
2138  uint32 dataOffset;
2139  uint8 unknown13[2];
2140  uint32 compressedSize;
2141  uint8 unknown14;
2142  uint8 keyframeFlag;
2143  uint8 platformBit;
2144  uint8 unknown15;
2145  Rect rect2;
2146  uint32 hdpiFixed;
2147  uint32 vdpiFixed;
2148  uint16 bitsPerPixel;
2149  uint32 unknown16;
2150  uint16 decompressedBytesPerRow;
2151  uint32 decompressedSize;
2152 
2153  PlatformUnion platform;
2154  };
2155 
2156  struct FrameRangeDef {
2157  FrameRangeDef();
2158 
2159  uint32 startFrame;
2160  uint32 endFrame;
2161  uint8 lengthOfName;
2162  uint8 unknown14;
2163 
2164  Common::String name; // Null terminated
2165  };
2166 
2167  enum {
2168  kEncodingFlag_TemporalCompression = 0x80,
2169  kEncodingFlag_HasRanges = 0x20000000,
2170  kEncodingFlag_Trimming = 0x08,
2171  };
2172 
2174  FrameRangePart();
2175 
2176  uint32 tag;
2177  uint32 sizeIncludingTag;
2178 
2179  uint32 numFrameRanges;
2180  Common::Array<FrameRangeDef> frameRanges;
2181  };
2182 
2183  MToonAsset();
2184 
2185  uint32 marker;
2186  uint8 unknown1[8];
2187  uint32 assetID;
2188 
2189  bool haveMacPart;
2190  bool haveWinPart;
2191  PlatformUnion platform;
2192 
2193  uint32 frameDataPosition;
2194  uint32 sizeOfFrameData;
2195 
2196  // mToon data
2197  uint32 mtoonHeader[2];
2198  uint16 version;
2199  uint8 unknown2[4];
2200  uint32 encodingFlags;
2201  Rect rect;
2202 
2203  uint16 numFrames;
2204  uint8 unknown3[14];
2205  uint16 bitsPerPixel;
2206  uint32 codecID;
2207  uint8 unknown4_1[8];
2208  uint32 codecDataSize;
2209  Point registrationPoint;
2210 
2211  Common::Array<FrameDef> frames;
2212 
2213  // Codec data appears to be a 16-byte header followed by a QuickTime sample description
2214  // Note that the sample description is partly useless because frames can have different sizes
2215  // and the sample desc is only for the last frame!
2216  //
2217  // The 16-byte header is:
2218  // uint32be size of codec data
2219  // char[4] codec ID
2220  // byte[8] unknown (all 0?)
2221  Common::Array<uint8> codecData;
2222 
2223  FrameRangePart frameRangesPart;
2224 
2225 protected:
2226  DataReadErrorCode load(DataReader &reader) override;
2227 };
2228 
2229 struct TextAsset : public DataObject {
2231  uint8 unknown9[2];
2232  uint16 spanStart;
2233  uint8 unknown10[4];
2234  uint16 fontID;
2235  uint8 fontFlags;
2236  uint8 unknown11[1];
2237  uint16 size;
2238  uint8 unknown12[6];
2239  };
2240 
2241  struct MacPart {
2242  uint8 unknown3[44];
2243  };
2244 
2245  struct WinPart {
2246  uint8 unknown4[10];
2247  };
2248 
2250  MacPart mac;
2251  WinPart win;
2252  };
2253 
2254  TextAsset();
2255 
2256  uint32 persistFlags;
2257  uint32 sizeIncludingTag;
2258  uint32 unknown1;
2259  uint32 assetID;
2260  uint32 unknown2;
2261  Rect bitmapRect;
2262  uint32 hdpi;
2263  uint32 vdpi;
2264  uint16 unknown5;
2265  uint8 pitchBigEndian[2];
2266  uint32 unknown6;
2267 
2268  uint32 bitmapSize;
2269  uint8 unknown7[20];
2270  uint32 textSize;
2271  uint8 unknown8[8];
2272  uint16 alignment;
2273  uint16 isBitmap;
2274 
2275  bool haveMacPart;
2276  bool haveWinPart;
2277  PlatformPart platform;
2278 
2279  Common::String text;
2280  Common::Array<uint8> bitmapData;
2281 
2282  bool isBottomUp;
2283 
2284  Common::Array<MacFormattingSpan> macFormattingSpans;
2285 
2286 protected:
2287  DataReadErrorCode load(DataReader &reader) override;
2288 };
2289 
2290 struct AssetDataChunk : public DataObject {
2291  AssetDataChunk();
2292 
2293  uint32 unknown1;
2294  uint32 sizeIncludingTag;
2295  int64 filePosition;
2296 
2297 protected:
2298  DataReadErrorCode load(DataReader &reader) override;
2299 };
2300 
2302  virtual Common::SharedPtr<Data::PlugInModifierData> createModifierData() const = 0;
2303  virtual PlugIn &getPlugIn() const = 0;
2304 };
2305 
2307 public:
2308  const IPlugInModifierDataFactory *findLoader(const char *modifierName) const;
2309  void registerLoader(const char *modifierName, const IPlugInModifierDataFactory *loader);
2310 
2311 private:
2313 };
2314 
2315 DataReadErrorCode loadDataObject(const PlugInModifierRegistry &registry, DataReader &reader, Common::SharedPtr<DataObject> &outObject);
2316 
2317 template<size_t TSize>
2318 inline bool DataReader::readBytes(uint8(&arr)[TSize]) {
2319  return this->read(arr, TSize);
2320 }
2321 
2322 template<size_t TSize>
2323 inline bool DataReader::readChars(char (&arr)[TSize]) {
2324  return this->read(arr, TSize);
2325 }
2326 
2327 } // End of namespace Data
2328 
2329 } // End of namespace MTropolis
2330 
2331 #endif /* MTROPOLIS_DATA_H */
Definition: data.h:1755
Definition: str.h:59
Definition: data.h:1184
Definition: data.h:990
Definition: data.h:612
Definition: data.h:664
Definition: data-io.h:167
Definition: data.h:820
Definition: data.h:1209
Definition: data.h:2106
Definition: data.h:535
Definition: data.h:1993
Definition: data.h:547
Definition: data.h:1937
Definition: data.h:1767
Definition: rect.h:144
Definition: data.h:346
Definition: data.h:1115
Definition: data.h:1033
Definition: stream.h:745
Definition: runtime.h:1185
Definition: data.h:917
Definition: noncopyable.h:39
Definition: data.h:384
Definition: data.h:1004
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: data-io.h:37
Definition: hashmap.h:85
Definition: data.h:399
Definition: data.h:1162
Definition: data.h:886
Definition: algorithm.h:29
Definition: xpfloat.h:32
Definition: rect.h:45
Definition: data.h:1952
Definition: data.h:777
Definition: data.h:942
Definition: data.h:356
Definition: data.h:332
Definition: data.h:406
Definition: data.h:365
Definition: data.h:1659
Definition: actions.h:25
Definition: data.h:2065
Definition: data-io.h:121
Definition: data.h:798
Definition: data.h:518
Definition: data.h:858
Definition: data.h:954
Definition: ptr.h:159
Definition: data.h:391
Definition: data.h:1683
Definition: data.h:2290
Definition: data.h:1904
Definition: data.h:2229
Definition: data.h:375
Definition: data.h:261
Definition: data.h:653
Definition: data.h:1927
Definition: data.h:2008
Definition: data.h:674
Definition: core.h:33