Skip to content

Commit

Permalink
make the C++ synth_core etc. a bit more portable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
PoroCYon committed Jul 28, 2019
1 parent e31b73a commit b08450b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
11 changes: 10 additions & 1 deletion v2/ronan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

//#pragma intrinsic (atan, cos, fabs)

#if !defined(_MSC_VER) && !defined(__stdcall)
#define __stdcall
#endif

#ifdef _MSC_VER
static sInt sFtol (const float f)
{
__asm
Expand Down Expand Up @@ -96,6 +100,11 @@ static sF64 sFExp(sF64 f)

return f;
}
#else
#define sFtol(a) ((sInt)(a))
#define sFPow(a, b) powf(a, b)
#define sFExp(a) expf(a)
#endif

#ifndef sCopyMem
#define sCopyMem memcpy
Expand Down Expand Up @@ -585,4 +594,4 @@ extern "C" void __stdcall synthSetLyrics(void *a_pthis,const char **a_ptr)
wsptr->baseptr=wsptr->ptr=wsptr->texts[0];
}

#endif
#endif
17 changes: 13 additions & 4 deletions v2/sounddef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
#include "sounddef.h"
#include "v2mconv.h"

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define V2_memset ZeroMemory
#else
#ifndef V2_memset
#include <string.h>
#define V2_memset(p,s) memset(p,0,s)
#endif
#endif

// lr: in case you miss the arrays: look in sounddef.h

Expand Down Expand Up @@ -112,8 +120,7 @@ void sdInit()
p+=v2gtopics[i].no;
}

#ifdef RONAN
ZeroMemory(speech,64*256);
V2_memset(speech,64*256);
for (int i=0; i<64; i++)
speechptrs[i]=speech[i];

Expand Down Expand Up @@ -216,7 +223,7 @@ static sBool sdLoadBank(file &in)


#ifdef RONAN
ZeroMemory(speech,64*256);
V2_memset(speech,64*256);
#endif

if (!in.eof())
Expand All @@ -232,7 +239,9 @@ static sBool sdLoadBank(file &in)
}
#else
#ifndef SINGLECHN
#ifdef _WIN32
if (sml) MessageBox(0,"Warning: Not loading speech synth texts\nIf you overwrite the file later, the texts will be lost!","Farbrausch V2",MB_ICONEXCLAMATION);
#endif
#endif
in.seekcur(sml);
#endif
Expand Down Expand Up @@ -337,4 +346,4 @@ void sdInitPatch()
{
memcpy(soundmem+128*4+v2curpatch*v2soundsize,v2initsnd,v2soundsize);
sprintf(patchnames[v2curpatch],"Init Patch #%03d",v2curpatch);
}
}
7 changes: 6 additions & 1 deletion v2/sounddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ const int v2ntopics = sizeof(v2topics)/sizeof(V2TOPIC);
//
////////////////////////////////////////////

__declspec(selectany) const char *v2sources[] = {
#ifdef _MSC_VER
__declspec(selectany)
#else
__attribute__((__weak__))
#endif
const char *v2sources[] = {
"Velocity",
"Modulation",
"Breath",
Expand Down
7 changes: 7 additions & 0 deletions v2/synth_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <string.h>
#include <stdlib.h>

#if !defined(_MSC_VER) && !defined(__stdcall)
#define __stdcall
#endif

// TODO:
// - VU meters?

Expand Down Expand Up @@ -243,6 +247,8 @@ static inline sF32 lerp(sF32 a, sF32 b, sF32 t)
// DEBUG
#include <stdarg.h>
#include <stdio.h>

#ifdef _WIN32
extern "C" void __stdcall OutputDebugStringA(const char *what);
static void dprintf(const char *fmt, ...)
{
Expand All @@ -253,6 +259,7 @@ static void dprintf(const char *fmt, ...)
va_end(arg);
OutputDebugStringA(buf);
}
#endif

// --------------------------------------------------------------------------
// Building blocks
Expand Down
6 changes: 5 additions & 1 deletion v2/v2mconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

#define printf2

#ifdef _MSC_VER
#pragma intrinsic (pow, sqrt, log)
#endif

extern const char * const v2mconv_errors[] =
{
Expand Down Expand Up @@ -53,7 +55,9 @@ static struct _ssbase {


extern "C" void * memset(void *, int, size_t);
#ifdef _MSC_VER
#pragma intrinsic (memset)
#endif

static void readfile(const unsigned char *inptr, const int inlen)
{
Expand Down Expand Up @@ -407,4 +411,4 @@ unsigned long GetV2MPatchData(const unsigned char *inptr, const int inlen,
}

return base.maxp;
}
}

0 comments on commit b08450b

Please sign in to comment.