if (val == 0 && (r & 0xff8) == 0xd88)\r
return;\r
\r
- do_samples_if_needed(cycles, 0);\r
+ do_samples_if_needed(cycles, 0, 16);\r
\r
if(r>=0x0c00 && r<0x0d80) // some channel info?\r
{\r
//-------------------------------------------------//\r
case H_SPUaddr:\r
spu.spuAddr = (unsigned long) val<<3;\r
+ //check_irq_io(spu.spuAddr);\r
break;\r
//-------------------------------------------------//\r
case H_SPUdata:\r
*(unsigned short *)(spu.spuMemC + spu.spuAddr) = HTOLE16(val);\r
spu.spuAddr += 2;\r
spu.spuAddr &= 0x7fffe;\r
+ check_irq_io(spu.spuAddr);\r
break;\r
//-------------------------------------------------//\r
case H_SPUctrl:\r
case H_SPUirqAddr:\r
//if (val & 1)\r
// log_unhandled("w irq with lsb: %08lx %04x\n", reg, val);\r
- spu.pSpuIrq=spu.spuMemC+(((unsigned long) val<<3)&~0xf);\r
+ spu.pSpuIrq = spu.spuMemC + (((int)val << 3) & ~0xf);\r
+ //check_irq_io(spu.spuAddr);\r
goto upd_irq;\r
//-------------------------------------------------//\r
case H_SPUrvolL:\r
*/\r
//-------------------------------------------------//\r
case H_SPUon1:\r
+ do_samples_if_needed(cycles, 0, 2);\r
SoundOn(0,16,val);\r
break;\r
//-------------------------------------------------//\r
- case H_SPUon2:\r
+ case H_SPUon2:\r
+ do_samples_if_needed(cycles, 0, 2);\r
SoundOn(16,24,val);\r
break;\r
//-------------------------------------------------//\r
// READ REGISTER: called by main emu\r
////////////////////////////////////////////////////////////////////////\r
\r
-unsigned short CALLBACK SPUreadRegister(unsigned long reg)\r
+unsigned short CALLBACK SPUreadRegister(unsigned long reg, unsigned int cycles)\r
{\r
const unsigned long r = reg & 0xffe;\r
\r
{\r
case 12: // get adsr vol\r
{\r
- const int ch=(r>>4)-0xc0;\r
- if(spu.dwNewChannel&(1<<ch)) return 1; // we are started, but not processed? return 1\r
- if((spu.dwChannelsAudible&(1<<ch)) && // same here... we haven't decoded one sample yet, so no envelope yet. return 1 as well\r
- !spu.s_chan[ch].ADSRX.EnvelopeVol)\r
- return 1;\r
- return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol>>16);\r
+ // this used to return 1 immediately after keyon to deal with\r
+ // some poor timing, but that causes Rayman 2 to lose track of\r
+ // it's channels on busy scenes and start looping some of them forever\r
+ const int ch = (r>>4) - 0xc0;\r
+ if (spu.s_chan[ch].bStarting)\r
+ do_samples_if_needed(cycles, 0, 2);\r
+ return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol >> 16);\r
}\r
\r
case 14: // get loop address\r
case H_SPUaddr:\r
return (unsigned short)(spu.spuAddr>>3);\r
\r
+ // this reportedly doesn't work on real hw\r
case H_SPUdata:\r
{\r
unsigned short s = LE16TOH(*(unsigned short *)(spu.spuMemC + spu.spuAddr));\r
spu.spuAddr += 2;\r
spu.spuAddr &= 0x7fffe;\r
+ //check_irq_io(spu.spuAddr);\r
return s;\r
}\r
\r
if((val&1) && regAreaGetCh(ch, 6)) // mmm... start has to be set before key on !?!\r
{\r
spu.s_chan[ch].bIgnoreLoop = 0;\r
+ spu.s_chan[ch].bStarting = 1;\r
spu.dwNewChannel|=(1<<ch);\r
}\r
}\r
spu.s_chan[ch].iRawPitch = NP;\r
spu.s_chan[ch].sinc = NP << 4;\r
spu.s_chan[ch].sinc_inv = 0;\r
- spu.s_chan[ch].bNewPitch = 1;\r
\r
// don't mess spu.dwChannelsAudible as adsr runs independently\r
}\r