I have some more SCSP fixes - these ones are AO specific.

The main AO fix relates to a problem I noticed in the 8-bit sampler in that it didn't account for sound memory being byte-swapped, making the 8-bit samples come out distorted. While I was at it, I also put in the interpolation code from MAME into the sampler.

Also I noticed that in the panning fix I put in awhile back, I screwed up the operator precedence, so I fixed that (someone else had already noticed this and fixed it for the MAME update).

Patch against AO SDK 1.1.4:

Code
diff -Nru aosdk_base/eng_ssf/scsp.c aosdk/eng_ssf/scsp.c
--- aosdk_base/eng_ssf/scsp.c	2007-12-11 08:52:18.000000000 -0800
+++ aosdk/eng_ssf/scsp.c	2007-12-12 04:00:20.000000000 -0800
@@ -512,7 +512,7 @@
 		if(iPAN&0x4) SegaDB-=12;
 		if(iPAN&0x8) SegaDB-=24;
 
-		if(iPAN&0xf==0xf) PAN=0.0;
+		if((iPAN&0xf)==0xf) PAN=0.0;
 		else PAN=pow(10.0,SegaDB/20.0);
 
 		if(iPAN<0x10)
@@ -1125,13 +1125,23 @@
 
 	if(PCM8B(slot))	//8 bit signed
 	{
-		INT8 *p=(signed char *) (slot->base+(addr));
-		sample=(p[0])<<8;
+		INT8 *p=(signed char *) (SCSP->SCSPRAM+((SA(slot)+addr)^1));
+		//sample=(p[0])<<8;
+		INT32 s;
+		INT32 fpart=slot->cur_addr&((1<<SHIFT)-1);
+		s=(int) (p[0]<<8)*((1<<SHIFT)-fpart)+(int) slot->Prev*fpart;
+		sample=(s>>SHIFT);
+		slot->Prev=p[0]<<8;
 	}
 	else	//16 bit signed (endianness?)
 	{
 		INT16 *p=(signed short *) (slot->base+addr);
-		sample=LE16(p[0]);
+		//sample=LE16(p[0]);
+		INT32 s;
+		INT32 fpart=slot->cur_addr&((1<<SHIFT)-1);
+		s=(int) LE16(p[0])*((1<<SHIFT)-fpart)+(int) slot->Prev*fpart;
+		sample=(s>>SHIFT);
+		slot->Prev=LE16(p[0]);
 	}
 
 	if(SBCTL(slot)&0x1)


Changes (AO-specific):
-Fixed 8-bit sampler to handle byte-swapped RAM
-Added in interpolation code from MAME
-Fixed an error in the panning calculation

Last edited by kingshriek; 12/12/07 12:16 PM.