--- xmil/sound/sound.c 2004/08/05 11:46:26 1.2 +++ xmil/sound/sound.c 2008/06/02 20:07:32 1.6 @@ -1,13 +1,15 @@ #include "compiler.h" -// #include "wavefile.h" + +#if !defined(DISABLE_SOUND) + +#include "wavefile.h" #include "dosio.h" #include "soundmng.h" -// #include "cpucore.h" -// #include "pccore.h" -// #include "iocore.h" +#include "z80core.h" +#include "pccore.h" #include "sound.h" #include "sndcsec.h" -// #include "getsnd.h" +/* #include "getsnd.h" */ SOUNDCFG soundcfg; @@ -65,9 +67,9 @@ static void streamprepare(UINT samples) #if defined(SUPPORT_WAVEREC) -// ---- wave rec +/* wave rec */ -BOOL sound_recstart(const char *filename) { +BRESULT sound_recstart(const OEMCHAR *filename) { WAVEWR rec; @@ -124,7 +126,7 @@ static void streamfilewrite(UINT samples else if (samp < -32768) { samp = -32768; } - // little endianなので satuation_s16は使えない + /* little endianなので satuation_s16は使えない */ buf[i*2+0] = (UINT8)samp; buf[i*2+1] = (UINT8)(samp >> 8); } @@ -164,9 +166,9 @@ static void filltailsample(UINT count) { #endif -// ---- +/* ---- */ -BOOL sound_create(UINT rate, UINT ms) { +BRESULT sound_create(UINT rate, UINT ms) { UINT samples; UINT reserve; @@ -179,7 +181,6 @@ BOOL sound_create(UINT rate, UINT ms) { soundmng_reset(); soundcfg.rate = rate; - sound_changeclock(); #if defined(SOUNDRESERVE) reserve = rate * SOUNDRESERVE / 1000; @@ -225,14 +226,12 @@ void sound_reset(void) { if (sndstream.buffer) { soundmng_reset(); streamreset(); - soundcfg.length = 0; -// soundcfg.lastclock = CPU_CLOCK; + soundcfg.lastclock = CPU_CLOCK; } } void sound_changeclock(void) { -#if 0 UINT32 clock; UINT hz; UINT hzmax; @@ -241,11 +240,11 @@ void sound_changeclock(void) { return; } - // とりあえず 25で割り切れる。 + /* とりあえず 25で割り切れる。 */ clock = pccore.realclock / 25; hz = soundcfg.rate / 25; - // で、クロック数に合せて調整。(64bit演算しろよな的) + /* で、クロック数に合せて調整。(64bit演算しろよな的) */ hzmax = (1 << (32 - 8)) / (clock >> 8); while(hzmax < hz) { clock = (clock + 1) >> 1; @@ -256,7 +255,6 @@ void sound_changeclock(void) { soundcfg.clockbase = clock; soundcfg.minclock = 2 * clock / hz; soundcfg.lastclock = CPU_CLOCK; -#endif } void sound_streamregist(void *hdl, SOUNDCB cbfn) { @@ -272,9 +270,8 @@ void sound_streamregist(void *hdl, SOUND } -// ---- +/* ---- */ -#if 0 void sound_sync(void) { UINT32 length; @@ -282,7 +279,6 @@ void sound_sync(void) { if (sndstream.buffer == NULL) { return; } - length = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK - soundcfg.lastclock; if (length < soundcfg.minclock) { return; @@ -300,43 +296,6 @@ void sound_sync(void) { #endif streamprepare(length); soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; - beep_eventreset(); - SNDCSEC_LEAVE; - - soundcfg.writecount += length; - if (soundcfg.writecount >= 100) { - soundcfg.writecount = 0; - soundmng_sync(); - } -} -#endif - -void sound_makesample(UINT length) { - - soundcfg.length += length; -} - -void sound_sync(void) { - - UINT length; - - length = soundcfg.length; - if (length == 0) { - return; - } - if (sndstream.buffer == NULL) { - return; - } - SNDCSEC_ENTER; -#if defined(SUPPORT_WAVEREC) - if (sndstream.rec) { - streamfilewrite(length); - } - else -#endif - streamprepare(length); -// soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; - soundcfg.length = 0; SNDCSEC_LEAVE; soundcfg.writecount += length; @@ -354,7 +313,7 @@ const SINT32 *sound_pcmlock(void) { const SINT32 *ret; if (locks) { -// TRACEOUT(("sound pcm lock: already locked")); + /* TRACEOUT(("sound pcm lock: already locked")); */ return(NULL); } locks++; @@ -370,8 +329,7 @@ const SINT32 *ret; #endif { streamprepare(sndstream.remain - sndstream.reserve); - soundcfg.length = 0; -// soundcfg.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; + soundcfg.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; } } else { @@ -393,9 +351,11 @@ void sound_pcmunlock(const SINT32 *hdl) } sndstream.ptr = sndstream.buffer + (leng * 2); sndstream.remain = sndstream.samples + sndstream.reserve - leng; -// sndstream.remain += sndstream.samples; + /* sndstream.remain += sndstream.samples; */ SNDCSEC_LEAVE; locks--; } } +#endif +