ScummVM API documentation
map_mif.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 SCUMM_HE_MOONBASE_MAP_MIF_H
23#define SCUMM_HE_MOONBASE_MAP_MIF_H
24
25#ifdef ENABLE_HE
26
27#include "scumm/he/intern_he.h"
28
29namespace Scumm {
30
31#define MAX_TILE_COUNT 80
32
33#include "common/pack-start.h" // START STRUCT PACKING
34
35struct PixelLoc {
36 uint16 x;
37 uint16 y;
38};
39
40struct EnergyPoolLoc {
41 PixelLoc location;
42 PixelLoc dummy;
43};
44
45
46struct MapFile {
47 // Header:
48 uint16 headerDummy;
49 uint16 terrainDimX;
50 uint16 terrainDimY;
51 uint16 mapType;
52 uint16 numEnergyPools;
53
54 uint16 terrainStates[80][161];
55 uint8 space1[230];
56 char name[17];
57 uint8 space2[25837];
58 EnergyPoolLoc poolLocs[49];
59 PixelLoc lastPool;
60 uint16 dummy;
61 PixelLoc fourPlayerPoints[4]; // 2^0
62 PixelLoc threePlayerPoints[3]; // 2^1
63 PixelLoc twoPlayerPoints[2]; // 2^2
64 PixelLoc twoVTwoPoints[4]; // 2^3
65 PixelLoc oneVThreePoints[4]; // 2^4
66 PixelLoc oneVTwoPoints[3]; // 2^5
67
68 MapFile() {
69 memset(this, 0, sizeof(MapFile));
70
71 mapType = 1;
72 memset(fourPlayerPoints, 0xFF, sizeof(fourPlayerPoints));
73 memset(threePlayerPoints, 0xFF, sizeof(threePlayerPoints));
74 memset(twoPlayerPoints, 0xFF, sizeof(twoPlayerPoints));
75 memset(twoVTwoPoints, 0xFF, sizeof(twoVTwoPoints));
76 memset(oneVThreePoints, 0xFF, sizeof(oneVThreePoints));
77 memset(oneVTwoPoints, 0xFF, sizeof(oneVTwoPoints));
78 }
79} PACKED_STRUCT;
80
81#include "common/pack-end.h" // END STRUCT PACKING
82
83class MIF {
84public:
85 MIF();
86
87 void generateMap(MapFile *map);
88
89 int _dimension = 0; // 32 (small), 40 (medium), 48 (large), 56 (huge), 64 (SAI)
90 int _mapType = 0;
91 char _name[17] = {};
92 byte _cornerMap[MAX_TILE_COUNT][MAX_TILE_COUNT] = { {}, {} };
93 int8 _centerMap[MAX_TILE_COUNT][MAX_TILE_COUNT] = { {}, {} };
94private:
95
96 void defineStartLocations(MapFile *map);
97 void defineEnergyPools(MapFile *map);
98 void makeCraters(MapFile *map);
99 uint16 findTileFor(int x, int y);
100
101 inline char tlCenter(int x, int y) const {
102 return _centerMap[(0 == x) ? _dimension - 1 : x - 1][(0 == y) ? _dimension - 1 : y - 1];
103 }
104
105 inline char tCenter(int x, int y) const {
106 return _centerMap[x][(0 == y) ? _dimension - 1 : y - 1];
107 }
108
109 inline char trCenter(int x, int y) const {
110 return _centerMap[(x + 1) % _dimension][(0 == y) ? _dimension - 1 : y - 1];
111 }
112
113 inline char lCenter(int x, int y) const {
114 return _centerMap[(0 == x) ? _dimension - 1 : x - 1][y];
115 }
116
117 inline char rCenter(int x, int y) const {
118 return _centerMap[(x + 1) % _dimension][y];
119 }
120
121 inline char blCenter(int x, int y) const {
122 return _centerMap[(0 == x) ? _dimension - 1 : x - 1][(y + 1) % _dimension];
123 }
124
125 inline char bCenter(int x, int y) const {
126 return _centerMap[x][(y + 1) % _dimension];
127 }
128
129 inline char brCenter(int x, int y) const {
130 return _centerMap[(x + 1) % _dimension][(y + 1) % _dimension];
131 }
132
133 inline byte tlCorner(int x, int y) const {
134 return _cornerMap[x][y];
135 }
136
137 inline byte trCorner(int x, int y) const {
138 return _cornerMap[(x + 1) % _dimension][y];
139 }
140
141 inline byte blCorner(int x, int y) const {
142 return _cornerMap[x][(y + 1) % _dimension];
143 }
144
145 inline byte brCorner(int x, int y) const {
146 return _cornerMap[(x + 1) % _dimension][(y + 1) % _dimension];
147 }
148
149 inline byte ttllCorner(int x, int y) const {
150 return tlCorner((x == 0) ? _dimension - 1 : x - 1, (y == 0) ? _dimension - 1: y - 1);
151 }
152
153 inline byte ttlCorner(int x, int y) const {
154 return trCorner((x == 0) ? _dimension - 1 : x - 1, (y == 0) ? _dimension - 1: y - 1);
155 }
156
157 inline byte ttrCorner(int x, int y) const {
158 return tlCorner((x + 1) % _dimension, (y == 0) ? _dimension - 1: y - 1);
159 }
160
161 inline byte ttrrCorner(int x, int y) const {
162 return trCorner((x + 1) % _dimension, (y == 0) ? _dimension - 1: y - 1);
163 }
164
165 inline byte tllCorner(int x, int y) const {
166 return tlCorner((x == 0) ? _dimension - 1 : x - 1, y);
167 }
168
169 inline byte trrCorner(int x, int y) const {
170 return trCorner((x + 1) % _dimension, y);
171 }
172
173 inline byte bllCorner(int x, int y) const {
174 return blCorner((x == 0) ? _dimension - 1 : x - 1, y);
175 }
176
177 inline byte brrCorner(int x, int y) const {
178 return brCorner((x + 1) % _dimension, y);
179 }
180
181 inline byte bbllCorner(int x, int y) const {
182 return blCorner((x == 0) ? _dimension - 1 : x - 1, (y + 1) % _dimension);
183 }
184
185 inline byte bblCorner(int x, int y) const {
186 return brCorner((x == 0) ? _dimension - 1 : x - 1, (y + 1) % _dimension);
187 }
188
189 inline byte bbrCorner(int x, int y) const {
190 return blCorner((x + 1) % _dimension, (y + 1) % _dimension);
191 }
192
193 inline byte bbrrCorner(int x, int y) const {
194 return brCorner((x + 1) % _dimension, (y + 1) % _dimension);
195 }
196
197};
198
199} // End of namespace Scumm
200
201#endif // ENABLE_HE
202
203#endif // SCUMM_HE_MOONBASE_MAP_MIF_H
Definition: actor.h:30