+ if(flags & 1)
+ s_chan[ch].pCurr = s_chan[ch].pLoop;
+
+ s_chan[ch].bJump = flags & 1;
+ return ret;
+}
+
+#define make_do_samples(name, fmod_code, interp_start, interp1_code, interp2_code, interp_end) \
+static int do_samples_##name(int ch, int ns, int ns_to) \
+{ \
+ int sinc = s_chan[ch].sinc; \
+ int spos = s_chan[ch].spos; \
+ int sbpos = s_chan[ch].iSBPos; \
+ int *SB = s_chan[ch].SB; \
+ int ret = -1; \
+ int d, fa; \
+ interp_start; \
+ \
+ for (; ns < ns_to; ns++) \
+ { \
+ fmod_code; \
+ \
+ while (spos >= 0x10000) \
+ { \
+ if(sbpos == 28) \
+ { \
+ sbpos = 0; \
+ d = decode_block(ch); \
+ if(d && iSPUIRQWait) \
+ { \
+ ret = ns; \
+ goto out; \
+ } \
+ } \
+ \
+ fa = SB[sbpos++]; \
+ interp1_code; \
+ spos -= 0x10000; \
+ } \
+ \
+ interp2_code; \
+ spos += sinc; \
+ } \
+ \
+out: \
+ s_chan[ch].sinc = sinc; \
+ s_chan[ch].spos = spos; \
+ s_chan[ch].iSBPos = sbpos; \
+ interp_end; \
+ \
+ return ret; \
+}
+
+#define fmod_recv_check \
+ if(s_chan[ch].bFMod==1 && iFMod[ns]) \
+ sinc = FModChangeFrequency(ch,ns)
+
+make_do_samples(default, fmod_recv_check, ,
+ StoreInterpolationVal(ch, fa),
+ ChanBuf[ns] = iGetInterpolationVal(ch), )
+make_do_samples(noint, , fa = s_chan[ch].SB[29], , ChanBuf[ns] = fa, s_chan[ch].SB[29] = fa)
+
+#define simple_interp_store \
+ s_chan[ch].SB[28] = 0; \
+ s_chan[ch].SB[29] = s_chan[ch].SB[30]; \
+ s_chan[ch].SB[30] = s_chan[ch].SB[31]; \
+ s_chan[ch].SB[31] = fa; \
+ s_chan[ch].SB[32] = 1
+
+#define simple_interp_get \
+ if(sinc<0x10000) /* -> upsampling? */ \
+ InterpolateUp(ch); /* --> interpolate up */ \
+ else InterpolateDown(ch); /* --> else down */ \
+ ChanBuf[ns] = s_chan[ch].SB[29]
+
+make_do_samples(simple, , ,
+ simple_interp_store, simple_interp_get, )
+
+static int do_samples_noise(int ch, int ns, int ns_to)
+{
+ int level, shift, bit;
+
+ s_chan[ch].spos += s_chan[ch].sinc * (ns_to - ns);
+ while (s_chan[ch].spos >= 28*0x10000)