summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/blargg_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/blargg_common.h')
-rw-r--r--lib/rbcodec/codecs/libgme/blargg_common.h160
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
103uses at least 32-bit ints, so it's hard to even find a system with 16-bit ints
104to test with. The issue can't be gotten around by using a suitable blargg_int
105everywhere either, because int is often converted to implicitly when doing
106arithmetic 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