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,65 +0,0 @@
1
-/* Simple byte-based ring buffer. Licensed under public domain (C) BearOso. */
2
-
3
-#pragma once
4
-
5
-#include <memory>
6
-#include <algorithm>
7
-#include <cstring>
8
-
9
-class ring_buffer
10
-{
11
-protected:
12
-	int size;
13
-	int buffer_size;
14
-	int start;
15
-	std::unique_ptr<unsigned char[]> buffer;
16
-
17
-public:
18
-	ring_buffer(int buf_size)
19
-	{
20
-		this->buffer_size = buf_size;
21
-		this->buffer.reset(new unsigned char[this->buffer_size]);
22
-		this->clear();
23
-	}
24
-
25
-	bool push(unsigned char *src, int bytes)
26
-	{
27
-		if (this->space_empty() < bytes)
28
-			return false;
29
-
30
-		int end = (this->start + this->size) % this->buffer_size;
31
-		int first_write_size = std::min(bytes, this->buffer_size - end);
32
-
33
-		std::copy_n(&src[0], first_write_size, &this->buffer[end]);
34
-
35
-		if (bytes > first_write_size)
36
-			std::copy(&src[first_write_size], &src[bytes], &this->buffer[0]);
37
-
38
-		this->size += bytes;
39
-
40
-		return true;
41
-	}
42
-
43
-	int space_empty()
44
-	{
45
-		return this->buffer_size - this->size;
46
-	}
47
-
48
-	int space_filled()
49
-	{
50
-		return this->size;
51
-	}
52
-
53
-	void clear()
54
-	{
55
-		this->start = this->size = 0;
56
-		std::fill_n(&this->buffer[0], this->buffer_size, 0);
57
-	}
58
-
59
-	void resize(int new_size)
60
-	{
61
-		this->buffer_size = new_size;
62
-		this->buffer.reset(new unsigned char[this->buffer_size]);
63
-		this->clear();
64
-	}
65
-};
Browse code

* Fixes for gcc and clang (while they can compile the code, the DLLs made aren't functional, but oh well).

* [2SF] Used more up-to-date asmjit, despite the ugly looking code.

Naram Qashat authored on 2014/09/17 19:51:45
Showing 1 changed files
... ...
@@ -2,6 +2,7 @@
2 2
 
3 3
 #pragma once
4 4
 
5
+#include <memory>
5 6
 #include <algorithm>
6 7
 #include <cstring>
7 8
 
... ...
@@ -11,21 +12,16 @@ protected:
11 12
 	int size;
12 13
 	int buffer_size;
13 14
 	int start;
14
-	unsigned char *buffer;
15
+	std::unique_ptr<unsigned char[]> buffer;
15 16
 
16 17
 public:
17
-	ring_buffer(int buffer_size)
18
+	ring_buffer(int buf_size)
18 19
 	{
19
-		this->buffer_size = buffer_size;
20
-		this->buffer = new unsigned char[this->buffer_size];
20
+		this->buffer_size = buf_size;
21
+		this->buffer.reset(new unsigned char[this->buffer_size]);
21 22
 		this->clear();
22 23
 	}
23 24
 
24
-	~ring_buffer()
25
-	{
26
-		delete[] buffer;
27
-	}
28
-
29 25
 	bool push(unsigned char *src, int bytes)
30 26
 	{
31 27
 		if (this->space_empty() < bytes)
... ...
@@ -60,11 +56,10 @@ public:
60 56
 		std::fill_n(&this->buffer[0], this->buffer_size, 0);
61 57
 	}
62 58
 
63
-	void resize(int size)
59
+	void resize(int new_size)
64 60
 	{
65
-		delete[] this->buffer;
66
-		this->buffer_size = size;
67
-		this->buffer = new unsigned char[this->buffer_size];
61
+		this->buffer_size = new_size;
62
+		this->buffer.reset(new unsigned char[this->buffer_size]);
68 63
 		this->clear();
69 64
 	}
70 65
 };
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
... ...
@@ -1,7 +1,6 @@
1 1
 /* Simple byte-based ring buffer. Licensed under public domain (C) BearOso. */
2 2
 
3
-#ifndef __RING_BUFFER_H
4
-#define __RING_BUFFER_H
3
+#pragma once
5 4
 
6 5
 #include <algorithm>
7 6
 #include <cstring>
... ...
@@ -69,5 +68,3 @@ public:
69 68
 		this->clear();
70 69
 	}
71 70
 };
72
-
73
-#endif
Browse code

[SNSF] Replaced most uses of fill/copy with fill_n/copy_n, and a few other minor code cleanups.

Naram Qashat authored on 2013/05/27 22:34:22
Showing 1 changed files
... ...
@@ -19,9 +19,7 @@ public:
19 19
 	{
20 20
 		this->buffer_size = buffer_size;
21 21
 		this->buffer = new unsigned char[this->buffer_size];
22
-		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
23
-
24
-		this->size = this->start = 0;
22
+		this->clear();
25 23
 	}
26 24
 
27 25
 	~ring_buffer()
... ...
@@ -37,7 +35,7 @@ public:
37 35
 		int end = (this->start + this->size) % this->buffer_size;
38 36
 		int first_write_size = std::min(bytes, this->buffer_size - end);
39 37
 
40
-		std::copy(&src[0], &src[first_write_size], &this->buffer[end]);
38
+		std::copy_n(&src[0], first_write_size, &this->buffer[end]);
41 39
 
42 40
 		if (bytes > first_write_size)
43 41
 			std::copy(&src[first_write_size], &src[bytes], &this->buffer[0]);
... ...
@@ -60,7 +58,7 @@ public:
60 58
 	void clear()
61 59
 	{
62 60
 		this->start = this->size = 0;
63
-		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
61
+		std::fill_n(&this->buffer[0], this->buffer_size, 0);
64 62
 	}
65 63
 
66 64
 	void resize(int size)
... ...
@@ -68,9 +66,7 @@ public:
68 66
 		delete[] this->buffer;
69 67
 		this->buffer_size = size;
70 68
 		this->buffer = new unsigned char[this->buffer_size];
71
-		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
72
-
73
-		this->size = this->start = 0;
69
+		this->clear();
74 70
 	}
75 71
 };
76 72
 
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
... ...
@@ -3,109 +3,75 @@
3 3
 #ifndef __RING_BUFFER_H
4 4
 #define __RING_BUFFER_H
5 5
 
6
-#include <string.h>
7
-
8
-#undef MIN
9
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
6
+#include <algorithm>
7
+#include <cstring>
10 8
 
11 9
 class ring_buffer
12 10
 {
13 11
 protected:
14
-    int size;
15
-    int buffer_size;
16
-    int start;
17
-    unsigned char *buffer;
12
+	int size;
13
+	int buffer_size;
14
+	int start;
15
+	unsigned char *buffer;
18 16
 
19 17
 public:
20
-    ring_buffer (int buffer_size)
21
-    {
22
-        this->buffer_size = buffer_size;
23
-        buffer = new unsigned char[this->buffer_size];
24
-        memset (buffer, 0, this->buffer_size);
25
-
26
-        size = 0;
27
-        start = 0;
28
-    }
29
-
30
-    ~ring_buffer()
31
-    {
32
-        delete[] buffer;
33
-    }
34
-
35
-    bool
36
-    push (unsigned char *src, int bytes)
37
-    {
38
-        if (space_empty () < bytes)
39
-            return false;
40
-
41
-        int end = (start + size) % buffer_size;
42
-        int first_write_size = MIN (bytes, buffer_size - end);
43
-
44
-        memcpy (buffer + end, src, first_write_size);
45
-
46
-        if (bytes > first_write_size)
47
-            memcpy (buffer, src + first_write_size, bytes - first_write_size);
48
-
49
-        size += bytes;
50
-
51
-        return true;
52
-    }
53
-
54
-    bool
55
-    pull (unsigned char *dst, int bytes)
56
-    {
57
-        if (space_filled () < bytes)
58
-            return false;
59
-
60
-        memcpy (dst, buffer + start, MIN (bytes, buffer_size - start));
61
-
62
-        if (bytes > (buffer_size - start))
63
-            memcpy (dst + (buffer_size - start), buffer, bytes - (buffer_size - start));
64
-
65
-        start = (start + bytes) % buffer_size;
66
-        size -= bytes;
67
-
68
-        return true;
69
-    }
70
-
71
-    inline int
72
-    space_empty()
73
-    {
74
-        return buffer_size - size;
75
-    }
76
-
77
-    inline int
78
-    space_filled()
79
-    {
80
-        return size;
81
-    }
82
-
83
-    void
84
-    clear()
85
-    {
86
-        start = 0;
87
-        size = 0;
88
-        memset (buffer, 0, buffer_size);
89
-    }
90
-
91
-    void
92
-    resize (int size)
93
-    {
94
-        delete[] buffer;
95
-        buffer_size = size;
96
-        buffer = new unsigned char[buffer_size];
97
-        memset (buffer, 0, this->buffer_size);
98
-
99
-        size = 0;
100
-        start = 0;
101
-    }
102
-
103
-    inline void
104
-    cache_silence()
105
-    {
106
-        clear ();
107
-        size = buffer_size;
108
-    }
18
+	ring_buffer(int buffer_size)
19
+	{
20
+		this->buffer_size = buffer_size;
21
+		this->buffer = new unsigned char[this->buffer_size];
22
+		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
23
+
24
+		this->size = this->start = 0;
25
+	}
26
+
27
+	~ring_buffer()
28
+	{
29
+		delete[] buffer;
30
+	}
31
+
32
+	bool push(unsigned char *src, int bytes)
33
+	{
34
+		if (this->space_empty() < bytes)
35
+			return false;
36
+
37
+		int end = (this->start + this->size) % this->buffer_size;
38
+		int first_write_size = std::min(bytes, this->buffer_size - end);
39
+
40
+		std::copy(&src[0], &src[first_write_size], &this->buffer[end]);
41
+
42
+		if (bytes > first_write_size)
43
+			std::copy(&src[first_write_size], &src[bytes], &this->buffer[0]);
44
+
45
+		this->size += bytes;
46
+
47
+		return true;
48
+	}
49
+
50
+	int space_empty()
51
+	{
52
+		return this->buffer_size - this->size;
53
+	}
54
+
55
+	int space_filled()
56
+	{
57
+		return this->size;
58
+	}
59
+
60
+	void clear()
61
+	{
62
+		this->start = this->size = 0;
63
+		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
64
+	}
65
+
66
+	void resize(int size)
67
+	{
68
+		delete[] this->buffer;
69
+		this->buffer_size = size;
70
+		this->buffer = new unsigned char[this->buffer_size];
71
+		std::fill(&this->buffer[0], &this->buffer[this->buffer_size], 0);
72
+
73
+		this->size = this->start = 0;
74
+	}
109 75
 };
110 76
 
111 77
 #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,111 @@
1
+/* Simple byte-based ring buffer. Licensed under public domain (C) BearOso. */
2
+
3
+#ifndef __RING_BUFFER_H
4
+#define __RING_BUFFER_H
5
+
6
+#include <string.h>
7
+
8
+#undef MIN
9
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
10
+
11
+class ring_buffer
12
+{
13
+protected:
14
+    int size;
15
+    int buffer_size;
16
+    int start;
17
+    unsigned char *buffer;
18
+
19
+public:
20
+    ring_buffer (int buffer_size)
21
+    {
22
+        this->buffer_size = buffer_size;
23
+        buffer = new unsigned char[this->buffer_size];
24
+        memset (buffer, 0, this->buffer_size);
25
+
26
+        size = 0;
27
+        start = 0;
28
+    }
29
+
30
+    ~ring_buffer()
31
+    {
32
+        delete[] buffer;
33
+    }
34
+
35
+    bool
36
+    push (unsigned char *src, int bytes)
37
+    {
38
+        if (space_empty () < bytes)
39
+            return false;
40
+
41
+        int end = (start + size) % buffer_size;
42
+        int first_write_size = MIN (bytes, buffer_size - end);
43
+
44
+        memcpy (buffer + end, src, first_write_size);
45
+
46
+        if (bytes > first_write_size)
47
+            memcpy (buffer, src + first_write_size, bytes - first_write_size);
48
+
49
+        size += bytes;
50
+
51
+        return true;
52
+    }
53
+
54
+    bool
55
+    pull (unsigned char *dst, int bytes)
56
+    {
57
+        if (space_filled () < bytes)
58
+            return false;
59
+
60
+        memcpy (dst, buffer + start, MIN (bytes, buffer_size - start));
61
+
62
+        if (bytes > (buffer_size - start))
63
+            memcpy (dst + (buffer_size - start), buffer, bytes - (buffer_size - start));
64
+
65
+        start = (start + bytes) % buffer_size;
66
+        size -= bytes;
67
+
68
+        return true;
69
+    }
70
+
71
+    inline int
72
+    space_empty()
73
+    {
74
+        return buffer_size - size;
75
+    }
76
+
77
+    inline int
78
+    space_filled()
79
+    {
80
+        return size;
81
+    }
82
+
83
+    void
84
+    clear()
85
+    {
86
+        start = 0;
87
+        size = 0;
88
+        memset (buffer, 0, buffer_size);
89
+    }
90
+
91
+    void
92
+    resize (int size)
93
+    {
94
+        delete[] buffer;
95
+        buffer_size = size;
96
+        buffer = new unsigned char[buffer_size];
97
+        memset (buffer, 0, this->buffer_size);
98
+
99
+        size = 0;
100
+        start = 0;
101
+    }
102
+
103
+    inline void
104
+    cache_silence()
105
+    {
106
+        clear ();
107
+        size = buffer_size;
108
+    }
109
+};
110
+
111
+#endif