File: map_mif.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (203 lines) | stat: -rw-r--r-- 5,458 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef SCUMM_HE_MOONBASE_MAP_MIF_H
#define SCUMM_HE_MOONBASE_MAP_MIF_H

#ifdef ENABLE_HE

#include "scumm/he/intern_he.h"

namespace Scumm {

#define MAX_TILE_COUNT 80

#include "common/pack-start.h"	// START STRUCT PACKING

struct PixelLoc {
	uint16 x;
	uint16 y;
};

struct EnergyPoolLoc {
	PixelLoc location;
	PixelLoc dummy;
};


struct MapFile {
	// Header:
	uint16 headerDummy;
	uint16 terrainDimX;
	uint16 terrainDimY;
	uint16 mapType;
	uint16 numEnergyPools;

	uint16 terrainStates[80][161];
	uint8 space1[230];
	char name[17];
	uint8 space2[25837];
	EnergyPoolLoc poolLocs[49];
	PixelLoc lastPool;
	uint16 dummy;
	PixelLoc fourPlayerPoints[4];  // 2^0
	PixelLoc threePlayerPoints[3]; // 2^1
	PixelLoc twoPlayerPoints[2];   // 2^2
	PixelLoc twoVTwoPoints[4];     // 2^3
	PixelLoc oneVThreePoints[4];   // 2^4
	PixelLoc oneVTwoPoints[3];     // 2^5

	MapFile() {
		memset(this, 0, sizeof(MapFile));

		mapType = 1;
		memset(fourPlayerPoints, 0xFF, sizeof(fourPlayerPoints));
		memset(threePlayerPoints, 0xFF, sizeof(threePlayerPoints));
		memset(twoPlayerPoints, 0xFF, sizeof(twoPlayerPoints));
		memset(twoVTwoPoints, 0xFF, sizeof(twoVTwoPoints));
		memset(oneVThreePoints, 0xFF, sizeof(oneVThreePoints));
		memset(oneVTwoPoints, 0xFF, sizeof(oneVTwoPoints));
	}
} PACKED_STRUCT;

#include "common/pack-end.h"	// END STRUCT PACKING

class MIF {
public:
	MIF();

	void generateMap(MapFile *map);

	int _dimension = 0; // 32 (small), 40 (medium), 48 (large), 56 (huge), 64 (SAI)
	int _mapType = 0;
	char _name[17] = {};
	byte _cornerMap[MAX_TILE_COUNT][MAX_TILE_COUNT] = { {}, {} };
	int8 _centerMap[MAX_TILE_COUNT][MAX_TILE_COUNT] = { {}, {} };
private:

	void defineStartLocations(MapFile *map);
	void defineEnergyPools(MapFile *map);
	void makeCraters(MapFile *map);
	uint16 findTileFor(int x, int y);

	inline char tlCenter(int x, int y) const {
		return _centerMap[(0 == x) ? _dimension - 1 : x - 1][(0 == y) ? _dimension - 1 : y - 1];
	}

	inline char tCenter(int x, int y) const {
		return _centerMap[x][(0 == y) ? _dimension - 1 : y - 1];
	}

	inline char trCenter(int x, int y) const {
		return _centerMap[(x + 1) % _dimension][(0 == y) ? _dimension - 1 : y - 1];
	}

	inline char lCenter(int x, int y) const {
		return _centerMap[(0 == x) ? _dimension - 1 : x - 1][y];
	}

	inline char rCenter(int x, int y) const {
		return _centerMap[(x + 1) % _dimension][y];
	}

	inline char blCenter(int x, int y) const {
		return _centerMap[(0 == x) ? _dimension - 1 : x - 1][(y + 1) % _dimension];
	}

	inline char bCenter(int x, int y) const {
		return _centerMap[x][(y + 1) % _dimension];
	}

	inline char brCenter(int x, int y) const {
		return _centerMap[(x + 1) % _dimension][(y + 1) % _dimension];
	}

	inline byte tlCorner(int x, int y) const {
		return _cornerMap[x][y];
	}

	inline byte trCorner(int x, int y) const {
		return _cornerMap[(x + 1) % _dimension][y];
	}

	inline byte blCorner(int x, int y) const {
		return _cornerMap[x][(y + 1) % _dimension];
	}

	inline byte brCorner(int x, int y) const {
		return _cornerMap[(x + 1) % _dimension][(y + 1) % _dimension];
	}

	inline byte ttllCorner(int x, int y) const {
		return tlCorner((x == 0) ? _dimension - 1 : x - 1, (y == 0) ? _dimension - 1: y - 1);
	}

	inline byte ttlCorner(int x, int y) const {
		return trCorner((x == 0) ? _dimension - 1 : x - 1, (y == 0) ? _dimension - 1: y - 1);
	}

	inline byte ttrCorner(int x, int y) const {
		return tlCorner((x + 1) % _dimension, (y == 0) ? _dimension - 1: y - 1);
	}

	inline byte ttrrCorner(int x, int y) const {
		return trCorner((x + 1) % _dimension, (y == 0) ? _dimension - 1: y - 1);
	}

	inline byte tllCorner(int x, int y) const {
		return tlCorner((x == 0) ? _dimension - 1 : x - 1, y);
	}

	inline byte trrCorner(int x, int y) const {
		return trCorner((x + 1) % _dimension, y);
	}

	inline byte bllCorner(int x, int y) const {
		return blCorner((x == 0) ? _dimension - 1 : x - 1, y);
	}

	inline byte brrCorner(int x, int y) const {
		return brCorner((x + 1) % _dimension, y);
	}

	inline byte bbllCorner(int x, int y) const {
		return blCorner((x == 0) ? _dimension - 1 : x - 1, (y + 1) % _dimension);
	}

	inline byte bblCorner(int x, int y) const {
		return brCorner((x == 0) ? _dimension - 1 : x - 1, (y + 1) % _dimension);
	}

	inline byte bbrCorner(int x, int y) const {
		return blCorner((x + 1) % _dimension, (y + 1) % _dimension);
	}

	inline byte bbrrCorner(int x, int y) const {
		return brCorner((x + 1) % _dimension, (y + 1) % _dimension);
	}

};

} // End of namespace Scumm

#endif // ENABLE_HE

#endif // SCUMM_HE_MOONBASE_MAP_MIF_H