diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/blargg_common.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libgme/blargg_common.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/blargg_common.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/blargg_common.h b/lib/rbcodec/codecs/libgme/blargg_common.h new file mode 100644 index 0000000000..74cc227eed --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blargg_common.h | |||
@@ -0,0 +1,160 @@ | |||
1 | // Sets up common environment for Shay Green's libraries. | ||
2 | // To change configuration options, modify blargg_config.h, not this file. | ||
3 | |||
4 | #ifndef BLARGG_COMMON_H | ||
5 | #define BLARGG_COMMON_H | ||
6 | |||
7 | #include <stddef.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <string.h> | ||
10 | #include <limits.h> | ||
11 | |||
12 | #undef BLARGG_COMMON_H | ||
13 | // allow blargg_config.h to #include blargg_common.h | ||
14 | #include "blargg_config.h" | ||
15 | #include "blargg_source.h" | ||
16 | #ifndef BLARGG_COMMON_H | ||
17 | #define BLARGG_COMMON_H | ||
18 | |||
19 | #if defined(ROCKBOX) | ||
20 | #include "codeclib.h" | ||
21 | #endif | ||
22 | |||
23 | // common defines | ||
24 | #define FP_ONE_CLOCK (1LL << 12) | ||
25 | #define FP_ONE_TEMPO (1LL << 24) | ||
26 | #define FP_ONE_GAIN (1LL << 24) | ||
27 | #define FP_ONE_VOLUME FP_ONE_GAIN | ||
28 | |||
29 | // IRAM configuration | ||
30 | #if (CONFIG_CPU == MCF5250) | ||
31 | #define EMU2413_CALC_ICODE | ||
32 | |||
33 | #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) | ||
34 | #define EMU2413_CALC_ICODE ICODE_ATTR | ||
35 | |||
36 | #elif defined(CPU_S5L870X) | ||
37 | #define EMU2413_CALC_ICODE | ||
38 | |||
39 | #else | ||
40 | #define EMU2413_CALC_ICODE | ||
41 | |||
42 | #endif | ||
43 | |||
44 | // BLARGG_RESTRICT: equivalent to C99's restrict, where supported | ||
45 | #if __GNUC__ >= 3 || _MSC_VER >= 1100 | ||
46 | #define BLARGG_RESTRICT __restrict | ||
47 | #else | ||
48 | #define BLARGG_RESTRICT | ||
49 | #endif | ||
50 | |||
51 | // STATIC_CAST(T,expr): Used in place of static_cast<T> (expr) | ||
52 | #ifndef STATIC_CAST | ||
53 | #define STATIC_CAST(T,expr) ((T) (expr)) | ||
54 | #endif | ||
55 | |||
56 | // blargg_err_t (0 on success, otherwise error string) | ||
57 | #ifndef blargg_err_t | ||
58 | typedef const char* blargg_err_t; | ||
59 | #endif | ||
60 | |||
61 | #define BLARGG_4CHAR( a, b, c, d ) \ | ||
62 | ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF)) | ||
63 | |||
64 | // BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. | ||
65 | #ifndef BOOST_STATIC_ASSERT | ||
66 | #ifdef _MSC_VER | ||
67 | // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified | ||
68 | #define BOOST_STATIC_ASSERT( expr ) \ | ||
69 | void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) | ||
70 | #else | ||
71 | // Some other compilers fail when declaring same function multiple times in class, | ||
72 | // so differentiate them by line | ||
73 | #define BOOST_STATIC_ASSERT( expr ) \ | ||
74 | void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) | ||
75 | #endif | ||
76 | #endif | ||
77 | |||
78 | // BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, | ||
79 | // compiler is assumed to support bool. If undefined, availability is determined. | ||
80 | #ifndef BLARGG_COMPILER_HAS_BOOL | ||
81 | #if defined (__MWERKS__) | ||
82 | #if !__option(bool) | ||
83 | #define BLARGG_COMPILER_HAS_BOOL 0 | ||
84 | #endif | ||
85 | #elif defined (_MSC_VER) | ||
86 | #if _MSC_VER < 1100 | ||
87 | #define BLARGG_COMPILER_HAS_BOOL 0 | ||
88 | #endif | ||
89 | #elif defined (__GNUC__) | ||
90 | // supports bool | ||
91 | #elif __cplusplus < 199711 | ||
92 | #define BLARGG_COMPILER_HAS_BOOL 0 | ||
93 | #endif | ||
94 | #endif | ||
95 | #if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL | ||
96 | // If you get errors here, modify your blargg_config.h file | ||
97 | typedef int bool; | ||
98 | static bool true = 1; | ||
99 | static bool false = 0; | ||
100 | #endif | ||
101 | |||
102 | /* My code depends on int being at least 32 bits. Almost everything these days | ||
103 | uses at least 32-bit ints, so it's hard to even find a system with 16-bit ints | ||
104 | to test with. The issue can't be gotten around by using a suitable blargg_int | ||
105 | everywhere either, because int is often converted to implicitly when doing | ||
106 | arithmetic on smaller types. */ | ||
107 | #if UINT_MAX < 0xFFFFFFFF | ||
108 | #error "int must be at least 32 bits" | ||
109 | #endif | ||
110 | |||
111 | // int8_t etc. | ||
112 | |||
113 | |||
114 | // ROCKBOX: If defined, use <codeclib.h> for int_8_t etc | ||
115 | #if defined (ROCKBOX) | ||
116 | #include <codecs/lib/codeclib.h> | ||
117 | // HAVE_STDINT_H: If defined, use <stdint.h> for int8_t etc. | ||
118 | #elif defined (HAVE_STDINT_H) | ||
119 | #include <stdint.h> | ||
120 | #define BOOST | ||
121 | |||
122 | // HAVE_INTTYPES_H: If defined, use <stdint.h> for int8_t etc. | ||
123 | #elif defined (HAVE_INTTYPES_H) | ||
124 | #include <inttypes.h> | ||
125 | #define BOOST | ||
126 | |||
127 | #else | ||
128 | #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F | ||
129 | typedef signed char int8_t; | ||
130 | typedef unsigned char uint8_t; | ||
131 | #else | ||
132 | // No suitable 8-bit type available | ||
133 | typedef struct see_blargg_common_h int8_t; | ||
134 | typedef struct see_blargg_common_h uint8_t; | ||
135 | #endif | ||
136 | |||
137 | #if USHRT_MAX == 0xFFFF | ||
138 | typedef short int16_t; | ||
139 | typedef unsigned short uint16_t; | ||
140 | #else | ||
141 | // No suitable 16-bit type available | ||
142 | typedef struct see_blargg_common_h int16_t; | ||
143 | typedef struct see_blargg_common_h uint16_t; | ||
144 | #endif | ||
145 | |||
146 | #if ULONG_MAX == 0xFFFFFFFF | ||
147 | typedef long int32_t; | ||
148 | typedef unsigned long uint32_t; | ||
149 | #elif UINT_MAX == 0xFFFFFFFF | ||
150 | typedef int int32_t; | ||
151 | typedef unsigned int uint32_t; | ||
152 | #else | ||
153 | // No suitable 32-bit type available | ||
154 | typedef struct see_blargg_common_h int32_t; | ||
155 | typedef struct see_blargg_common_h uint32_t; | ||
156 | #endif | ||
157 | #endif | ||
158 | |||
159 | #endif | ||
160 | #endif | ||