Browse code

Update snes9x code from 1.53 to 1.6.0.

Notable differences from upstream:
* Did not use the same #include setup for the new byuu apu and instead chose to do things more traditionally, as the latter is also much easier to deal with in Visual Studio than just including .cpp files into other .cpp files...
* MSU1 support not included (I see no need for this in a plugin meant to be used for original SNES music).
* The dynamic rate control on the APU not included (I also see no need for it in this plugin).
* The extra resamplers I added in were removed as the original hermite resampler was folded into a single non-inhertiable resampler.
* Bits of cleanup.

Naram Qashat authored on 2021/04/19 21:20:36
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,38 +0,0 @@
1
-// Sets up common environment for Shay Green's libraries.
2
-// To change configuration options, modify blargg_config.h, not this file.
3
-
4
-// snes_spc 0.9.0
5
-#pragma once
6
-
7
-#include <cstddef>
8
-#include <cstdlib>
9
-#include <cassert>
10
-#include <climits>
11
-
12
-#include "blargg_config.h"
13
-
14
-// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
15
-// compiler is assumed to support bool. If undefined, availability is determined.
16
-#ifndef BLARGG_COMPILER_HAS_BOOL
17
-# if defined(__MWERKS__)
18
-#  if !__option(bool)
19
-#   define BLARGG_COMPILER_HAS_BOOL 0
20
-#  endif
21
-# elif defined(_MSC_VER)
22
-#  if _MSC_VER < 1100
23
-#   define BLARGG_COMPILER_HAS_BOOL 0
24
-#  endif
25
-# elif defined(__GNUC__)
26
-// supports bool
27
-# elif __cplusplus < 199711
28
-#  define BLARGG_COMPILER_HAS_BOOL 0
29
-# endif
30
-#endif
31
-#if defined(BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
32
-// If you get errors here, modify your blargg_config.h file
33
-typedef int bool;
34
-const bool true = 1;
35
-const bool false = 0;
36
-#endif
37
-
38
-#include <cstdint>
Browse code

A few more cases of using #pragma once instead of include guards.

Naram Qashat authored on 2014/09/08 14:51:19
Showing 1 changed files
... ...
@@ -2,19 +2,14 @@
2 2
 // To change configuration options, modify blargg_config.h, not this file.
3 3
 
4 4
 // snes_spc 0.9.0
5
-#ifndef BLARGG_COMMON_H
6
-#define BLARGG_COMMON_H
5
+#pragma once
7 6
 
8 7
 #include <cstddef>
9 8
 #include <cstdlib>
10 9
 #include <cassert>
11 10
 #include <climits>
12 11
 
13
-#undef BLARGG_COMMON_H
14
-// allow blargg_config.h to #include blargg_common.h
15 12
 #include "blargg_config.h"
16
-#ifndef BLARGG_COMMON_H
17
-#define BLARGG_COMMON_H
18 13
 
19 14
 // BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
20 15
 // compiler is assumed to support bool. If undefined, availability is determined.
... ...
@@ -41,6 +36,3 @@ const bool false = 0;
41 36
 #endif
42 37
 
43 38
 #include <cstdint>
44
-
45
-#endif
46
-#endif
Browse code

[SNSF] Massive code cleanup, as well as removing as much unused code/variables as possible.

Naram Qashat authored on 2013/05/23 06:02:16
Showing 1 changed files
... ...
@@ -5,10 +5,10 @@
5 5
 #ifndef BLARGG_COMMON_H
6 6
 #define BLARGG_COMMON_H
7 7
 
8
-#include <stddef.h>
9
-#include <stdlib.h>
10
-#include <assert.h>
11
-#include <limits.h>
8
+#include <cstddef>
9
+#include <cstdlib>
10
+#include <cassert>
11
+#include <climits>
12 12
 
13 13
 #undef BLARGG_COMMON_H
14 14
 // allow blargg_config.h to #include blargg_common.h
... ...
@@ -16,171 +16,31 @@
16 16
 #ifndef BLARGG_COMMON_H
17 17
 #define BLARGG_COMMON_H
18 18
 
19
-// BLARGG_RESTRICT: equivalent to restrict, where supported
20
-#if defined (__GNUC__) || _MSC_VER >= 1100
21
-	#define BLARGG_RESTRICT __restrict
22
-#else
23
-	#define BLARGG_RESTRICT
24
-#endif
25
-
26
-// STATIC_CAST(T,expr): Used in place of static_cast<T> (expr)
27
-#ifndef STATIC_CAST
28
-	#define STATIC_CAST(T,expr) ((T) (expr))
29
-#endif
30
-
31
-// blargg_err_t (0 on success, otherwise error string)
32
-#ifndef blargg_err_t
33
-	typedef const char* blargg_err_t;
34
-#endif
35
-
36
-// blargg_vector - very lightweight vector of POD types (no constructor/destructor)
37
-template<class T>
38
-class blargg_vector {
39
-	T* begin_;
40
-	size_t size_;
41
-public:
42
-	blargg_vector() : begin_( 0 ), size_( 0 ) { }
43
-	~blargg_vector() { free( begin_ ); }
44
-	size_t size() const { return size_; }
45
-	T* begin() const { return begin_; }
46
-	T* end() const { return begin_ + size_; }
47
-	blargg_err_t resize( size_t n )
48
-	{
49
-		// TODO: blargg_common.cpp to hold this as an outline function, ugh
50
-		void* p = realloc( begin_, n * sizeof (T) );
51
-		if ( p )
52
-			begin_ = (T*) p;
53
-		else if ( n > size_ ) // realloc failure only a problem if expanding
54
-			return "Out of memory";
55
-		size_ = n;
56
-		return 0;
57
-	}
58
-	void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); }
59
-	T& operator [] ( size_t n ) const
60
-	{
61
-		assert( n <= size_ ); // <= to allow past-the-end value
62
-		return begin_ [n];
63
-	}
64
-};
65
-
66
-#ifndef BLARGG_DISABLE_NOTHROW
67
-	// throw spec mandatory in ISO C++ if operator new can return NULL
68
-	#if __cplusplus >= 199711 || defined (__GNUC__)
69
-		#define BLARGG_THROWS( spec ) throw spec
70
-	#else
71
-		#define BLARGG_THROWS( spec )
72
-	#endif
73
-	#define BLARGG_DISABLE_NOTHROW \
74
-		void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\
75
-		void operator delete ( void* p ) { free( p ); }
76
-	#define BLARGG_NEW new
77
-#else
78
-	#include <new>
79
-	#define BLARGG_NEW new (std::nothrow)
80
-#endif
81
-
82
-// BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant)
83
-#define BLARGG_4CHAR( a, b, c, d ) \
84
-	((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF))
85
-
86
-// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0.
87
-#ifndef BOOST_STATIC_ASSERT
88
-	#ifdef _MSC_VER
89
-		// MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified
90
-		#define BOOST_STATIC_ASSERT( expr ) \
91
-			void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] )
92
-	#else
93
-		// Some other compilers fail when declaring same function multiple times in class,
94
-		// so differentiate them by line
95
-		#define BOOST_STATIC_ASSERT( expr ) \
96
-			void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] )
97
-	#endif
98
-#endif
99
-
100 19
 // BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
101 20
 // compiler is assumed to support bool. If undefined, availability is determined.
102 21
 #ifndef BLARGG_COMPILER_HAS_BOOL
103
-	#if defined (__MWERKS__)
104
-		#if !__option(bool)
105
-			#define BLARGG_COMPILER_HAS_BOOL 0
106
-		#endif
107
-	#elif defined (_MSC_VER)
108
-		#if _MSC_VER < 1100
109
-			#define BLARGG_COMPILER_HAS_BOOL 0
110
-		#endif
111
-	#elif defined (__GNUC__)
112
-		// supports bool
113
-	#elif __cplusplus < 199711
114
-		#define BLARGG_COMPILER_HAS_BOOL 0
115
-	#endif
116
-#endif
117
-#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
118
-	// If you get errors here, modify your blargg_config.h file
119
-	typedef int bool;
120
-	const bool true  = 1;
121
-	const bool false = 0;
122
-#endif
123
-
124
-// blargg_long/blargg_ulong = at least 32 bits, int if it's big enough
125
-
126
-#if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF
127
-	typedef long blargg_long;
128
-#else
129
-	typedef int blargg_long;
130
-#endif
131
-
132
-#if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF
133
-	typedef unsigned long blargg_ulong;
134
-#else
135
-	typedef unsigned blargg_ulong;
136
-#endif
137
-
138
-// BOOST::int8_t etc.
139
-
140
-// HAVE_STDINT_H: If defined, use <stdint.h> for int8_t etc.
141
-#if defined (HAVE_STDINT_H)
142
-	#include <stdint.h>
143
-	#define BOOST
144
-
145
-// HAVE_INTTYPES_H: If defined, use <stdint.h> for int8_t etc.
146
-#elif defined (HAVE_INTTYPES_H)
147
-	#include <inttypes.h>
148
-	#define BOOST
149
-
150
-#else
151
-	struct BOOST
152
-	{
153
-		#if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F
154
-			typedef signed char     int8_t;
155
-			typedef unsigned char   uint8_t;
156
-		#else
157
-			// No suitable 8-bit type available
158
-			typedef struct see_blargg_common_h int8_t;
159
-			typedef struct see_blargg_common_h uint8_t;
160
-		#endif
161
-		
162
-		#if USHRT_MAX == 0xFFFF
163
-			typedef short           int16_t;
164
-			typedef unsigned short  uint16_t;
165
-		#else
166
-			// No suitable 16-bit type available
167
-			typedef struct see_blargg_common_h int16_t;
168
-			typedef struct see_blargg_common_h uint16_t;
169
-		#endif
170
-		
171
-		#if ULONG_MAX == 0xFFFFFFFF
172
-			typedef long            int32_t;
173
-			typedef unsigned long   uint32_t;
174
-		#elif UINT_MAX == 0xFFFFFFFF
175
-			typedef int             int32_t;
176
-			typedef unsigned int    uint32_t;
177
-		#else
178
-			// No suitable 32-bit type available
179
-			typedef struct see_blargg_common_h int32_t;
180
-			typedef struct see_blargg_common_h uint32_t;
181
-		#endif
182
-	};
183
-#endif
22
+# if defined(__MWERKS__)
23
+#  if !__option(bool)
24
+#   define BLARGG_COMPILER_HAS_BOOL 0
25
+#  endif
26
+# elif defined(_MSC_VER)
27
+#  if _MSC_VER < 1100
28
+#   define BLARGG_COMPILER_HAS_BOOL 0
29
+#  endif
30
+# elif defined(__GNUC__)
31
+// supports bool
32
+# elif __cplusplus < 199711
33
+#  define BLARGG_COMPILER_HAS_BOOL 0
34
+# endif
35
+#endif
36
+#if defined(BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
37
+// If you get errors here, modify your blargg_config.h file
38
+typedef int bool;
39
+const bool true = 1;
40
+const bool false = 0;
41
+#endif
42
+
43
+#include <cstdint>
184 44
 
185 45
 #endif
186 46
 #endif
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,186 @@
1
+// Sets up common environment for Shay Green's libraries.
2
+// To change configuration options, modify blargg_config.h, not this file.
3
+
4
+// snes_spc 0.9.0
5
+#ifndef BLARGG_COMMON_H
6
+#define BLARGG_COMMON_H
7
+
8
+#include <stddef.h>
9
+#include <stdlib.h>
10
+#include <assert.h>
11
+#include <limits.h>
12
+
13
+#undef BLARGG_COMMON_H
14
+// allow blargg_config.h to #include blargg_common.h
15
+#include "blargg_config.h"
16
+#ifndef BLARGG_COMMON_H
17
+#define BLARGG_COMMON_H
18
+
19
+// BLARGG_RESTRICT: equivalent to restrict, where supported
20
+#if defined (__GNUC__) || _MSC_VER >= 1100
21
+	#define BLARGG_RESTRICT __restrict
22
+#else
23
+	#define BLARGG_RESTRICT
24
+#endif
25
+
26
+// STATIC_CAST(T,expr): Used in place of static_cast<T> (expr)
27
+#ifndef STATIC_CAST
28
+	#define STATIC_CAST(T,expr) ((T) (expr))
29
+#endif
30
+
31
+// blargg_err_t (0 on success, otherwise error string)
32
+#ifndef blargg_err_t
33
+	typedef const char* blargg_err_t;
34
+#endif
35
+
36
+// blargg_vector - very lightweight vector of POD types (no constructor/destructor)
37
+template<class T>
38
+class blargg_vector {
39
+	T* begin_;
40
+	size_t size_;
41
+public:
42
+	blargg_vector() : begin_( 0 ), size_( 0 ) { }
43
+	~blargg_vector() { free( begin_ ); }
44
+	size_t size() const { return size_; }
45
+	T* begin() const { return begin_; }
46
+	T* end() const { return begin_ + size_; }
47
+	blargg_err_t resize( size_t n )
48
+	{
49
+		// TODO: blargg_common.cpp to hold this as an outline function, ugh
50
+		void* p = realloc( begin_, n * sizeof (T) );
51
+		if ( p )
52
+			begin_ = (T*) p;
53
+		else if ( n > size_ ) // realloc failure only a problem if expanding
54
+			return "Out of memory";
55
+		size_ = n;
56
+		return 0;
57
+	}
58
+	void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); }
59
+	T& operator [] ( size_t n ) const
60
+	{
61
+		assert( n <= size_ ); // <= to allow past-the-end value
62
+		return begin_ [n];
63
+	}
64
+};
65
+
66
+#ifndef BLARGG_DISABLE_NOTHROW
67
+	// throw spec mandatory in ISO C++ if operator new can return NULL
68
+	#if __cplusplus >= 199711 || defined (__GNUC__)
69
+		#define BLARGG_THROWS( spec ) throw spec
70
+	#else
71
+		#define BLARGG_THROWS( spec )
72
+	#endif
73
+	#define BLARGG_DISABLE_NOTHROW \
74
+		void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\
75
+		void operator delete ( void* p ) { free( p ); }
76
+	#define BLARGG_NEW new
77
+#else
78
+	#include <new>
79
+	#define BLARGG_NEW new (std::nothrow)
80
+#endif
81
+
82
+// BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant)
83
+#define BLARGG_4CHAR( a, b, c, d ) \
84
+	((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF))
85
+
86
+// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0.
87
+#ifndef BOOST_STATIC_ASSERT
88
+	#ifdef _MSC_VER
89
+		// MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified
90
+		#define BOOST_STATIC_ASSERT( expr ) \
91
+			void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] )
92
+	#else
93
+		// Some other compilers fail when declaring same function multiple times in class,
94
+		// so differentiate them by line
95
+		#define BOOST_STATIC_ASSERT( expr ) \
96
+			void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] )
97
+	#endif
98
+#endif
99
+
100
+// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
101
+// compiler is assumed to support bool. If undefined, availability is determined.
102
+#ifndef BLARGG_COMPILER_HAS_BOOL
103
+	#if defined (__MWERKS__)
104
+		#if !__option(bool)
105
+			#define BLARGG_COMPILER_HAS_BOOL 0
106
+		#endif
107
+	#elif defined (_MSC_VER)
108
+		#if _MSC_VER < 1100
109
+			#define BLARGG_COMPILER_HAS_BOOL 0
110
+		#endif
111
+	#elif defined (__GNUC__)
112
+		// supports bool
113
+	#elif __cplusplus < 199711
114
+		#define BLARGG_COMPILER_HAS_BOOL 0
115
+	#endif
116
+#endif
117
+#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
118
+	// If you get errors here, modify your blargg_config.h file
119
+	typedef int bool;
120
+	const bool true  = 1;
121
+	const bool false = 0;
122
+#endif
123
+
124
+// blargg_long/blargg_ulong = at least 32 bits, int if it's big enough
125
+
126
+#if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF
127
+	typedef long blargg_long;
128
+#else
129
+	typedef int blargg_long;
130
+#endif
131
+
132
+#if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF
133
+	typedef unsigned long blargg_ulong;
134
+#else
135
+	typedef unsigned blargg_ulong;
136
+#endif
137
+
138
+// BOOST::int8_t etc.
139
+
140
+// HAVE_STDINT_H: If defined, use <stdint.h> for int8_t etc.
141
+#if defined (HAVE_STDINT_H)
142
+	#include <stdint.h>
143
+	#define BOOST
144
+
145
+// HAVE_INTTYPES_H: If defined, use <stdint.h> for int8_t etc.
146
+#elif defined (HAVE_INTTYPES_H)
147
+	#include <inttypes.h>
148
+	#define BOOST
149
+
150
+#else
151
+	struct BOOST
152
+	{
153
+		#if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F
154
+			typedef signed char     int8_t;
155
+			typedef unsigned char   uint8_t;
156
+		#else
157
+			// No suitable 8-bit type available
158
+			typedef struct see_blargg_common_h int8_t;
159
+			typedef struct see_blargg_common_h uint8_t;
160
+		#endif
161
+		
162
+		#if USHRT_MAX == 0xFFFF
163
+			typedef short           int16_t;
164
+			typedef unsigned short  uint16_t;
165
+		#else
166
+			// No suitable 16-bit type available
167
+			typedef struct see_blargg_common_h int16_t;
168
+			typedef struct see_blargg_common_h uint16_t;
169
+		#endif
170
+		
171
+		#if ULONG_MAX == 0xFFFFFFFF
172
+			typedef long            int32_t;
173
+			typedef unsigned long   uint32_t;
174
+		#elif UINT_MAX == 0xFFFFFFFF
175
+			typedef int             int32_t;
176
+			typedef unsigned int    uint32_t;
177
+		#else
178
+			// No suitable 32-bit type available
179
+			typedef struct see_blargg_common_h int32_t;
180
+			typedef struct see_blargg_common_h uint32_t;
181
+		#endif
182
+	};
183
+#endif
184
+
185
+#endif
186
+#endif