summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2019-07-20 19:52:30 -0400
committerFranklin Wei <git@fwei.tk>2019-07-21 15:13:35 -0400
commit2ca47176f9fffade0569a0c18f75536cd020a19c (patch)
treeb556d122d1270b761fb64f791d35fedad4854a4f
parentf83de422fa7f4d107ce69a1be66cf35afb60314f (diff)
downloadrockbox-2ca47176f9fffade0569a0c18f75536cd020a19c.tar.gz
rockbox-2ca47176f9fffade0569a0c18f75536cd020a19c.zip
quake: pack structs which could potentially be unaligned
The d*_t structs are from "d"isk, which means they could be unaligned. Packing them saves me from having to rewrite every single access to them. Change-Id: I6d5a9525fff368bf29bdb85cf1672fce02ce3396
-rw-r--r--apps/plugins/sdl/progs/quake/bspfile.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/apps/plugins/sdl/progs/quake/bspfile.h b/apps/plugins/sdl/progs/quake/bspfile.h
index 308902632b..ac15ed7330 100644
--- a/apps/plugins/sdl/progs/quake/bspfile.h
+++ b/apps/plugins/sdl/progs/quake/bspfile.h
@@ -79,6 +79,7 @@ typedef struct
79 79
80#define HEADER_LUMPS 15 80#define HEADER_LUMPS 15
81 81
82// packed to avoid unaligned accesses on ARM
82typedef struct 83typedef struct
83{ 84{
84 float mins[3], maxs[3]; 85 float mins[3], maxs[3];
@@ -86,19 +87,19 @@ typedef struct
86 int headnode[MAX_MAP_HULLS]; 87 int headnode[MAX_MAP_HULLS];
87 int visleafs; // not including the solid leaf 0 88 int visleafs; // not including the solid leaf 0
88 int firstface, numfaces; 89 int firstface, numfaces;
89} dmodel_t; 90} __attribute__((packed)) dmodel_t;
90 91
91typedef struct 92typedef struct
92{ 93{
93 int version; 94 int version;
94 lump_t lumps[HEADER_LUMPS]; 95 lump_t lumps[HEADER_LUMPS];
95} dheader_t; 96} __attribute__((packed)) dheader_t;
96 97
97typedef struct 98typedef struct
98{ 99{
99 int nummiptex; 100 int nummiptex;
100 int dataofs[4]; // [nummiptex] 101 int dataofs[4]; // [nummiptex]
101} dmiptexlump_t; 102} __attribute__((packed)) dmiptexlump_t;
102 103
103#define MIPLEVELS 4 104#define MIPLEVELS 4
104typedef struct miptex_s 105typedef struct miptex_s
@@ -106,13 +107,13 @@ typedef struct miptex_s
106 char name[16]; 107 char name[16];
107 unsigned width, height; 108 unsigned width, height;
108 unsigned offsets[MIPLEVELS]; // four mip maps stored 109 unsigned offsets[MIPLEVELS]; // four mip maps stored
109} miptex_t; 110} __attribute__((packed)) miptex_t;
110 111
111 112
112typedef struct 113typedef struct
113{ 114{
114 float point[3]; 115 float point[3];
115} dvertex_t; 116} __attribute__((packed)) dvertex_t;
116 117
117 118
118// 0-2 are axial planes 119// 0-2 are axial planes
@@ -130,7 +131,7 @@ typedef struct
130 float normal[3]; 131 float normal[3];
131 float dist; 132 float dist;
132 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate 133 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
133} dplane_t; 134} __attribute__((packed)) dplane_t;
134 135
135 136
136 137
@@ -160,13 +161,13 @@ typedef struct
160 short maxs[3]; 161 short maxs[3];
161 unsigned short firstface; 162 unsigned short firstface;
162 unsigned short numfaces; // counting both sides 163 unsigned short numfaces; // counting both sides
163} dnode_t; 164} __attribute__((packed)) dnode_t;
164 165
165typedef struct 166typedef struct
166{ 167{
167 int planenum; 168 int planenum;
168 short children[2]; // negative numbers are contents 169 short children[2]; // negative numbers are contents
169} dclipnode_t; 170} __attribute__((packed)) dclipnode_t;
170 171
171 172
172typedef struct texinfo_s 173typedef struct texinfo_s
@@ -174,7 +175,7 @@ typedef struct texinfo_s
174 float vecs[2][4]; // [s/t][xyz offset] 175 float vecs[2][4]; // [s/t][xyz offset]
175 int miptex; 176 int miptex;
176 int flags; 177 int flags;
177} texinfo_t; 178} __attribute__((packed)) texinfo_t;
178#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision 179#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
179 180
180// note that edge 0 is never used, because negative edge nums are used for 181// note that edge 0 is never used, because negative edge nums are used for
@@ -182,7 +183,7 @@ typedef struct texinfo_s
182typedef struct 183typedef struct
183{ 184{
184 unsigned short v[2]; // vertex numbers 185 unsigned short v[2]; // vertex numbers
185} dedge_t; 186} __attribute__((packed)) dedge_t;
186 187
187#define MAXLIGHTMAPS 4 188#define MAXLIGHTMAPS 4
188typedef struct 189typedef struct
@@ -197,7 +198,7 @@ typedef struct
197// lighting info 198// lighting info
198 byte styles[MAXLIGHTMAPS]; 199 byte styles[MAXLIGHTMAPS];
199 int lightofs; // start of [numstyles*surfsize] samples 200 int lightofs; // start of [numstyles*surfsize] samples
200} dface_t; 201} __attribute__((packed)) dface_t;
201 202
202 203
203 204
@@ -222,7 +223,7 @@ typedef struct
222 unsigned short nummarksurfaces; 223 unsigned short nummarksurfaces;
223 224
224 byte ambient_level[NUM_AMBIENTS]; 225 byte ambient_level[NUM_AMBIENTS];
225} dleaf_t; 226} __attribute__((packed)) dleaf_t;
226 227
227 228
228//============================================================================ 229//============================================================================
@@ -296,7 +297,7 @@ typedef struct epair_s
296 struct epair_s *next; 297 struct epair_s *next;
297 char *key; 298 char *key;
298 char *value; 299 char *value;
299} epair_t; 300} __attribute__((packed)) epair_t;
300 301
301typedef struct 302typedef struct
302{ 303{
@@ -304,7 +305,7 @@ typedef struct
304 int firstbrush; 305 int firstbrush;
305 int numbrushes; 306 int numbrushes;
306 epair_t *epairs; 307 epair_t *epairs;
307} entity_t; 308} __attribute__((packed)) entity_t;
308 309
309extern int num_entities; 310extern int num_entities;
310extern entity_t entities[MAX_MAP_ENTITIES]; 311extern entity_t entities[MAX_MAP_ENTITIES];