Mercurial > hg > dmlib
annotate dmlib.h @ 770:a8bd679934c7
Indentation cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 10 May 2013 11:29:35 +0300 |
parents | 2726d91e3409 |
children | e15e0469499a |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Main header file | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
569 | 5 * (C) Copyright 2011-2013 Tecnic Software productions (TNSP) |
0 | 6 */ |
7 #ifndef DMLIB_H | |
8 #define DMLIB_H | |
9 | |
288
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
10 #include <SDL_config.h> |
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
11 #include <SDL_endian.h> |
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
12 #include <SDL_types.h> |
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
13 #include <SDL_mutex.h> |
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
14 #include <SDL_video.h> |
0 | 15 #include <stdarg.h> |
16 | |
17 #ifdef DM_USE_ASSERTS | |
770 | 18 # include <assert.h> |
0 | 19 #else |
770 | 20 # define assert(NEXPR) // stub |
0 | 21 #endif |
22 | |
23 #ifdef __cplusplus | |
24 extern "C" { | |
25 #endif | |
26 | |
27 // Defaults | |
569 | 28 #define DM_PROG_AUTHOR "By Matti 'ccr' Hamalainen (C) Copyright 2013 TNSP" |
341 | 29 #define DM_PROG_LICENSE "Et all, see README / COPYING for more information." |
0 | 30 |
31 /* Error codes | |
32 */ | |
33 enum { | |
770 | 34 // General error codes |
35 DMERR_OK = 0, | |
36 DMERR_PROGRESS, // Status OK, but operation in progress | |
26
2f463a59d732
Implement rudimentary resource system.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
37 |
770 | 38 DMERR_FOPEN, |
39 DMERR_FREAD, | |
40 DMERR_FWRITE, | |
41 DMERR_FSEEK, | |
42 DMERR_NOT_FOUND, // Resource/data not found | |
0 | 43 |
770 | 44 DMERR_INVALID_DATA, // Some data was invalid |
45 DMERR_MALLOC, // Memory allocation failure | |
46 DMERR_ALREADY_INIT, // Resource has already been initialized | |
47 DMERR_INIT_FAIL, // General initialization failure | |
48 DMERR_INVALID_ARGS, | |
0 | 49 |
770 | 50 DMERR_NULLPTR, // NULL pointer specified in critical argument |
51 DMERR_NOT_SUPPORTED,// Operation not supported | |
52 DMERR_OUT_OF_DATA, | |
53 DMERR_EXTRA_DATA, | |
54 DMERR_BOUNDS, | |
0 | 55 |
770 | 56 DMERR_INTERNAL, |
506
443228332e5b
Add new error code for internal errors.
Matti Hamalainen <ccr@tnsp.org>
parents:
411
diff
changeset
|
57 |
770 | 58 // PACK-file subsystem |
59 DMERR_NOTPACK, | |
60 DMERR_VERSION, | |
61 DMERR_INVALID, | |
62 DMERR_COMPRESSION, | |
0 | 63 }; |
64 | |
65 | |
66 // Resource management defines | |
67 #define DMRES_NAME_LEN 32 | |
68 #define DMRES_DATA_PACK "data.pak" // Name of the data-file | |
601
588998ccc07a
Change resource directory path DATA/ -> data/
Matti Hamalainen <ccr@tnsp.org>
parents:
569
diff
changeset
|
69 #define DMRES_DATA_PATH "data/" // Sub-directory path |
0 | 70 #define DMRES_RES_FILE "res.txt" // Resource data file |
71 | |
72 | |
73 /* Define a boolean type | |
74 */ | |
75 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) | |
76 typedef enum { FALSE = 0, TRUE = 1 } BOOL; | |
77 #endif | |
78 | |
79 #ifndef BOOL | |
770 | 80 # ifdef bool |
81 # define BOOL bool | |
82 # else | |
83 # define BOOL int | |
84 # endif | |
0 | 85 #endif |
86 | |
87 | |
305
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
88 /* Math constants |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
89 */ |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
90 #define DM_PI 3.14159265358f |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
91 #define DM_PI2 6.28318530718f |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
92 #define DM_E 2.71828182846f |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
93 |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
94 |
0 | 95 /* Fixed point math type |
96 */ | |
97 typedef union | |
98 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
99 Sint64 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
100 Sint32 w[2]; |
0 | 101 } DMFixedPoint; |
102 | |
103 | |
104 typedef union | |
105 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
106 Sint32 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
107 Sint16 w[2]; |
0 | 108 } DMFixedPoint32; |
109 | |
110 | |
111 /* Macros for fixed point math | |
112 */ | |
113 #if __GNUC__ >= 3 | |
114 # define FP_SET(a, k) a.dw = k ## ULL | |
115 #else | |
116 # define FP_SET(a, k) a.dw = k | |
117 #endif | |
118 | |
138
459a1be2bd0f
A minor improvement to FP_CONV() fixed point macro.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
119 #define FP_CONV(a, k) a.dw = (k) |
0 | 120 |
121 #ifndef SDL_BYTEORDER | |
122 # error Undefined byteorder! | |
123 #endif | |
124 | |
125 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
126 # define FP_SETH(a, k) a.w[0] = (k) | |
127 # define FP_SETL(a, k) a.w[1] = (k) | |
128 # define FP_SETHL(a, h, l) { a.w[0] = (h); a.w[1] = (l); } | |
129 # define FP_GETH(a) a.w[0] | |
130 # define FP_GETL(a) a.w[1] | |
131 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
132 # define FP_SETH(a, k) a.w[1] = (k) | |
133 # define FP_SETL(a, k) a.w[0] = (k) | |
134 # define FP_SETHL(a, h, l) { a.w[1] = (h); a.w[0] = (l); } | |
135 # define FP_GETH(a) a.w[1] | |
136 # define FP_GETL(a) a.w[0] | |
137 #else | |
138 # error Unsupported byte order! | |
139 #endif | |
140 | |
141 #define FP_PRINTF(a) printf("%.8x:%.8x", FP_GETH(a), FP_GETL(a)) | |
142 #define FP_PRINTF32(a) printf("%.4x:%.4x", FP_GETH(a), FP_GETL(a)) | |
143 | |
144 #define FP_ADD(a, b) a.dw += b.dw | |
145 #define FP_SUB(a, b) a.dw -= b.dw | |
146 #define FP_ADD_R(r, a, b) r.dw = a.dw + b.dw | |
147 #define FP_SUB_R(r, a, b) r.dw = a.dw - b.dw | |
148 #define FP_DIV(a, b) a.dw /= b.dw | |
149 #define FP_MUL(a, b) a.dw *= b.dw | |
150 #define FP_DIV_R(r, a, b) r.dw = (a.dw / b.dw) | |
151 #define FP_MUL_R(r, a, b) r.dw = (a.dw * b.dw) | |
152 | |
153 | |
154 /* Miscellaneous types | |
155 */ | |
156 typedef struct | |
157 { | |
158 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
159 Uint8 a,g,b,r; | |
160 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
161 Uint8 r,g,b,a; | |
162 #endif | |
163 } DMRGBA32; | |
164 | |
165 | |
166 typedef float DMFloat; | |
167 | |
168 | |
118
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
169 // Macro for swapping two lvalues of same type |
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
170 #define DM_SWAP(T, A, B) { if ((B) < (A)) { T swtmp = (B); B = (A); A = swtmp; } } |
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
171 |
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
172 |
0 | 173 /* Drawing modes used by blitting and some other functions. |
174 */ | |
175 enum | |
176 { | |
177 DMD_NONE = 0x0000, | |
178 DMD_TRANSPARENT = 0x0001, | |
179 DMD_SATURATE = 0x0002, | |
180 | |
181 DMD_ANTIALIAS = 0x0004, | |
182 | |
183 DMD_NMODES = 6 | |
184 }; | |
185 | |
186 | |
187 // Available bitdepths. Not all functions may support every one of these. | |
188 enum | |
189 { | |
190 DMD_8BIT = 0, | |
191 DMD_32BIT, | |
192 | |
193 DMD_NBITDEPTHS | |
194 }; | |
195 | |
196 | |
197 static inline int dmBitsPerPixel2Index(int bpp) | |
198 { | |
199 return (bpp == 8 ? 0 : (bpp == 32 ? 1 : -1)); | |
200 } | |
201 | |
202 | |
203 /* Generic parameter interpolation | |
204 */ | |
205 #define DMM_S_CURVE(t) ((t) * (t) * (3.0f - 2.0f * (t))) | |
206 #define DMM_LERP(t, a, b) ((a) + (t) * ((b) - (a))) | |
207 | |
208 typedef struct | |
209 { | |
210 DMFloat start, end, nsteps; | |
211 } DMLerpContext; | |
212 | |
213 | |
214 void dmLerpInit(DMLerpContext *ctx, DMFloat start, DMFloat end, DMFloat nsteps); | |
108
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
215 DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
216 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
217 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
218 static inline DMFloat dmClamp10(const DMFloat a) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
219 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
220 return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
221 } |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
222 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
223 |
153
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
224 static inline int dmClamp(const int v, const int min, const int max) |
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
225 { |
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
226 return (v < min ? min : (v > max ? max : v)); |
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
227 } |
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
228 |
0b2866e25bf1
Add dmClamp(value, min, max) for clamping integer values.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
229 |
108
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
230 static inline DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
231 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
232 const DMFloat n = step / ctx->nsteps; |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
233 const DMFloat v = DMM_S_CURVE(n); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
234 return DMM_LERP(v, ctx->start, ctx->end); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
235 } |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
236 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
237 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
238 static inline DMFloat dmLerpSCurveClamp(DMLerpContext *ctx, const DMFloat step) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
239 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
240 const DMFloat n = dmClamp10(step / ctx->nsteps); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
241 const DMFloat v = DMM_S_CURVE(n); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
242 return DMM_LERP(v, ctx->start, ctx->end); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
243 } |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
244 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
245 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
246 static inline DMFloat dmLerp1(DMLerpContext *ctx, const DMFloat step) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
247 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
248 const DMFloat v = step / ctx->nsteps; |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
249 return DMM_LERP(v, ctx->start, ctx->end); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
250 } |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
251 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
252 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
253 static inline DMFloat dmLerp1Clamp(DMLerpContext *ctx, const DMFloat step) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
254 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
255 const DMFloat v = dmClamp10(step / ctx->nsteps); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
256 return DMM_LERP(v, ctx->start, ctx->end); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
257 } |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
258 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
259 |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
260 static inline DMFloat dmCatmullRomClamp(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3) |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
261 { |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
262 return dmCatmullRom(dmClamp10(t), p0, p1, p2, p3); |
72813cece1ba
Move some lerp functions to the header as static inline functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
263 } |
0 | 264 |
265 | |
266 /* Perlin noise | |
267 */ | |
268 void dmPerlinInit(void); | |
269 DMFloat dmPerlinNoise2D(DMFloat x, DMFloat y, DMFloat alpha, DMFloat beta, int n); | |
270 | |
271 | |
272 /* Arbitrary line drawing | |
273 */ | |
274 #ifdef DM_GFX_LINES | |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
275 #define DM_HEADER |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
276 #include "dmlinefunc.h" |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
277 |
262
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
278 enum |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
279 { |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
280 CLIP_TOP = 1, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
281 CLIP_BOTTOM = 2, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
282 CLIP_RIGHT = 4, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
283 CLIP_LEFT = 8 |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
284 }; |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
285 |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
286 #define DM_CLIP_FUNC dmClipLineCoordsFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
287 #define DM_COORD_TYPE DMFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
288 #include "dmlineclip.h" |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
289 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
290 #undef DM_HEADER |
0 | 291 #endif |
292 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
293 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
294 /* Various blitting functions |
0 | 295 */ |
296 #ifdef DM_GFX_BLITS | |
297 typedef int (*DMScaledBlitFunc)(SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst); | |
298 DMScaledBlitFunc dmGetScaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); | |
299 int dmScaledBlitSurfaceAny(SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst, int mode); | |
19
10f58ff516b3
Add function prototypes for two special case scaled blit functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
300 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
301 typedef int (*DMUnscaledBlitFunc)(SDL_Surface *src, const int x0, const int y0, SDL_Surface *dst); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
302 DMUnscaledBlitFunc dmGetUnscaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
303 int dmUnscaledBlitSurfaceAny(SDL_Surface *src, const int x0, const int y0, SDL_Surface *dst, int mode); |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
304 |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
305 SDL_Surface *dmConvertScaledSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags, const int dwidth, const int dheight); |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
306 |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
307 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
308 #define DM_HEADER |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
309 #include "dmblitfunc.h" |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
310 #undef DM_HEADER |
612
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
311 |
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
312 #endif // DM_GFX_BLITS |
0 | 313 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
314 |
0 | 315 /* Misc functions |
316 */ | |
317 #ifdef DM_GFX_MISC | |
612
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
318 |
0 | 319 void dmFillRect(SDL_Surface *screen, int x0, int y0, int x1, int y1, const Uint32 col); |
320 void dmDrawHLine(SDL_Surface *screen, int x0, int x1, int yc, const Uint32 col); | |
321 void dmDrawVLine(SDL_Surface *screen, int y0, int y1, int xc, const Uint32 col); | |
150
e147c07e41cb
Add dmDrawBox3D() and dmFillBox3D().
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
322 |
e147c07e41cb
Add dmDrawBox3D() and dmFillBox3D().
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
323 void dmDrawBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 ucol, Uint32 dcol); |
e147c07e41cb
Add dmDrawBox3D() and dmFillBox3D().
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
324 void dmFillBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 bgcol, Uint32 ucol, Uint32 dcol); |
e147c07e41cb
Add dmDrawBox3D() and dmFillBox3D().
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
325 |
612
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
326 #endif // DM_GFX_MISC |
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
327 |
90
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
328 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
329 static inline void dmClearSurface(SDL_Surface *screen, const Uint32 col) |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
330 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
331 SDL_FillRect(screen, NULL, col); |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
332 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
333 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
334 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
335 static inline Uint32 dmMapRGB(SDL_Surface *screen, int r, int g, int b) |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
336 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
337 return SDL_MapRGB(screen->format, r, g, b); |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
338 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
339 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
340 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
341 static inline Uint32 dmMapRGBA(SDL_Surface *screen, int r, int g, int b, int a) |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
342 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
343 return SDL_MapRGBA(screen->format, r, g, b, a); |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
344 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
345 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
346 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
347 static inline int dmDirectBlitSurface(SDL_Surface *bmp, SDL_Surface *screen) |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
348 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
349 return SDL_BlitSurface(bmp, NULL, screen, NULL); |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
350 } |
0 | 351 |
352 | |
611
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
353 static inline SDL_Surface *dmCopySurface(SDL_Surface *src) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
354 { |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
355 if (src != NULL) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
356 return SDL_ConvertSurface(src, src->format, src->flags); |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
357 else |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
358 return NULL; |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
359 } |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
360 |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
361 |
0 | 362 /* Global variables |
363 */ | |
364 extern char *dmProgName, | |
365 *dmProgDesc, | |
366 *dmProgVersion, | |
367 *dmProgAuthor, | |
368 *dmProgLicense; | |
369 | |
370 extern int dmVerbosity; | |
371 void dmInitProg(char *name, char *desc, char *version, char *author, char *license); | |
372 void dmPrintBanner(FILE *outFile, const char *name, const char *usage); | |
373 | |
374 void dmMsgVA(int level, const char *fmt, va_list ap); | |
375 void dmMsg(int level, const char *fmt, ...); | |
376 void dmPrintVA(int level, const char *fmt, va_list ap); | |
377 void dmPrint(int level, const char *fmt, ...); | |
378 void dmErrorVA(const char *fmt, va_list); | |
379 void dmError(const char *fmt, ...); | |
380 | |
381 void * dmMalloc(size_t); | |
382 void * dmMalloc0(size_t); | |
383 void * dmRealloc(void *, size_t); | |
384 void * dmCalloc(size_t, size_t); | |
385 void dmFree(void *); | |
386 | |
387 BOOL dmGetIntVal(const char *s, int *i); | |
388 | |
389 int dmGetErrno(); | |
390 const char *dmErrorStr(int error); | |
391 | |
392 char * dm_strdup(const char *); | |
744
2726d91e3409
Add implementation of dm_strndup().
Matti Hamalainen <ccr@tnsp.org>
parents:
612
diff
changeset
|
393 char * dm_strndup(const char *, const size_t n); |
0 | 394 char * dm_strdup_vprintf(const char *, va_list); |
395 char * dm_strdup_printf(const char *, ...); | |
396 | |
397 | |
294
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
398 /* Mutexes |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
399 */ |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
400 #ifdef DM_MUTEX_DEBUG |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
401 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
402 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
403 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
404 BOOL used; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
405 Uint32 id; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
406 int state; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
407 } DMMutexLock; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
408 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
409 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
410 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
411 char *cr_file; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
412 int cr_line; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
413 SDL_mutex *m; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
414 DMMutexLock locks[8]; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
415 } DMMutex; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
416 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
417 #define dmMutexLock(x) dmDOMutexLock(x, __FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
418 #define dmMutexUnlock(x) dmDOMutexUnlock(x, __FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
419 #define dmCreateMutex(x) dmDOCreateMutex(__FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
420 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
421 int dmDOMutexLock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
422 int dmDOMutexUnlock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
423 DMMutex * dmDOCreateMutex(const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
424 void dmDestroyMutex(DMMutex *mutex); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
425 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
426 #else |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
427 #define DMMutex SDL_mutex |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
428 #define dmCreateMutex() SDL_CreateMutex() |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
429 #define dmDestroyMutex(x) SDL_DestroyMutex(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
430 #define dmMutexLock(x) SDL_mutexP(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
431 #define dmMutexUnlock(x) SDL_mutexV(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
432 #endif |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
433 |
0 | 434 /* Endianess swapping macros |
435 */ | |
436 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ | |
437 (Uint16) ((Uint16) (value) >> 8) | \ | |
438 (Uint16) ((Uint16) (value) << 8)) ) | |
439 | |
440 | |
441 #define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ | |
442 (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ | |
443 (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ | |
444 (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ | |
445 (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) | |
446 | |
447 #ifdef DM_HAVE_64BIT | |
448 #define DM_SWAP_64_LE_BE(value) ((Uint64) ( \ | |
449 (((Uint64) (value) & (Uint64) 0x00000000000000ffULL) << 56) | \ | |
450 (((Uint64) (value) & (Uint64) 0x000000000000ff00ULL) << 40) | \ | |
451 (((Uint64) (value) & (Uint64) 0x0000000000ff0000ULL) << 24) | \ | |
452 (((Uint64) (value) & (Uint64) 0x00000000ff000000ULL) << 8) | \ | |
453 (((Uint64) (value) & (Uint64) 0x000000ff00000000ULL) >> 8) | \ | |
454 (((Uint64) (value) & (Uint64) 0x0000ff0000000000ULL) >> 24) | \ | |
455 (((Uint64) (value) & (Uint64) 0x00ff000000000000ULL) >> 40) | \ | |
456 (((Uint64) (value) & (Uint64) 0xff00000000000000ULL) >> 56))) | |
457 #endif | |
458 | |
459 /* Macros that swap only when needed ... | |
460 */ | |
461 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
770 | 462 # define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
463 # define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
464 # define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) | |
465 # define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 466 |
770 | 467 # define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) |
468 # define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) | |
469 # define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) | |
470 # define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) | |
0 | 471 |
770 | 472 # ifdef DM_HAVE_64BIT |
473 # define DM_LE64_TO_NATIVE(value) DM_SWAP_64_LE_BE(value) | |
474 # define DM_NATIVE_TO_LE64(value) DM_SWAP_64_LE_BE(value) | |
475 # define DM_BE64_TO_NATIVE(value) ((Uint64) (value)) | |
476 # define DM_NATIVE_TO_BE64(value) ((Uint64) (value)) | |
477 # endif | |
0 | 478 |
479 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
480 | |
770 | 481 # define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) |
482 # define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) | |
483 # define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) | |
484 # define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) | |
0 | 485 |
770 | 486 # define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
487 # define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
488 # define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) | |
489 # define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 490 |
770 | 491 # ifdef DM_HAVE_64BIT |
492 # define DM_LE64_TO_NATIVE(value) ((Uint64) (value)) | |
493 # define DM_NATIVE_TO_LE64(value) ((Uint64) (value)) | |
494 # define DM_BE64_TO_NATIVE(value) DM_SWAP_64_LE_BE(value) | |
495 # define DM_NATIVE_TO_BE64(value) DM_SWAP_64_LE_BE(value) | |
496 # endif | |
0 | 497 #endif |
498 | |
499 | |
500 #ifdef __cplusplus | |
501 } | |
502 #endif | |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
503 |
0 | 504 #endif // DMLIB_H |