X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=bcac4d9ad63d8e95e4d7b48204447482d8125819;hb=3c7a8977ddbdbfb4a8840a487fadade29bd939d6;hp=e75f70861882a43e5a5a3a331bbd839086727c58;hpb=6c9db47c7c54b925e00a96b17faa05e17d6af262;p=pcsx_rearmed.git diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index e75f7086..bcac4d9a 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -22,6 +22,7 @@ #include "externals.h" #include "registers.h" #include "spu_config.h" +#include "spu.h" static void SoundOn(int start,int end,unsigned short val); static void SoundOff(int start,int end,unsigned short val); @@ -36,17 +37,19 @@ static void ReverbOn(int start,int end,unsigned short val); // WRITE REGISTERS: called by main emu //////////////////////////////////////////////////////////////////////// -static const uint32_t ignore_dupe[8] = { +static const uint32_t ignore_dupe[16] = { // ch 0-15 c40 c80 cc0 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, // ch 16-24 d40 control reverb - 0x7f7f7f7f, 0x7f7f7f7f, 0xff05ff0f, 0xffffffff + 0x7f7f7f7f, 0x7f7f7f7f, 0xff05ff0f, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, unsigned int cycles) { - int r = reg & 0xfff; + int r = reg & 0xffe; int rofs = (r - 0xc00) >> 1; int changed = spu.regArea[rofs] != val; spu.regArea[rofs] = val; @@ -118,18 +121,26 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, } return; } + else if (0x0e00 <= r && r < 0x0e60) + { + int ch = (r >> 2) & 0x1f; + log_unhandled("c%02d w %cvol %04x\n", ch, (r & 2) ? 'r' : 'l', val); + spu.s_chan[ch].iVolume[(r >> 1) & 1] = (signed short)val >> 1; + } switch(r) { //-------------------------------------------------// case H_SPUaddr: spu.spuAddr = (unsigned long) val<<3; + //check_irq_io(spu.spuAddr); break; //-------------------------------------------------// case H_SPUdata: - *(unsigned short *)(spu.spuMemC + spu.spuAddr) = val; + *(unsigned short *)(spu.spuMemC + spu.spuAddr) = HTOLE16(val); spu.spuAddr += 2; spu.spuAddr &= 0x7fffe; + check_irq_io(spu.spuAddr); break; //-------------------------------------------------// case H_SPUctrl: @@ -149,7 +160,10 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, goto rvbd; //-------------------------------------------------// case H_SPUirqAddr: - spu.pSpuIrq=spu.spuMemC+(((unsigned long) val<<3)&~0xf); + //if (val & 1) + // log_unhandled("w irq with lsb: %08lx %04x\n", reg, val); + spu.pSpuIrq = spu.spuMemC + (((int)val << 3) & ~0xf); + //check_irq_io(spu.spuAddr); goto upd_irq; //-------------------------------------------------// case H_SPUrvolL: @@ -297,7 +311,7 @@ rvbd: unsigned short CALLBACK SPUreadRegister(unsigned long reg) { - const unsigned long r=reg&0xfff; + const unsigned long r = reg & 0xffe; if(r>=0x0c00 && r<0x0d80) { @@ -320,6 +334,13 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) } } } + else if (0x0e00 <= r && r < 0x0e60) + { + int ch = (r >> 2) & 0x1f; + int v = spu.s_chan[ch].iVolume[(r >> 1) & 1] << 1; + log_unhandled("c%02d r %cvol %04x\n", ch, (r & 2) ? 'r' : 'l', v); + return v; + } switch(r) { @@ -332,11 +353,13 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case H_SPUaddr: return (unsigned short)(spu.spuAddr>>3); + // this reportedly doesn't work on real hw case H_SPUdata: { - unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr); + unsigned short s = LE16TOH(*(unsigned short *)(spu.spuMemC + spu.spuAddr)); spu.spuAddr += 2; spu.spuAddr &= 0x7fffe; + //check_irq_io(spu.spuAddr); return s; } @@ -350,6 +373,19 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case H_SPUMute2: log_unhandled("r isOn: %08lx\n", reg); break; + + case 0x0dac: + case H_SPUirqAddr: + case H_CDLeft: + case H_CDRight: + case H_ExtLeft: + case H_ExtRight: + break; + + default: + if (r >= 0xda0) + log_unhandled("spu r %08lx\n", reg); + break; } return spu.regArea[(r-0xc00)>>1]; @@ -462,6 +498,7 @@ static void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME vol&=0x3fff; spu.s_chan[ch].iLeftVolume=vol; // store volume + //spu.regArea[(0xe00-0xc00)/2 + ch*2 + 0] = vol << 1; } //////////////////////////////////////////////////////////////////////// @@ -489,6 +526,7 @@ static void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME vol&=0x3fff; spu.s_chan[ch].iRightVolume=vol; + //spu.regArea[(0xe00-0xc00)/2 + ch*2 + 1] = vol << 1; } //////////////////////////////////////////////////////////////////////// @@ -504,11 +542,9 @@ static void SetPitch(int ch,unsigned short val) // SET PITCH spu.s_chan[ch].iRawPitch = NP; spu.s_chan[ch].sinc = NP << 4; spu.s_chan[ch].sinc_inv = 0; - spu.SB[ch * SB_SIZE + 32] = 1; // -> freq change in simple interpolation mode: set flag - if (val) - spu.dwChannelsAudible |= 1u << ch; - else - spu.dwChannelsAudible &= ~(1u << ch); + spu.s_chan[ch].bNewPitch = 1; + + // don't mess spu.dwChannelsAudible as adsr runs independently } ////////////////////////////////////////////////////////////////////////