ScummVM API documentation
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/asset.h"
32 #include "mediastation/mediascript/function.h"
33 
34 namespace MediaStation {
35 
36 enum ContextParametersSectionType {
37  kContextParametersEmptySection = 0x0000,
38  kContextParametersVariable = 0x0014,
39  kContextParametersName = 0x0bb9,
40  kContextParametersFileNumber = 0x0011,
41  kContextParametersBytecode = 0x0017
42 };
43 
44 enum ContextSectionType {
45  kContextEmptySection = 0x0000,
46  kContextOldStyleSection = 0x000d,
47  kContextParametersSection = 0x000e,
48  kContextPaletteSection = 0x05aa,
49  kContextUnkAtEndSection = 0x0010,
50  kContextAssetHeaderSection = 0x0011,
51  kContextPoohSection = 0x057a,
52  kContextAssetLinkSection = 0x0013,
53  kContextFunctionSection = 0x0031
54 };
55 
56 class Screen;
57 
58 class Context : public Datafile {
59 public:
60  Context(const Common::Path &path);
61  ~Context();
62 
63  uint32 _unk1;
64  uint32 _subfileCount;
65  uint32 _fileSize;
66  Graphics::Palette *_palette = nullptr;
67  Screen *_screenAsset = nullptr;
68 
69  Asset *getAssetById(uint assetId);
70  Asset *getAssetByChunkReference(uint chunkReference);
71  Function *getFunctionById(uint functionId);
72  ScriptValue *getVariable(uint variableId);
73 
74 private:
75  // This is not an internal file ID, but the number of the file
76  // as it appears in the filename. For instance, the context in
77  // "100.cxt" would have file number 100.
78  uint _fileNumber = 0;
79  Common::String _contextName;
80 
83  Common::HashMap<uint, Asset *> _assetsByChunkReference;
85 
86  void readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk);
87  void readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk);
88 
89  bool readHeaderSection(Chunk &chunk);
90  void readCreateContextData(Chunk &chunk);
91  Asset *readCreateAssetData(Chunk &chunk);
92  void readCreateVariableData(Chunk &chunk);
93 
94  void readAssetInFirstSubfile(Chunk &chunk);
95  void readAssetFromLaterSubfile(Subfile &subfile);
96 };
97 
98 } // End of namespace MediaStation
99 
100 #endif
Definition: str.h:59
Definition: datafile.h:145
Definition: asset.h:32
Definition: context.h:58
Definition: datafile.h:103
Definition: path.h:52
Definition: screen.h:34
Definition: atari-screen.h:58
Definition: asset.h:122
Definition: function.h:32
Definition: hashmap.h:85
Definition: datafile.h:129
Simple class for handling a palette data.
Definition: palette.h:55
Definition: scriptvalue.h:36