aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-06-19 22:32:10 +0300
committerWohlstand <admin@wohlnet.ru>2017-06-19 22:32:10 +0300
commit68fad96a61c23520d2ec0f90de0c5e03c96f2f82 (patch)
tree86c8678b1f93a8c8bb1641853373aaf156d66490 /src
parent850a5a1b1cbaa4b85990368bf998fce72639e156 (diff)
downloadlibADLMIDI-68fad96a61c23520d2ec0f90de0c5e03c96f2f82.tar.gz
libADLMIDI-68fad96a61c23520d2ec0f90de0c5e03c96f2f82.tar.bz2
libADLMIDI-68fad96a61c23520d2ec0f90de0c5e03c96f2f82.zip
Fixed compatibility with MSVC
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi.cpp2
-rw-r--r--src/adlmidi_midiplay.cpp3
-rw-r--r--src/adlmidi_mus2mid.c8
-rw-r--r--src/adlmidi_private.hpp9
-rw-r--r--src/adlmidi_xmi2mid.c26
-rw-r--r--src/dbopl.h13
6 files changed, 41 insertions, 20 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 5bb384d..5b707e8 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -375,7 +375,7 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
if(ate < device->backup_samples_size)
{
- for(int j = 0; j < ate; j++)
+ for(ssize_t j = 0; j < ate; j++)
device->backup_samples[(ate - 1) - j] = device->backup_samples[(device->backup_samples_size - 1) - j];
}
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index b207790..be0e87e 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -1321,8 +1321,7 @@ void MIDIplay::UpdateArpeggio(double) // amount = amount of time passed
for(uint32_t c = 0; c < opl.NumChannels; ++c)
{
retry_arpeggio:
-
- if(c > std::numeric_limits<int32_t>::max())
+ if(c > INT32_MAX)
break;
size_t n_users = ch[c].users.size();
diff --git a/src/adlmidi_mus2mid.c b/src/adlmidi_mus2mid.c
index 956510b..8462cd9 100644
--- a/src/adlmidi_mus2mid.c
+++ b/src/adlmidi_mus2mid.c
@@ -225,7 +225,7 @@ int AdlMidi_mus2midi(uint8_t *in, uint32_t insize,
int channelMap[MIDI_MAXCHANNELS], currentChannel;
if (insize < MUS_HEADERSIZE) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);*/
return (-1);
}
@@ -241,16 +241,16 @@ int AdlMidi_mus2midi(uint8_t *in, uint32_t insize,
header.instrCnt = READ_INT16(&in[12]);
if (memcmp(header.ID, MUS_ID, 4)) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_MUS, NULL, 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_MUS, NULL, 0);*/
return (-1);
}
if (insize < (uint32_t)header.scoreLen + (uint32_t)header.scoreStart) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);*/
return (-1);
}
/* channel #15 should be excluded in the numchannels field: */
if (header.channels > MIDI_MAXCHANNELS - 1) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, NULL, 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, NULL, 0);*/
return (-1);
}
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index 8848f14..46e6e2e 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -37,6 +37,15 @@
#ifdef _WIN32
#undef NO_OLDNAMES
+
+#ifdef _MSC_VER
+#ifdef _WIN64
+ typedef __int64 ssize_t;
+#else
+ typedef __int32 ssize_t;
+#endif
+#endif
+
#endif
#include <vector>
#include <string>
diff --git a/src/adlmidi_xmi2mid.c b/src/adlmidi_xmi2mid.c
index 5d8cedc..9c93957 100644
--- a/src/adlmidi_xmi2mid.c
+++ b/src/adlmidi_xmi2mid.c
@@ -467,7 +467,7 @@ int AdlMidi_xmi2midi(uint8_t *in, uint32_t insize,
int ret = -1;
if (convert_type > XMIDI_CONVERT_MT32_TO_GS) {
- //_WM_ERROR_NEW("%s:%i: %d is an invalid conversion type.", __FUNCTION__, __LINE__, convert_type);
+ /*_WM_ERROR_NEW("%s:%i: %d is an invalid conversion type.", __FUNCTION__, __LINE__, convert_type);*/
return (ret);
}
@@ -477,12 +477,12 @@ int AdlMidi_xmi2midi(uint8_t *in, uint32_t insize,
ctx.convert_type = convert_type;
if (ParseXMI(&ctx) < 0) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);*/
goto _end;
}
if (ExtractTracks(&ctx) < 0) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_MIDI, NULL, 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_MIDI, NULL, 0);*/
goto _end;
}
@@ -908,7 +908,7 @@ static uint32_t ConvertListToMTrk(struct xmi_ctx *ctx, midi_event *mlist) {
/* Never occur */
default:
- //_WM_DEBUG_MSG("%s: unrecognized event", __FUNCTION__);
+ /*_WM_DEBUG_MSG("%s: unrecognized event", __FUNCTION__);*/
break;
}
}
@@ -951,7 +951,7 @@ static uint32_t ExtractTracksFromXmi(struct xmi_ctx *ctx) {
/* Convert it */
if (!(ppqn = ConvertFiletoList(ctx))) {
- //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, NULL, 0);
+ /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, NULL, 0);*/
break;
}
ctx->timing[num] = ppqn;
@@ -978,7 +978,7 @@ static int ParseXMI(struct xmi_ctx *ctx) {
file_size = getsrcsize(ctx);
if (getsrcpos(ctx) + 8 > file_size) {
-badfile: //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);
+badfile: /*_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too short)", 0);*/
return (-1);
}
@@ -999,7 +999,7 @@ badfile: //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too shor
/* XDIRless XMIDI, we can handle them here. */
if (!memcmp(buf, "XMID", 4)) {
- //_WM_DEBUG_MSG("Warning: XMIDI without XDIR");
+ /*_WM_DEBUG_MSG("Warning: XMIDI without XDIR");*/
ctx->info.tracks = 1;
}
/* Not an XMIDI that we recognise */
@@ -1053,8 +1053,8 @@ badfile: //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too shor
copy(ctx, buf, 4);
if (memcmp(buf, "CAT ", 4)) {
- //_WM_ERROR_NEW("XMI error: expected \"CAT \", found \"%c%c%c%c\".",
- // buf[0], buf[1], buf[2], buf[3]);
+ /*_WM_ERROR_NEW("XMI error: expected \"CAT \", found \"%c%c%c%c\".",
+ buf[0], buf[1], buf[2], buf[3]);*/
return (-1);
}
@@ -1065,8 +1065,8 @@ badfile: //_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_CORUPT, "(too shor
copy(ctx, buf, 4);
if (memcmp(buf, "XMID", 4)) {
- //_WM_ERROR_NEW("XMI error: expected \"XMID\", found \"%c%c%c%c\".",
- // buf[0], buf[1], buf[2], buf[3]);
+ /*_WM_ERROR_NEW("XMI error: expected \"XMID\", found \"%c%c%c%c\".",
+ buf[0], buf[1], buf[2], buf[3]);*/
return (-1);
}
@@ -1091,8 +1091,8 @@ static int ExtractTracks(struct xmi_ctx *ctx) {
i = ExtractTracksFromXmi(ctx);
if (i != ctx->info.tracks) {
- //_WM_ERROR_NEW("XMI error: extracted only %u out of %u tracks from XMIDI",
- // ctx->info.tracks, i);
+ /*_WM_ERROR_NEW("XMI error: extracted only %u out of %u tracks from XMIDI",
+ ctx->info.tracks, i);*/
return (-1);
}
diff --git a/src/dbopl.h b/src/dbopl.h
index bdd439d..bbe40de 100644
--- a/src/dbopl.h
+++ b/src/dbopl.h
@@ -29,8 +29,13 @@ typedef signed short Bit16s;
typedef unsigned char Bit8u;
typedef signed char Bit8s;
#define INLINE inline
+#ifdef _MSC_VER
+#define GCC_UNLIKELY(x) (!!(x) == 0)
+#define GCC_LIKELY(x) (!!(x) == 1)
+#else
#define GCC_UNLIKELY(x) __builtin_expect((x),0)
#define GCC_LIKELY(x) __builtin_expect((x),1)
+#endif
/* END MIDIPLAY GLUE */
//Use 8 handlers based on a small logatirmic wavetabe and an exponential table for volume
@@ -43,6 +48,14 @@ typedef signed char Bit8s;
//Select the type of wave generator routine
#define DBOPL_WAVE WAVE_TABLEMUL
+#ifdef _MSC_VER
+#ifdef _WIN64
+typedef __int64 ssize_t;
+#else
+typedef __int32 ssize_t;
+#endif
+#endif
+
namespace DBOPL
{