ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
context.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_CONTEXT_H
23 #define MEDIASTATION_CONTEXT_H
24 
25 #include "common/str.h"
26 #include "common/path.h"
27 #include "common/hashmap.h"
28 #include "graphics/palette.h"
29 
30 #include "mediastation/datafile.h"
31 #include "mediastation/assetheader.h"
32 #include "mediastation/mediascript/function.h"
33 #include "mediastation/mediascript/variable.h"
34 
35 namespace MediaStation {
36 
37 enum ContextParametersSectionType {
38  kContextParametersEmptySection = 0x0000,
39  kContextParametersVariable = 0x0014,
40  kContextParametersName = 0x0bb9,
41  kContextParametersFileNumber = 0x0011,
42  kContextParametersBytecode = 0x0017
43 };
44 
45 enum ContextSectionType {
46  kContextEmptySection = 0x0000,
47  kContextOldStyleSection = 0x000d,
48  kContextParametersSection = 0x000e,
49  kContextPaletteSection = 0x05aa,
50  kContextUnkAtEndSection = 0x0010,
51  kContextAssetHeaderSection = 0x0011,
52  kContextPoohSection = 0x057a,
53  kContextAssetLinkSection = 0x0013,
54  kContextFunctionSection = 0x0031
55 };
56 
57 class Context : public Datafile {
58 public:
59  Context(const Common::Path &path);
60  ~Context();
61 
62  uint32 _unk1;
63  uint32 _subfileCount;
64  uint32 _fileSize;
65  Graphics::Palette *_palette = nullptr;
66  // TODO: Eliminate this screenAsset because the screen that this context
67  // represents is now an asset in itself.
68  AssetHeader *_screenAsset = nullptr;
69 
70  Asset *getAssetById(uint assetId);
71  Asset *getAssetByChunkReference(uint chunkReference);
72  Function *getFunctionById(uint functionId);
73  void registerActiveAssets();
74 
75 private:
76  // This is not an internal file ID, but the number of the file
77  // as it appears in the filename. For instance, the context in
78  // "100.cxt" would have file number 100.
79  uint _fileNumber = 0;
80  Common::String *_contextName = nullptr;
81 
84  Common::HashMap<uint, Asset *> _assetsByChunkReference;
85 
86  void readParametersSection(Chunk &chunk);
87  void readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk);
88  void readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk);
89  bool readHeaderSection(Subfile &subfile, Chunk &chunk);
90 
91  void readAssetInFirstSubfile(Chunk &chunk);
92  void readAssetFromLaterSubfile(Subfile &subfile);
93 };
94 
95 } // End of namespace MediaStation
96 
97 #endif
Definition: str.h:59
Definition: datafile.h:81
Definition: asset.h:33
Definition: context.h:57
Definition: datafile.h:39
Definition: path.h:52
Definition: asset.h:37
Definition: function.h:32
Definition: hashmap.h:85
Definition: assetheader.h:162
Definition: datafile.h:65
Simple class for handling a palette data.
Definition: palette.h:51