示例#1
0
static void VR0_RenderAudio(vr0_state *VR0, int nsamples,stream_sample_t *l,stream_sample_t *r)
{
	INT16 *SAMPLES;
	UINT32 st=STATUS;
	signed int lsample=0,rsample=0;
	UINT32 CLK=(VR0->SOUNDREGS[0x600/4]>>0)&0xff;
	UINT32 NCH=(VR0->SOUNDREGS[0x600/4]>>8)&0xff;
	UINT32 CT1=(VR0->SOUNDREGS[0x600/4]>>16)&0xff;
	UINT32 CT2=(VR0->SOUNDREGS[0x600/4]>>24)&0xff;
	int div;
	int s;


	if(CT1&0x20)
		SAMPLES=(INT16 *)VR0->TexBase;
	else
		SAMPLES=(INT16 *)VR0->FBBase;

	if(CLK)
		div=((30<<16)|0x8000)/(CLK+1);
	else
		div=1<<16;

	for(s=0;s<nsamples;++s)
	{
		int i;
		lsample=rsample=0;
		for(i=0;i<=NCH;++i)
		{
			signed int sample;
			UINT32 cur=CURSADDR(i);
			UINT32 a=LOOPBEGIN(i)+(cur>>10);
			UINT8 Mode=VR0->SOUNDREGS[(0x20/4)*i+0x8/4]>>24;
			signed int LVOL=VR0->SOUNDREGS[(0x20/4)*i+0xc/4]>>24;
			signed int RVOL=VR0->SOUNDREGS[(0x20/4)*i+0x10/4]>>24;

			INT32 DSADD=(DSADDR(i)*div)>>16;

			if(!(st&(1<<i)) || !(CT2&0x80))
				continue;

			if(Mode&0x10)		//u-law
			{
				UINT16 s=SAMPLES[a];
				if((cur&0x200))
					s>>=8;
				sample=(signed short)ULawTo16[s&0xff];
			}
			else
			{
				if(Mode&0x20)	//8bit
				{
					UINT16 s=SAMPLES[a];
					if((cur&0x200))
						s>>=8;
					sample=(signed short) (((signed char) (s&0xff))<<8);
				}
				else				//16bit
				{
示例#2
0
void vr0sound_device::VR0_RenderAudio(int nsamples, stream_sample_t *l, stream_sample_t *r)
{
	int16_t *SAMPLES;
	uint32_t st=STATUS;
	signed int lsample,rsample=0;
	uint32_t CLK=(m_SOUNDREGS[0x600/4]>>0)&0xff;
	uint32_t NCH=(m_SOUNDREGS[0x600/4]>>8)&0xff;
	uint32_t CT1=(m_SOUNDREGS[0x600/4]>>16)&0xff;
	uint32_t CT2=(m_SOUNDREGS[0x600/4]>>24)&0xff;
	int div;
	int s;


	if(CT1&0x20)
		SAMPLES=(int16_t *)m_TexBase;
	else
		SAMPLES=(int16_t *)m_FBBase;

	if(CLK)
		div=((30<<16)|0x8000)/(CLK+1);
	else
		div=1<<16;

	for(s=0;s<nsamples;++s)
	{
		int i;
		lsample=rsample=0;
		for(i=0;i<=NCH;++i)
		{
			signed int sample;
			uint32_t cur=CURSADDR(i);
			uint32_t a=LOOPBEGIN(i)+(cur>>10);
			uint8_t Mode=m_SOUNDREGS[(0x20/4)*i+0x8/4]>>24;
			signed int LVOL=m_SOUNDREGS[(0x20/4)*i+0xc/4]>>24;
			signed int RVOL=m_SOUNDREGS[(0x20/4)*i+0x10/4]>>24;

			int32_t DSADD=(DSADDR(i)*div)>>16;

			if(!(st&(1<<i)) || !(CT2&0x80))
				continue;

			if(Mode&0x10)       //u-law
			{
				uint16_t s=SAMPLES[a];
				if((cur&0x200))
					s>>=8;
				sample=(signed short)ULawTo16[s&0xff];
			}
			else
			{
				if(Mode&0x20)   //8bit
				{
					uint16_t s=SAMPLES[a];
					if((cur&0x200))
						s>>=8;
					sample=(signed short) (((signed char) (s&0xff))<<8);
				}
				else                //16bit
				{