update / reconfigure libmodplug and rebuild it:
authorOzkan Sezer <sezeroz@gmail.com>
Wed, 24 Oct 2018 01:01:02 +0300
changeset 914121b1e9b5684
parent 913 270f416f3a4f
child 915 2e274cefe1db
update / reconfigure libmodplug and rebuild it:

- disable wav formats handling: SDL_mixer has its own code for it.
- disable midi formats handling: SDL_mixer has timidity or native midi for it.
- disable experimental (possibly broken) file save support: not used, ever.
- don't export cplusplus interface from shared libs. SDL_mixer doesn't use it.
- disable mmcmp unpacking. disable broken pp20 unpacking.
- merge https://github.com/Konstanty/libmodplug/pull/36 (fix PSM loader overwrites const data)
- merge https://github.com/Konstanty/libmodplug/pull/39 (case-sensitive STM signature checks)
- merge https://github.com/Konstanty/libmodplug/pull/40 (big-endian-friendly MDL track length read)
- merge https://github.com/Konstanty/libmodplug/pull/24 (make some stuff static)
- merge https://github.com/Konstanty/libmodplug/pull/14 (NO_PACKING and MODPLUG_NO_FILESAVE ifdefs)
- merge https://github.com/Konstanty/libmodplug/pull/32 (replace setenv)
- merge https://github.com/Konstanty/libmodplug/pull/41 (timidity paths update)
VisualC/external/lib/x64/libmodplug-1.dll
VisualC/external/lib/x86/libmodplug-1.dll
Xcode/Frameworks/modplug.framework/Versions/A/modplug
external/libmodplug-0.8.9.0/configure
external/libmodplug-0.8.9.0/configure.ac
external/libmodplug-0.8.9.0/libmodplug-0.8.9.0.patch
external/libmodplug-0.8.9.0/src/config.h.in
external/libmodplug-0.8.9.0/src/libmodplug/it_defs.h
external/libmodplug-0.8.9.0/src/libmodplug/sndfile.h
external/libmodplug-0.8.9.0/src/libmodplug/stdafx.h
external/libmodplug-0.8.9.0/src/load_669.cpp
external/libmodplug-0.8.9.0/src/load_abc.cpp
external/libmodplug-0.8.9.0/src/load_amf.cpp
external/libmodplug-0.8.9.0/src/load_dmf.cpp
external/libmodplug-0.8.9.0/src/load_it.cpp
external/libmodplug-0.8.9.0/src/load_mdl.cpp
external/libmodplug-0.8.9.0/src/load_mid.cpp
external/libmodplug-0.8.9.0/src/load_mod.cpp
external/libmodplug-0.8.9.0/src/load_pat.cpp
external/libmodplug-0.8.9.0/src/load_psm.cpp
external/libmodplug-0.8.9.0/src/load_s3m.cpp
external/libmodplug-0.8.9.0/src/load_stm.cpp
external/libmodplug-0.8.9.0/src/load_wav.cpp
external/libmodplug-0.8.9.0/src/mmcmp.cpp
external/libmodplug-0.8.9.0/src/sndfile.cpp
external/libmodplug-0.8.9.0/src/sndmix.cpp
     1.1 Binary file VisualC/external/lib/x64/libmodplug-1.dll has changed
     2.1 Binary file VisualC/external/lib/x86/libmodplug-1.dll has changed
     3.1 Binary file Xcode/Frameworks/modplug.framework/Versions/A/modplug has changed
     4.1 --- a/external/libmodplug-0.8.9.0/configure	Sat Oct 20 21:00:02 2018 +0300
     4.2 +++ b/external/libmodplug-0.8.9.0/configure	Wed Oct 24 01:01:02 2018 +0300
     4.3 @@ -16702,13 +16702,12 @@
     4.4  
     4.5  done
     4.6  
     4.7 -for ac_func in setenv sinf
     4.8 +for ac_func in sinf
     4.9  do :
    4.10 -  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    4.11 -ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
    4.12 -if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
    4.13 +  ac_fn_cxx_check_func "$LINENO" "sinf" "ac_cv_func_sinf"
    4.14 +if test "x$ac_cv_func_sinf" = xyes; then :
    4.15    cat >>confdefs.h <<_ACEOF
    4.16 -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
    4.17 +#define HAVE_SINF 1
    4.18  _ACEOF
    4.19  
    4.20  fi
     5.1 --- a/external/libmodplug-0.8.9.0/configure.ac	Sat Oct 20 21:00:02 2018 +0300
     5.2 +++ b/external/libmodplug-0.8.9.0/configure.ac	Wed Oct 24 01:01:02 2018 +0300
     5.3 @@ -29,7 +29,7 @@
     5.4  
     5.5  AC_HEADER_STDC
     5.6  AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
     5.7 -AC_CHECK_FUNCS(setenv sinf)
     5.8 +AC_CHECK_FUNCS(sinf)
     5.9  
    5.10  CXXFLAGS="$CXXFLAGS -fno-exceptions -Wall -ffast-math -fno-common -D_REENTRANT"
    5.11  
    5.12 @@ -99,6 +99,6 @@
    5.13  AC_SUBST(MODPLUG_LIBRARY_VERSION)
    5.14  
    5.15  AC_CONFIG_FILES([Makefile
    5.16 -          src/Makefile
    5.17 +	  src/Makefile
    5.18  	  libmodplug.pc])
    5.19  AC_OUTPUT
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/external/libmodplug-0.8.9.0/libmodplug-0.8.9.0.patch	Wed Oct 24 01:01:02 2018 +0300
     6.3 @@ -0,0 +1,905 @@
     6.4 +- disable wav formats handling: SDL_mixer has its own code for it.
     6.5 +- disable midi formats handling: SDL_mixer has timidity or native midi for it.
     6.6 +- disable experimental file save support: no one uses it, ever.
     6.7 +- don't export cplusplus interface from shared libs. SDL_mixer doesn't use it.
     6.8 +- disable mmcmp unpacking. disable broken pp20 unpacking.
     6.9 +- merge https://github.com/Konstanty/libmodplug/pull/36 (fix PSM loader overwrites const data)
    6.10 +- merge https://github.com/Konstanty/libmodplug/pull/39 (case-sensitive STM signature checks)
    6.11 +- merge https://github.com/Konstanty/libmodplug/pull/40 (big-endian-friendly MDL track length read)
    6.12 +- merge https://github.com/Konstanty/libmodplug/pull/24 (make some stuff static)
    6.13 +- merge https://github.com/Konstanty/libmodplug/pull/14 (NO_PACKING / MODPLUG_NO_FILESAVE ifdefs)
    6.14 +- merge https://github.com/Konstanty/libmodplug/pull/32 (replace setenv)
    6.15 +- merge https://github.com/Konstanty/libmodplug/pull/41 (timidity paths update)
    6.16 +
    6.17 +diff -u libmodplug-0.8.9.0/configure.ac~ libmodplug-0.8.9.0/configure.ac
    6.18 +--- libmodplug-0.8.9.0/configure.ac~
    6.19 ++++ libmodplug-0.8.9.0/configure.ac
    6.20 +@@ -29,7 +29,7 @@ LT_INIT([win32-dll])
    6.21 + 
    6.22 + AC_HEADER_STDC
    6.23 + AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
    6.24 +-AC_CHECK_FUNCS(setenv sinf)
    6.25 ++AC_CHECK_FUNCS(sinf)
    6.26 + 
    6.27 + CXXFLAGS="$CXXFLAGS -fno-exceptions -Wall -ffast-math -fno-common -D_REENTRANT"
    6.28 + 
    6.29 +@@ -99,6 +99,6 @@ MODPLUG_LIBRARY_VERSION=1:0:0
    6.30 + AC_SUBST(MODPLUG_LIBRARY_VERSION)
    6.31 + 
    6.32 + AC_CONFIG_FILES([Makefile
    6.33 +-          src/Makefile
    6.34 ++	  src/Makefile
    6.35 + 	  libmodplug.pc])
    6.36 + AC_OUTPUT
    6.37 +diff -u libmodplug-0.8.9.0/configure~ libmodplug-0.8.9.0/configure
    6.38 +--- libmodplug-0.8.9.0/configure~
    6.39 ++++ libmodplug-0.8.9.0/configure
    6.40 +@@ -16702,13 +16702,12 @@ fi
    6.41 + 
    6.42 + done
    6.43 + 
    6.44 +-for ac_func in setenv sinf
    6.45 ++for ac_func in sinf
    6.46 + do :
    6.47 +-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    6.48 +-ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
    6.49 +-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
    6.50 ++  ac_fn_cxx_check_func "$LINENO" "sinf" "ac_cv_func_sinf"
    6.51 ++if test "x$ac_cv_func_sinf" = xyes; then :
    6.52 +   cat >>confdefs.h <<_ACEOF
    6.53 +-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
    6.54 ++#define HAVE_SINF 1
    6.55 + _ACEOF
    6.56 + 
    6.57 + fi
    6.58 +diff -u libmodplug-0.8.9.0/src/config.h.in~ libmodplug-0.8.9.0/src/config.h.in
    6.59 +--- libmodplug-0.8.9.0/src/config.h.in~
    6.60 ++++ libmodplug-0.8.9.0/src/config.h.in
    6.61 +@@ -15,9 +15,6 @@
    6.62 + /* Define to 1 if you have the <memory.h> header file. */
    6.63 + #undef HAVE_MEMORY_H
    6.64 + 
    6.65 +-/* Define to 1 if you have the `setenv' function. */
    6.66 +-#undef HAVE_SETENV
    6.67 +-
    6.68 + /* Define to 1 if you have the `sinf' function. */
    6.69 + #undef HAVE_SINF
    6.70 + 
    6.71 +diff -up libmodplug-0.8.9.0/src/libmodplug/it_defs.h~ libmodplug-0.8.9.0/src/libmodplug/it_defs.h
    6.72 +--- libmodplug-0.8.9.0/src/libmodplug/it_defs.h~
    6.73 ++++ libmodplug-0.8.9.0/src/libmodplug/it_defs.h
    6.74 +@@ -128,7 +128,9 @@ typedef struct ITSAMPLESTRUCT
    6.75 + 
    6.76 + #pragma pack()
    6.77 + 
    6.78 +-extern BYTE autovibit2xm[8];
    6.79 +-extern BYTE autovibxm2it[8];
    6.80 ++#if 0/* made these two static to load_it.cpp */
    6.81 ++extern const BYTE autovibit2xm[8];
    6.82 ++extern const BYTE autovibxm2it[8];
    6.83 ++#endif
    6.84 + 
    6.85 + #endif
    6.86 +diff -up libmodplug-0.8.9.0/src/libmodplug/sndfile.h~ libmodplug-0.8.9.0/src/libmodplug/sndfile.h
    6.87 +--- libmodplug-0.8.9.0/src/libmodplug/sndfile.h~
    6.88 ++++ libmodplug-0.8.9.0/src/libmodplug/sndfile.h
    6.89 +@@ -456,7 +456,7 @@ typedef struct _MODCOMMAND
    6.90 + // Mix Plugins
    6.91 + #define MIXPLUG_MIXREADY			0x01	// Set when cleared
    6.92 + 
    6.93 +-class MODPLUG_EXPORT IMixPlugin
    6.94 ++class /*MODPLUG_EXPORT*/ IMixPlugin
    6.95 + {
    6.96 + public:
    6.97 + 	virtual ~IMixPlugin() {};
    6.98 +@@ -535,7 +535,7 @@ typedef VOID (* LPSNDMIXHOOKPROC)(int *,
    6.99 + 
   6.100 + 
   6.101 + //==============
   6.102 +-class MODPLUG_EXPORT CSoundFile
   6.103 ++class /*MODPLUG_EXPORT*/ CSoundFile
   6.104 + //==============
   6.105 + {
   6.106 + public:	// Static Members
   6.107 +@@ -638,7 +638,9 @@ public:
   6.108 + 	BOOL ReadIT(LPCBYTE lpStream, DWORD dwMemLength);
   6.109 + 	BOOL Read669(LPCBYTE lpStream, DWORD dwMemLength);
   6.110 + 	BOOL ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
   6.111 ++#ifndef NO_WAVFORMAT
   6.112 + 	BOOL ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
   6.113 ++#endif
   6.114 + 	BOOL ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
   6.115 + 	BOOL ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
   6.116 + 	BOOL ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
   6.117 +@@ -653,12 +655,14 @@ public:
   6.118 + 	BOOL ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
   6.119 + 	BOOL ReadJ2B(LPCBYTE lpStream, DWORD dwMemLength);
   6.120 + 	BOOL ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
   6.121 ++#ifndef NO_MIDIFORMATS
   6.122 + 	BOOL ReadABC(LPCBYTE lpStream, DWORD dwMemLength);
   6.123 + 	BOOL TestABC(LPCBYTE lpStream, DWORD dwMemLength);
   6.124 + 	BOOL ReadMID(LPCBYTE lpStream, DWORD dwMemLength);
   6.125 + 	BOOL TestMID(LPCBYTE lpStream, DWORD dwMemLength);
   6.126 + 	BOOL ReadPAT(LPCBYTE lpStream, DWORD dwMemLength);
   6.127 + 	BOOL TestPAT(LPCBYTE lpStream, DWORD dwMemLength);
   6.128 ++#endif
   6.129 + 	// Save Functions
   6.130 + #ifndef MODPLUG_NO_FILESAVE
   6.131 + 	UINT WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen=0);
   6.132 +@@ -666,14 +670,16 @@ public:
   6.133 + 	BOOL SaveS3M(LPCSTR lpszFileName, UINT nPacking=0);
   6.134 + 	BOOL SaveMod(LPCSTR lpszFileName, UINT nPacking=0);
   6.135 + 	BOOL SaveIT(LPCSTR lpszFileName, UINT nPacking=0);
   6.136 +-#endif // MODPLUG_NO_FILESAVE
   6.137 +-	// MOD Convert function
   6.138 + 	UINT GetBestSaveFormat() const;
   6.139 + 	UINT GetSaveFormats() const;
   6.140 ++#endif
   6.141 ++	// MOD Convert function
   6.142 + 	void ConvertModCommand(MODCOMMAND *) const;
   6.143 + 	void S3MConvert(MODCOMMAND *m, BOOL bIT) const;
   6.144 ++#ifndef MODPLUG_NO_FILESAVE
   6.145 + 	void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const;
   6.146 + 	WORD ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const;
   6.147 ++#endif
   6.148 + 
   6.149 + public:
   6.150 + 	// Real-time sound functions
   6.151 +@@ -759,8 +765,11 @@ public:
   6.152 + 	BOOL IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const;
   6.153 + 	// Read/Write sample functions
   6.154 + 	signed char GetDeltaValue(signed char prev, UINT n) const { return (signed char)(prev + CompressionTable[n & 0x0F]); }
   6.155 ++#if !(defined(MODPLUG_NO_FILESAVE)||defined(NO_PACKING))
   6.156 + 	UINT PackSample(int &sample, int next);
   6.157 + 	BOOL CanPackSample(LPSTR pSample, UINT nLen, UINT nPacking, BYTE *result=NULL);
   6.158 ++#endif // NO_FILESAVE, NO_PACKING
   6.159 ++
   6.160 + 	UINT ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR pMemFile, DWORD dwMemLength);
   6.161 + 	BOOL DestroySample(UINT nSample);
   6.162 + 	BOOL DestroyInstrument(UINT nInstr);
   6.163 +diff -up libmodplug-0.8.9.0/src/libmodplug/stdafx.h~ libmodplug-0.8.9.0/src/libmodplug/stdafx.h
   6.164 +--- libmodplug-0.8.9.0/src/libmodplug/stdafx.h~
   6.165 ++++ libmodplug-0.8.9.0/src/libmodplug/stdafx.h
   6.166 +@@ -21,9 +21,15 @@
   6.167 + # include <stdint.h>
   6.168 + #endif
   6.169 + 
   6.170 ++/*#define MMCMP_SUPPORT*/
   6.171 ++
   6.172 + /* disable AGC and FILESAVE for all targets for uniformity. */
   6.173 + #define NO_AGC
   6.174 + #define MODPLUG_NO_FILESAVE
   6.175 ++/*#define NO_PACKING*/
   6.176 ++/*#define NO_FILTER */
   6.177 ++#define NO_MIDIFORMATS
   6.178 ++#define NO_WAVFORMAT
   6.179 + 
   6.180 + #ifdef _WIN32
   6.181 + 
   6.182 +@@ -88,12 +94,6 @@ typedef const char* LPCSTR;
   6.183 + typedef void* PVOID;
   6.184 + typedef void VOID;
   6.185 + 
   6.186 +-inline LONG MulDiv (long a, long b, long c)
   6.187 +-{
   6.188 +-/*if (!c) return 0;*/
   6.189 +-  return ((uint64_t) a * (uint64_t) b ) / c;
   6.190 +-}
   6.191 +-
   6.192 + #define LPCTSTR LPCSTR
   6.193 + #define lstrcpyn strncpy
   6.194 + #define lstrcpy strcpy
   6.195 +diff -up libmodplug-0.8.9.0/src/load_669.cpp~ libmodplug-0.8.9.0/src/load_669.cpp
   6.196 +--- libmodplug-0.8.9.0/src/load_669.cpp~
   6.197 ++++ libmodplug-0.8.9.0/src/load_669.cpp
   6.198 +@@ -17,7 +17,7 @@
   6.199 + typedef struct tagFILEHEADER669
   6.200 + {
   6.201 + 	WORD sig;				// 'if' or 'JN'
   6.202 +-        signed char songmessage[108];	// Song Message
   6.203 ++	signed char songmessage[108];	// Song Message
   6.204 + 	BYTE samples;			// number of samples (1-64)
   6.205 + 	BYTE patterns;			// number of patterns (1-128)
   6.206 + 	BYTE restartpos;
   6.207 +@@ -35,7 +35,7 @@ typedef struct tagSAMPLE669
   6.208 + 	BYTE loopend[4];
   6.209 + } SAMPLE669;
   6.210 + 
   6.211 +-DWORD lengthArrayToDWORD(const BYTE length[4]) {
   6.212 ++static DWORD lengthArrayToDWORD(const BYTE length[4]) {
   6.213 + 	DWORD len = (length[3] << 24) +
   6.214 + 		(length[2] << 16) +
   6.215 + 		(length[1] << 8) +
   6.216 +diff -up libmodplug-0.8.9.0/src/load_abc.cpp~ libmodplug-0.8.9.0/src/load_abc.cpp
   6.217 +--- libmodplug-0.8.9.0/src/load_abc.cpp~
   6.218 ++++ libmodplug-0.8.9.0/src/load_abc.cpp
   6.219 +@@ -37,9 +37,11 @@
   6.220 + #include "stdafx.h"
   6.221 + #include "sndfile.h"
   6.222 + 
   6.223 ++#ifndef NO_MIDIFORMATS
   6.224 ++
   6.225 + #include "load_pat.h"
   6.226 + 
   6.227 +-#if _MSC_VER >= 1600
   6.228 ++#if defined(_MSC_VER) && (_MSC_VER >= 1300)
   6.229 + #define putenv _putenv
   6.230 + #define strdup _strdup
   6.231 + #endif
   6.232 +@@ -256,16 +258,6 @@ static void abc_add_setjumploop(ABCHANDL
   6.233 + static uint32_t abc_pattracktime(ABCHANDLE *h, uint32_t tracktime);
   6.234 + static int abc_patno(ABCHANDLE *h, uint32_t tracktime);
   6.235 + 
   6.236 +-#ifndef HAVE_SETENV
   6.237 +-static void setenv(const char *name, const char *value, int overwrite)
   6.238 +-{
   6.239 +-	int len = strlen(name)+1+strlen(value)+1;
   6.240 +-	char *str = (char *)malloc(len);
   6.241 +-	sprintf(str, "%s=%s", name, value);
   6.242 +-	putenv(str);
   6.243 +-	free(str);
   6.244 +-}
   6.245 +-#endif
   6.246 + 
   6.247 + static int abc_isvalidchar(char c) {
   6.248 + 	return(isalpha(c) || isdigit(c) || isspace(c) || c == '%' || c == ':');
   6.249 +@@ -2345,9 +2337,9 @@ BOOL CSoundFile::TestABC(const BYTE *lpS
   6.250 + // =====================================================================================
   6.251 + static ABCHANDLE *ABC_Init(void)
   6.252 + {
   6.253 ++	static char buf[40];
   6.254 + 	ABCHANDLE   *retval;
   6.255 + 	char *p;
   6.256 +-	char buf[10];
   6.257 + 	retval = (ABCHANDLE *)calloc(1,sizeof(ABCHANDLE));
   6.258 + 	if( !retval ) return NULL;
   6.259 + 	retval->track       = NULL;
   6.260 +@@ -2365,16 +2357,16 @@ static ABCHANDLE *ABC_Init(void)
   6.261 + 			retval->pickrandom = atoi(p);
   6.262 + 		if( *p == '-' ) {
   6.263 + 			retval->pickrandom = atoi(p+1)-1; // xmms preloads the file
   6.264 +-			sprintf(buf,"-%ld",retval->pickrandom+2);
   6.265 +-			setenv(ABC_ENV_NORANDOMPICK, buf, 1);
   6.266 ++			sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
   6.267 ++			putenv(buf);
   6.268 + 		}
   6.269 + 	}
   6.270 + 	else {
   6.271 + 		srandom((uint32_t)time(0));	// initialize random generator with seed
   6.272 + 		retval->pickrandom = 1+(int)(10000.0*random()/(RAND_MAX+1.0));
   6.273 + 		// can handle pickin' from songbooks with 10.000 songs
   6.274 +-		sprintf(buf,"-%ld",retval->pickrandom); // xmms preloads the file
   6.275 +-		setenv(ABC_ENV_NORANDOMPICK, buf, 1);
   6.276 ++		sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom); // xmms preloads the file
   6.277 ++		putenv(buf);
   6.278 + 	}
   6.279 + 	return retval;
   6.280 + }
   6.281 +@@ -4878,3 +4870,4 @@ BOOL CSoundFile::ReadABC(const uint8_t *
   6.282 + 	ABC_Cleanup(h);	// we dont need it anymore
   6.283 + 	return 1;
   6.284 + }
   6.285 ++#endif // NO_MIDIFORMATS
   6.286 +diff -up libmodplug-0.8.9.0/src/load_amf.cpp~ libmodplug-0.8.9.0/src/load_amf.cpp
   6.287 +--- libmodplug-0.8.9.0/src/load_amf.cpp~
   6.288 ++++ libmodplug-0.8.9.0/src/load_amf.cpp
   6.289 +@@ -44,7 +44,6 @@ typedef struct _AMFSAMPLE
   6.290 + 	UCHAR volume;
   6.291 + } AMFSAMPLE;
   6.292 + 
   6.293 +-
   6.294 + #pragma pack()
   6.295 + 
   6.296 + 
   6.297 +@@ -52,7 +51,7 @@ typedef struct _AMFSAMPLE
   6.298 + extern void Log(LPCSTR, ...);
   6.299 + #endif
   6.300 + 
   6.301 +-VOID AMF_Unpack(MODCOMMAND *pPat, const BYTE *pTrack, UINT nRows, UINT nChannels)
   6.302 ++static VOID AMF_Unpack(MODCOMMAND *pPat, const BYTE *pTrack, UINT nRows, UINT nChannels)
   6.303 + //-------------------------------------------------------------------------------
   6.304 + {
   6.305 + 	UINT lastinstr = 0;
   6.306 +@@ -163,7 +162,6 @@ VOID AMF_Unpack(MODCOMMAND *pPat, const 
   6.307 + }
   6.308 + 
   6.309 + 
   6.310 +-
   6.311 + BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength)
   6.312 + //-----------------------------------------------------------
   6.313 + {
   6.314 +diff -up libmodplug-0.8.9.0/src/load_dmf.cpp~ libmodplug-0.8.9.0/src/load_dmf.cpp
   6.315 +--- libmodplug-0.8.9.0/src/load_dmf.cpp~
   6.316 ++++ libmodplug-0.8.9.0/src/load_dmf.cpp
   6.317 +@@ -509,7 +509,7 @@ typedef struct DMF_HTREE
   6.318 + 
   6.319 + 
   6.320 + // DMF Huffman ReadBits
   6.321 +-BYTE DMFReadBits(DMF_HTREE *tree, UINT nbits)
   6.322 ++static BYTE DMFReadBits(DMF_HTREE *tree, UINT nbits)
   6.323 + //-------------------------------------------
   6.324 + {
   6.325 + 	BYTE x = 0, bitv = 1;
   6.326 +@@ -534,7 +534,7 @@ BYTE DMFReadBits(DMF_HTREE *tree, UINT n
   6.327 + // tree: [8-bit value][12-bit index][12-bit index] = 32-bit
   6.328 + //
   6.329 + 
   6.330 +-void DMFNewNode(DMF_HTREE *tree)
   6.331 ++static void DMFNewNode(DMF_HTREE *tree)
   6.332 + //------------------------------
   6.333 + {
   6.334 + 	BYTE isleft, isright;
   6.335 +diff -up libmodplug-0.8.9.0/src/load_it.cpp~ libmodplug-0.8.9.0/src/load_it.cpp
   6.336 +--- libmodplug-0.8.9.0/src/load_it.cpp~
   6.337 ++++ libmodplug-0.8.9.0/src/load_it.cpp
   6.338 +@@ -15,19 +15,18 @@
   6.339 + #pragma warning(disable:4244)
   6.340 + #endif
   6.341 + 
   6.342 ++static const
   6.343 + BYTE autovibit2xm[8] =
   6.344 + { 0, 3, 1, 4, 2, 0, 0, 0 };
   6.345 +-
   6.346 ++#ifndef MODPLUG_NO_FILESAVE
   6.347 ++static const
   6.348 + BYTE autovibxm2it[8] =
   6.349 + { 0, 2, 4, 1, 3, 0, 0, 0 };
   6.350 ++#endif
   6.351 + 
   6.352 + //////////////////////////////////////////////////////////
   6.353 + // Impulse Tracker IT file support
   6.354 + 
   6.355 +-// for conversion of XM samples
   6.356 +-extern WORD XMPeriodTable[96+8];
   6.357 +-extern UINT XMLinearTable[768];
   6.358 +-
   6.359 + static inline UINT ConvertVolParam(UINT value)
   6.360 + //--------------------------------------------
   6.361 + {
   6.362 +diff -up libmodplug-0.8.9.0/src/load_mdl.cpp~ libmodplug-0.8.9.0/src/load_mdl.cpp
   6.363 +--- libmodplug-0.8.9.0/src/load_mdl.cpp~
   6.364 ++++ libmodplug-0.8.9.0/src/load_mdl.cpp
   6.365 +@@ -42,7 +42,7 @@ typedef struct MDLPATTERNDATA
   6.366 + } MDLPATTERNDATA;
   6.367 + 
   6.368 + 
   6.369 +-void ConvertMDLCommand(MODCOMMAND *m, UINT eff, UINT data)
   6.370 ++static void ConvertMDLCommand(MODCOMMAND *m, UINT eff, UINT data)
   6.371 + //--------------------------------------------------------
   6.372 + {
   6.373 + 	UINT command = 0, param = data;
   6.374 +@@ -91,7 +91,7 @@ void ConvertMDLCommand(MODCOMMAND *m, UI
   6.375 + }
   6.376 + 
   6.377 + 
   6.378 +-void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, const BYTE *lpTracks, UINT len)
   6.379 ++static void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, const BYTE *lpTracks, UINT len)
   6.380 + //-------------------------------------------------------------------------------------------------
   6.381 + {
   6.382 + 	MODCOMMAND cmd, *m = pat;
   6.383 +@@ -168,7 +168,6 @@ void UnpackMDLTrack(MODCOMMAND *pat, UIN
   6.384 + }
   6.385 + 
   6.386 + 
   6.387 +-
   6.388 + BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength)
   6.389 + //---------------------------------------------------------------
   6.390 + {
   6.391 +@@ -429,12 +428,13 @@ BOOL CSoundFile::ReadMDL(const BYTE *lpS
   6.392 + 		for (UINT ipat=0; ipat<npatterns; ipat++)
   6.393 + 		{
   6.394 + 			if ((Patterns[ipat] = AllocatePattern(PatternSize[ipat], m_nChannels)) == NULL) break;
   6.395 +-			for (UINT chn=0; chn<m_nChannels; chn++) if ((patterntracks[ipat*32+chn]) && (patterntracks[ipat*32+chn] <= ntracks) && (*(WORD *)lpStream+dwTrackPos) < dwMemLength-dwTrackPos)
   6.396 ++			for (UINT chn=0; chn<m_nChannels; chn++) if ((patterntracks[ipat*32+chn]) && (patterntracks[ipat*32+chn] <= ntracks))
   6.397 + 			{
   6.398 ++			    const BYTE *lpTracks = lpStream + dwTrackPos;
   6.399 ++			    UINT len = lpTracks[0] | (lpTracks[1] << 8);
   6.400 ++			    if (len < dwMemLength-dwTrackPos) {
   6.401 + 				MODCOMMAND *m = Patterns[ipat] + chn;
   6.402 + 				UINT nTrack = patterntracks[ipat*32+chn];
   6.403 +-				const BYTE *lpTracks = lpStream + dwTrackPos;
   6.404 +-				UINT len = lpTracks[0] | (lpTracks[1] << 8);
   6.405 + 
   6.406 + 				lpTracks += 2;
   6.407 + 				for (UINT ntrk=1; ntrk<nTrack && lpTracks < (dwMemLength + lpStream - len); ntrk++)
   6.408 +@@ -447,6 +447,7 @@ BOOL CSoundFile::ReadMDL(const BYTE *lpS
   6.409 + 				if ( len > dwMemLength - dwTrackPos ) len = 0;
   6.410 + 
   6.411 + 				UnpackMDLTrack(m, m_nChannels, PatternSize[ipat], nTrack, lpTracks, len);
   6.412 ++			    }
   6.413 + 			}
   6.414 + 		}
   6.415 + 	}
   6.416 +diff -up libmodplug-0.8.9.0/src/load_mid.cpp~ libmodplug-0.8.9.0/src/load_mid.cpp
   6.417 +--- libmodplug-0.8.9.0/src/load_mid.cpp~
   6.418 ++++ libmodplug-0.8.9.0/src/load_mid.cpp
   6.419 +@@ -35,6 +35,9 @@
   6.420 + 
   6.421 + #include "stdafx.h"
   6.422 + #include "sndfile.h"
   6.423 ++
   6.424 ++#ifndef NO_MIDIFORMATS
   6.425 ++
   6.426 + #define PAN_LEFT    0x30
   6.427 + #define PAN_RIGHT   0xD0
   6.428 + #define MAX_POLYPHONY 16  // max notes in one midi channel
   6.429 +@@ -92,7 +95,7 @@ typedef struct _MIDTRACK
   6.430 + #undef _mm_free
   6.431 + #endif
   6.432 + 
   6.433 +-#define MMSTREAM										FILE
   6.434 ++#define MMSTREAM				FILE
   6.435 + #define _mm_fseek(f,pos,whence)			fseek(f,pos,whence)
   6.436 + #define _mm_read_UBYTES(buf,sz,f)		fread(buf,sz,1,f)
   6.437 + #define _mm_read_SBYTES(buf,sz,f)		fread(buf,sz,1,f)
   6.438 +@@ -1582,3 +1585,4 @@ BOOL CSoundFile::ReadMID(const BYTE *lpS
   6.439 + 	avoid_reentry = 0; // it is safe now, I'm finished
   6.440 + 	return TRUE;
   6.441 + }
   6.442 ++#endif // NO_MIDIFORMATS
   6.443 +diff -up libmodplug-0.8.9.0/src/load_mod.cpp~ libmodplug-0.8.9.0/src/load_mod.cpp
   6.444 +--- libmodplug-0.8.9.0/src/load_mod.cpp~
   6.445 ++++ libmodplug-0.8.9.0/src/load_mod.cpp
   6.446 +@@ -60,6 +60,7 @@ void CSoundFile::ConvertModCommand(MODCO
   6.447 + }
   6.448 + 
   6.449 + 
   6.450 ++#ifndef MODPLUG_NO_FILESAVE
   6.451 + WORD CSoundFile::ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const
   6.452 + //------------------------------------------------------------------
   6.453 + {
   6.454 +@@ -144,6 +145,7 @@ WORD CSoundFile::ModSaveCommand(const MO
   6.455 + 	}
   6.456 + 	return (WORD)((command << 8) | (param));
   6.457 + }
   6.458 ++#endif // MODPLUG_NO_FILESAVE
   6.459 + 
   6.460 + 
   6.461 + #pragma pack(1)
   6.462 +@@ -184,7 +186,7 @@ static BOOL IsValidName(LPCSTR s, int le
   6.463 + 	return TRUE;
   6.464 + }
   6.465 + 
   6.466 +-BOOL IsMagic(LPCSTR s1, LPCSTR s2)
   6.467 ++static BOOL IsMagic(LPCSTR s1, LPCSTR s2)
   6.468 + {
   6.469 + 	return ((*(DWORD *)s1) == (*(DWORD *)s2)) ? TRUE : FALSE;
   6.470 + }
   6.471 +diff -up libmodplug-0.8.9.0/src/load_pat.cpp~ libmodplug-0.8.9.0/src/load_pat.cpp
   6.472 +--- libmodplug-0.8.9.0/src/load_pat.cpp~
   6.473 ++++ libmodplug-0.8.9.0/src/load_pat.cpp
   6.474 +@@ -44,16 +44,18 @@
   6.475 + #include "stdafx.h"
   6.476 + #include "sndfile.h"
   6.477 + 
   6.478 ++#ifndef NO_MIDIFORMATS
   6.479 ++
   6.480 + #include "load_pat.h"
   6.481 + 
   6.482 +-#ifdef MSC_VER
   6.483 ++#ifdef _WIN32
   6.484 + #define DIRDELIM		'\\'
   6.485 + #define TIMIDITYCFG	"C:\\TIMIDITY\\TIMIDITY.CFG"
   6.486 + #define PATHFORPAT	"C:\\TIMIDITY\\INSTRUMENTS"
   6.487 + #else
   6.488 + #define DIRDELIM		'/'
   6.489 +-#define TIMIDITYCFG	"/usr/local/share/timidity/timidity.cfg"
   6.490 +-#define PATHFORPAT	"/usr/local/share/timidity/instruments"
   6.491 ++#define TIMIDITYCFG	"/etc/timidity.cfg" /*"/usr/share/timidity/timidity.cfg"*/
   6.492 ++#define PATHFORPAT	"/usr/share/timidity/instruments"
   6.493 + #endif
   6.494 + 
   6.495 + #define PAT_ENV_PATH2CFG			"MMPAT_PATH_TO_CFG"
   6.496 +@@ -764,10 +766,7 @@ BOOL CSoundFile::TestPAT(const BYTE *lpS
   6.497 + // =====================================================================================
   6.498 + static PATHANDLE *PAT_Init(void)
   6.499 + {
   6.500 +-	PATHANDLE   *retval;
   6.501 +-	retval = (PATHANDLE *)calloc(1,sizeof(PATHANDLE));
   6.502 +-	if( !retval ) return NULL;
   6.503 +-	return retval;
   6.504 ++	return (PATHANDLE *)calloc(1,sizeof(PATHANDLE));
   6.505 + }
   6.506 + 
   6.507 + // =====================================================================================
   6.508 +@@ -1259,3 +1258,4 @@ BOOL CSoundFile::ReadPAT(const BYTE *lpS
   6.509 + 	PAT_Cleanup(h);	// we dont need it anymore
   6.510 + 	return 1;
   6.511 + }
   6.512 ++#endif // NO_MIDIFORMATS
   6.513 +diff -up libmodplug-0.8.9.0/src/load_psm.cpp~ libmodplug-0.8.9.0/src/load_psm.cpp
   6.514 +--- libmodplug-0.8.9.0/src/load_psm.cpp~
   6.515 ++++ libmodplug-0.8.9.0/src/load_psm.cpp
   6.516 +@@ -84,7 +84,9 @@ typedef struct _PSMSAMPLE
   6.517 + 	BYTE reserved6[19];
   6.518 + } PSMSAMPLE;
   6.519 + 
   6.520 +-void swap_PSMSAMPLE(PSMSAMPLE* p){
   6.521 ++#pragma pack()
   6.522 ++
   6.523 ++static void swap_PSMSAMPLE(PSMSAMPLE* p){
   6.524 + 	p->smpid = bswapLE32(p->smpid);
   6.525 + 	p->length = bswapLE32(p->length);
   6.526 + 	p->loopstart = bswapLE32(p->loopstart);
   6.527 +@@ -92,13 +94,11 @@ void swap_PSMSAMPLE(PSMSAMPLE* p){
   6.528 + 	p->samplerate = bswapLE32(p->samplerate);
   6.529 + }
   6.530 + 
   6.531 +-#pragma pack()
   6.532 +-
   6.533 + 
   6.534 + BOOL CSoundFile::ReadPSM(LPCBYTE lpStream, DWORD dwMemLength)
   6.535 + //-----------------------------------------------------------
   6.536 + {
   6.537 +-	PSMCHUNK *pfh = (PSMCHUNK *)lpStream;
   6.538 ++	PSMCHUNK pfh = *(const PSMCHUNK *)lpStream;
   6.539 + 	DWORD dwMemPos, dwSongPos;
   6.540 + 	DWORD smpnames[MAX_SAMPLES];
   6.541 + 	DWORD patptrs[MAX_PATTERNS];
   6.542 +@@ -108,17 +108,17 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.543 + 	if (dwMemLength < 256) return FALSE;
   6.544 + 
   6.545 + 	// Swap chunk
   6.546 +-	swap_PSMCHUNK(pfh);
   6.547 ++	swap_PSMCHUNK(&pfh);
   6.548 + 
   6.549 + 	// Chunk0: "PSM ",filesize,"FILE"
   6.550 +-	if (pfh->id == PSM_ID_OLD)
   6.551 ++	if (pfh.id == PSM_ID_OLD)
   6.552 + 	{
   6.553 + 	#ifdef PSM_LOG
   6.554 + 		Log("Old PSM format not supported\n");
   6.555 + 	#endif
   6.556 + 		return FALSE;
   6.557 + 	}
   6.558 +-	if ((pfh->id != PSM_ID_NEW) || (pfh->len+12 > dwMemLength) || (pfh->listid != IFFID_FILE)) return FALSE;
   6.559 ++	if ((pfh.id != PSM_ID_NEW) || (pfh.len+12 > dwMemLength) || (pfh.listid != IFFID_FILE)) return FALSE;
   6.560 + 	m_nType = MOD_TYPE_PSM;
   6.561 + 	m_nChannels = 16;
   6.562 + 	m_nSamples = 0;
   6.563 +@@ -132,13 +132,13 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.564 + 	}
   6.565 + 	while (dwMemPos+8 < dwMemLength)
   6.566 + 	{
   6.567 +-		PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
   6.568 +-		swap_PSMCHUNK(pchunk);
   6.569 +-		if ((pchunk->len >= dwMemLength - 8) || (dwMemPos + pchunk->len + 8 > dwMemLength)) break;
   6.570 ++		PSMCHUNK pchunk = *(const PSMCHUNK *)(lpStream+dwMemPos);
   6.571 ++		swap_PSMCHUNK(&pchunk);
   6.572 ++		if ((pchunk.len >= dwMemLength - 8) || (dwMemPos + pchunk.len + 8 > dwMemLength)) break;
   6.573 + 		dwMemPos += 8;
   6.574 + 		PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
   6.575 +-		ULONG len = pchunk->len;
   6.576 +-		if (len) switch(pchunk->id)
   6.577 ++		ULONG len = pchunk.len;
   6.578 ++		if (len) switch(pchunk.id)
   6.579 + 		{
   6.580 + 		// "TITL": Song title
   6.581 + 		case IFFID_TITL:
   6.582 +@@ -166,21 +166,21 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.583 + 			{
   6.584 + 				m_nSamples++;
   6.585 + 				MODINSTRUMENT *pins = &Ins[m_nSamples];
   6.586 +-				PSMSAMPLE *psmp = (PSMSAMPLE *)pdata;
   6.587 +-				swap_PSMSAMPLE(psmp);
   6.588 +-				smpnames[m_nSamples] = psmp->smpid;
   6.589 +-				memcpy(m_szNames[m_nSamples], psmp->samplename, 31);
   6.590 ++				PSMSAMPLE psmp = *(PSMSAMPLE *)pdata;
   6.591 ++				swap_PSMSAMPLE(&psmp);
   6.592 ++				smpnames[m_nSamples] = psmp.smpid;
   6.593 ++				memcpy(m_szNames[m_nSamples], psmp.samplename, 31);
   6.594 + 				m_szNames[m_nSamples][31] = 0;
   6.595 + 				samplemap[m_nSamples-1] = (BYTE)m_nSamples;
   6.596 + 				// Init sample
   6.597 + 				pins->nGlobalVol = 0x40;
   6.598 +-				pins->nC4Speed = psmp->samplerate;
   6.599 +-				pins->nLength = psmp->length;
   6.600 +-				pins->nLoopStart = psmp->loopstart;
   6.601 +-				pins->nLoopEnd = psmp->loopend;
   6.602 ++				pins->nC4Speed = psmp.samplerate;
   6.603 ++				pins->nLength = psmp.length;
   6.604 ++				pins->nLoopStart = psmp.loopstart;
   6.605 ++				pins->nLoopEnd = psmp.loopend;
   6.606 + 				pins->nPan = 128;
   6.607 +-				pins->nVolume = (psmp->defvol+1) * 2;
   6.608 +-				pins->uFlags = (psmp->flags & 0x80) ? CHN_LOOP : 0;
   6.609 ++				pins->nVolume = (psmp.defvol+1) * 2;
   6.610 ++				pins->uFlags = (psmp.flags & 0x80) ? CHN_LOOP : 0;
   6.611 + 				if (pins->nLoopStart > 0) pins->nLoopStart--;
   6.612 + 				// Point to sample data
   6.613 + 				pdata += 0x60;
   6.614 +@@ -199,17 +199,17 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.615 + 		default:
   6.616 + 			{
   6.617 + 				CHAR s[8], s2[64];
   6.618 +-				*(DWORD *)s = pchunk->id;
   6.619 ++				*(DWORD *)s = pchunk.id;
   6.620 + 				s[4] = 0;
   6.621 +-				wsprintf(s2, "%s: %4d bytes @ %4d\n", s, pchunk->len, dwMemPos);
   6.622 ++				wsprintf(s2, "%s: %4d bytes @ %4d\n", s, pchunk.len, dwMemPos);
   6.623 + 				OutputDebugString(s2);
   6.624 + 			}
   6.625 + 	#endif
   6.626 + 		}
   6.627 +-		dwMemPos += pchunk->len;
   6.628 ++		dwMemPos += pchunk.len;
   6.629 + 	}
   6.630 + 	// Step #1: convert song structure
   6.631 +-	PSMSONGHDR *pSong = (PSMSONGHDR *)(lpStream+dwSongPos+8);
   6.632 ++	const PSMSONGHDR *pSong = (const PSMSONGHDR *)(lpStream+dwSongPos+8);
   6.633 + 	if ((!dwSongPos) || (pSong->channels < 2) || (pSong->channels > 32)) return TRUE;
   6.634 + 	m_nChannels = pSong->channels;
   6.635 + 	// Valid song header -> convert attached chunks
   6.636 +@@ -218,13 +218,13 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.637 + 		dwMemPos = dwSongPos + 8 + 11; // sizeof(PSMCHUNK)+sizeof(PSMSONGHDR)
   6.638 + 		while (dwMemPos + 8 < dwSongEnd)
   6.639 + 		{
   6.640 +-			PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
   6.641 +-			swap_PSMCHUNK(pchunk);
   6.642 ++			PSMCHUNK pchunk = *(const PSMCHUNK *)(lpStream+dwMemPos);
   6.643 ++			swap_PSMCHUNK(&pchunk);
   6.644 + 			dwMemPos += 8;
   6.645 +-			if ((pchunk->len > dwSongEnd) || (dwMemPos + pchunk->len > dwSongEnd)) break;
   6.646 ++			if ((pchunk.len > dwSongEnd) || (dwMemPos + pchunk.len > dwSongEnd)) break;
   6.647 + 			PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
   6.648 +-			ULONG len = pchunk->len;
   6.649 +-			switch(pchunk->id)
   6.650 ++			ULONG len = pchunk.len;
   6.651 ++			switch(pchunk.id)
   6.652 + 			{
   6.653 + 			case IFFID_OPLH:
   6.654 + 				if (len >= 0x20)
   6.655 +@@ -237,7 +237,7 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.656 + 						DWORD dwName = *(DWORD *)(pdata+pos);
   6.657 + 						for (UINT i=0; i<nPatterns; i++)
   6.658 + 						{
   6.659 +-							DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
   6.660 ++							DWORD dwPatName = ((const PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
   6.661 + 							if (dwName == dwPatName)
   6.662 + 							{
   6.663 + 								bFound = TRUE;
   6.664 +@@ -258,7 +258,7 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.665 + 						DWORD dwName = *(DWORD *)(pdata+pos);
   6.666 + 						for (UINT i=0; i<nPatterns; i++)
   6.667 + 						{
   6.668 +-							DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
   6.669 ++							DWORD dwPatName = ((const PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
   6.670 + 							if (dwName == dwPatName)
   6.671 + 							{
   6.672 + 								Order[iOrd++] = i;
   6.673 +@@ -270,23 +270,23 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.674 + 				}
   6.675 + 				break;
   6.676 + 			}
   6.677 +-			dwMemPos += pchunk->len;
   6.678 ++			dwMemPos += pchunk.len;
   6.679 + 		}
   6.680 + 	}
   6.681 + 
   6.682 + 	// Step #2: convert patterns
   6.683 + 	for (UINT nPat=0; nPat<nPatterns; nPat++)
   6.684 + 	{
   6.685 +-		PSMPATTERN *pPsmPat = (PSMPATTERN *)(lpStream+patptrs[nPat]+8);
   6.686 +-		swap_PSMPATTERN(pPsmPat);
   6.687 ++		PSMPATTERN pPsmPat = *(const PSMPATTERN *)(lpStream+patptrs[nPat]+8);
   6.688 ++		swap_PSMPATTERN(&pPsmPat);
   6.689 + 		ULONG len = *(DWORD *)(lpStream+patptrs[nPat]+4) - 12;
   6.690 +-		UINT nRows = pPsmPat->rows;
   6.691 +-		if (len > pPsmPat->size) len = pPsmPat->size;
   6.692 ++		UINT nRows = pPsmPat.rows;
   6.693 ++		if (len > pPsmPat.size) len = pPsmPat.size;
   6.694 + 		if ((nRows < 64) || (nRows > 256)) nRows = 64;
   6.695 + 		PatternSize[nPat] = nRows;
   6.696 + 		if ((Patterns[nPat] = AllocatePattern(nRows, m_nChannels)) == NULL) break;
   6.697 + 		MODCOMMAND *m = Patterns[nPat];
   6.698 +-		BYTE *p = pPsmPat->data;
   6.699 ++		BYTE *p = pPsmPat.data;
   6.700 + 		MODCOMMAND *sp, dummy;
   6.701 + 		UINT pos = 0;
   6.702 + 		UINT row = 0;
   6.703 +@@ -295,7 +295,7 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.704 + 		Log("Pattern %d at offset 0x%04X\n", nPat, (DWORD)(p - (BYTE *)lpStream));
   6.705 + 	#endif
   6.706 + 		UINT flags, ch;
   6.707 +-		rowlim = bswapLE16(pPsmPat->reserved1)-2;
   6.708 ++		rowlim = bswapLE16(pPsmPat.reserved1)-2;
   6.709 + 		while ((row < nRows) && (pos+3 < len))
   6.710 + 		{
   6.711 + 			if ((pos+1) >= rowlim) {
   6.712 +@@ -393,7 +393,7 @@ BOOL CSoundFile::ReadPSM(LPCBYTE lpStrea
   6.713 + 	#ifdef PSM_LOG
   6.714 + 		if (pos < len)
   6.715 + 		{
   6.716 +-			Log("Pattern %d: %d/%d[%d] rows (%d bytes) -> %d bytes left\n", nPat, row, nRows, pPsmPat->rows, pPsmPat->size, len-pos);
   6.717 ++			Log("Pattern %d: %d/%d[%d] rows (%d bytes) -> %d bytes left\n", nPat, row, nRows, pPsmPat.rows, pPsmPat.size, len-pos);
   6.718 + 		}
   6.719 + 	#endif
   6.720 + 	}
   6.721 +diff -up libmodplug-0.8.9.0/src/load_s3m.cpp~ libmodplug-0.8.9.0/src/load_s3m.cpp
   6.722 +--- libmodplug-0.8.9.0/src/load_s3m.cpp~
   6.723 ++++ libmodplug-0.8.9.0/src/load_s3m.cpp
   6.724 +@@ -105,6 +105,7 @@ void CSoundFile::S3MConvert(MODCOMMAND *
   6.725 + }
   6.726 + 
   6.727 + 
   6.728 ++#ifndef MODPLUG_NO_FILESAVE
   6.729 + void CSoundFile::S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const
   6.730 + //---------------------------------------------------------------------
   6.731 + {
   6.732 +@@ -182,6 +183,7 @@ void CSoundFile::S3MSaveConvert(UINT *pc
   6.733 + 	*pcmd = command;
   6.734 + 	*pprm = param;
   6.735 + }
   6.736 ++#endif // MODPLUG_NO_FILESAVE
   6.737 + 
   6.738 + static DWORD boundInput(DWORD input, DWORD smin, DWORD smax)
   6.739 + {
   6.740 +diff -up libmodplug-0.8.9.0/src/load_stm.cpp~ libmodplug-0.8.9.0/src/load_stm.cpp
   6.741 +--- libmodplug-0.8.9.0/src/load_stm.cpp~
   6.742 ++++ libmodplug-0.8.9.0/src/load_stm.cpp
   6.743 +@@ -64,8 +64,8 @@ BOOL CSoundFile::ReadSTM(const BYTE *lpS
   6.744 + 	
   6.745 + 	if ((!lpStream) || (dwMemLength < sizeof(STMHEADER))) return FALSE;
   6.746 + 	if ((phdr->filetype != 2) || (phdr->unused != 0x1A)
   6.747 +-	 || ((strncasecmp(phdr->trackername, "!SCREAM!", 8))
   6.748 +-	  && (strncasecmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
   6.749 ++	 || ((strncmp(phdr->trackername, "!Scream!", 8))
   6.750 ++	  && (strncmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
   6.751 + 	memcpy(m_szNames[0], phdr->songname, 20);
   6.752 + 	// Read STM header
   6.753 + 	m_nType = MOD_TYPE_STM;
   6.754 +diff -up libmodplug-0.8.9.0/src/load_wav.cpp~ libmodplug-0.8.9.0/src/load_wav.cpp
   6.755 +--- libmodplug-0.8.9.0/src/load_wav.cpp~
   6.756 ++++ libmodplug-0.8.9.0/src/load_wav.cpp
   6.757 +@@ -7,6 +7,8 @@
   6.758 + #include "stdafx.h"
   6.759 + #include "sndfile.h"
   6.760 + 
   6.761 ++#ifndef NO_WAVFORMAT
   6.762 ++
   6.763 + #ifndef WAVE_FORMAT_EXTENSIBLE
   6.764 + #define WAVE_FORMAT_EXTENSIBLE	0xFFFE
   6.765 + #endif
   6.766 +@@ -170,7 +172,6 @@ static const int gIMAUnpackTable[90] =
   6.767 +   32767, 0
   6.768 + };
   6.769 + 
   6.770 +-
   6.771 + BOOL IMAADPCMUnpack16(signed short *pdest, UINT nLen, LPBYTE psrc, DWORD dwBytes, UINT pkBlkAlign)
   6.772 + //------------------------------------------------------------------------------------------------
   6.773 + {
   6.774 +@@ -215,3 +216,4 @@ BOOL IMAADPCMUnpack16(signed short *pdes
   6.775 + 	}
   6.776 + 	return TRUE;
   6.777 + }
   6.778 ++#endif // NO_WAVFORMAT
   6.779 +diff -up libmodplug-0.8.9.0/src/mmcmp.cpp~ libmodplug-0.8.9.0/src/mmcmp.cpp
   6.780 +--- libmodplug-0.8.9.0/src/mmcmp.cpp~
   6.781 ++++ libmodplug-0.8.9.0/src/mmcmp.cpp
   6.782 +@@ -8,6 +8,7 @@
   6.783 + #include "stdafx.h"
   6.784 + #include "sndfile.h"
   6.785 + 
   6.786 ++#ifdef MMCMP_SUPPORT
   6.787 + BOOL PP20_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength);
   6.788 + 
   6.789 + #pragma pack(1)
   6.790 +@@ -501,3 +502,4 @@ BOOL PP20_Unpack(LPCBYTE *ppMemFile, LPD
   6.791 + 	*pdwMemLength = dwDstLen;
   6.792 + 	return TRUE;
   6.793 + }
   6.794 ++#endif /* MMCMP_SUPPORT */
   6.795 +diff -up libmodplug-0.8.9.0/src/sndfile.cpp~ libmodplug-0.8.9.0/src/sndfile.cpp
   6.796 +--- libmodplug-0.8.9.0/src/sndfile.cpp~
   6.797 ++++ libmodplug-0.8.9.0/src/sndfile.cpp
   6.798 +@@ -9,8 +9,6 @@
   6.799 + #include "libmodplug/stdafx.h"
   6.800 + #include "libmodplug/sndfile.h"
   6.801 + 
   6.802 +-#define MMCMP_SUPPORT
   6.803 +-
   6.804 + #ifdef MMCMP_SUPPORT
   6.805 + extern BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength);
   6.806 + #endif
   6.807 +@@ -24,9 +22,11 @@ extern void ITUnpack8Bit(signed char *pS
   6.808 + extern void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215);
   6.809 + 
   6.810 + 
   6.811 ++#ifndef MODPLUG_NO_FILESAVE
   6.812 ++#ifndef NO_PACKING
   6.813 ++
   6.814 + #define MAX_PACK_TABLES		3
   6.815 + 
   6.816 +-
   6.817 + // Compression table
   6.818 + static const signed char UnpackTable[MAX_PACK_TABLES][16] =
   6.819 + //--------------------------------------------
   6.820 +@@ -40,6 +40,8 @@ static const signed char UnpackTable[MAX
   6.821 + 	{0, 1, 2, 3, 5, 7, 12, 19,
   6.822 + 	-1, -2, -3, -5, -7, -12, -19, -31}
   6.823 + };
   6.824 ++#endif
   6.825 ++#endif
   6.826 + 
   6.827 + 
   6.828 + //////////////////////////////////////////////////////////
   6.829 +@@ -140,12 +142,16 @@ BOOL CSoundFile::Create(LPCBYTE lpStream
   6.830 + 		if ((!ReadXM(lpStream, dwMemLength))
   6.831 + 		 && (!ReadS3M(lpStream, dwMemLength))
   6.832 + 		 && (!ReadIT(lpStream, dwMemLength))
   6.833 ++#ifndef NO_WAVFORMAT
   6.834 + 		 && (!ReadWav(lpStream, dwMemLength))
   6.835 ++#endif
   6.836 + #ifndef MODPLUG_BASIC_SUPPORT
   6.837 ++#ifndef NO_MIDIFORMATS
   6.838 + /* Sequencer File Format Support */
   6.839 + 		 && (!ReadABC(lpStream, dwMemLength))
   6.840 + 		 && (!ReadMID(lpStream, dwMemLength))
   6.841 + 		 && (!ReadPAT(lpStream, dwMemLength))
   6.842 ++#endif
   6.843 + 		 && (!ReadSTM(lpStream, dwMemLength))
   6.844 + 		 && (!ReadMed(lpStream, dwMemLength))
   6.845 + 		 && (!ReadMTM(lpStream, dwMemLength))
   6.846 +@@ -753,6 +759,7 @@ void CSoundFile::LoopPattern(int nPat, i
   6.847 + }
   6.848 + 
   6.849 + 
   6.850 ++#ifndef MODPLUG_NO_FILESAVE
   6.851 + UINT CSoundFile::GetBestSaveFormat() const
   6.852 + //----------------------------------------
   6.853 + {
   6.854 +@@ -767,7 +774,6 @@ UINT CSoundFile::GetBestSaveFormat() con
   6.855 + 	return MOD_TYPE_IT;
   6.856 + }
   6.857 + 
   6.858 +-
   6.859 + UINT CSoundFile::GetSaveFormats() const
   6.860 + //-------------------------------------
   6.861 + {
   6.862 +@@ -786,6 +792,7 @@ UINT CSoundFile::GetSaveFormats() const
   6.863 + 	}
   6.864 + 	return n;
   6.865 + }
   6.866 ++#endif // MODPLUG_NO_FILESAVE
   6.867 + 
   6.868 + 
   6.869 + UINT CSoundFile::GetSampleName(UINT nSample,LPSTR s) const
   6.870 +@@ -817,6 +824,8 @@ UINT CSoundFile::GetInstrumentName(UINT 
   6.871 + }
   6.872 + 
   6.873 + 
   6.874 ++#ifndef MODPLUG_NO_FILESAVE
   6.875 ++
   6.876 + #ifndef NO_PACKING
   6.877 + UINT CSoundFile::PackSample(int &sample, int next)
   6.878 + //------------------------------------------------
   6.879 +@@ -877,8 +886,6 @@ BOOL CSoundFile::CanPackSample(LPSTR pSa
   6.880 + }
   6.881 + #endif // NO_PACKING
   6.882 + 
   6.883 +-#ifndef MODPLUG_NO_FILESAVE
   6.884 +-
   6.885 + UINT CSoundFile::WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen)
   6.886 + //-----------------------------------------------------------------------------------
   6.887 + {
   6.888 +diff -up libmodplug-0.8.9.0/src/sndmix.cpp~ libmodplug-0.8.9.0/src/sndmix.cpp
   6.889 +--- libmodplug-0.8.9.0/src/sndmix.cpp~
   6.890 ++++ libmodplug-0.8.9.0/src/sndmix.cpp
   6.891 +@@ -60,7 +60,7 @@ UINT gnReverbSend;
   6.892 + 
   6.893 + // Log tables for pre-amp
   6.894 + // We don't want the tracker to get too loud
   6.895 +-const UINT PreAmpTable[16] =
   6.896 ++static const UINT PreAmpTable[16] =
   6.897 + {
   6.898 + 	0x60, 0x60, 0x60, 0x70,	// 0-7
   6.899 + 	0x80, 0x88, 0x90, 0x98,	// 8-15
   6.900 +@@ -68,7 +68,7 @@ const UINT PreAmpTable[16] =
   6.901 + 	0xB4, 0xB8, 0xBC, 0xC0,	// 24-31
   6.902 + };
   6.903 + 
   6.904 +-const UINT PreAmpAGCTable[16] =
   6.905 ++static const UINT PreAmpAGCTable[16] =
   6.906 + {
   6.907 + 	0x60, 0x60, 0x60, 0x60,
   6.908 + 	0x68, 0x70, 0x78, 0x80,
     7.1 --- a/external/libmodplug-0.8.9.0/src/config.h.in	Sat Oct 20 21:00:02 2018 +0300
     7.2 +++ b/external/libmodplug-0.8.9.0/src/config.h.in	Wed Oct 24 01:01:02 2018 +0300
     7.3 @@ -15,9 +15,6 @@
     7.4  /* Define to 1 if you have the <memory.h> header file. */
     7.5  #undef HAVE_MEMORY_H
     7.6  
     7.7 -/* Define to 1 if you have the `setenv' function. */
     7.8 -#undef HAVE_SETENV
     7.9 -
    7.10  /* Define to 1 if you have the `sinf' function. */
    7.11  #undef HAVE_SINF
    7.12  
     8.1 --- a/external/libmodplug-0.8.9.0/src/libmodplug/it_defs.h	Sat Oct 20 21:00:02 2018 +0300
     8.2 +++ b/external/libmodplug-0.8.9.0/src/libmodplug/it_defs.h	Wed Oct 24 01:01:02 2018 +0300
     8.3 @@ -128,7 +128,9 @@
     8.4  
     8.5  #pragma pack()
     8.6  
     8.7 -extern BYTE autovibit2xm[8];
     8.8 -extern BYTE autovibxm2it[8];
     8.9 +#if 0/* made these two static to load_it.cpp */
    8.10 +extern const BYTE autovibit2xm[8];
    8.11 +extern const BYTE autovibxm2it[8];
    8.12 +#endif
    8.13  
    8.14  #endif
     9.1 --- a/external/libmodplug-0.8.9.0/src/libmodplug/sndfile.h	Sat Oct 20 21:00:02 2018 +0300
     9.2 +++ b/external/libmodplug-0.8.9.0/src/libmodplug/sndfile.h	Wed Oct 24 01:01:02 2018 +0300
     9.3 @@ -456,7 +456,7 @@
     9.4  // Mix Plugins
     9.5  #define MIXPLUG_MIXREADY			0x01	// Set when cleared
     9.6  
     9.7 -class MODPLUG_EXPORT IMixPlugin
     9.8 +class /*MODPLUG_EXPORT*/ IMixPlugin
     9.9  {
    9.10  public:
    9.11  	virtual ~IMixPlugin() {};
    9.12 @@ -535,7 +535,7 @@
    9.13  
    9.14  
    9.15  //==============
    9.16 -class MODPLUG_EXPORT CSoundFile
    9.17 +class /*MODPLUG_EXPORT*/ CSoundFile
    9.18  //==============
    9.19  {
    9.20  public:	// Static Members
    9.21 @@ -638,7 +638,9 @@
    9.22  	BOOL ReadIT(LPCBYTE lpStream, DWORD dwMemLength);
    9.23  	BOOL Read669(LPCBYTE lpStream, DWORD dwMemLength);
    9.24  	BOOL ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
    9.25 +#ifndef NO_WAVFORMAT
    9.26  	BOOL ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
    9.27 +#endif
    9.28  	BOOL ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
    9.29  	BOOL ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
    9.30  	BOOL ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
    9.31 @@ -653,12 +655,14 @@
    9.32  	BOOL ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
    9.33  	BOOL ReadJ2B(LPCBYTE lpStream, DWORD dwMemLength);
    9.34  	BOOL ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
    9.35 +#ifndef NO_MIDIFORMATS
    9.36  	BOOL ReadABC(LPCBYTE lpStream, DWORD dwMemLength);
    9.37  	BOOL TestABC(LPCBYTE lpStream, DWORD dwMemLength);
    9.38  	BOOL ReadMID(LPCBYTE lpStream, DWORD dwMemLength);
    9.39  	BOOL TestMID(LPCBYTE lpStream, DWORD dwMemLength);
    9.40  	BOOL ReadPAT(LPCBYTE lpStream, DWORD dwMemLength);
    9.41  	BOOL TestPAT(LPCBYTE lpStream, DWORD dwMemLength);
    9.42 +#endif
    9.43  	// Save Functions
    9.44  #ifndef MODPLUG_NO_FILESAVE
    9.45  	UINT WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen=0);
    9.46 @@ -666,14 +670,16 @@
    9.47  	BOOL SaveS3M(LPCSTR lpszFileName, UINT nPacking=0);
    9.48  	BOOL SaveMod(LPCSTR lpszFileName, UINT nPacking=0);
    9.49  	BOOL SaveIT(LPCSTR lpszFileName, UINT nPacking=0);
    9.50 -#endif // MODPLUG_NO_FILESAVE
    9.51 -	// MOD Convert function
    9.52  	UINT GetBestSaveFormat() const;
    9.53  	UINT GetSaveFormats() const;
    9.54 +#endif
    9.55 +	// MOD Convert function
    9.56  	void ConvertModCommand(MODCOMMAND *) const;
    9.57  	void S3MConvert(MODCOMMAND *m, BOOL bIT) const;
    9.58 +#ifndef MODPLUG_NO_FILESAVE
    9.59  	void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const;
    9.60  	WORD ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const;
    9.61 +#endif
    9.62  
    9.63  public:
    9.64  	// Real-time sound functions
    9.65 @@ -759,8 +765,11 @@
    9.66  	BOOL IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const;
    9.67  	// Read/Write sample functions
    9.68  	signed char GetDeltaValue(signed char prev, UINT n) const { return (signed char)(prev + CompressionTable[n & 0x0F]); }
    9.69 +#if !(defined(MODPLUG_NO_FILESAVE)||defined(NO_PACKING))
    9.70  	UINT PackSample(int &sample, int next);
    9.71  	BOOL CanPackSample(LPSTR pSample, UINT nLen, UINT nPacking, BYTE *result=NULL);
    9.72 +#endif // NO_FILESAVE, NO_PACKING
    9.73 +
    9.74  	UINT ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR pMemFile, DWORD dwMemLength);
    9.75  	BOOL DestroySample(UINT nSample);
    9.76  	BOOL DestroyInstrument(UINT nInstr);
    10.1 --- a/external/libmodplug-0.8.9.0/src/libmodplug/stdafx.h	Sat Oct 20 21:00:02 2018 +0300
    10.2 +++ b/external/libmodplug-0.8.9.0/src/libmodplug/stdafx.h	Wed Oct 24 01:01:02 2018 +0300
    10.3 @@ -21,9 +21,15 @@
    10.4  # include <stdint.h>
    10.5  #endif
    10.6  
    10.7 +/*#define MMCMP_SUPPORT*/
    10.8 +
    10.9  /* disable AGC and FILESAVE for all targets for uniformity. */
   10.10  #define NO_AGC
   10.11  #define MODPLUG_NO_FILESAVE
   10.12 +/*#define NO_PACKING*/
   10.13 +/*#define NO_FILTER */
   10.14 +#define NO_MIDIFORMATS
   10.15 +#define NO_WAVFORMAT
   10.16  
   10.17  #ifdef _WIN32
   10.18  
   10.19 @@ -88,12 +94,6 @@
   10.20  typedef void* PVOID;
   10.21  typedef void VOID;
   10.22  
   10.23 -inline LONG MulDiv (long a, long b, long c)
   10.24 -{
   10.25 -/*if (!c) return 0;*/
   10.26 -  return ((uint64_t) a * (uint64_t) b ) / c;
   10.27 -}
   10.28 -
   10.29  #define LPCTSTR LPCSTR
   10.30  #define lstrcpyn strncpy
   10.31  #define lstrcpy strcpy
    11.1 --- a/external/libmodplug-0.8.9.0/src/load_669.cpp	Sat Oct 20 21:00:02 2018 +0300
    11.2 +++ b/external/libmodplug-0.8.9.0/src/load_669.cpp	Wed Oct 24 01:01:02 2018 +0300
    11.3 @@ -17,7 +17,7 @@
    11.4  typedef struct tagFILEHEADER669
    11.5  {
    11.6  	WORD sig;				// 'if' or 'JN'
    11.7 -        signed char songmessage[108];	// Song Message
    11.8 +	signed char songmessage[108];	// Song Message
    11.9  	BYTE samples;			// number of samples (1-64)
   11.10  	BYTE patterns;			// number of patterns (1-128)
   11.11  	BYTE restartpos;
   11.12 @@ -35,7 +35,7 @@
   11.13  	BYTE loopend[4];
   11.14  } SAMPLE669;
   11.15  
   11.16 -DWORD lengthArrayToDWORD(const BYTE length[4]) {
   11.17 +static DWORD lengthArrayToDWORD(const BYTE length[4]) {
   11.18  	DWORD len = (length[3] << 24) +
   11.19  		(length[2] << 16) +
   11.20  		(length[1] << 8) +
    12.1 --- a/external/libmodplug-0.8.9.0/src/load_abc.cpp	Sat Oct 20 21:00:02 2018 +0300
    12.2 +++ b/external/libmodplug-0.8.9.0/src/load_abc.cpp	Wed Oct 24 01:01:02 2018 +0300
    12.3 @@ -37,9 +37,11 @@
    12.4  #include "stdafx.h"
    12.5  #include "sndfile.h"
    12.6  
    12.7 +#ifndef NO_MIDIFORMATS
    12.8 +
    12.9  #include "load_pat.h"
   12.10  
   12.11 -#if _MSC_VER >= 1600
   12.12 +#if defined(_MSC_VER) && (_MSC_VER >= 1300)
   12.13  #define putenv _putenv
   12.14  #define strdup _strdup
   12.15  #endif
   12.16 @@ -256,16 +258,6 @@
   12.17  static uint32_t abc_pattracktime(ABCHANDLE *h, uint32_t tracktime);
   12.18  static int abc_patno(ABCHANDLE *h, uint32_t tracktime);
   12.19  
   12.20 -#ifndef HAVE_SETENV
   12.21 -static void setenv(const char *name, const char *value, int overwrite)
   12.22 -{
   12.23 -	int len = strlen(name)+1+strlen(value)+1;
   12.24 -	char *str = (char *)malloc(len);
   12.25 -	sprintf(str, "%s=%s", name, value);
   12.26 -	putenv(str);
   12.27 -	free(str);
   12.28 -}
   12.29 -#endif
   12.30  
   12.31  static int abc_isvalidchar(char c) {
   12.32  	return(isalpha(c) || isdigit(c) || isspace(c) || c == '%' || c == ':');
   12.33 @@ -2345,9 +2337,9 @@
   12.34  // =====================================================================================
   12.35  static ABCHANDLE *ABC_Init(void)
   12.36  {
   12.37 +	static char buf[40];
   12.38  	ABCHANDLE   *retval;
   12.39  	char *p;
   12.40 -	char buf[10];
   12.41  	retval = (ABCHANDLE *)calloc(1,sizeof(ABCHANDLE));
   12.42  	if( !retval ) return NULL;
   12.43  	retval->track       = NULL;
   12.44 @@ -2365,16 +2357,16 @@
   12.45  			retval->pickrandom = atoi(p);
   12.46  		if( *p == '-' ) {
   12.47  			retval->pickrandom = atoi(p+1)-1; // xmms preloads the file
   12.48 -			sprintf(buf,"-%ld",retval->pickrandom+2);
   12.49 -			setenv(ABC_ENV_NORANDOMPICK, buf, 1);
   12.50 +			sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
   12.51 +			putenv(buf);
   12.52  		}
   12.53  	}
   12.54  	else {
   12.55  		srandom((uint32_t)time(0));	// initialize random generator with seed
   12.56  		retval->pickrandom = 1+(int)(10000.0*random()/(RAND_MAX+1.0));
   12.57  		// can handle pickin' from songbooks with 10.000 songs
   12.58 -		sprintf(buf,"-%ld",retval->pickrandom); // xmms preloads the file
   12.59 -		setenv(ABC_ENV_NORANDOMPICK, buf, 1);
   12.60 +		sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom); // xmms preloads the file
   12.61 +		putenv(buf);
   12.62  	}
   12.63  	return retval;
   12.64  }
   12.65 @@ -4878,3 +4870,4 @@
   12.66  	ABC_Cleanup(h);	// we dont need it anymore
   12.67  	return 1;
   12.68  }
   12.69 +#endif // NO_MIDIFORMATS
    13.1 --- a/external/libmodplug-0.8.9.0/src/load_amf.cpp	Sat Oct 20 21:00:02 2018 +0300
    13.2 +++ b/external/libmodplug-0.8.9.0/src/load_amf.cpp	Wed Oct 24 01:01:02 2018 +0300
    13.3 @@ -44,7 +44,6 @@
    13.4  	UCHAR volume;
    13.5  } AMFSAMPLE;
    13.6  
    13.7 -
    13.8  #pragma pack()
    13.9  
   13.10  
   13.11 @@ -52,7 +51,7 @@
   13.12  extern void Log(LPCSTR, ...);
   13.13  #endif
   13.14  
   13.15 -VOID AMF_Unpack(MODCOMMAND *pPat, const BYTE *pTrack, UINT nRows, UINT nChannels)
   13.16 +static VOID AMF_Unpack(MODCOMMAND *pPat, const BYTE *pTrack, UINT nRows, UINT nChannels)
   13.17  //-------------------------------------------------------------------------------
   13.18  {
   13.19  	UINT lastinstr = 0;
   13.20 @@ -163,7 +162,6 @@
   13.21  }
   13.22  
   13.23  
   13.24 -
   13.25  BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength)
   13.26  //-----------------------------------------------------------
   13.27  {
    14.1 --- a/external/libmodplug-0.8.9.0/src/load_dmf.cpp	Sat Oct 20 21:00:02 2018 +0300
    14.2 +++ b/external/libmodplug-0.8.9.0/src/load_dmf.cpp	Wed Oct 24 01:01:02 2018 +0300
    14.3 @@ -509,7 +509,7 @@
    14.4  
    14.5  
    14.6  // DMF Huffman ReadBits
    14.7 -BYTE DMFReadBits(DMF_HTREE *tree, UINT nbits)
    14.8 +static BYTE DMFReadBits(DMF_HTREE *tree, UINT nbits)
    14.9  //-------------------------------------------
   14.10  {
   14.11  	BYTE x = 0, bitv = 1;
   14.12 @@ -534,7 +534,7 @@
   14.13  // tree: [8-bit value][12-bit index][12-bit index] = 32-bit
   14.14  //
   14.15  
   14.16 -void DMFNewNode(DMF_HTREE *tree)
   14.17 +static void DMFNewNode(DMF_HTREE *tree)
   14.18  //------------------------------
   14.19  {
   14.20  	BYTE isleft, isright;
    15.1 --- a/external/libmodplug-0.8.9.0/src/load_it.cpp	Sat Oct 20 21:00:02 2018 +0300
    15.2 +++ b/external/libmodplug-0.8.9.0/src/load_it.cpp	Wed Oct 24 01:01:02 2018 +0300
    15.3 @@ -15,19 +15,18 @@
    15.4  #pragma warning(disable:4244)
    15.5  #endif
    15.6  
    15.7 +static const
    15.8  BYTE autovibit2xm[8] =
    15.9  { 0, 3, 1, 4, 2, 0, 0, 0 };
   15.10 -
   15.11 +#ifndef MODPLUG_NO_FILESAVE
   15.12 +static const
   15.13  BYTE autovibxm2it[8] =
   15.14  { 0, 2, 4, 1, 3, 0, 0, 0 };
   15.15 +#endif
   15.16  
   15.17  //////////////////////////////////////////////////////////
   15.18  // Impulse Tracker IT file support
   15.19  
   15.20 -// for conversion of XM samples
   15.21 -extern WORD XMPeriodTable[96+8];
   15.22 -extern UINT XMLinearTable[768];
   15.23 -
   15.24  static inline UINT ConvertVolParam(UINT value)
   15.25  //--------------------------------------------
   15.26  {
    16.1 --- a/external/libmodplug-0.8.9.0/src/load_mdl.cpp	Sat Oct 20 21:00:02 2018 +0300
    16.2 +++ b/external/libmodplug-0.8.9.0/src/load_mdl.cpp	Wed Oct 24 01:01:02 2018 +0300
    16.3 @@ -42,7 +42,7 @@
    16.4  } MDLPATTERNDATA;
    16.5  
    16.6  
    16.7 -void ConvertMDLCommand(MODCOMMAND *m, UINT eff, UINT data)
    16.8 +static void ConvertMDLCommand(MODCOMMAND *m, UINT eff, UINT data)
    16.9  //--------------------------------------------------------
   16.10  {
   16.11  	UINT command = 0, param = data;
   16.12 @@ -91,7 +91,7 @@
   16.13  }
   16.14  
   16.15  
   16.16 -void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, const BYTE *lpTracks, UINT len)
   16.17 +static void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, const BYTE *lpTracks, UINT len)
   16.18  //-------------------------------------------------------------------------------------------------
   16.19  {
   16.20  	MODCOMMAND cmd, *m = pat;
   16.21 @@ -168,7 +168,6 @@
   16.22  }
   16.23  
   16.24  
   16.25 -
   16.26  BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength)
   16.27  //---------------------------------------------------------------
   16.28  {
   16.29 @@ -429,12 +428,13 @@
   16.30  		for (UINT ipat=0; ipat<npatterns; ipat++)
   16.31  		{
   16.32  			if ((Patterns[ipat] = AllocatePattern(PatternSize[ipat], m_nChannels)) == NULL) break;
   16.33 -			for (UINT chn=0; chn<m_nChannels; chn++) if ((patterntracks[ipat*32+chn]) && (patterntracks[ipat*32+chn] <= ntracks) && (*(WORD *)lpStream+dwTrackPos) < dwMemLength-dwTrackPos)
   16.34 +			for (UINT chn=0; chn<m_nChannels; chn++) if ((patterntracks[ipat*32+chn]) && (patterntracks[ipat*32+chn] <= ntracks))
   16.35  			{
   16.36 +			    const BYTE *lpTracks = lpStream + dwTrackPos;
   16.37 +			    UINT len = lpTracks[0] | (lpTracks[1] << 8);
   16.38 +			    if (len < dwMemLength-dwTrackPos) {
   16.39  				MODCOMMAND *m = Patterns[ipat] + chn;
   16.40  				UINT nTrack = patterntracks[ipat*32+chn];
   16.41 -				const BYTE *lpTracks = lpStream + dwTrackPos;
   16.42 -				UINT len = lpTracks[0] | (lpTracks[1] << 8);
   16.43  
   16.44  				lpTracks += 2;
   16.45  				for (UINT ntrk=1; ntrk<nTrack && lpTracks < (dwMemLength + lpStream - len); ntrk++)
   16.46 @@ -447,6 +447,7 @@
   16.47  				if ( len > dwMemLength - dwTrackPos ) len = 0;
   16.48  
   16.49  				UnpackMDLTrack(m, m_nChannels, PatternSize[ipat], nTrack, lpTracks, len);
   16.50 +			    }
   16.51  			}
   16.52  		}
   16.53  	}
    17.1 --- a/external/libmodplug-0.8.9.0/src/load_mid.cpp	Sat Oct 20 21:00:02 2018 +0300
    17.2 +++ b/external/libmodplug-0.8.9.0/src/load_mid.cpp	Wed Oct 24 01:01:02 2018 +0300
    17.3 @@ -35,6 +35,9 @@
    17.4  
    17.5  #include "stdafx.h"
    17.6  #include "sndfile.h"
    17.7 +
    17.8 +#ifndef NO_MIDIFORMATS
    17.9 +
   17.10  #define PAN_LEFT    0x30
   17.11  #define PAN_RIGHT   0xD0
   17.12  #define MAX_POLYPHONY 16  // max notes in one midi channel
   17.13 @@ -92,7 +95,7 @@
   17.14  #undef _mm_free
   17.15  #endif
   17.16  
   17.17 -#define MMSTREAM										FILE
   17.18 +#define MMSTREAM				FILE
   17.19  #define _mm_fseek(f,pos,whence)			fseek(f,pos,whence)
   17.20  #define _mm_read_UBYTES(buf,sz,f)		fread(buf,sz,1,f)
   17.21  #define _mm_read_SBYTES(buf,sz,f)		fread(buf,sz,1,f)
   17.22 @@ -1582,3 +1585,4 @@
   17.23  	avoid_reentry = 0; // it is safe now, I'm finished
   17.24  	return TRUE;
   17.25  }
   17.26 +#endif // NO_MIDIFORMATS
    18.1 --- a/external/libmodplug-0.8.9.0/src/load_mod.cpp	Sat Oct 20 21:00:02 2018 +0300
    18.2 +++ b/external/libmodplug-0.8.9.0/src/load_mod.cpp	Wed Oct 24 01:01:02 2018 +0300
    18.3 @@ -60,6 +60,7 @@
    18.4  }
    18.5  
    18.6  
    18.7 +#ifndef MODPLUG_NO_FILESAVE
    18.8  WORD CSoundFile::ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const
    18.9  //------------------------------------------------------------------
   18.10  {
   18.11 @@ -144,6 +145,7 @@
   18.12  	}
   18.13  	return (WORD)((command << 8) | (param));
   18.14  }
   18.15 +#endif // MODPLUG_NO_FILESAVE
   18.16  
   18.17  
   18.18  #pragma pack(1)
   18.19 @@ -184,7 +186,7 @@
   18.20  	return TRUE;
   18.21  }
   18.22  
   18.23 -BOOL IsMagic(LPCSTR s1, LPCSTR s2)
   18.24 +static BOOL IsMagic(LPCSTR s1, LPCSTR s2)
   18.25  {
   18.26  	return ((*(DWORD *)s1) == (*(DWORD *)s2)) ? TRUE : FALSE;
   18.27  }
    19.1 --- a/external/libmodplug-0.8.9.0/src/load_pat.cpp	Sat Oct 20 21:00:02 2018 +0300
    19.2 +++ b/external/libmodplug-0.8.9.0/src/load_pat.cpp	Wed Oct 24 01:01:02 2018 +0300
    19.3 @@ -44,16 +44,18 @@
    19.4  #include "stdafx.h"
    19.5  #include "sndfile.h"
    19.6  
    19.7 +#ifndef NO_MIDIFORMATS
    19.8 +
    19.9  #include "load_pat.h"
   19.10  
   19.11 -#ifdef MSC_VER
   19.12 +#ifdef _WIN32
   19.13  #define DIRDELIM		'\\'
   19.14  #define TIMIDITYCFG	"C:\\TIMIDITY\\TIMIDITY.CFG"
   19.15  #define PATHFORPAT	"C:\\TIMIDITY\\INSTRUMENTS"
   19.16  #else
   19.17  #define DIRDELIM		'/'
   19.18 -#define TIMIDITYCFG	"/usr/local/share/timidity/timidity.cfg"
   19.19 -#define PATHFORPAT	"/usr/local/share/timidity/instruments"
   19.20 +#define TIMIDITYCFG	"/etc/timidity.cfg" /*"/usr/share/timidity/timidity.cfg"*/
   19.21 +#define PATHFORPAT	"/usr/share/timidity/instruments"
   19.22  #endif
   19.23  
   19.24  #define PAT_ENV_PATH2CFG			"MMPAT_PATH_TO_CFG"
   19.25 @@ -764,10 +766,7 @@
   19.26  // =====================================================================================
   19.27  static PATHANDLE *PAT_Init(void)
   19.28  {
   19.29 -	PATHANDLE   *retval;
   19.30 -	retval = (PATHANDLE *)calloc(1,sizeof(PATHANDLE));
   19.31 -	if( !retval ) return NULL;
   19.32 -	return retval;
   19.33 +	return (PATHANDLE *)calloc(1,sizeof(PATHANDLE));
   19.34  }
   19.35  
   19.36  // =====================================================================================
   19.37 @@ -1259,3 +1258,4 @@
   19.38  	PAT_Cleanup(h);	// we dont need it anymore
   19.39  	return 1;
   19.40  }
   19.41 +#endif // NO_MIDIFORMATS
    20.1 --- a/external/libmodplug-0.8.9.0/src/load_psm.cpp	Sat Oct 20 21:00:02 2018 +0300
    20.2 +++ b/external/libmodplug-0.8.9.0/src/load_psm.cpp	Wed Oct 24 01:01:02 2018 +0300
    20.3 @@ -84,7 +84,9 @@
    20.4  	BYTE reserved6[19];
    20.5  } PSMSAMPLE;
    20.6  
    20.7 -void swap_PSMSAMPLE(PSMSAMPLE* p){
    20.8 +#pragma pack()
    20.9 +
   20.10 +static void swap_PSMSAMPLE(PSMSAMPLE* p){
   20.11  	p->smpid = bswapLE32(p->smpid);
   20.12  	p->length = bswapLE32(p->length);
   20.13  	p->loopstart = bswapLE32(p->loopstart);
   20.14 @@ -92,13 +94,11 @@
   20.15  	p->samplerate = bswapLE32(p->samplerate);
   20.16  }
   20.17  
   20.18 -#pragma pack()
   20.19 -
   20.20  
   20.21  BOOL CSoundFile::ReadPSM(LPCBYTE lpStream, DWORD dwMemLength)
   20.22  //-----------------------------------------------------------
   20.23  {
   20.24 -	PSMCHUNK *pfh = (PSMCHUNK *)lpStream;
   20.25 +	PSMCHUNK pfh = *(const PSMCHUNK *)lpStream;
   20.26  	DWORD dwMemPos, dwSongPos;
   20.27  	DWORD smpnames[MAX_SAMPLES];
   20.28  	DWORD patptrs[MAX_PATTERNS];
   20.29 @@ -108,17 +108,17 @@
   20.30  	if (dwMemLength < 256) return FALSE;
   20.31  
   20.32  	// Swap chunk
   20.33 -	swap_PSMCHUNK(pfh);
   20.34 +	swap_PSMCHUNK(&pfh);
   20.35  
   20.36  	// Chunk0: "PSM ",filesize,"FILE"
   20.37 -	if (pfh->id == PSM_ID_OLD)
   20.38 +	if (pfh.id == PSM_ID_OLD)
   20.39  	{
   20.40  	#ifdef PSM_LOG
   20.41  		Log("Old PSM format not supported\n");
   20.42  	#endif
   20.43  		return FALSE;
   20.44  	}
   20.45 -	if ((pfh->id != PSM_ID_NEW) || (pfh->len+12 > dwMemLength) || (pfh->listid != IFFID_FILE)) return FALSE;
   20.46 +	if ((pfh.id != PSM_ID_NEW) || (pfh.len+12 > dwMemLength) || (pfh.listid != IFFID_FILE)) return FALSE;
   20.47  	m_nType = MOD_TYPE_PSM;
   20.48  	m_nChannels = 16;
   20.49  	m_nSamples = 0;
   20.50 @@ -132,13 +132,13 @@
   20.51  	}
   20.52  	while (dwMemPos+8 < dwMemLength)
   20.53  	{
   20.54 -		PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
   20.55 -		swap_PSMCHUNK(pchunk);
   20.56 -		if ((pchunk->len >= dwMemLength - 8) || (dwMemPos + pchunk->len + 8 > dwMemLength)) break;
   20.57 +		PSMCHUNK pchunk = *(const PSMCHUNK *)(lpStream+dwMemPos);
   20.58 +		swap_PSMCHUNK(&pchunk);
   20.59 +		if ((pchunk.len >= dwMemLength - 8) || (dwMemPos + pchunk.len + 8 > dwMemLength)) break;
   20.60  		dwMemPos += 8;
   20.61  		PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
   20.62 -		ULONG len = pchunk->len;
   20.63 -		if (len) switch(pchunk->id)
   20.64 +		ULONG len = pchunk.len;
   20.65 +		if (len) switch(pchunk.id)
   20.66  		{
   20.67  		// "TITL": Song title
   20.68  		case IFFID_TITL:
   20.69 @@ -166,21 +166,21 @@
   20.70  			{
   20.71  				m_nSamples++;
   20.72  				MODINSTRUMENT *pins = &Ins[m_nSamples];
   20.73 -				PSMSAMPLE *psmp = (PSMSAMPLE *)pdata;
   20.74 -				swap_PSMSAMPLE(psmp);
   20.75 -				smpnames[m_nSamples] = psmp->smpid;
   20.76 -				memcpy(m_szNames[m_nSamples], psmp->samplename, 31);
   20.77 +				PSMSAMPLE psmp = *(PSMSAMPLE *)pdata;
   20.78 +				swap_PSMSAMPLE(&psmp);
   20.79 +				smpnames[m_nSamples] = psmp.smpid;
   20.80 +				memcpy(m_szNames[m_nSamples], psmp.samplename, 31);
   20.81  				m_szNames[m_nSamples][31] = 0;
   20.82  				samplemap[m_nSamples-1] = (BYTE)m_nSamples;
   20.83  				// Init sample
   20.84  				pins->nGlobalVol = 0x40;
   20.85 -				pins->nC4Speed = psmp->samplerate;
   20.86 -				pins->nLength = psmp->length;
   20.87 -				pins->nLoopStart = psmp->loopstart;
   20.88 -				pins->nLoopEnd = psmp->loopend;
   20.89 +				pins->nC4Speed = psmp.samplerate;
   20.90 +				pins->nLength = psmp.length;
   20.91 +				pins->nLoopStart = psmp.loopstart;
   20.92 +				pins->nLoopEnd = psmp.loopend;
   20.93  				pins->nPan = 128;
   20.94 -				pins->nVolume = (psmp->defvol+1) * 2;
   20.95 -				pins->uFlags = (psmp->flags & 0x80) ? CHN_LOOP : 0;
   20.96 +				pins->nVolume = (psmp.defvol+1) * 2;
   20.97 +				pins->uFlags = (psmp.flags & 0x80) ? CHN_LOOP : 0;
   20.98  				if (pins->nLoopStart > 0) pins->nLoopStart--;
   20.99  				// Point to sample data
  20.100  				pdata += 0x60;
  20.101 @@ -199,17 +199,17 @@
  20.102  		default:
  20.103  			{
  20.104  				CHAR s[8], s2[64];
  20.105 -				*(DWORD *)s = pchunk->id;
  20.106 +				*(DWORD *)s = pchunk.id;
  20.107  				s[4] = 0;
  20.108 -				wsprintf(s2, "%s: %4d bytes @ %4d\n", s, pchunk->len, dwMemPos);
  20.109 +				wsprintf(s2, "%s: %4d bytes @ %4d\n", s, pchunk.len, dwMemPos);
  20.110  				OutputDebugString(s2);
  20.111  			}
  20.112  	#endif
  20.113  		}
  20.114 -		dwMemPos += pchunk->len;
  20.115 +		dwMemPos += pchunk.len;
  20.116  	}
  20.117  	// Step #1: convert song structure
  20.118 -	PSMSONGHDR *pSong = (PSMSONGHDR *)(lpStream+dwSongPos+8);
  20.119 +	const PSMSONGHDR *pSong = (const PSMSONGHDR *)(lpStream+dwSongPos+8);
  20.120  	if ((!dwSongPos) || (pSong->channels < 2) || (pSong->channels > 32)) return TRUE;
  20.121  	m_nChannels = pSong->channels;
  20.122  	// Valid song header -> convert attached chunks
  20.123 @@ -218,13 +218,13 @@
  20.124  		dwMemPos = dwSongPos + 8 + 11; // sizeof(PSMCHUNK)+sizeof(PSMSONGHDR)
  20.125  		while (dwMemPos + 8 < dwSongEnd)
  20.126  		{
  20.127 -			PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
  20.128 -			swap_PSMCHUNK(pchunk);
  20.129 +			PSMCHUNK pchunk = *(const PSMCHUNK *)(lpStream+dwMemPos);
  20.130 +			swap_PSMCHUNK(&pchunk);
  20.131  			dwMemPos += 8;
  20.132 -			if ((pchunk->len > dwSongEnd) || (dwMemPos + pchunk->len > dwSongEnd)) break;
  20.133 +			if ((pchunk.len > dwSongEnd) || (dwMemPos + pchunk.len > dwSongEnd)) break;
  20.134  			PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
  20.135 -			ULONG len = pchunk->len;
  20.136 -			switch(pchunk->id)
  20.137 +			ULONG len = pchunk.len;
  20.138 +			switch(pchunk.id)
  20.139  			{
  20.140  			case IFFID_OPLH:
  20.141  				if (len >= 0x20)
  20.142 @@ -237,7 +237,7 @@
  20.143  						DWORD dwName = *(DWORD *)(pdata+pos);
  20.144  						for (UINT i=0; i<nPatterns; i++)
  20.145  						{
  20.146 -							DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
  20.147 +							DWORD dwPatName = ((const PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
  20.148  							if (dwName == dwPatName)
  20.149  							{
  20.150  								bFound = TRUE;
  20.151 @@ -258,7 +258,7 @@
  20.152  						DWORD dwName = *(DWORD *)(pdata+pos);
  20.153  						for (UINT i=0; i<nPatterns; i++)
  20.154  						{
  20.155 -							DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
  20.156 +							DWORD dwPatName = ((const PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
  20.157  							if (dwName == dwPatName)
  20.158  							{
  20.159  								Order[iOrd++] = i;
  20.160 @@ -270,23 +270,23 @@
  20.161  				}
  20.162  				break;
  20.163  			}
  20.164 -			dwMemPos += pchunk->len;
  20.165 +			dwMemPos += pchunk.len;
  20.166  		}
  20.167  	}
  20.168  
  20.169  	// Step #2: convert patterns
  20.170  	for (UINT nPat=0; nPat<nPatterns; nPat++)
  20.171  	{
  20.172 -		PSMPATTERN *pPsmPat = (PSMPATTERN *)(lpStream+patptrs[nPat]+8);
  20.173 -		swap_PSMPATTERN(pPsmPat);
  20.174 +		PSMPATTERN pPsmPat = *(const PSMPATTERN *)(lpStream+patptrs[nPat]+8);
  20.175 +		swap_PSMPATTERN(&pPsmPat);
  20.176  		ULONG len = *(DWORD *)(lpStream+patptrs[nPat]+4) - 12;
  20.177 -		UINT nRows = pPsmPat->rows;
  20.178 -		if (len > pPsmPat->size) len = pPsmPat->size;
  20.179 +		UINT nRows = pPsmPat.rows;
  20.180 +		if (len > pPsmPat.size) len = pPsmPat.size;
  20.181  		if ((nRows < 64) || (nRows > 256)) nRows = 64;
  20.182  		PatternSize[nPat] = nRows;
  20.183  		if ((Patterns[nPat] = AllocatePattern(nRows, m_nChannels)) == NULL) break;
  20.184  		MODCOMMAND *m = Patterns[nPat];
  20.185 -		BYTE *p = pPsmPat->data;
  20.186 +		BYTE *p = pPsmPat.data;
  20.187  		MODCOMMAND *sp, dummy;
  20.188  		UINT pos = 0;
  20.189  		UINT row = 0;
  20.190 @@ -295,7 +295,7 @@
  20.191  		Log("Pattern %d at offset 0x%04X\n", nPat, (DWORD)(p - (BYTE *)lpStream));
  20.192  	#endif
  20.193  		UINT flags, ch;
  20.194 -		rowlim = bswapLE16(pPsmPat->reserved1)-2;
  20.195 +		rowlim = bswapLE16(pPsmPat.reserved1)-2;
  20.196  		while ((row < nRows) && (pos+3 < len))
  20.197  		{
  20.198  			if ((pos+1) >= rowlim) {
  20.199 @@ -393,7 +393,7 @@
  20.200  	#ifdef PSM_LOG
  20.201  		if (pos < len)
  20.202  		{
  20.203 -			Log("Pattern %d: %d/%d[%d] rows (%d bytes) -> %d bytes left\n", nPat, row, nRows, pPsmPat->rows, pPsmPat->size, len-pos);
  20.204 +			Log("Pattern %d: %d/%d[%d] rows (%d bytes) -> %d bytes left\n", nPat, row, nRows, pPsmPat.rows, pPsmPat.size, len-pos);
  20.205  		}
  20.206  	#endif
  20.207  	}
    21.1 --- a/external/libmodplug-0.8.9.0/src/load_s3m.cpp	Sat Oct 20 21:00:02 2018 +0300
    21.2 +++ b/external/libmodplug-0.8.9.0/src/load_s3m.cpp	Wed Oct 24 01:01:02 2018 +0300
    21.3 @@ -105,6 +105,7 @@
    21.4  }
    21.5  
    21.6  
    21.7 +#ifndef MODPLUG_NO_FILESAVE
    21.8  void CSoundFile::S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const
    21.9  //---------------------------------------------------------------------
   21.10  {
   21.11 @@ -182,6 +183,7 @@
   21.12  	*pcmd = command;
   21.13  	*pprm = param;
   21.14  }
   21.15 +#endif // MODPLUG_NO_FILESAVE
   21.16  
   21.17  static DWORD boundInput(DWORD input, DWORD smin, DWORD smax)
   21.18  {
    22.1 --- a/external/libmodplug-0.8.9.0/src/load_stm.cpp	Sat Oct 20 21:00:02 2018 +0300
    22.2 +++ b/external/libmodplug-0.8.9.0/src/load_stm.cpp	Wed Oct 24 01:01:02 2018 +0300
    22.3 @@ -64,8 +64,8 @@
    22.4  	
    22.5  	if ((!lpStream) || (dwMemLength < sizeof(STMHEADER))) return FALSE;
    22.6  	if ((phdr->filetype != 2) || (phdr->unused != 0x1A)
    22.7 -	 || ((strncasecmp(phdr->trackername, "!SCREAM!", 8))
    22.8 -	  && (strncasecmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
    22.9 +	 || ((strncmp(phdr->trackername, "!Scream!", 8))
   22.10 +	  && (strncmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
   22.11  	memcpy(m_szNames[0], phdr->songname, 20);
   22.12  	// Read STM header
   22.13  	m_nType = MOD_TYPE_STM;
    23.1 --- a/external/libmodplug-0.8.9.0/src/load_wav.cpp	Sat Oct 20 21:00:02 2018 +0300
    23.2 +++ b/external/libmodplug-0.8.9.0/src/load_wav.cpp	Wed Oct 24 01:01:02 2018 +0300
    23.3 @@ -7,6 +7,8 @@
    23.4  #include "stdafx.h"
    23.5  #include "sndfile.h"
    23.6  
    23.7 +#ifndef NO_WAVFORMAT
    23.8 +
    23.9  #ifndef WAVE_FORMAT_EXTENSIBLE
   23.10  #define WAVE_FORMAT_EXTENSIBLE	0xFFFE
   23.11  #endif
   23.12 @@ -170,7 +172,6 @@
   23.13    32767, 0
   23.14  };
   23.15  
   23.16 -
   23.17  BOOL IMAADPCMUnpack16(signed short *pdest, UINT nLen, LPBYTE psrc, DWORD dwBytes, UINT pkBlkAlign)
   23.18  //------------------------------------------------------------------------------------------------
   23.19  {
   23.20 @@ -215,3 +216,4 @@
   23.21  	}
   23.22  	return TRUE;
   23.23  }
   23.24 +#endif // NO_WAVFORMAT
    24.1 --- a/external/libmodplug-0.8.9.0/src/mmcmp.cpp	Sat Oct 20 21:00:02 2018 +0300
    24.2 +++ b/external/libmodplug-0.8.9.0/src/mmcmp.cpp	Wed Oct 24 01:01:02 2018 +0300
    24.3 @@ -8,6 +8,7 @@
    24.4  #include "stdafx.h"
    24.5  #include "sndfile.h"
    24.6  
    24.7 +#ifdef MMCMP_SUPPORT
    24.8  BOOL PP20_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength);
    24.9  
   24.10  #pragma pack(1)
   24.11 @@ -501,3 +502,4 @@
   24.12  	*pdwMemLength = dwDstLen;
   24.13  	return TRUE;
   24.14  }
   24.15 +#endif /* MMCMP_SUPPORT */
    25.1 --- a/external/libmodplug-0.8.9.0/src/sndfile.cpp	Sat Oct 20 21:00:02 2018 +0300
    25.2 +++ b/external/libmodplug-0.8.9.0/src/sndfile.cpp	Wed Oct 24 01:01:02 2018 +0300
    25.3 @@ -9,8 +9,6 @@
    25.4  #include "libmodplug/stdafx.h"
    25.5  #include "libmodplug/sndfile.h"
    25.6  
    25.7 -#define MMCMP_SUPPORT
    25.8 -
    25.9  #ifdef MMCMP_SUPPORT
   25.10  extern BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength);
   25.11  #endif
   25.12 @@ -24,9 +22,11 @@
   25.13  extern void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215);
   25.14  
   25.15  
   25.16 +#ifndef MODPLUG_NO_FILESAVE
   25.17 +#ifndef NO_PACKING
   25.18 +
   25.19  #define MAX_PACK_TABLES		3
   25.20  
   25.21 -
   25.22  // Compression table
   25.23  static const signed char UnpackTable[MAX_PACK_TABLES][16] =
   25.24  //--------------------------------------------
   25.25 @@ -40,6 +40,8 @@
   25.26  	{0, 1, 2, 3, 5, 7, 12, 19,
   25.27  	-1, -2, -3, -5, -7, -12, -19, -31}
   25.28  };
   25.29 +#endif
   25.30 +#endif
   25.31  
   25.32  
   25.33  //////////////////////////////////////////////////////////
   25.34 @@ -140,12 +142,16 @@
   25.35  		if ((!ReadXM(lpStream, dwMemLength))
   25.36  		 && (!ReadS3M(lpStream, dwMemLength))
   25.37  		 && (!ReadIT(lpStream, dwMemLength))
   25.38 +#ifndef NO_WAVFORMAT
   25.39  		 && (!ReadWav(lpStream, dwMemLength))
   25.40 +#endif
   25.41  #ifndef MODPLUG_BASIC_SUPPORT
   25.42 +#ifndef NO_MIDIFORMATS
   25.43  /* Sequencer File Format Support */
   25.44  		 && (!ReadABC(lpStream, dwMemLength))
   25.45  		 && (!ReadMID(lpStream, dwMemLength))
   25.46  		 && (!ReadPAT(lpStream, dwMemLength))
   25.47 +#endif
   25.48  		 && (!ReadSTM(lpStream, dwMemLength))
   25.49  		 && (!ReadMed(lpStream, dwMemLength))
   25.50  		 && (!ReadMTM(lpStream, dwMemLength))
   25.51 @@ -753,6 +759,7 @@
   25.52  }
   25.53  
   25.54  
   25.55 +#ifndef MODPLUG_NO_FILESAVE
   25.56  UINT CSoundFile::GetBestSaveFormat() const
   25.57  //----------------------------------------
   25.58  {
   25.59 @@ -767,7 +774,6 @@
   25.60  	return MOD_TYPE_IT;
   25.61  }
   25.62  
   25.63 -
   25.64  UINT CSoundFile::GetSaveFormats() const
   25.65  //-------------------------------------
   25.66  {
   25.67 @@ -786,6 +792,7 @@
   25.68  	}
   25.69  	return n;
   25.70  }
   25.71 +#endif // MODPLUG_NO_FILESAVE
   25.72  
   25.73  
   25.74  UINT CSoundFile::GetSampleName(UINT nSample,LPSTR s) const
   25.75 @@ -817,6 +824,8 @@
   25.76  }
   25.77  
   25.78  
   25.79 +#ifndef MODPLUG_NO_FILESAVE
   25.80 +
   25.81  #ifndef NO_PACKING
   25.82  UINT CSoundFile::PackSample(int &sample, int next)
   25.83  //------------------------------------------------
   25.84 @@ -877,8 +886,6 @@
   25.85  }
   25.86  #endif // NO_PACKING
   25.87  
   25.88 -#ifndef MODPLUG_NO_FILESAVE
   25.89 -
   25.90  UINT CSoundFile::WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen)
   25.91  //-----------------------------------------------------------------------------------
   25.92  {
    26.1 --- a/external/libmodplug-0.8.9.0/src/sndmix.cpp	Sat Oct 20 21:00:02 2018 +0300
    26.2 +++ b/external/libmodplug-0.8.9.0/src/sndmix.cpp	Wed Oct 24 01:01:02 2018 +0300
    26.3 @@ -60,7 +60,7 @@
    26.4  
    26.5  // Log tables for pre-amp
    26.6  // We don't want the tracker to get too loud
    26.7 -const UINT PreAmpTable[16] =
    26.8 +static const UINT PreAmpTable[16] =
    26.9  {
   26.10  	0x60, 0x60, 0x60, 0x70,	// 0-7
   26.11  	0x80, 0x88, 0x90, 0x98,	// 8-15
   26.12 @@ -68,7 +68,7 @@
   26.13  	0xB4, 0xB8, 0xBC, 0xC0,	// 24-31
   26.14  };
   26.15  
   26.16 -const UINT PreAmpAGCTable[16] =
   26.17 +static const UINT PreAmpAGCTable[16] =
   26.18  {
   26.19  	0x60, 0x60, 0x60, 0x60,
   26.20  	0x68, 0x70, 0x78, 0x80,