Mercurial > hg > dmlib
annotate src/dmlib.h @ 2550:c58cd7797aff
Bump copyright years.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 25 Feb 2022 15:33:38 +0200 |
parents | b544a8e32a35 |
children | ef6c826c5b7a |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Main header file | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
2550 | 5 * (C) Copyright 2011-2022 Tecnic Software productions (TNSP) |
0 | 6 */ |
7 #ifndef DMLIB_H | |
8 #define DMLIB_H | |
9 | |
2542
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
10 // Meh, this is a hack due to the crap non-portability of 64bit |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
11 // printf PRI* type specifiers/modifiers |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
12 #if !defined(DM_USE_BONK_TYPES) && (defined(__MINGW32__) || defined(__MINGW64__)) |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
13 # define __USE_MINGW_ANSI_STDIO 1 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
14 #endif |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
15 |
288
e2f286781180
Use more glanular header includes from SDL, enables us to succesfully link
Matti Hamalainen <ccr@tnsp.org>
parents:
265
diff
changeset
|
16 #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
|
17 #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
|
18 #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
|
19 #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
|
20 #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
|
21 #include <SDL_video.h> |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1554
diff
changeset
|
22 #include <SDL_render.h> |
1554
7ed25973dbcb
Add some missing includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1453
diff
changeset
|
23 #include <stdio.h> |
0 | 24 #include <stdarg.h> |
1554
7ed25973dbcb
Add some missing includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1453
diff
changeset
|
25 #include <stdlib.h> |
7ed25973dbcb
Add some missing includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1453
diff
changeset
|
26 #include <ctype.h> |
2392
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
27 #include <inttypes.h> |
2424
3b28868475e8
Remember to include <string.h> for memset() now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2414
diff
changeset
|
28 #include <string.h> |
1554
7ed25973dbcb
Add some missing includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1453
diff
changeset
|
29 |
0 | 30 |
31 #ifdef DM_USE_ASSERTS | |
770 | 32 # include <assert.h> |
0 | 33 #else |
770 | 34 # define assert(NEXPR) // stub |
0 | 35 #endif |
36 | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
37 |
1143
e7c3de96b6fd
Check if we are compiling for Windows and if we are compiling under MINGW.
Matti Hamalainen <ccr@tnsp.org>
parents:
1106
diff
changeset
|
38 // Check for arch bitness |
e7c3de96b6fd
Check if we are compiling for Windows and if we are compiling under MINGW.
Matti Hamalainen <ccr@tnsp.org>
parents:
1106
diff
changeset
|
39 #if defined(__WIN64) || defined(_WIN64) || defined(_WIN32) || defined(__WIN32) |
2394
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
40 # define DM_PLAT_WINDOWS 1 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
41 #else |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
42 # define DM_PLAT_UNIX 1 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
43 #endif |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
44 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
45 // Check for arch bitness |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
46 #if !defined(DM_ARCH) && (defined(__WIN64) || defined(_WIN64)) |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
47 # define DM_ARCH 64 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
48 #endif |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
49 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
50 #if !defined(DM_ARCH) && (defined(__WIN32) || defined(_WIN32)) |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
51 # define DM_ARCH 32 |
1143
e7c3de96b6fd
Check if we are compiling for Windows and if we are compiling under MINGW.
Matti Hamalainen <ccr@tnsp.org>
parents:
1106
diff
changeset
|
52 #endif |
1145
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
53 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
54 #if !defined(DM_ARCH) |
2394
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
55 # if UINTPTR_MAX == 0xffffffff |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
56 # define DM_ARCH 32 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
57 # elif UINTPTR_MAX == 0xffffffffffffffff |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
58 # define DM_ARCH 64 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
59 # endif |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
60 #endif |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
61 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
62 |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
63 #if !defined(DM_ARCH) |
147d40b708ea
Copy improvements to the platform 32/64bit logic from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2393
diff
changeset
|
64 # if defined(__LP64__) || defined(_LP64) |
1145
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
65 # define DM_ARCH 64 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
66 # else |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
67 # define DM_ARCH 32 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
68 # endif |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
69 #endif |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
70 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
71 |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
72 // Kludge, as MinGW64 cross-compiler does not like certain printf() format specifiers |
2542
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
73 #if defined(__MINGW32__) || defined(__MINGW64__) |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
74 # define DM_ATTR_PRINTF_FMT(xstart, xend) |
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
75 #else |
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
76 # define DM_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) |
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
77 #endif |
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
78 |
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
79 |
1145
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
80 // Do we have a valid arch? |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
81 // If so, set some printf specifiers |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
82 #if DM_ARCH == 32 |
2542
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
83 # define DM_PRIu32 PRIu32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
84 # define DM_PRId32 PRId32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
85 # define DM_PRIx32 PRIx32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
86 # define DM_PRIX32 PRIX32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
87 # ifdef TH_USE_BONK_TYPES |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
88 # define DM_PRIu64 "lld" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
89 # define DM_PRId64 "lld" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
90 # define DM_PRIx64 "llx" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
91 # define DM_PRIX64 "llX" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
92 # define DM_PRId_OFF_T "ld" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
93 # define DM_PRIx_OFF_T "lx" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
94 # define DM_PRIX_OFF_T "lX" |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
95 # else |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
96 # define DM_PRIu64 PRIu64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
97 # define DM_PRId64 PRId64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
98 # define DM_PRIx64 PRIx64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
99 # define DM_PRIX64 PRIX64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
100 # define DM_PRId_OFF_T PRId32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
101 # define DM_PRIx_OFF_T PRIx32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
102 # define DM_PRIX_OFF_T PRIX32 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
103 # endif |
2392
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
104 # define DM_PRIu_SIZE_T PRIu32 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
105 # define DM_PRId_SSIZE_T PRId32 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
106 # define DM_PRIx_SIZE_T PRIx32 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
107 # define DM_PRIX_SIZE_T PRIX32 |
2542
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
108 |
1145
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
109 #elif DM_ARCH == 64 |
2542
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
110 # define DM_PRIu64 PRIu64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
111 # define DM_PRId64 PRId64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
112 # define DM_PRIx64 PRIx64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
113 # define DM_PRIX64 PRIX64 |
b544a8e32a35
Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
114 # ifdef TH_USE_BONK_TYPES |
2392
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
115 # define DM_PRIu_SIZE_T "I64u" |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
116 # define DM_PRId_SSIZE_T "I64d" |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
117 # define DM_PRIx_SIZE_T "I64x" |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
118 # define DM_PRIX_SIZE_T "I64X" |
2393
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
119 # define DM_PRId_OFF_T "I64d" |
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
120 # define DM_PRIx_OFF_T "I64x" |
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
121 # define DM_PRIX_OFF_T "I64X" |
2353
a1265a407524
Fix / improve DM_PRI* constants generated for Windows 64bit platform.
Matti Hamalainen <ccr@tnsp.org>
parents:
2352
diff
changeset
|
122 # else |
2392
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
123 # define DM_PRIu_SIZE_T PRIu64 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
124 # define DM_PRId_SSIZE_T PRId64 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
125 # define DM_PRIx_SIZE_T PRIx64 |
835b231d8083
Use standard inttypes.h for defining the DM_PRI* format specifiers, except
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
126 # define DM_PRIX_SIZE_T PRIX64 |
2393
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
127 # define DM_PRId_OFF_T PRId64 |
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
128 # define DM_PRIx_OFF_T PRIx64 |
85700c9b7dc8
Add new DM_PRI*_OFF_T specifiers for off_t type.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
129 # define DM_PRIX_OFF_T PRIX64 |
2353
a1265a407524
Fix / improve DM_PRI* constants generated for Windows 64bit platform.
Matti Hamalainen <ccr@tnsp.org>
parents:
2352
diff
changeset
|
130 # endif |
1145
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
131 #else |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
132 # error Could not determine architecture (32/64bit), please define DM_ARCH=32 or 64 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
133 #endif |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
134 |
af2c9f76c782
MinGW does not define PRI* format specifiers, so define them ourselves :S
Matti Hamalainen <ccr@tnsp.org>
parents:
1143
diff
changeset
|
135 |
0 | 136 #ifdef __cplusplus |
137 extern "C" { | |
138 #endif | |
139 | |
140 // Defaults | |
2550 | 141 #define DM_PROG_AUTHOR "By Matti 'ccr' Hamalainen (C) Copyright 2002-2022 TNSP" |
2410
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2404
diff
changeset
|
142 #define DM_PROG_LICENSE "This program is distributed under a 3-clause BSD -style license." |
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2404
diff
changeset
|
143 |
0 | 144 |
145 /* Error codes | |
146 */ | |
147 enum { | |
770 | 148 // General error codes |
149 DMERR_OK = 0, | |
150 DMERR_PROGRESS, // Status OK, but operation in progress | |
831
a855f88f86ee
Reorder internal error code.
Matti Hamalainen <ccr@tnsp.org>
parents:
816
diff
changeset
|
151 |
a855f88f86ee
Reorder internal error code.
Matti Hamalainen <ccr@tnsp.org>
parents:
816
diff
changeset
|
152 DMERR_INTERNAL, |
26
2f463a59d732
Implement rudimentary resource system.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
153 |
770 | 154 DMERR_FOPEN, |
155 DMERR_FREAD, | |
156 DMERR_FWRITE, | |
157 DMERR_FSEEK, | |
158 DMERR_NOT_FOUND, // Resource/data not found | |
0 | 159 |
770 | 160 DMERR_INVALID_DATA, // Some data was invalid |
161 DMERR_MALLOC, // Memory allocation failure | |
162 DMERR_ALREADY_INIT, // Resource has already been initialized | |
163 DMERR_INIT_FAIL, // General initialization failure | |
164 DMERR_INVALID_ARGS, | |
0 | 165 |
770 | 166 DMERR_NULLPTR, // NULL pointer specified in critical argument |
167 DMERR_NOT_SUPPORTED,// Operation not supported | |
168 DMERR_OUT_OF_DATA, | |
169 DMERR_EXTRA_DATA, | |
170 DMERR_BOUNDS, | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1048
diff
changeset
|
171 |
908
03bda6477ad4
Add new error code DMERR_DATA_ERROR.
Matti Hamalainen <ccr@tnsp.org>
parents:
889
diff
changeset
|
172 DMERR_DATA_ERROR, // Data decoding/encoding/parsing error |
1817 | 173 |
1273
132706e3b94b
Improve error handling and reporting slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1172
diff
changeset
|
174 DMERR_VERSION, // Unsupported data version |
0 | 175 |
770 | 176 // PACK-file subsystem |
177 DMERR_NOTPACK, | |
1273
132706e3b94b
Improve error handling and reporting slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1172
diff
changeset
|
178 DMERR_PACK_VERSION, |
770 | 179 DMERR_INVALID, |
180 DMERR_COMPRESSION, | |
0 | 181 }; |
182 | |
955 | 183 |
813 | 184 // Directory/path separator stuff |
185 #define DM_DIR_SEPARATOR '/' | |
186 | |
0 | 187 |
188 // Resource management defines | |
189 #define DMRES_NAME_LEN 32 | |
190 #define DMRES_RES_FILE "res.txt" // Resource data file | |
191 | |
192 | |
193 /* Define a boolean type | |
194 */ | |
195 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) | |
196 typedef enum { FALSE = 0, TRUE = 1 } BOOL; | |
197 #endif | |
198 | |
199 #ifndef BOOL | |
770 | 200 # ifdef bool |
201 # define BOOL bool | |
202 # else | |
203 # define BOOL int | |
204 # endif | |
0 | 205 #endif |
206 | |
207 | |
305
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
208 /* Math constants |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
209 */ |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
210 #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
|
211 #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
|
212 #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
|
213 |
036fde2fd630
Add mathematical constants DM_PI, DM_PI2 and DM_E.
Matti Hamalainen <ccr@tnsp.org>
parents:
294
diff
changeset
|
214 |
1146 | 215 /* Fixed point math types |
0 | 216 */ |
217 typedef union | |
218 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
219 Sint64 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
220 Sint32 w[2]; |
0 | 221 } DMFixedPoint; |
222 | |
223 | |
224 typedef union | |
225 { | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
226 Sint32 dw; |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
227 Sint16 w[2]; |
0 | 228 } DMFixedPoint32; |
229 | |
230 | |
231 /* Macros for fixed point math | |
232 */ | |
956
d4e411192238
Remove check for GCC >= 3.x, it's only sane to support 4+.
Matti Hamalainen <ccr@tnsp.org>
parents:
955
diff
changeset
|
233 #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
|
234 #define FP_CONV(a, k) a.dw = (k) |
0 | 235 |
236 #ifndef SDL_BYTEORDER | |
237 # error Undefined byteorder! | |
238 #endif | |
239 | |
240 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
241 # define FP_SETH(a, k) a.w[0] = (k) | |
242 # define FP_SETL(a, k) a.w[1] = (k) | |
243 # 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
|
244 # 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
|
245 # 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
|
246 # 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
|
247 # define FP_GETL16(a) a.w[1] |
0 | 248 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) |
249 # define FP_SETH(a, k) a.w[1] = (k) | |
250 # define FP_SETL(a, k) a.w[0] = (k) | |
251 # 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
|
252 # 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
|
253 # 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
|
254 # 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
|
255 # define FP_GETL16(a) a.w[0] |
0 | 256 #else |
257 # error Unsupported byte order! | |
258 #endif | |
259 | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
805
diff
changeset
|
260 #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
|
261 #define FP_PRINTF32(a) printf("%.4x:%.4x", FP_GETH16(a), FP_GETL16(a)) |
0 | 262 |
263 #define FP_ADD(a, b) a.dw += b.dw | |
264 #define FP_SUB(a, b) a.dw -= b.dw | |
265 #define FP_ADD_R(r, a, b) r.dw = a.dw + b.dw | |
266 #define FP_SUB_R(r, a, b) r.dw = a.dw - b.dw | |
267 #define FP_DIV(a, b) a.dw /= b.dw | |
268 #define FP_MUL(a, b) a.dw *= b.dw | |
269 #define FP_DIV_R(r, a, b) r.dw = (a.dw / b.dw) | |
270 #define FP_MUL_R(r, a, b) r.dw = (a.dw * b.dw) | |
271 | |
272 | |
273 /* Miscellaneous types | |
274 */ | |
275 typedef struct | |
276 { | |
277 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
278 Uint8 a,g,b,r; | |
279 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
280 Uint8 r,g,b,a; | |
281 #endif | |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
282 } DMColor; |
0 | 283 |
284 | |
285 typedef float DMFloat; | |
286 | |
287 | |
118
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
288 // Macro for swapping two lvalues of same type |
2486
6d12670e0248
Rename DM_SWAP() macro to DM_SWAP_IF().
Matti Hamalainen <ccr@tnsp.org>
parents:
2424
diff
changeset
|
289 #define DM_SWAP(T, A, B) { T swtmp = (B); B = (A); A = swtmp; } |
6d12670e0248
Rename DM_SWAP() macro to DM_SWAP_IF().
Matti Hamalainen <ccr@tnsp.org>
parents:
2424
diff
changeset
|
290 #define DM_SWAP_IF(T, A, B) { if ((B) < (A)) { T swtmp = (B); B = (A); A = swtmp; } } |
118
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
291 |
c36e0316de9f
Move DM_SWAP() macro to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
292 |
0 | 293 /* Drawing modes used by blitting and some other functions. |
294 */ | |
295 enum | |
296 { | |
297 DMD_NONE = 0x0000, | |
298 DMD_TRANSPARENT = 0x0001, | |
299 DMD_SATURATE = 0x0002, | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1048
diff
changeset
|
300 |
0 | 301 DMD_ANTIALIAS = 0x0004, |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1048
diff
changeset
|
302 |
0 | 303 DMD_NMODES = 6 |
304 }; | |
305 | |
306 | |
307 // Available bitdepths. Not all functions may support every one of these. | |
308 enum | |
309 { | |
310 DMD_8BIT = 0, | |
311 DMD_32BIT, | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1048
diff
changeset
|
312 |
0 | 313 DMD_NBITDEPTHS |
314 }; | |
315 | |
316 | |
317 static inline int dmBitsPerPixel2Index(int bpp) | |
318 { | |
319 return (bpp == 8 ? 0 : (bpp == 32 ? 1 : -1)); | |
320 } | |
321 | |
322 | |
980
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
323 static inline DMFloat dmClamp10(const DMFloat a) |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
324 { |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
325 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
|
326 } |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
327 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
328 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
329 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
|
330 { |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
331 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
|
332 } |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
333 |
43594ac98f91
Move dmClamp*() functions back to dmlib.h
Matti Hamalainen <ccr@tnsp.org>
parents:
976
diff
changeset
|
334 |
0 | 335 /* Arbitrary line drawing |
336 */ | |
337 #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
|
338 #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
|
339 #include "dmlinefunc.h" |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
340 |
262
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
341 enum |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
342 { |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
343 CLIP_TOP = 1, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
344 CLIP_BOTTOM = 2, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
345 CLIP_RIGHT = 4, |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
346 CLIP_LEFT = 8 |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
347 }; |
9d015d32841a
Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
348 |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
349 #define DM_CLIP_FUNC dmClipLineCoordsFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
350 #define DM_COORD_TYPE DMFloat |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
351 #include "dmlineclip.h" |
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
352 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
353 #undef DM_HEADER |
0 | 354 #endif |
355 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
356 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
357 /* Various blitting functions |
0 | 358 */ |
359 #ifdef DM_GFX_BLITS | |
360 typedef int (*DMScaledBlitFunc)(SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst); | |
361 DMScaledBlitFunc dmGetScaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); | |
362 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
|
363 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
364 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
|
365 DMUnscaledBlitFunc dmGetUnscaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
366 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
|
367 |
1601
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
368 SDL_Surface *dmConvertScaledSurface(SDL_Surface *src, SDL_PixelFormat *fmt, const int dwidth, const int dheight); |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
369 |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
370 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
371 #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
|
372 #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
|
373 #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
|
374 |
696f03f30c0e
Make certain static inline graphics functions always available, no need to
Matti Hamalainen <ccr@tnsp.org>
parents:
611
diff
changeset
|
375 #endif // DM_GFX_BLITS |
0 | 376 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
377 |
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
|
378 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
|
379 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
380 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
|
381 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
382 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
383 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
384 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
|
385 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
386 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
|
387 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
388 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
389 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
390 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
|
391 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
392 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
|
393 } |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
394 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
395 |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
396 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
|
397 { |
1ab3fd8b9afc
Move some very tiny gfx functions to the dmlib header as static inline ones.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
398 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
|
399 } |
0 | 400 |
401 | |
611
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
402 static inline SDL_Surface *dmCopySurface(SDL_Surface *src) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
403 { |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
404 if (src != NULL) |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
405 return SDL_ConvertSurface(src, src->format, src->flags); |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
406 else |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
407 return NULL; |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
408 } |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
409 |
828d86cd10e0
Add new dmCopySurface() helper/wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
410 |
0 | 411 /* Global variables |
412 */ | |
2404 | 413 extern char |
414 *dmProgName, | |
415 *dmProgDesc, | |
416 *dmProgVersion, | |
417 *dmProgAuthor, | |
418 *dmProgLicense; | |
419 | |
0 | 420 |
421 extern int dmVerbosity; | |
422 void dmInitProg(char *name, char *desc, char *version, char *author, char *license); | |
423 void dmPrintBanner(FILE *outFile, const char *name, const char *usage); | |
2410
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2404
diff
changeset
|
424 void dmPrintLicense(FILE *outFile); |
0 | 425 |
426 void dmMsgVA(int level, const char *fmt, va_list ap); | |
2383
43e39d9ec42f
Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents:
2361
diff
changeset
|
427 void dmMsg(int level, const char *fmt, ...) |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
428 DM_ATTR_PRINTF_FMT(2, 3); |
0 | 429 void dmPrintVA(int level, const char *fmt, va_list ap); |
2383
43e39d9ec42f
Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents:
2361
diff
changeset
|
430 void dmPrint(int level, const char *fmt, ...) |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
431 DM_ATTR_PRINTF_FMT(2, 3); |
0 | 432 |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
956
diff
changeset
|
433 int dmErrorVA(const int error, const char *fmt, va_list); |
2383
43e39d9ec42f
Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents:
2361
diff
changeset
|
434 int dmError(const int error, const char *fmt, ...) |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
435 DM_ATTR_PRINTF_FMT(2, 3); |
2383
43e39d9ec42f
Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents:
2361
diff
changeset
|
436 void dmErrorMsg(const char *fmt, ...) |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
437 DM_ATTR_PRINTF_FMT(1, 2); |
955 | 438 int dmGetErrno(); |
439 const char *dmErrorStr(const int error); | |
440 | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
441 #ifdef DM_DEBUG |
2404 | 442 # define dmErrorDBG dmError |
443 # define dmErrorDBGMsg dmErrorMsg | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
444 #else |
2404 | 445 # define dmErrorDBG(ecode, fmt, ...) (ecode) // Dummy |
446 # define dmErrorDBGMsg(fmt, ...) | |
1046
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
447 #endif |
7e54b2d08ce7
Add special debug error message function/macro that can be
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
448 |
1451 | 449 void * dmMalloc(size_t len); |
450 void * dmMalloc0(size_t len); | |
451 void * dmRealloc(void *ptr, size_t len); | |
452 void * dmCalloc(size_t n, size_t len); | |
453 void dmFree(void *ptr); | |
1453
73a4158b2e55
Add missing dmFreeRReal() function prototype.
Matti Hamalainen <ccr@tnsp.org>
parents:
1452
diff
changeset
|
454 void dmFreeRReal(void **ptr); |
1452
3a1f4e810874
Add dmFreeR() macro/function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1451
diff
changeset
|
455 #define dmFreeR(ptr) dmFreeRReal((void **) ptr) |
1451 | 456 |
2027
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
457 |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
458 /** String trimming option flags for dm_strdup_trim() |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
459 */ |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
460 enum |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
461 { |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
462 DM_TRIM_START = 1, |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
463 DM_TRIM_END = 2, |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
464 DM_TRIM_BOTH = 3 |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
465 }; |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
466 |
1882 | 467 char * dm_strdup(const char *str); |
468 char * dm_strndup(const char *str, const size_t n); | |
2027
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
469 char * dm_strdup_trim(const char *src, const int flags); |
750a7e125546
Add in several string helper functions from th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
2004
diff
changeset
|
470 char * dm_strndup_trim(const char *src, const size_t n, const int flags); |
1884
47fe47f01fea
Implement dm_strdup_vprintf_len(const char *fmt, va_list args, int *len), which
Matti Hamalainen <ccr@tnsp.org>
parents:
1882
diff
changeset
|
471 char * dm_strdup_vprintf_len(const char *fmt, va_list args, int *len); |
1882 | 472 char * dm_strdup_vprintf(const char *fmt, va_list args); |
473 char * dm_strdup_printf(const char *fmt, ...); | |
0 | 474 |
816 | 475 char * dm_strrcasecmp(char *str, const char *needle); |
0 | 476 |
2004
161e731eb152
Improve dmGetIntVal() to accept an optional negative value boolean flag
Matti Hamalainen <ccr@tnsp.org>
parents:
1884
diff
changeset
|
477 BOOL dmGetIntVal(const char *str, unsigned int *value, BOOL *neg); |
955 | 478 |
479 | |
294
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
480 /* Mutexes |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
481 */ |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
482 #ifdef DM_MUTEX_DEBUG |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
483 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
484 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
485 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
486 BOOL used; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
487 Uint32 id; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
488 int state; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
489 } DMMutexLock; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
490 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
491 typedef struct |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
492 { |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
493 char *cr_file; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
494 int cr_line; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
495 SDL_mutex *m; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
496 DMMutexLock locks[8]; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
497 } DMMutex; |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
498 |
2404 | 499 # define dmMutexLock(x) dmDOMutexLock(x, __FILE__, (int) __LINE__) |
500 # define dmMutexUnlock(x) dmDOMutexUnlock(x, __FILE__, (int) __LINE__) | |
501 # define dmCreateMutex(x) dmDOCreateMutex(__FILE__, (int) __LINE__) | |
294
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
502 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
503 int dmDOMutexLock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
504 int dmDOMutexUnlock(DMMutex *mutex, const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
505 DMMutex * dmDOCreateMutex(const char *file, const int line); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
506 void dmDestroyMutex(DMMutex *mutex); |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
507 |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
508 #else |
2404 | 509 # define DMMutex SDL_mutex |
510 # define dmCreateMutex() SDL_CreateMutex() | |
511 # define dmDestroyMutex(x) SDL_DestroyMutex(x) | |
512 # define dmMutexLock(x) SDL_mutexP(x) | |
513 # define dmMutexUnlock(x) SDL_mutexV(x) | |
294
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
514 #endif |
dd9809a93425
Improve mutex debugging facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
515 |
2404 | 516 |
0 | 517 /* Endianess swapping macros |
518 */ | |
955 | 519 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ |
0 | 520 (Uint16) ((Uint16) (value) >> 8) | \ |
521 (Uint16) ((Uint16) (value) << 8)) ) | |
522 | |
523 | |
955 | 524 #define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ |
0 | 525 (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ |
526 (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ | |
527 (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ | |
528 (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) | |
529 | |
955 | 530 #define DM_SWAP_64_LE_BE(value) ((Uint64) ( \ |
531 (((Uint64) (value) & (Uint64) 0x00000000000000ffULL) << 56) | \ | |
532 (((Uint64) (value) & (Uint64) 0x000000000000ff00ULL) << 40) | \ | |
533 (((Uint64) (value) & (Uint64) 0x0000000000ff0000ULL) << 24) | \ | |
534 (((Uint64) (value) & (Uint64) 0x00000000ff000000ULL) << 8) | \ | |
535 (((Uint64) (value) & (Uint64) 0x000000ff00000000ULL) >> 8) | \ | |
536 (((Uint64) (value) & (Uint64) 0x0000ff0000000000ULL) >> 24) | \ | |
537 (((Uint64) (value) & (Uint64) 0x00ff000000000000ULL) >> 40) | \ | |
0 | 538 (((Uint64) (value) & (Uint64) 0xff00000000000000ULL) >> 56))) |
873 | 539 |
0 | 540 |
541 /* Macros that swap only when needed ... | |
542 */ | |
543 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
770 | 544 # define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
545 # define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
546 # define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) | |
547 # define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 548 |
770 | 549 # define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) |
550 # define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) | |
551 # define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) | |
552 # define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) | |
0 | 553 |
872
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
554 # 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
|
555 # 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
|
556 # define DM_BE64_TO_NATIVE(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
557 # define DM_NATIVE_TO_BE64(value) ((Uint64) (value)) |
0 | 558 |
559 #elif (SDL_BYTEORDER == SDL_LIL_ENDIAN) | |
560 | |
770 | 561 # define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) |
562 # define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) | |
563 # define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) | |
564 # define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) | |
0 | 565 |
770 | 566 # define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) |
567 # define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
568 # define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) | |
569 # define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) | |
0 | 570 |
872
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
571 # define DM_LE64_TO_NATIVE(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
572 # define DM_NATIVE_TO_LE64(value) ((Uint64) (value)) |
b01d04e44b6f
Assume we always have 64bit type.
Matti Hamalainen <ccr@tnsp.org>
parents:
871
diff
changeset
|
573 # 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
|
574 # define DM_NATIVE_TO_BE64(value) DM_SWAP_64_LE_BE(value) |
0 | 575 #endif |
576 | |
577 | |
578 #ifdef __cplusplus | |
579 } | |
580 #endif | |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
581 |
0 | 582 #endif // DMLIB_H |