game-music-emu: Merge branch 'master' of bitbucket.org:mpyne/game-music-emu

From a53553adef6b9d54d302273f239d52286ef2adc0 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 4 Oct 2023 15:51:56 +0300
Subject: [PATCH 1/5] remove __cplusplus condition from BLARGG_EXPORT
 visibility defininion.

This cannot lead to problems, because:
(1) blargg_source.h is not a public header anymore, and
(2) the definition is additionally guarded by `LIBGME_VISIBILITY`, which
is a private libgme symbol only defined during build of libgme itself.
---
 gme/blargg_source.h | 2 +-
 gme/gme.h           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gme/blargg_source.h b/gme/blargg_source.h
index deea918..acf9204 100644
--- a/gme/blargg_source.h
+++ b/gme/blargg_source.h
@@ -70,7 +70,7 @@ typedef unsigned char byte;
         #else
             #define BLARGG_EXPORT /* Leave blank: friendly with both static and shared linking */
         #endif
-    #elif defined (LIBGME_VISIBILITY) && defined(__cplusplus)
+    #elif defined (LIBGME_VISIBILITY)
         #define BLARGG_EXPORT __attribute__((visibility ("default")))
     #else
         #define BLARGG_EXPORT
diff --git a/gme/gme.h b/gme/gme.h
index 6920c73..25ffa54 100644
--- a/gme/gme.h
+++ b/gme/gme.h
@@ -23,9 +23,9 @@ typedef struct Music_Emu Music_Emu;
         #if defined(BLARGG_BUILD_DLL)
             #define BLARGG_EXPORT __declspec(dllexport)
         #else
-            #define BLARGG_EXPORT /* Leave blank: friendly with both static and shared linking */
+            #define BLARGG_EXPORT /* Leave blank: friendly with both static and shared linking. */
         #endif
-    #elif defined (LIBGME_VISIBILITY) && defined(__cplusplus)
+    #elif defined (LIBGME_VISIBILITY)
         #define BLARGG_EXPORT __attribute__((visibility ("default")))
     #else
         #define BLARGG_EXPORT

From 635661b6a51eea3bfd7e49c4cbfabbfee61b162a Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Wed, 4 Oct 2023 15:56:50 +0300
Subject: [PATCH 2/5] blargg_source.h: remove duplicated BLARGG_EXPORT defines

they are only needed in gme.cpp/gme.h, and aren't needed
here anymore.
---
 gme/blargg_source.h | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/gme/blargg_source.h b/gme/blargg_source.h
index acf9204..d03b094 100644
--- a/gme/blargg_source.h
+++ b/gme/blargg_source.h
@@ -62,21 +62,6 @@
 #define byte byte_
 typedef unsigned char byte;
 
-/* Setup compiler defines useful for exporting required public API symbols in gme.cpp */
-#ifndef BLARGG_EXPORT
-    #if defined (_WIN32)
-        #if defined(BLARGG_BUILD_DLL)
-            #define BLARGG_EXPORT __declspec(dllexport)
-        #else
-            #define BLARGG_EXPORT /* Leave blank: friendly with both static and shared linking */
-        #endif
-    #elif defined (LIBGME_VISIBILITY)
-        #define BLARGG_EXPORT __attribute__((visibility ("default")))
-    #else
-        #define BLARGG_EXPORT
-    #endif
-#endif
-
 /* deprecated */
 #define BLARGG_CHECK_ALLOC CHECK_ALLOC
 #define BLARGG_RETURN_ERR RETURN_ERR

From df1ac5053371445be96e0f923f0c40d5dc748d29 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Wed, 4 Oct 2023 17:50:40 +0300
Subject: [PATCH 3/5] gme.h: fix wrong 'since' version documentations

---
 gme/gme.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gme/gme.h b/gme/gme.h
index 6920c73..2256e76 100644
--- a/gme/gme.h
+++ b/gme/gme.h
@@ -72,12 +72,13 @@ BLARGG_EXPORT void gme_set_fade_msecs( Music_Emu*, int start_msec, int length_ms
  *
  * By default, playback limits are loaded and applied.
  *
- * @since 0.6.2
+ * @since 0.6.3
  */
 BLARGG_EXPORT void gme_set_autoload_playback_limit( Music_Emu *, int do_autoload_limit );
 
 /** See gme_set_autoload_playback_limit.
- * @since 0.6.2
+ * (This was actually added in 0.6.3, but wasn't exported because of a typo.)
+ * @since 0.6.4
  */
 BLARGG_EXPORT int gme_autoload_playback_limit( Music_Emu const* );
 
@@ -237,7 +238,7 @@ BLARGG_EXPORT int gme_type_multitrack( gme_type_t );
 
 /* whether the pcm output retrieved by gme_play() will have all 8 voices rendered to their
  * individual stereo channel or (if false) these voices get mixed into one single stereo channel
- * @since 0.6.2 */
+ * @since 0.6.3 */
 BLARGG_EXPORT int gme_multi_channel( Music_Emu const* );
 
 /******** Advanced file loading ********/
@@ -261,7 +262,7 @@ BLARGG_EXPORT gme_type_t gme_identify_extension( const char path_or_extension []
  * Get typical file extension for a given music type.  This is not a replacement
  * for a file content identification library (but see gme_identify_header).
  *
- * @since 0.6.2
+ * @since 0.6.3
  */
 BLARGG_EXPORT const char* gme_type_extension( gme_type_t music_type );
 
@@ -276,7 +277,7 @@ BLARGG_EXPORT Music_Emu* gme_new_emu( gme_type_t, int sample_rate );
 /* Create new multichannel emulator and set sample rate. Returns NULL if out of memory.
  * If you only need track information, pass gme_info_only for sample_rate.
  * (see gme_multi_channel for more information on multichannel support)
- * @since 0.6.2
+ * @since 0.6.3
  */
 BLARGG_EXPORT Music_Emu* gme_new_emu_multi_channel( gme_type_t, int sample_rate );
 

From 3542bc465f326a7cc58d95543bcb666e952267a7 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Wed, 4 Oct 2023 17:56:56 +0300
Subject: [PATCH 4/5] gme/ext: remove unnecessary mamedef.h, add missing
 newlines at end.

---
 gme/ext/2413tone.h |  2 +-
 gme/ext/emu2413.c  |  2 --
 gme/ext/mamedef.h  | 62 ----------------------------------------------
 gme/ext/panning.h  |  2 +-
 4 files changed, 2 insertions(+), 66 deletions(-)
 delete mode 100644 gme/ext/mamedef.h

diff --git a/gme/ext/2413tone.h b/gme/ext/2413tone.h
index fb42e3f..c041dc9 100644
--- a/gme/ext/2413tone.h
+++ b/gme/ext/2413tone.h
@@ -17,4 +17,4 @@
 0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,
 0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,
 0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,
-0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,
\ No newline at end of file
+0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,
diff --git a/gme/ext/emu2413.c b/gme/ext/emu2413.c
index e41753f..701dbde 100644
--- a/gme/ext/emu2413.c
+++ b/gme/ext/emu2413.c
@@ -55,8 +55,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include "mamedef.h"
-#undef INLINE
 #include "emu2413.h"
 #include "panning.h" // Maxim
 
diff --git a/gme/ext/mamedef.h b/gme/ext/mamedef.h
deleted file mode 100644
index bc6cfbf..0000000
--- a/gme/ext/mamedef.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef __MAMEDEF_H__
-#define __MAMEDEF_H__
-
-// typedefs to use MAME's (U)INTxx types (copied from MAME\src\ods\odscomm.h)
-/* 8-bit values */
-typedef unsigned char						UINT8;
-typedef signed char 						INT8;
-
-/* 16-bit values */
-typedef unsigned short						UINT16;
-typedef signed short						INT16;
-
-/* 32-bit values */
-#ifndef _WINDOWS_H
-typedef unsigned int						UINT32;
-typedef signed int							INT32;
-#endif
-
-/* 64-bit values */
-#ifndef _WINDOWS_H
-#ifdef _MSC_VER
-typedef signed __int64						INT64;
-typedef unsigned __int64					UINT64;
-#else
-__extension__ typedef unsigned long long	UINT64;
-__extension__ typedef signed long long		INT64;
-#endif
-#endif
-
-/* offsets and addresses are 32-bit (for now...) */
-typedef UINT32	offs_t;
-
-/* stream_sample_t is used to represent a single sample in a sound stream */
-typedef INT32 stream_sample_t;
-
-#ifdef VGM_BIG_ENDIAN
-#define BYTE_XOR_BE(x)	 (x)
-#else
-#define BYTE_XOR_BE(x)	((x) ^ 0x01)
-#endif
-
-#if defined(_MSC_VER)
-//#define INLINE	static __forceinline
-#define INLINE	static __inline
-#elif defined(__GNUC__)
-#define INLINE	static __inline__
-#else
-#define INLINE	static inline
-#endif
-#ifndef M_PI
-#define M_PI	3.14159265358979323846
-#endif
-
-#ifdef _DEBUG
-#define logerror	printf
-#else
-#define logerror
-#endif
-
-typedef void (*SRATE_CALLBACK)(void*, UINT32);
-
-#endif	// __MAMEDEF_H__
diff --git a/gme/ext/panning.h b/gme/ext/panning.h
index b6bab25..59a33d3 100644
--- a/gme/ext/panning.h
+++ b/gme/ext/panning.h
@@ -10,4 +10,4 @@
 void calc_panning(float channels[2], int position);
 void centre_panning(float channels[2]);
 
-#endif
\ No newline at end of file
+#endif

From f8b277220069cf605e947a91604bab433f51dbeb Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Thu, 5 Oct 2023 00:04:56 +0300
Subject: [PATCH 5/5] blargg_endian.h: fix GET_LE32 inline asm for gcc powerpc

---
 gme/blargg_endian.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gme/blargg_endian.h b/gme/blargg_endian.h
index 46e58e2..0f1e7a6 100644
--- a/gme/blargg_endian.h
+++ b/gme/blargg_endian.h
@@ -142,7 +142,7 @@ inline void set_be32( void* p, blargg_ulong n )
 				#define SET_LE32( addr, in )    (__stwbrx( in, addr, 0 ))
 			#elif defined (__GNUC__)
 				#define GET_LE16( addr )        ({unsigned short ppc_lhbrx_; __asm__ volatile( "lhbrx %0,0,%1" : "=r" (ppc_lhbrx_) : "r" (addr) : "memory" ); ppc_lhbrx_;})
-				#define GET_LE32( addr )        ({unsigned short ppc_lwbrx_; __asm__ volatile( "lwbrx %0,0,%1" : "=r" (ppc_lwbrx_) : "r" (addr) : "memory" ); ppc_lwbrx_;})
+				#define GET_LE32( addr )        ({unsigned int ppc_lwbrx_; __asm__ volatile( "lwbrx %0,0,%1" : "=r" (ppc_lwbrx_) : "r" (addr) : "memory" ); ppc_lwbrx_;})
 				#define SET_LE16( addr, in )    ({__asm__ volatile( "sthbrx %0,0,%1" : : "r" (in), "r" (addr) : "memory" );})
 				#define SET_LE32( addr, in )    ({__asm__ volatile( "stwbrx %0,0,%1" : : "r" (in), "r" (addr) : "memory" );})
 			#endif