| version 1.2, 2004/08/05 11:46:26 | version 1.4, 2004/08/18 15:42:33 | 
| Line 2 | Line 2 | 
 | // #include     "wavefile.h" | // #include     "wavefile.h" | 
 | #include        "dosio.h" | #include        "dosio.h" | 
 | #include        "soundmng.h" | #include        "soundmng.h" | 
| // #include     "cpucore.h" | #include        "z80core.h" | 
| // #include     "pccore.h" | #include        "pccore.h" | 
 | // #include     "iocore.h" | // #include     "iocore.h" | 
 | #include        "sound.h" | #include        "sound.h" | 
 | #include        "sndcsec.h" | #include        "sndcsec.h" | 
| Line 67  static void streamprepare(UINT samples) | Line 67  static void streamprepare(UINT samples) | 
 | #if defined(SUPPORT_WAVEREC) | #if defined(SUPPORT_WAVEREC) | 
 | // ---- wave rec | // ---- wave rec | 
 |  |  | 
| BOOL sound_recstart(const char *filename) { | BRESULT sound_recstart(const OEMCHAR *filename) { | 
 |  |  | 
 | WAVEWR  rec; | WAVEWR  rec; | 
 |  |  | 
| Line 166  static void filltailsample(UINT count) { | Line 166  static void filltailsample(UINT count) { | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| BOOL sound_create(UINT rate, UINT ms) { | BRESULT sound_create(UINT rate, UINT ms) { | 
 |  |  | 
 | UINT    samples; | UINT    samples; | 
 | UINT    reserve; | UINT    reserve; | 
| Line 179  BOOL sound_create(UINT rate, UINT ms) { | Line 179  BOOL sound_create(UINT rate, UINT ms) { | 
 | soundmng_reset(); | soundmng_reset(); | 
 |  |  | 
 | soundcfg.rate = rate; | soundcfg.rate = rate; | 
 | sound_changeclock(); |  | 
 |  |  | 
 | #if defined(SOUNDRESERVE) | #if defined(SOUNDRESERVE) | 
 | reserve = rate * SOUNDRESERVE / 1000; | reserve = rate * SOUNDRESERVE / 1000; | 
| Line 225  void sound_reset(void) { | Line 224  void sound_reset(void) { | 
 | if (sndstream.buffer) { | if (sndstream.buffer) { | 
 | soundmng_reset(); | soundmng_reset(); | 
 | streamreset(); | streamreset(); | 
| soundcfg.length = 0; | soundcfg.lastclock = CPU_CLOCK; | 
| //              soundcfg.lastclock = CPU_CLOCK; |  | 
 | } | } | 
 | } | } | 
 |  |  | 
 | void sound_changeclock(void) { | void sound_changeclock(void) { | 
 |  |  | 
 | #if 0 |  | 
 | UINT32  clock; | UINT32  clock; | 
 | UINT    hz; | UINT    hz; | 
 | UINT    hzmax; | UINT    hzmax; | 
| Line 256  void sound_changeclock(void) { | Line 253  void sound_changeclock(void) { | 
 | soundcfg.clockbase = clock; | soundcfg.clockbase = clock; | 
 | soundcfg.minclock = 2 * clock / hz; | soundcfg.minclock = 2 * clock / hz; | 
 | soundcfg.lastclock = CPU_CLOCK; | soundcfg.lastclock = CPU_CLOCK; | 
 | #endif |  | 
 | } | } | 
 |  |  | 
 | void sound_streamregist(void *hdl, SOUNDCB cbfn) { | void sound_streamregist(void *hdl, SOUNDCB cbfn) { | 
| Line 274  void sound_streamregist(void *hdl, SOUND | Line 270  void sound_streamregist(void *hdl, SOUND | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
 | #if 0 |  | 
 | void sound_sync(void) { | void sound_sync(void) { | 
 |  |  | 
 | UINT32  length; | UINT32  length; | 
| Line 282  void sound_sync(void) { | Line 277  void sound_sync(void) { | 
 | if (sndstream.buffer == NULL) { | if (sndstream.buffer == NULL) { | 
 | return; | return; | 
 | } | } | 
 |  |  | 
 | length = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK - soundcfg.lastclock; | length = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK - soundcfg.lastclock; | 
 | if (length < soundcfg.minclock) { | if (length < soundcfg.minclock) { | 
 | return; | return; | 
| Line 300  void sound_sync(void) { | Line 294  void sound_sync(void) { | 
 | #endif | #endif | 
 | streamprepare(length); | streamprepare(length); | 
 | soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; | 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; | SNDCSEC_LEAVE; | 
 |  |  | 
 | soundcfg.writecount += length; | soundcfg.writecount += length; | 
| Line 370  const SINT32 *ret; | Line 327  const SINT32 *ret; | 
 | #endif | #endif | 
 | { | { | 
 | streamprepare(sndstream.remain - sndstream.reserve); | 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 { | else { |