| version 1.1.1.1, 2003/10/16 17:58:48 | version 1.7, 2004/02/03 08:24:40 | 
| Line 6 | Line 6 | 
 | #include        "soundmng.h" | #include        "soundmng.h" | 
 | #include        "extromio.h" | #include        "extromio.h" | 
 | #include        "sound.h" | #include        "sound.h" | 
 |  | #include        "juliet.h" | 
 | #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) | 
 | #include        "vermouth.h" | #include        "vermouth.h" | 
 | #endif | #endif | 
 |  |  | 
 |  | #ifdef __cplusplus | 
 |  | extern "C" { | 
 |  | #endif | 
 |  | void __fastcall satuation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size); | 
 |  | #ifdef __cplusplus | 
 |  | } | 
 |  | #endif | 
 |  |  | 
 |  |  | 
 | #if 1 | #if 1 | 
 | #define DSBUFFERDESC_SIZE       20                      // DirectX3 Structsize | #define DSBUFFERDESC_SIZE       20                      // DirectX3 Structsize | 
| Line 30  static LPDIRECTSOUNDBUFFER pDSData3; | Line 39  static LPDIRECTSOUNDBUFFER pDSData3; | 
 | static  UINT                            dsstreambytes; | static  UINT                            dsstreambytes; | 
 | static  BYTE                            dsstreamevent; | static  BYTE                            dsstreamevent; | 
 | static  LPDIRECTSOUNDBUFFER pDSwave3[SOUND_MAXPCM]; | static  LPDIRECTSOUNDBUFFER pDSwave3[SOUND_MAXPCM]; | 
| static  BYTE                            mute; | static  UINT                            mute; | 
|  | static  void                            (PARTSCALL *fnmix)(SINT16 *dst, | 
|  | const SINT32 *src, UINT size); | 
 |  |  | 
 | #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) | 
 | MIDIMOD         vermouth_module = NULL; | MIDIMOD         vermouth_module = NULL; | 
| Line 64  UINT soundmng_create(UINT rate, UINT ms) | Line 75  UINT soundmng_create(UINT rate, UINT ms) | 
 | UINT                    samples; | UINT                    samples; | 
 | DSBUFFERDESC    dsbdesc; | DSBUFFERDESC    dsbdesc; | 
 | PCMWAVEFORMAT   pcmwf; | PCMWAVEFORMAT   pcmwf; | 
 | #if defined(VERMOUTH_LIB) |  | 
 | UINT                    num; |  | 
 | #endif |  | 
 |  |  | 
 | if ((pDSound == NULL) || | if ((pDSound == NULL) || | 
 | (rate != 11025) && (rate != 22050) && (rate != 44100)) { | (rate != 11025) && (rate != 22050) && (rate != 44100)) { | 
 | goto stcre_err1; | goto stcre_err1; | 
 | } | } | 
| if (ms < 50) { | if (ms < 40) { | 
| ms = 50; | ms = 40; | 
 | } | } | 
 | else if (ms > 1000) { | else if (ms > 1000) { | 
 | ms = 1000; | ms = 1000; | 
| Line 85  UINT soundmng_create(UINT rate, UINT ms) | Line 93  UINT soundmng_create(UINT rate, UINT ms) | 
 | samples = (rate * ms) / 2000; | samples = (rate * ms) / 2000; | 
 | samples = (samples + 3) & (~3); | samples = (samples + 3) & (~3); | 
 | dsstreambytes = samples * 2 * sizeof(SINT16); | dsstreambytes = samples * 2 * sizeof(SINT16); | 
 |  | soundmng_setreverse(FALSE); | 
 |  |  | 
 | ZeroMemory(&pcmwf, sizeof(PCMWAVEFORMAT)); | ZeroMemory(&pcmwf, sizeof(PCMWAVEFORMAT)); | 
 | pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; | pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; | 
| Line 107  UINT soundmng_create(UINT rate, UINT ms) | Line 116  UINT soundmng_create(UINT rate, UINT ms) | 
 |  |  | 
 | #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) | 
 | vermouth_module = midimod_create(rate); | vermouth_module = midimod_create(rate); | 
| for (num=0; num<128; num++) { | midimod_loadall(vermouth_module); | 
| midimod_loadprogram(vermouth_module, num); |  | 
| midimod_loadrhythm(vermouth_module, num); |  | 
| } |  | 
 | #endif | #endif | 
 | dsstreamevent = (BYTE)-1; | dsstreamevent = (BYTE)-1; | 
 | soundmng_reset(); | soundmng_reset(); | 
| Line 167  static void streamenable(BOOL play) { | Line 173  static void streamenable(BOOL play) { | 
 | pDSData3->Stop(); | pDSData3->Stop(); | 
 | } | } | 
 | } | } | 
 |  | juliet_YMF288Enable(play); | 
 | } | } | 
 |  |  | 
 | void soundmng_play(void) { | void soundmng_play(void) { | 
| Line 204  const SINT32 *pcm; | Line 211  const SINT32 *pcm; | 
 | } | } | 
 | if (SUCCEEDED(hr)) { | if (SUCCEEDED(hr)) { | 
 | if (pcm) { | if (pcm) { | 
| satuation_s16((SINT16 *)blockptr1, pcm, blocksize1); | (*fnmix)((SINT16 *)blockptr1, pcm, blocksize1); | 
 | } | } | 
 | else { | else { | 
 | ZeroMemory(blockptr1, blocksize1); | ZeroMemory(blockptr1, blocksize1); | 
| Line 238  void soundmng_sync(void) { | Line 245  void soundmng_sync(void) { | 
 | } | } | 
 |  |  | 
 | void soundmng_setreverse(BOOL reverse) { | void soundmng_setreverse(BOOL reverse) { | 
 |  |  | 
 |  | if (!reverse) { | 
 |  | if (mmxflag) { | 
 |  | fnmix = satuation_s16; | 
 |  | } | 
 |  | else { | 
 |  | fnmix = satuation_s16mmx; | 
 |  | } | 
 |  | } | 
 |  | else { | 
 |  | fnmix = satuation_s16x; | 
 |  | } | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 442  void soundmng_deinitialize(void) { | Line 461  void soundmng_deinitialize(void) { | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| void soundmng_enable(void) { | void soundmng_enable(UINT proc) { | 
 |  |  | 
| if (mute) { | if (!(mute & (1 << proc))) { | 
| mute = 0; | return; | 
|  | } | 
|  | mute &= ~(1 << proc); | 
|  | if (!mute) { | 
 | soundmng_reset(); | soundmng_reset(); | 
 | streamenable(TRUE); | streamenable(TRUE); | 
 | } | } | 
 | } | } | 
 |  |  | 
| void soundmng_disable(void) { | void soundmng_disable(UINT proc) { | 
 |  |  | 
 | if (!mute) { | if (!mute) { | 
 | mute = 1; |  | 
 | streamenable(FALSE); | streamenable(FALSE); | 
 | pcmstop(); | pcmstop(); | 
 | } | } | 
 |  | mute |= 1 << proc; | 
 | } | } | 
 |  |  |