ScummVM API documentation
base_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 // Immutable WBASE resource model.
23 
24 #ifndef HOPKINS_BASE_DATA_H
25 #define HOPKINS_BASE_DATA_H
26 
27 #include "hopkins/base_types.h"
28 
29 #include "common/array.h"
30 #include "common/path.h"
31 #include "common/str.h"
32 
33 namespace Hopkins {
34 
35 class BaseData {
36 public:
37  BaseData();
38 
39  static bool hasRequiredResources(Common::String *missingResources = nullptr);
40  static void appendAudioResourceReport(Common::String &missingResources);
41 
42  bool load(Common::String &errorMessage);
43 
44  uint16 mapCodeAt(int mapPos) const;
45  uint16 mapCodeXY(int x, int y) const;
46  uint16 objectCodeAt(int mapPos) const;
47 
48  const byte *palette() const { return _palette; }
49  const BaseBitmap &wallBitmap(uint id) const;
50  const BaseBitmap &objectBitmap(uint id) const;
51  const BaseBitmap &weaponFrame(uint id) const;
52  const BaseBitmap &fontFrame(uint id) const;
53 
54  int32 sinQ16(int angle) const;
55  int32 cosQ16(int angle) const;
56  int32 longTanQ16(int angle) const;
57  int32 longInvTanQ16(int angle) const;
58  int32 invCos(int angle) const;
59  int32 invSin(int angle) const;
60  int32 longCosQ16(int angle) const;
61  int32 xNextQ16(int angle) const;
62  int32 yNextQ16(int angle) const;
63  int32 viewCosQ16(int column) const;
64  int32 floorCos(int column) const;
65  int16 distanceHeight(int distance) const;
66  int32 adjustTable(int distance) const;
67 
68 private:
69  bool loadMap(Common::String &errorMessage);
70  bool loadPalette(Common::String &errorMessage);
71  bool loadInfo(Common::String &errorMessage);
72  bool loadBitmaps(Common::String &errorMessage);
73  bool loadBbm(const Common::Path &filename, BaseBitmap &bitmap, Common::String &errorMessage);
74  bool loadSpr(const Common::Path &filename, Common::Array<BaseBitmap> &frames, Common::String &errorMessage);
75  void buildDerivedTables();
76 
77  uint16 _map[kBaseMapCellCount];
78  uint16 _objectMap[kBaseMapCellCount];
79  byte _palette[256 * 3];
80 
81  Common::Array<int32> _trig[7];
82  Common::Array<int32> _xNext;
83  Common::Array<int32> _yNext;
84  int32 _viewCos[kBaseViewWidth];
85  int32 _floorCos[kBaseViewWidth + 1];
86  int16 _distanceHeight[kBaseMaximumDistance + 1];
87  int32 _adjust[kBaseMaximumDistance + 1];
88 
89  Common::Array<BaseBitmap> _wallBitmaps;
90  Common::Array<BaseBitmap> _objectBitmaps;
91  Common::Array<BaseBitmap> _weaponFrames;
92  Common::Array<BaseBitmap> _fontFrames;
93 };
94 
95 } // End of namespace Hopkins
96 
97 #endif // HOPKINS_BASE_DATA_H
Definition: str.h:59
Definition: array.h:52
Definition: path.h:52
Definition: anim.h:30
Definition: base_data.h:35
Definition: base_types.h:109