ScummVM API documentation
px_mapfile.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  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 // NOTES
28 
29 // 1. A session has a number of maps. These maps may, though don't have to, correspond to the
30 // slices in the walkgrid data. Each map is one item in a px_linkeddatafile. The data structures
31 // below describe the internal structure of this.
32 
33 // 2. Each entry in the px_linkeddatafile is simply a uint32 count of the number of objects in
34 // this level, followed by the objects themselves, which are all one of the types listed below.
35 
36 // 3. All x,y,z coordinates are divided by two before storage, so we can fit them in a byte. Thus
37 // the map is stored half-scale.
38 
39 // Make sure this header gets included only once.
40 #ifndef ICB_PX_MAPFILE_H_INCLUDED
41 #define ICB_PX_MAPFILE_H_INCLUDED
42 
43 // Include headers needed by this file.
44 #include "engines/icb/common/px_common.h"
45 
46 namespace ICB {
47 
48 // This defines a schema version number for the data. If the format is changed then this number should
49 // be changed to prevent the engine running with out-of-date data.
50 #define REMORA_MAP_FILE_VERSION 100
51 
52 // These define extensions and names for these files.
53 #if !defined(REMORA_MAP_FILENAME)
54 #define REMORA_MAP_FILENAME "remora_map"
55 #endif
56 
57 #if !defined(REMORA_MAP_PC_EXT)
58 #define REMORA_MAP_PC_EXT "rmf_pc"
59 #endif
60 
61 #if !defined(REMORA_MAP_PSX_EXT)
62 #define REMORA_MAP_PSX_EXT "rmf_psx"
63 #endif
64 
65 #if !defined(PX_MAP_EXT)
66 #if defined(_PSX)
67 #define PX_MAP_EXT REMORA_MAP_PSX_EXT
68 #else
69 #define PX_MAP_EXT REMORA_MAP_PC_EXT
70 #endif
71 #endif
72 
73 // This defines the 'knowledge levels' that items can have. Basically, the idea is that an object
74 // will only get drawn in the game if the knowledge level for the player is greater than or equal
75 // to the level stored for the object.
76 #define REMORA_MAP_MAX_KNOWLEDGE_LEVEL 3
77 
78 // These are definitions for the object types. These are packed in with the 'level' indicator. So
79 // if you had a line that should be displayed only when the player's knowledge is at level 4 (i.e. the
80 // player is currently in a location), then it would have the following code:
81 // 0x40 | 0x02 = 0x42.
82 enum MapObjectType { REMORA_MAP_RECTANGLE = 0, REMORA_MAP_FILLED_RECTANGLE, REMORA_MAP_LINE, REMORA_MAP_TEXT, REMORA_MAP_POLYGON, REMORA_MAP_NUM_OBJECTS };
83 
84 // These macros allow access to the two halves of the packed field mentioned previously.
85 #define GET_KNOWLEDGE_LEVEL(x) ((uint32)((x & 0xf0) >> 4))
86 #define GET_OBJECT_TYPE(x) ((MapObjectType)(x & 0x0f))
87 
88 // type _map_colour_point
89 // This holds a point with a colour. This is not used in the objects that have a fixed number
90 // of points because we lose 3 padding bytes per point.
91 typedef struct {
92  uint8 nX, nY;
93  uint8 nR, nG, nB;
94  uint8 nPad1;
95  uint8 nPad2;
96  uint8 nPad3;
98 
99 // type _map_rectangle
100 // An outline rectangle - object type 0.
101 typedef struct {
102  uint32 nLocationNameHash; // Hash of the location this object is part of.
103  uint8 nLevelAndType; // See note above for how to construct this field.
104  uint8 nX1, nY1; // Top-left corner of the rectangle.
105  uint8 nR1, nG1, nB1; // Colour for top-left corner.
106  uint8 nX2, nY2; // Bottom-right corner of the rectangle.
107  uint8 nR2, nG2, nB2; // Colour for bottom-right corner.
108  uint8 nWidth; // Width to draw rectangle line.
110 
111 // type _map_filled_rectangle
112 // A filled rectangle - object type 1.
113 typedef struct {
114  uint32 nLocationNameHash; // Hash of the location this object is part of.
115  uint8 nLevelAndType; // See note above for how to construct this field.
116  uint8 nX1, nY1; // Top-left corner of the rectangle.
117  uint8 nR1, nG1, nB1; // Colour for top-left corner.
118  uint8 nX2, nY2; // Bottom-right corner of the rectangle.
119  uint8 nR2, nG2, nB2; // Colour for bottom-right corner.
120  uint8 nPad1;
122 
123 // type _map_line
124 // A line - object type 2.
125 typedef struct {
126  uint32 nLocationNameHash; // Hash of the location this object is part of.
127  uint8 nLevelAndType; // See note above for how to construct this field.
128  uint8 nX1, nY1; // Top-left corner of the rectangle.
129  uint8 nR1, nG1, nB1; // Colour for top-left corner.
130  uint8 nX2, nY2; // Bottom-right corner of the rectangle.
131  uint8 nR2, nG2, nB2; // Colour for bottom-right corner.
132  uint8 nWidth; // Width to draw rectangle line.
133 } _map_line;
134 
135 // type _map_text
136 // Some text to be displayed - object type 3.
137 typedef struct {
138  uint32 nLocationNameHash; // Hash of the location this object is part of.
139  uint8 nLevelAndType; // See note above for how to construct this field.
140  uint8 nX, nY; // Bottom-left point to start drawing text.
141  uint8 nR, nG, nB; // Colour.
142  uint8 nPad1;
143  uint8 nPad2;
144  uint32 nTextHash; // Hash of the text.
145 } _map_text;
146 
147 // type _map_polygon
148 // A filled rectangle - object type 4.
149 typedef struct {
150  uint32 nLocationNameHash; // Hash of the location this object is part of.
151  uint8 nLevelAndType; // See note above for how to construct this field.
152  uint8 nNumPoints; // How many points it has.
153  uint8 m_nPad1;
154  uint8 m_nPad2;
155  _map_colour_point pPoints[1]; // The points for the polygon.
156 } _map_polygon;
157 
158 // This function works out the size of a polygon structure in the file because there are variable.
159 inline uint32 _map_polygon_sizeof(const _map_polygon *pPoly) { return (sizeof(_map_polygon) + (pPoly->nNumPoints - 1) * sizeof(_map_colour_point)); }
160 
161 } // End of namespace ICB
162 
163 #endif // #if !defined(_PX_MAPFILE_H_INCLUDED)
Definition: px_mapfile.h:101
Definition: actor.h:32
Definition: px_mapfile.h:113
Definition: px_mapfile.h:137
Definition: px_mapfile.h:149
Definition: px_mapfile.h:91
Definition: px_mapfile.h:125