ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
assetheader.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 MEDIASTATION_ASSET_HEADER_H
23 #define MEDIASTATION_ASSET_HEADER_H
24 
25 #include "common/str.h"
26 #include "common/rect.h"
27 #include "common/hashmap.h"
28 #include "graphics/palette.h"
29 
30 #include "mediastation/datafile.h"
31 #include "mediastation/mediascript/eventhandler.h"
32 
33 namespace MediaStation {
34 
36  uint32 headerChunkId;
37  uint32 audioChunkId;
38  uint32 videoChunkId;
39 };
40 
41 typedef uint32 ChunkReference;
42 
43 typedef uint32 AssetId;
44 
45 enum AssetType {
46  kAssetTypeScreen = 0x0001, // SCR
47  kAssetTypeStage = 0x0002, // STG
48  kAssetTypePath = 0x0004, // PTH
49  kAssetTypeSound = 0x0005, // SND
50  kAssetTypeTimer = 0x0006, // TMR
51  kAssetTypeImage = 0x0007, // IMG
52  kAssetTypeHotspot = 0x000b, // HSP
53  kAssetTypeSprite = 0x000e, // SPR
54  kAssetTypeLKZazu = 0x000f,
55  kAssetTypeLKConstellations = 0x0010,
56  kAssetTypeImageSet = 0x001d,
57  kAssetTypeCursor = 0x000c, // CSR
58  kAssetTypePrinter = 0x0019, // PRT
59  kAssetTypeMovie = 0x0016, // MOV
60  kAssetTypePalette = 0x0017,
61  kAssetTypeText = 0x001a, // TXT
62  kAssetTypeFont = 0x001b, // FON
63  kAssetTypeCamera = 0x001c, // CAM
64  kAssetTypeCanvas = 0x001e, // CVS
65  // TODO: Discover how the XSND differs from regular sounds.
66  // Only appears in Ariel.
67  kAssetTypeXsnd = 0x001f,
68  kAssetTypeXsndMidi = 0x0020,
69  // TODO: Figure out what this is. Only appears in Ariel.
70  kAssetTypeRecorder = 0x0021,
71  kAssetTypeFunction = 0x0069 // FUN
72 };
73 
74 enum AssetStartupType {
75  kAssetStartupInactive = 0,
76  kAssetStartupActive = 1
77 };
78 
79 enum AssetHeaderSectionType {
80  kAssetHeaderEmptySection = 0x0000,
81  kAssetHeaderSoundEncoding1 = 0x0001,
82  kAssetHeaderSoundEncoding2 = 0x0002,
83  kAssetHeaderEventHandler = 0x0017,
84  kAssetHeaderStageId = 0x0019,
85  kAssetHeaderAssetId = 0x001a,
86  kAssetHeaderChunkReference = 0x001b,
87  kAssetHeaderMovieAnimationChunkReference = 0x06a4,
88  kAssetHeaderMovieAudioChunkReference = 0x06a5,
89  kAssetHeaderAssetReference = 0x077b,
90  kAssetHeaderBoundingBox = 0x001c,
91  kAssetHeaderMouseActiveArea = 0x001d,
92  kAssetHeaderZIndex = 0x001e,
93  kAssetHeaderStartup = 0x001f,
94  kAssetHeaderTransparency = 0x0020,
95  kAssetHeaderHasOwnSubfile = 0x0021,
96  kAssetHeaderCursorResourceId = 0x0022,
97  kAssetHeaderFrameRate = 0x0024,
98  kAssetHeaderLoadType = 0x0032,
99  kAssetHeaderSoundInfo = 0x0033,
100  kAssetHeaderMovieLoadType = 0x0037,
101  kAssetHeaderSpriteChunkCount = 0x03e8,
102  kAssetHeaderPalette = 0x05aa,
103  kAssetHeaderDissolveFactor = 0x05dc,
104  kAssetHeaderGetOffstageEvents = 0x05dd,
105  kAssetHeaderX = 0x05de,
106  kAssetHeaderY = 0x05df,
107 
108  // PATH FIELDS.
109  kAssetHeaderStartPoint = 0x060e,
110  kAssetHeaderEndPoint = 0x060f,
111  kAssetHeaderPathTotalSteps = 0x0610,
112  kAssetHeaderStepRate = 0x0611,
113  kAssetHeaderDuration = 0x0612,
114 
115  // CAMERA FIELDS.
116  kAssetHeaderViewportOrigin = 0x076f,
117  kAssetHeaderLensOpen = 0x0770,
118 
119  // STAGE FIELDS.
120  kAssetHeaderStageUnk1 = 0x0771,
121  kAssetHeaderCylindricalX = 0x0772,
122  kAssetHeaderCylindricalY = 0x0773,
123  kAssetHeaderAssetName = 0x0bb8,
124 
125  // TEXT FIELDS.
126  kAssetHeaderEditable = 0x03eb,
127  kAssetHeaderFontId = 0x0258,
128  kAssetHeaderInitialText = 0x0259,
129  kAssetHeaderTextMaxLength = 0x25a,
130  kAssetHeaderTextJustification = 0x025b,
131  kAssetHeaderTextPosition = 0x25f,
132  kAssetHeaderTextUnk1 = 0x262,
133  kAssetHeaderTextUnk2 = 0x263,
134  kAssetHeaderTextCharacterClass = 0x0266,
135 
136  // SPRITE FIELDS.
137  kAssetHeaderSpriteFrameMapping = 0x03e9
138 };
139 
140 enum TextJustification {
141  kTextJustificationLeft = 0x25c,
142  kTextJustificationRight = 0x25d,
143  kTextJustificationCenter = 0x25e
144 };
145 
146 enum TextPosition {
147  kTextPositionMiddle = 0x25e,
148  kTextPositionTop = 0x260,
149  kTextPositionBotom = 0x261
150 };
151 
153  uint firstAsciiCode = 0;
154  uint lastAsciiCode = 0;
155 };
156 
157 enum SoundEncoding {
158  PCM_S16LE_MONO_22050 = 0x0010, // Uncompressed linear PCM
159  IMA_ADPCM_S16LE_MONO_22050 = 0x0004 // IMA ADPCM encoding, must be decoded
160 };
161 
162 class AssetHeader {
163 public:
164  AssetHeader(Chunk &chunk);
165  ~AssetHeader();
166 
167  uint32 _fileNumber = 0;
168  AssetType _type;
169  AssetId _id;
170 
171  ChunkReference _chunkReference = 0;
172  // These two are only used in movies.
173  ChunkReference _audioChunkReference = 0;
174  ChunkReference _animationChunkReference = 0;
175  Common::Rect *_boundingBox = nullptr;
176  Common::Array<Common::Point *> _mouseActiveArea;
177  int _zIndex = 0;
178  uint32 _assetReference = 0;
179  uint32 _startup = 0;
180  bool _transparency = false;
181  bool _hasOwnSubfile = false;
182  uint32 _cursorResourceId = 0;
183  uint32 _frameRate = 0;
184  uint32 _loadType = 0;
185  uint32 _rate = 0;
186  bool _editable = 0;
187  Graphics::Palette *_palette = nullptr;
188  bool _getOffstageEvents = 0;
189  uint32 _x = 0; // Image only.
190  uint32 _y = 0; // Image only.
191  Common::String *_name = nullptr;
192  uint32 _stageId = 0;
193  SoundEncoding _soundEncoding;
194  uint32 _chunkCount = 0;
195  Common::HashMap<uint32, uint32> _spriteFrameMapping;
196 
197  // PATH FIELDS.
198  uint32 _dissolveFactor = 0;
199  Common::Point *_startPoint = nullptr;
200  Common::Point *_endPoint = nullptr;
201  uint32 _stepRate = 0;
202  uint32 _duration = 0;
203  uint _totalSteps = 0;
204 
205  // EVENT HANDLER FIELDS.
207  Common::Array<EventHandler *> _timeHandlers;
208  Common::HashMap<uint, EventHandler *> _keyDownHandlers;
209  Common::Array<EventHandler *> _inputHandlers;
210  Common::Array<EventHandler *> _loadCompleteHandlers;
211 
212  // TEXT FIELDS.
213  Common::String *_text = nullptr;
214  uint _maxTextLength = 0;
215  uint _fontAssetId = 0;
216  TextJustification _justification;
217  TextPosition _position;
218  Common::Array<CharacterClass> _acceptedInput;
219 
220 private:
221  void readSection(AssetHeaderSectionType sectionType, Chunk &chunk);
222  AssetHeaderSectionType getSectionType(Chunk &chunk);
223 };
224 
225 } // End of namespace MediaStation
226 
227 #endif
Definition: assetheader.h:35
Definition: str.h:59
Definition: asset.h:33
Definition: array.h:52
Definition: datafile.h:39
Definition: rect.h:144
Definition: rect.h:45
Definition: assetheader.h:162
Simple class for handling a palette data.
Definition: palette.h:51
Definition: assetheader.h:152