Mercurial > hg > dmlib
annotate src/dmlib.h @ 1048:509e6ed3a24e
Finishing touches to the DM_DEBUG stuff.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 18:13:01 +0200 |
parents | b6c5e0c62588 |
children | e06abfde6c39 |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Main header file | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
863 | 5 * (C) Copyright 2011-2015 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> |
781
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
770
diff
changeset
|
14 #include <SDL_thread.h> |
288
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
15 #include <SDL_video.h> |
0 | 16 #include <stdarg.h> |
17 | |
18 #ifdef DM_USE_ASSERTS | |
770 | 19 # include <assert.h> |
0 | 20 #else |
770 | 21 # define assert(NEXPR) // stub |
0 | 22 #endif |
23 | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
24 |
0 | 25 #ifdef __cplusplus |
26 extern "C" { | |
27 #endif | |
28 | |
29 // Defaults | |
913 | 30 #define DM_PROG_AUTHOR "By Matti 'ccr' Hamalainen (C) Copyright 2015 TNSP" |
341 | 31 #define DM_PROG_LICENSE "Et all, see README / COPYING for more information." |
0 | 32 |
33 /* Error codes | |
34 */ | |
35 enum { | |
770 | 36 // General error codes |
37 DMERR_OK = 0, | |
38 DMERR_PROGRESS, // Status OK, but operation in progress | |
831
a855f88f86ee
Reorder internal error code.
Matti Hamalainen <ccr@tnsp.org>
parents:
816
diff
changeset
|
39 |
a855f88f86ee
Reorder internal error code.
Matti Hamalainen <ccr@tnsp.org>
parents:
816
diff
changeset
|
40 DMERR_INTERNAL, |
26
2f463a59d732
Implement rudimentary resource system.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
41 |
770 | 42 DMERR_FOPEN, |
43 DMERR_FREAD, | |
44 DMERR_FWRITE, | |
45 DMERR_FSEEK, | |
46 DMERR_NOT_FOUND, // Resource/data not found | |
0 | 47 |
770 | 48 DMERR_INVALID_DATA, // Some data was invalid |
49 DMERR_MALLOC, // Memory allocation failure | |
50 DMERR_ALREADY_INIT, // Resource has already been initialized | |
51 DMERR_INIT_FAIL, // General initialization failure | |
52 DMERR_INVALID_ARGS, | |
0 | 53 |
770 | 54 DMERR_NULLPTR, // NULL pointer specified in critical argument |
55 DMERR_NOT_SUPPORTED,// Operation not supported | |
56 DMERR_OUT_OF_DATA, | |
57 DMERR_EXTRA_DATA, | |
58 DMERR_BOUNDS, | |
908
03bda6477ad4
Add new error code DMERR_DATA_ERROR.
Matti Hamalainen <ccr@tnsp.org>
parents:
889
diff
changeset
|
59 |
03bda6477ad4
Add new error code DMERR_DATA_ERROR.
Matti Hamalainen <ccr@tnsp.org>
parents:
889
diff
changeset
|
60 DMERR_DATA_ERROR, // Data decoding/encoding/parsing error |
0 | 61 |
770 | 62 // PACK-file subsystem |
63 DMERR_NOTPACK, | |
64 DMERR_VERSION, | |
65 DMERR_INVALID, | |
66 DMERR_COMPRESSION, | |
0 | 67 }; |
68 | |
955 | 69 |
813 | 70 // Directory/path separator stuff |
71 #define DM_DIR_SEPARATOR '/' | |
72 | |
0 | 73 |
74 // Resource management defines | |
75 #define DMRES_NAME_LEN 32 | |
76 #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
|
77 #define DMRES_DATA_PATH "data/" // Sub-directory path |
0 | 78 #define DMRES_RES_FILE "res.txt" // Resource data file |
79 | |
80 | |
1047
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
81 /* File operations |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
82 */ |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
83 #ifdef HAVE_FSEEK64 |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
84 # define DM_FSEEK64 fseek64 |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
85 # define DM_FTELL64 ftell64 |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
86 #else |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
87 # define DM_FSEEK64 fseeko |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
88 # define DM_FTELL64 ftello |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
89 #endif |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
90 |
b6c5e0c62588
Move DM_FSEEK64() and DM_FTELL64() macro definitions to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1046
diff
changeset
|
91 |
0 | 92 /* Define a boolean type |
93 */ | |
94 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) | |
95 typedef enum { FALSE = 0, TRUE = 1 } BOOL; | |
96 #endif | |
97 | |
98 #ifndef BOOL | |
770 | 99 # ifdef bool |
100 # define BOOL bool | |
101 # else | |
102 # define BOOL int | |
103 # endif | |
0 | 104 #endif |
105 | |
106 | |
305
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
107 /* Math constants |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
108 */ |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
109 #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
|
110 #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
|
111 #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
|
112 |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
113 |
0 | 114 /* Fixed point math type |
115 */ | |
116 typedef union | |
117 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
118 Sint64 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
119 Sint32 w[2]; |
0 | 120 } DMFixedPoint; |
121 | |
122 | |
123 typedef union | |
124 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
125 Sint32 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
126 Sint16 w[2]; |
0 | 127 } DMFixedPoint32; |
128 | |
129 | |
130 /* Macros for fixed point math | |
131 */ | |
956
d4e411192238
Remove check for GCC >= 3.x, it's only sane to support 4+.
Matti Hamalainen <ccr@tnsp.org>
parents:
955
diff
changeset
|
132 #define FP_SET(a, k) a.dw = k ## ULL |
138
459a1be2bd0f
A minor improvement to FP_CONV() fixed point macro.
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
133 #define FP_CONV(a, k) a.dw = (k) |
0 | 134 |
135 #ifndef SDL_BYTEORDER | |
136 # error Undefined byteorder! | |
137 #endif | |
138 | |
139 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
140 # define FP_SETH(a, k) a.w[0] = (k) | |
141 # define FP_SETL(a, k) a.w[1] = (k) | |
142 # define FP_SETHL(a, h, l) { a.w[0] = (h); a.w[1] = (l); } | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
143 # define FP_GETH32(a) a.w[0] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
144 # define FP_GETL32(a) a.w[1] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
145 # define FP_GETH16(a) a.w[0] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
146 # define FP_GETL16(a) a.w[1] |
0 | 147 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) |
148 # define FP_SETH(a, k) a.w[1] = (k) | |
149 # define FP_SETL(a, k) a.w[0] = (k) | |
150 # define FP_SETHL(a, h, l) { a.w[1] = (h); a.w[0] = (l); } | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
151 # define FP_GETH32(a) a.w[1] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
152 # define FP_GETL32(a) a.w[0] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
153 # define FP_GETH16(a) a.w[1] |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
154 # define FP_GETL16(a) a.w[0] |
0 | 155 #else |
156 # error Unsupported byte order! | |
157 #endif | |
158 | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
159 #define FP_PRINTF64(a) printf("%.8x:%.8x", FP_GETH32(a), FP_GETL32(a)) |
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
160 #define FP_PRINTF32(a) printf("%.4x:%.4x", FP_GETH16(a), FP_GETL16(a)) |
0 | 161 |
162 #define FP_ADD(a, b) a.dw += b.dw | |
163 #define FP_SUB(a, b) a.dw -= b.dw | |
164 #define FP_ADD_R(r, a, b) r.dw = a.dw + b.dw | |
165 #define FP_SUB_R(r, a, b) r.dw = a.dw - b.dw | |
166 #define FP_DIV(a, b) a.dw /= b.dw | |
167 #define FP_MUL(a, b) a.dw *= b.dw | |
168 #define FP_DIV_R(r, a, b) r.dw = (a.dw / b.dw) | |
169 #define FP_MUL_R(r, a, b) r.dw = (a.dw * b.dw) | |
170 | |
171 | |
172 /* Miscellaneous types | |
173 */ | |
174 typedef struct | |
175 { | |
176 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
177 Uint8 a,g,b,r; | |
178 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
179 Uint8 r,g,b,a; | |
180 #endif | |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
181 } DMColor; |
0 | 182 |
183 | |
184 typedef float DMFloat; | |
185 | |
186 | |
118
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
187 // 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
|
188 #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
|
189 |
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
190 |
0 | 191 /* Drawing modes used by blitting and some other functions. |
192 */ | |
193 enum | |
194 { | |
195 DMD_NONE = 0x0000, | |
196 DMD_TRANSPARENT = 0x0001, | |
197 DMD_SATURATE = 0x0002, | |
198 | |
199 DMD_ANTIALIAS = 0x0004, | |
200 | |
201 DMD_NMODES = 6 | |
202 }; | |
203 | |
204 | |
205 // Available bitdepths. Not all functions may support every one of these. | |
206 enum | |
207 { | |
208 DMD_8BIT = 0, | |
209 DMD_32BIT, | |
210 | |
211 DMD_NBITDEPTHS | |
212 }; | |
213 | |
214 | |
215 static inline int dmBitsPerPixel2Index(int bpp) | |
216 { | |
217 return (bpp == 8 ? 0 : (bpp == 32 ? 1 : -1)); | |
218 } | |
219 | |
220 | |
980
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
221 static inline DMFloat dmClamp10(const DMFloat a) |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
222 { |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
223 return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
224 } |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
225 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
226 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
227 static inline int dmClamp(const int v, const int min, const int max) |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
228 { |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
229 return (v < min ? min : (v > max ? max : v)); |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
230 } |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
231 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
232 |
0 | 233 /* Arbitrary line drawing |
234 */ | |
235 #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
|
236 #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
|
237 #include "dmlinefunc.h" |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
238 |
262
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
239 enum |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
240 { |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
241 CLIP_TOP = 1, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
242 CLIP_BOTTOM = 2, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
243 CLIP_RIGHT = 4, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
244 CLIP_LEFT = 8 |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
245 }; |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
246 |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
247 #define DM_CLIP_FUNC dmClipLineCoordsFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
248 #define DM_COORD_TYPE DMFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
249 #include "dmlineclip.h" |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
250 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
251 #undef DM_HEADER |
0 | 252 #endif |
253 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
254 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
255 /* Various blitting functions |
0 | 256 */ |
257 #ifdef DM_GFX_BLITS | |
258 typedef int (*DMScaledBlitFunc)(SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst); | |
259 DMScaledBlitFunc dmGetScaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); | |
260 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
|
261 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
262 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
|
263 DMUnscaledBlitFunc dmGetUnscaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
264 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
|
265 |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
266 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
|
267 |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
268 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
269 #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
|
270 #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
|
271 #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
|
272 |
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
273 #endif // DM_GFX_BLITS |
0 | 274 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
275 |
0 | 276 /* Misc functions |
277 */ | |
278 #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
|
279 |
0 | 280 void dmFillRect(SDL_Surface *screen, int x0, int y0, int x1, int y1, const Uint32 col); |
281 void dmDrawHLine(SDL_Surface *screen, int x0, int x1, int yc, const Uint32 col); | |
282 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
|
283 |
e147c07e41cb
Add dmDrawBox3D() and dmFillBox3D().
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
284 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
|
285 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
|
286 |
612
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
287 #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
|
288 |
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
|
289 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
290 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
|
291 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
292 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
|
293 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
294 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
295 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
296 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
|
297 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
298 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
|
299 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
300 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
301 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
302 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
|
303 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
304 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
|
305 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
306 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
307 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
308 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
|
309 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
310 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
|
311 } |
0 | 312 |
313 | |
611
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
314 static inline SDL_Surface *dmCopySurface(SDL_Surface *src) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
315 { |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
316 if (src != NULL) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
317 return SDL_ConvertSurface(src, src->format, src->flags); |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
318 else |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
319 return NULL; |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
320 } |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
321 |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
322 |
0 | 323 /* Global variables |
324 */ | |
325 extern char *dmProgName, | |
326 *dmProgDesc, | |
327 *dmProgVersion, | |
328 *dmProgAuthor, | |
329 *dmProgLicense; | |
330 | |
331 extern int dmVerbosity; | |
332 void dmInitProg(char *name, char *desc, char *version, char *author, char *license); | |
333 void dmPrintBanner(FILE *outFile, const char *name, const char *usage); | |
334 | |
335 void dmMsgVA(int level, const char *fmt, va_list ap); | |
336 void dmMsg(int level, const char *fmt, ...); | |
337 void dmPrintVA(int level, const char *fmt, va_list ap); | |
338 void dmPrint(int level, const char *fmt, ...); | |
339 | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
956
diff
changeset
|
340 int dmErrorVA(const int error, const char *fmt, va_list); |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
956
diff
changeset
|
341 int dmError(const int error, const char *fmt, ...); |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
956
diff
changeset
|
342 void dmErrorMsg(const char *fmt, ...); |
955 | 343 int dmGetErrno(); |
344 const char *dmErrorStr(const int error); | |
345 | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
346 #ifdef DM_DEBUG |
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
347 # define dmErrorDBG dmError |
1048
509e6ed3a24e
Finishing touches to the DM_DEBUG stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
1047
diff
changeset
|
348 # define dmErrorDBGMsg dmErrorMsg |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
349 #else |
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
350 # define dmErrorDBG(ecode, fmt, ...) (ecode) // Dummy |
1048
509e6ed3a24e
Finishing touches to the DM_DEBUG stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
1047
diff
changeset
|
351 # define dmErrorDBGMsg(fmt, ...) |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
352 #endif |
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
353 |
0 | 354 void * dmMalloc(size_t); |
355 void * dmMalloc0(size_t); | |
356 void * dmRealloc(void *, size_t); | |
357 void * dmCalloc(size_t, size_t); | |
358 void dmFree(void *); | |
359 | |
360 char * dm_strdup(const char *); | |
744
2726d91e3409
Add implementation of dm_strndup().
Matti Hamalainen <ccr@tnsp.org>
parents:
612
diff
changeset
|
361 char * dm_strndup(const char *, const size_t n); |
0 | 362 char * dm_strdup_vprintf(const char *, va_list); |
363 char * dm_strdup_printf(const char *, ...); | |
364 | |
813 | 365 char * dm_basefilename(const char *filename); |
366 char * dm_strdup_fext(const char *filename, const char *fmt); | |
816 | 367 char * dm_strrcasecmp(char *str, const char *needle); |
0 | 368 |
955 | 369 BOOL dmGetIntVal(const char *s, unsigned int *i); |
370 | |
371 | |
294
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
372 /* Mutexes |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
373 */ |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
374 #ifdef DM_MUTEX_DEBUG |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
375 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
376 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
377 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
378 BOOL used; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
379 Uint32 id; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
380 int state; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
381 } DMMutexLock; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
382 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
383 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
384 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
385 char *cr_file; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
386 int cr_line; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
387 SDL_mutex *m; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
388 DMMutexLock locks[8]; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
389 } DMMutex; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
390 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
391 #define dmMutexLock(x) dmDOMutexLock(x, __FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
392 #define dmMutexUnlock(x) dmDOMutexUnlock(x, __FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
393 #define dmCreateMutex(x) dmDOCreateMutex(__FILE__, (int) __LINE__) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
394 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
395 int dmDOMutexLock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
396 int dmDOMutexUnlock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
397 DMMutex * dmDOCreateMutex(const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
398 void dmDestroyMutex(DMMutex *mutex); |
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 #else |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
401 #define DMMutex SDL_mutex |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
402 #define dmCreateMutex() SDL_CreateMutex() |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
403 #define dmDestroyMutex(x) SDL_DestroyMutex(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
404 #define dmMutexLock(x) SDL_mutexP(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
405 #define dmMutexUnlock(x) SDL_mutexV(x) |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
406 #endif |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
407 |
0 | 408 /* Endianess swapping macros |
409 */ | |
955 | 410 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ |
0 | 411 (Uint16) ((Uint16) (value) >> 8) | \ |
412 (Uint16) ((Uint16) (value) << 8)) ) | |
413 | |
414 | |
955 | 415 #define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ |
0 | 416 (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ |
417 (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ | |
418 (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ | |
419 (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) | |
420 | |
955 | 421 #define DM_SWAP_64_LE_BE(value) ((Uint64) ( \ |
422 (((Uint64) (value) & (Uint64) 0x00000000000000ffULL) << 56) | \ | |
423 (((Uint64) (value) & (Uint64) 0x000000000000ff00ULL) << 40) | \ | |
424 (((Uint64) (value) & (Uint64) 0x0000000000ff0000ULL) << 24) | \ | |
425 (((Uint64) (value) & (Uint64) 0x00000000ff000000ULL) << 8) | \ | |
426 (((Uint64) (value) & (Uint64) 0x000000ff00000000ULL) >> 8) | \ | |
427 (((Uint64) (value) & (Uint64) 0x0000ff0000000000ULL) >> 24) | \ | |
428 (((Uint64) (value) & (Uint64) 0x00ff000000000000ULL) >> 40) | \ | |
0 | 429 (((Uint64) (value) & (Uint64) 0xff00000000000000ULL) >> 56))) |
873 | 430 |
0 | 431 |
432 /* Macros that swap only when needed ... | |
433 */ | |
434 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
770 | 435 # define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
436 # define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
437 # define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) | |
438 # define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 439 |
770 | 440 # define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) |
441 # define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) | |
442 # define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) | |
443 # define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) | |
0 | 444 |
872
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
445 # define DM_LE64_TO_NATIVE(value) DM_SWAP_64_LE_BE(value) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
446 # define DM_NATIVE_TO_LE64(value) DM_SWAP_64_LE_BE(value) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
447 # define DM_BE64_TO_NATIVE(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
448 # define DM_NATIVE_TO_BE64(value) ((Uint64) (value)) |
0 | 449 |
450 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
451 | |
770 | 452 # define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) |
453 # define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) | |
454 # define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) | |
455 # define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) | |
0 | 456 |
770 | 457 # define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
458 # define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
459 # define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) | |
460 # define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 461 |
872
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
462 # define DM_LE64_TO_NATIVE(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
463 # define DM_NATIVE_TO_LE64(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
464 # define DM_BE64_TO_NATIVE(value) DM_SWAP_64_LE_BE(value) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
465 # define DM_NATIVE_TO_BE64(value) DM_SWAP_64_LE_BE(value) |
0 | 466 #endif |
467 | |
468 | |
469 #ifdef __cplusplus | |
470 } | |
471 #endif | |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
472 |
0 | 473 #endif // DMLIB_H |