summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/d_iface.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/d_iface.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/d_iface.h')
-rw-r--r--apps/plugins/sdl/progs/quake/d_iface.h231
1 files changed, 231 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/d_iface.h b/apps/plugins/sdl/progs/quake/d_iface.h
new file mode 100644
index 0000000000..8dc5ce94bc
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/d_iface.h
@@ -0,0 +1,231 @@
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// d_iface.h: interface header file for rasterization driver modules
21
22#define WARP_WIDTH 320
23#define WARP_HEIGHT 200
24
25#define MAX_LBM_HEIGHT 480
26
27typedef struct
28{
29 float u, v;
30 float s, t;
31 float zi;
32} emitpoint_t;
33
34typedef int ptype_t;
35
36enum {
37 pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
38};
39
40// !!! if this is changed, it must be changed in d_ifacea.h too !!!
41typedef struct particle_s
42{
43// driver-usable fields
44 vec3_t org;
45 float color;
46// drivers never touch the following fields
47 struct particle_s *next;
48 vec3_t vel;
49 float ramp;
50 float die;
51 ptype_t type;
52} particle_t;
53
54#define PARTICLE_Z_CLIP 8.0
55
56typedef struct polyvert_s {
57 float u, v, zi, s, t;
58} polyvert_t;
59
60typedef struct polydesc_s {
61 int numverts;
62 float nearzi;
63 msurface_t *pcurrentface;
64 polyvert_t *pverts;
65} polydesc_t;
66
67// !!! if this is changed, it must be changed in d_ifacea.h too !!!
68typedef struct finalvert_s {
69 int v[6]; // u, v, s, t, l, 1/z
70 int flags;
71 float reserved;
72} finalvert_t;
73
74// !!! if this is changed, it must be changed in d_ifacea.h too !!!
75typedef struct
76{
77 void *pskin;
78 maliasskindesc_t *pskindesc;
79 int skinwidth;
80 int skinheight;
81 mtriangle_t *ptriangles;
82 finalvert_t *pfinalverts;
83 int numtriangles;
84 int drawtype;
85 int seamfixupX16;
86} affinetridesc_t;
87
88// !!! if this is changed, it must be changed in d_ifacea.h too !!!
89typedef struct {
90 float u, v, zi, color;
91} screenpart_t;
92
93typedef struct
94{
95 int nump;
96 emitpoint_t *pverts; // there's room for an extra element at [nump],
97 // if the driver wants to duplicate element [0] at
98 // element [nump] to avoid dealing with wrapping
99 mspriteframe_t *pspriteframe;
100 vec3_t vup, vright, vpn; // in worldspace
101 float nearzi;
102} spritedesc_t;
103
104typedef struct
105{
106 int u, v;
107 float zi;
108 int color;
109} zpointdesc_t;
110
111extern cvar_t r_drawflat;
112extern int d_spanpixcount;
113extern int r_framecount; // sequence # of current frame since Quake
114 // started
115extern qboolean r_drawpolys; // 1 if driver wants clipped polygons
116 // rather than a span list
117extern qboolean r_drawculledpolys; // 1 if driver wants clipped polygons that
118 // have been culled by the edge list
119extern qboolean r_worldpolysbacktofront; // 1 if driver wants polygons
120 // delivered back to front rather
121 // than front to back
122extern qboolean r_recursiveaffinetriangles; // true if a driver wants to use
123 // recursive triangular subdivison
124 // and vertex drawing via
125 // D_PolysetDrawFinalVerts() past
126 // a certain distance (normally
127 // only used by the software
128 // driver)
129extern float r_aliasuvscale; // scale-up factor for screen u and v
130 // on Alias vertices passed to driver
131extern int r_pixbytes;
132extern qboolean r_dowarp;
133
134extern affinetridesc_t r_affinetridesc;
135extern spritedesc_t r_spritedesc;
136extern zpointdesc_t r_zpointdesc;
137extern polydesc_t r_polydesc;
138
139extern int d_con_indirect; // if 0, Quake will draw console directly
140 // to vid.buffer; if 1, Quake will
141 // draw console via D_DrawRect. Must be
142 // defined by driver
143
144extern vec3_t r_pright, r_pup, r_ppn;
145
146
147void D_Aff8Patch (void *pcolormap);
148void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height);
149void D_DisableBackBufferAccess (void);
150void D_EndDirectRect (int x, int y, int width, int height);
151void D_PolysetDraw (void);
152void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts);
153void D_DrawParticle (particle_t *pparticle);
154void D_DrawPoly (void);
155void D_DrawSprite (void);
156void D_DrawSurfaces (void);
157void D_DrawZPoint (void);
158void D_EnableBackBufferAccess (void);
159void D_EndParticles (void);
160void D_Init (void);
161void D_ViewChanged (void);
162void D_SetupFrame (void);
163void D_StartParticles (void);
164void D_TurnZOn (void);
165void D_WarpScreen (void);
166
167void D_FillRect (vrect_t *vrect, int color);
168void D_DrawRect (void);
169void D_UpdateRects (vrect_t *prect);
170
171// currently for internal use only, and should be a do-nothing function in
172// hardware drivers
173// FIXME: this should go away
174void D_PolysetUpdateTables (void);
175
176// these are currently for internal use only, and should not be used by drivers
177extern int r_skydirect;
178extern byte *r_skysource;
179
180// transparency types for D_DrawRect ()
181#define DR_SOLID 0
182#define DR_TRANSPARENT 1
183
184// !!! must be kept the same as in quakeasm.h !!!
185#define TRANSPARENT_COLOR 0xFF
186
187extern void *acolormap; // FIXME: should go away
188
189//=======================================================================//
190
191// callbacks to Quake
192
193typedef struct
194{
195 pixel_t *surfdat; // destination for generated surface
196 int rowbytes; // destination logical width in bytes
197 msurface_t *surf; // description for surface to generate
198 fixed8_t lightadj[MAXLIGHTMAPS];
199 // adjust for lightmap levels for dynamic lighting
200 texture_t *texture; // corrected for animating textures
201 int surfmip; // mipmapped ratio of surface texels / world pixels
202 int surfwidth; // in mipmapped texels
203 int surfheight; // in mipmapped texels
204} drawsurf_t;
205
206extern drawsurf_t r_drawsurf;
207
208void R_DrawSurface (void);
209void R_GenTile (msurface_t *psurf, void *pdest);
210
211
212// !!! if this is changed, it must be changed in d_ifacea.h too !!!
213#define TURB_TEX_SIZE 64 // base turbulent texture size
214
215// !!! if this is changed, it must be changed in d_ifacea.h too !!!
216#define CYCLE 128 // turbulent cycle size
217
218#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
219
220#define SKYSHIFT 7
221#define SKYSIZE (1 << SKYSHIFT)
222#define SKYMASK (SKYSIZE - 1)
223
224extern float skyspeed, skyspeed2;
225extern float skytime;
226
227extern int c_surf;
228extern vrect_t scr_vrect;
229
230extern byte *r_warpbuffer;
231