+ silentch = ~(spu.dwChannelOn|spu.dwNewChannel);
+
+ mask = spu.dwNewChannel & 0xffffff;
+ for (ch = 0; mask != 0; ch++, mask >>= 1) {
+ if (mask & 1)
+ StartSound(ch);
+ }
+
+ if (spu.dwChannelOn == 0)
+ InitREVERB(ns_to);
+ else {
+ do_channels(ns_to);
+ }
+
+ do_samples_finish(ns_to, silentch);
+
+ // advance "stopped" channels that can cause irqs
+ // (all chans are always playing on the real thing..)
+ if (spu.spuCtrl & CTRL_IRQ)
+ do_silent_chans(ns_to, silentch);
+
+ spu.cycles_played += ns_to * 768;
+ spu.decode_pos = (spu.decode_pos + ns_to) & 0x1ff;
+}
+
+void do_samples_finish(int ns_to, int silentch)
+{
+ int volmult = spu_config.iVolume;
+ int ns;
+ int d;
+
+ if(unlikely(silentch & spu.decode_dirty_ch & (1<<1))) // must clear silent channel decode buffers
+ {
+ memset(&spu.spuMem[0x800/2], 0, 0x400);
+ spu.decode_dirty_ch &= ~(1<<1);
+ }
+ if(unlikely(silentch & spu.decode_dirty_ch & (1<<3)))
+ {
+ memset(&spu.spuMem[0xc00/2], 0, 0x400);
+ spu.decode_dirty_ch &= ~(1<<3);
+ }
+
+ //---------------------------------------------------//
+ // mix XA infos (if any)
+
+ MixXA(ns_to, spu.decode_pos);
+
+ ///////////////////////////////////////////////////////
+ // mix all channels (including reverb) into one buffer
+
+ if(spu_config.iUseReverb)
+ REVERBDo(ns_to);