summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/model.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-02-11 15:34:30 -0500
committerFranklin Wei <git@fwei.tk>2019-07-19 22:37:40 -0400
commit5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4 (patch)
tree84406e21639529a185556a33e5de7f43cffc277b /apps/plugins/sdl/progs/quake/model.h
parentb70fecf21ddc21877ec1ae7888d9c18a979e37ad (diff)
downloadrockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.tar.gz
rockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.zip
Quake!
This ports id Software's Quake to run on the SDL plugin runtime. The source code originated from id under the GPLv2 license. I used https://github.com/ahefner/sdlquake as the base of my port. Performance is, unsurprisingly, not on par with what you're probably used to on PC. I average about 10FPS on ipod6g, but it's still playable. Sound works well enough, but in-game music is not supported. I've written ARM assembly routines for the inner sound loop. Make sure you turn the "brightness" all the way down, or colors will look funky. To run, extract Quake's data files to /.rockbox/quake. Have fun! Change-Id: I4285036e967d7f0722802d43cf2096c808ca5799
Diffstat (limited to 'apps/plugins/sdl/progs/quake/model.h')
-rw-r--r--apps/plugins/sdl/progs/quake/model.h383
1 files changed, 383 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/model.h b/apps/plugins/sdl/progs/quake/model.h
new file mode 100644
index 0000000000..899010f0fb
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/model.h
@@ -0,0 +1,383 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20
21#ifndef __MODEL__
22#define __MODEL__
23
24#include "modelgen.h"
25#include "spritegn.h"
26
27/*
28
29d*_t structures are on-disk representations
30m*_t structures are in-memory
31
32*/
33
34/*
35==============================================================================
36
37BRUSH MODELS
38
39==============================================================================
40*/
41
42
43//
44// in memory representation
45//
46// !!! if this is changed, it must be changed in asm_draw.h too !!!
47typedef struct
48{
49 vec3_t position;
50} mvertex_t;
51
52#define SIDE_FRONT 0
53#define SIDE_BACK 1
54#define SIDE_ON 2
55
56
57// plane_t structure
58// !!! if this is changed, it must be changed in asm_i386.h too !!!
59typedef struct mplane_s
60{
61 vec3_t normal;
62 float dist;
63 byte type; // for texture axis selection and fast side tests
64 byte signbits; // signx + signy<<1 + signz<<1
65 byte pad[2];
66} mplane_t;
67
68typedef struct texture_s
69{
70 char name[16];
71 unsigned width, height;
72 int anim_total; // total tenths in sequence ( 0 = no)
73 int anim_min, anim_max; // time for this frame min <=time< max
74 struct texture_s *anim_next; // in the animation sequence
75 struct texture_s *alternate_anims; // bmodels in frmae 1 use these
76 unsigned offsets[MIPLEVELS]; // four mip maps stored
77} texture_t;
78
79
80#define SURF_PLANEBACK 2
81#define SURF_DRAWSKY 4
82#define SURF_DRAWSPRITE 8
83#define SURF_DRAWTURB 0x10
84#define SURF_DRAWTILED 0x20
85#define SURF_DRAWBACKGROUND 0x40
86
87// !!! if this is changed, it must be changed in asm_draw.h too !!!
88typedef struct
89{
90 unsigned short v[2];
91 unsigned int cachededgeoffset;
92} medge_t;
93
94typedef struct
95{
96 float vecs[2][4];
97 float mipadjust;
98 texture_t *texture;
99 int flags;
100} mtexinfo_t;
101
102typedef struct msurface_s
103{
104 int visframe; // should be drawn when node is crossed
105
106 int dlightframe;
107 int dlightbits;
108
109 mplane_t *plane;
110 int flags;
111
112 int firstedge; // look up in model->surfedges[], negative numbers
113 int numedges; // are backwards edges
114
115// surface generation data
116 struct surfcache_s *cachespots[MIPLEVELS];
117
118 short texturemins[2];
119 short extents[2];
120
121 mtexinfo_t *texinfo;
122
123// lighting info
124 byte styles[MAXLIGHTMAPS];
125 byte *samples; // [numstyles*surfsize]
126} msurface_t;
127
128typedef struct mnode_s
129{
130// common with leaf
131 int contents; // 0, to differentiate from leafs
132 int visframe; // node needs to be traversed if current
133
134 short minmaxs[6]; // for bounding box culling
135
136 struct mnode_s *parent;
137
138// node specific
139 mplane_t *plane;
140 struct mnode_s *children[2];
141
142 unsigned short firstsurface;
143 unsigned short numsurfaces;
144} mnode_t;
145
146
147
148typedef struct mleaf_s
149{
150// common with node
151 int contents; // wil be a negative contents number
152 int visframe; // node needs to be traversed if current
153
154 short minmaxs[6]; // for bounding box culling
155
156 struct mnode_s *parent;
157
158// leaf specific
159 byte *compressed_vis;
160 efrag_t *efrags;
161
162 msurface_t **firstmarksurface;
163 int nummarksurfaces;
164 int key; // BSP sequence number for leaf's contents
165 byte ambient_sound_level[NUM_AMBIENTS];
166} mleaf_t;
167
168// !!! if this is changed, it must be changed in asm_i386.h too !!!
169typedef struct
170{
171 dclipnode_t *clipnodes;
172 mplane_t *planes;
173 int firstclipnode;
174 int lastclipnode;
175 vec3_t clip_mins;
176 vec3_t clip_maxs;
177} hull_t;
178
179/*
180==============================================================================
181
182SPRITE MODELS
183
184==============================================================================
185*/
186
187
188// FIXME: shorten these?
189typedef struct mspriteframe_s
190{
191 int width;
192 int height;
193 void *pcachespot; // remove?
194 float up, down, left, right;
195 byte pixels[4];
196} mspriteframe_t;
197
198typedef struct
199{
200 int numframes;
201 float *intervals;
202 mspriteframe_t *frames[1];
203} mspritegroup_t;
204
205typedef struct
206{
207 spriteframetype_t type;
208 mspriteframe_t *frameptr;
209} mspriteframedesc_t;
210
211typedef struct
212{
213 int type;
214 int maxwidth;
215 int maxheight;
216 int numframes;
217 float beamlength; // remove?
218 void *cachespot; // remove?
219 mspriteframedesc_t frames[1];
220} msprite_t;
221
222
223/*
224==============================================================================
225
226ALIAS MODELS
227
228Alias models are position independent, so the cache manager can move them.
229==============================================================================
230*/
231
232typedef struct
233{
234 aliasframetype_t type;
235 trivertx_t bboxmin;
236 trivertx_t bboxmax;
237 int frame;
238 char name[16];
239} maliasframedesc_t;
240
241typedef struct
242{
243 aliasskintype_t type;
244 void *pcachespot;
245 int skin;
246} maliasskindesc_t;
247
248typedef struct
249{
250 trivertx_t bboxmin;
251 trivertx_t bboxmax;
252 int frame;
253} maliasgroupframedesc_t;
254
255typedef struct
256{
257 int numframes;
258 int intervals;
259 maliasgroupframedesc_t frames[1];
260} maliasgroup_t;
261
262typedef struct
263{
264 int numskins;
265 int intervals;
266 maliasskindesc_t skindescs[1];
267} maliasskingroup_t;
268
269// !!! if this is changed, it must be changed in asm_draw.h too !!!
270typedef struct mtriangle_s {
271 int facesfront;
272 int vertindex[3];
273} mtriangle_t;
274
275typedef struct {
276 int model;
277 int stverts;
278 int skindesc;
279 int triangles;
280 maliasframedesc_t frames[1];
281} aliashdr_t;
282
283//===================================================================
284
285//
286// Whole model
287//
288
289typedef int modtype_t;
290enum {mod_brush, mod_sprite, mod_alias};
291
292#define EF_ROCKET 1 // leave a trail
293#define EF_GRENADE 2 // leave a trail
294#define EF_GIB 4 // leave a trail
295#define EF_ROTATE 8 // rotate (bonus items)
296#define EF_TRACER 16 // green split trail
297#define EF_ZOMGIB 32 // small blood trail
298#define EF_TRACER2 64 // orange split trail + rotate
299#define EF_TRACER3 128 // purple trail
300
301typedef struct model_s
302{
303 char name[MAX_QPATH];
304 qboolean needload; // bmodels and sprites don't cache normally
305
306 modtype_t type;
307 int numframes;
308 synctype_t synctype;
309
310 int flags;
311
312//
313// volume occupied by the model
314//
315 vec3_t mins, maxs;
316 float radius;
317
318//
319// brush model
320//
321 int firstmodelsurface, nummodelsurfaces;
322
323 int numsubmodels;
324 dmodel_t *submodels;
325
326 int numplanes;
327 mplane_t *planes;
328
329 int numleafs; // number of visible leafs, not counting 0
330 mleaf_t *leafs;
331
332 int numvertexes;
333 mvertex_t *vertexes;
334
335 int numedges;
336 medge_t *edges;
337
338 int numnodes;
339 mnode_t *nodes;
340
341 int numtexinfo;
342 mtexinfo_t *texinfo;
343
344 int numsurfaces;
345 msurface_t *surfaces;
346
347 int numsurfedges;
348 int *surfedges;
349
350 int numclipnodes;
351 dclipnode_t *clipnodes;
352
353 int nummarksurfaces;
354 msurface_t **marksurfaces;
355
356 hull_t hulls[MAX_MAP_HULLS];
357
358 int numtextures;
359 texture_t **textures;
360
361 byte *visdata;
362 byte *lightdata;
363 char *entities;
364
365//
366// additional model data
367//
368 cache_user_t cache; // only access through Mod_Extradata
369
370} model_t;
371
372//============================================================================
373
374void Mod_Init (void);
375void Mod_ClearAll (void);
376model_t *Mod_ForName (char *name, qboolean crash);
377void *Mod_Extradata (model_t *mod); // handles caching
378void Mod_TouchModel (char *name);
379
380mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
381byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
382
383#endif // __MODEL__