Previous Thread
Next Thread
Print Thread
Page 2 of 55 1 2 3 4 54 55
Joined: Sep 2007
Posts: 56
K
Member
Offline
Member
K
Joined: Sep 2007
Posts: 56
I've been attacking the envelope problems a bit more, mostly targeting problems with Radiant Silvergun, and I've came up with some more fixes. One problem I discovered is that if a slot was already in the release state, keying it off stopped it cold - this shouldn't be happening.

Patch against AO SDK release 1.1.1:
Code
--- aosdk_base\eng_ssf\scsp.c	2007-12-01 09:11:48.000000000 -0800
+++ aosdk\eng_ssf\scsp.c	2007-12-01 22:09:28.000000000 -0800
@@ -306,7 +306,7 @@
 	int Rate=base+(R<<1);
 	if(Rate>63)	Rate=63;
 	if(Rate<0) Rate=0;
-	return SCSP->ARTABLE[63-Rate];
+	return SCSP->DRTABLE[Rate];
 }
 
 static void Compute_EG(struct _SCSP *SCSP,struct _SLOT *slot)
@@ -366,9 +366,10 @@
 			slot->EG.volume-=slot->EG.RR;
 			if(slot->EG.volume<=0)
 			{
+				slot->EG.volume=0;
 				SCSP_StopSlot(slot,0);
-				slot->EG.volume=0x17F<<EG_SHIFT;
-				slot->EG.state=ATTACK;
+				//slot->EG.volume=0x17F<<EG_SHIFT;
+				//slot->EG.state=ATTACK;
 			}
 			break;
 		default:
@@ -421,7 +422,7 @@
 
 static void SCSP_StopSlot(struct _SLOT *slot,int keyoff)
 {
-	if(keyoff && slot->EG.state!=RELEASE)
+	if(keyoff /*&& slot->EG.state!=RELEASE*/)
 	{
 		slot->EG.state=RELEASE;
 	}
@@ -429,7 +430,6 @@
 	{
 		slot->active=0;
 	}
-
 	slot->udata.data[0]&=~0x800;
 }
 
@@ -559,7 +559,6 @@
 	{
 		SCSP->Slots[i].slot=i;
 		SCSP->Slots[i].active=0;
-		SCSP->Slots[i].active=0;
 		SCSP->Slots[i].base=NULL;
 	}
 
@@ -591,11 +590,11 @@
 				{
 					struct _SLOT *s2=SCSP->Slots+sl;
 					{
-						if(KEYONB(s2) && !s2->active)
+						if(KEYONB(s2) && s2->EG.state==RELEASE/*&& !s2->active*/)
 						{
 							SCSP_StartSlot(SCSP, s2);
 						}
-						if(!KEYONB(s2) && s2->active)
+						if(!KEYONB(s2) /*&& s2->active*/)
 						{
 							SCSP_StopSlot(s2,1);
 						}
@@ -1188,7 +1187,10 @@
 	if(!STWINH(slot))
 		*RBUFDST=sample;
 
-	sample=(sample*EG_TABLE[EG_Update(slot)>>(SHIFT-10)])>>SHIFT;
+	if(slot->EG.state==ATTACK)
+		sample=(sample*EG_Update(slot))>>SHIFT;
+	else
+		sample=(sample*EG_TABLE[EG_Update(slot)>>(SHIFT-10)])>>SHIFT;
 
 	return sample;
 }

Changes:
-Prevented keyoffs from killing slots when already in the release state
-Envelope steps in the attack state are apparently exponential. To account for this, I change the envelope output to linear for attacks.
-Change the release rate calculation to use the decay table instead of the attack one.



Also, I noticed in the MAME scsp.c source that the 16-bit PCM sample fix I posted earlier in this thread didn't get put in. Radiant Silvergun will need it for correct sound playback.

Here's the fix again, slightly modified so that it compiles without warnings in MAME (strict C90 compliance):

Code
--- mame_base\src\emu\sound\scsp.c	2007-11-18 15:54:28.000000000 -0800
+++ mame\src\emu\sound\scsp.c	2007-12-01 15:28:06.000000000 -0800
@@ -461,13 +461,15 @@
 
 static void SCSP_StartSlot(struct _SCSP *SCSP, struct _SLOT *slot)
 {
+	UINT32 start_offset;
 	slot->active=1;
-	slot->base=SCSP->SCSPRAM+SA(slot);
+	start_offset = PCM8B(slot) ? SA(slot) : SA(slot) & 0x7FFFE;
+	slot->base=SCSP->SCSPRAM + start_offset;
 	slot->cur_addr=0;
 	slot->step=SCSP_Step(slot);
 	Compute_EG(SCSP,slot);

Patch is against the most recent, unmodified scsp.c in MAME source.

Joined: Mar 2001
Posts: 17,215
Likes: 234
R
Very Senior Member
OP Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 17,215
Likes: 234
Ok, that's definitely much better. The drums at the start of Sakura Taisen #20 don't cut off immediately now, and Radient Silvergun is indeed quite improved. The 16-bit fix also corrects a few errant sound effects in Shienryu (one of the most underrated shmups ever, IMO).

Joined: Mar 2001
Posts: 17,215
Likes: 234
R
Very Senior Member
OP Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 17,215
Likes: 234
At the page.

Just syncs up the SCSP with the latest patches again.

BTW, these patches greatly improved NiGHTS also, except nights-2a has a weird pitch problem on the flute. Any ideas on that?

Joined: Mar 2001
Posts: 17,215
Likes: 234
R
Very Senior Member
OP Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 17,215
Likes: 234
I've launched my rip page. First up: a full SSF set of Radiant Silvergun from the ST-V version, fully tagged and timed. Plus a rarity that fell into my hands: a Qsound demo for the Saturn that was given away free to developers and made by game music legend Brian Schmidt. RSG will play quite nicely in the next AO test version (hopefully later today), but the QSound demo only works properly in kingshriek's KBmedia plugin for now.

Last edited by R. Belmont; 12/02/07 11:12 PM. Reason: I was on a bad spelling rampage this morning. all better.
Joined: Dec 1969
Posts: 920
Likes: 3
R
Senior Member
Offline
Senior Member
R
Joined: Dec 1969
Posts: 920
Likes: 3
Can you fire me over a code drop when you have a minute and I'll try to do a Mac version of this test too.

Joined: Oct 2006
Posts: 1,017
Likes: 21
S
Very Senior Member
Offline
Very Senior Member
S
Joined: Oct 2006
Posts: 1,017
Likes: 21
"Plus a rarity that fell into my hands: a Qsound demo for the Saturn that was given away free to developers and made by game music legend Brian Schmidt."

Amazing how things like that happen to turn up...

- Stiletto

Joined: Sep 2007
Posts: 56
K
Member
Offline
Member
K
Joined: Sep 2007
Posts: 56
With the SCSP EG in pretty good shape, I have turned to fix some of the remaining issues in the DSP. The main fix I put in was support for the input effect mixer which fixes many of the dry/wet balance issues. I put in floating point support as well for ring-buffer read/writes. This fixes popping issues when the DSP initially reads from the ring-buffer, which most driver versions initialize to 0x6000 (the DSP floating-point representation of zero).

I also noticed that the EG_Update() function can possibly return a negative value in the DECAY1 state, which would potentially cause a segfault when later used as an index for table lookup (and if it doesn't, the output from it would probably sound very bad). I fixed this by adding a clamp to zero in the DECAY1 state.

I also took a brief look at LFO code and noticed that the saw PLFO was mistakenly set to a triangle waveform, so I fixed that too.

Patch against AO SDK 1.1.2:

Code
diff -Nru aosdk_base/eng_ssf/scsp.c aosdk/eng_ssf/scsp.c
--- aosdk_base/eng_ssf/scsp.c	2007-12-02 10:27:02.000000000 -0800
+++ aosdk/eng_ssf/scsp.c	2007-12-09 04:09:59.000000000 -0800
@@ -351,6 +351,8 @@
 			break;
 		case DECAY1:
 			slot->EG.volume-=slot->EG.D1R;
+			if(slot->EG.volume<=0)
+				slot->EG.volume=0;
 			if(slot->EG.volume>>(EG_SHIFT+5)<slot->EG.DL)
 				slot->EG.state=DECAY2;
 			break;
@@ -1222,12 +1224,13 @@
 				++SCSP->BUFPTR;
 				SCSP->BUFPTR&=63;
 #ifdef USEDSP
-				SCSPDSP_SetSample(&SCSP->DSP,sample>>SHIFT,ISEL(slot),IMXL(slot));
+				Enc=((TL(slot))<<0x0)|((IMXL(slot))<<0xd);
+				SCSPDSP_SetSample(&SCSP->DSP,(sample*SCSP->LPANTABLE[Enc])>>SHIFT,ISEL(slot),IMXL(slot));
 #endif
 				Enc=((TL(slot))<<0x0)|((DIPAN(slot))<<0x8)|((DISDL(slot))<<0xd);
 				{
-					smpl+=(sample*SCSP->LPANTABLE[Enc])>>(SHIFT-1);
-					smpr+=(sample*SCSP->RPANTABLE[Enc])>>(SHIFT-1);
+					smpl+=(sample*SCSP->LPANTABLE[Enc])>>SHIFT;
+					smpr+=(sample*SCSP->RPANTABLE[Enc])>>SHIFT;
 				}
 			}
 
@@ -1240,14 +1243,14 @@
 			struct _SLOT *slot=SCSP->Slots+i;
 			if(EFSDL(slot))
 			{
-				unsigned short Enc=(TL(slot))|((EFPAN(slot))<<0x8)|((EFSDL(slot))<<0xd);
-				smpl+=(SCSP->DSP.EFREG[i]*SCSP->LPANTABLE[Enc])>>(SHIFT-4);
-				smpr+=(SCSP->DSP.EFREG[i]*SCSP->RPANTABLE[Enc])>>(SHIFT-4);
+				unsigned short Enc=((EFPAN(slot))<<0x8)|((EFSDL(slot))<<0xd);
+				smpl+=(SCSP->DSP.EFREG[i]*SCSP->LPANTABLE[Enc])>>SHIFT;
+				smpr+=(SCSP->DSP.EFREG[i]*SCSP->RPANTABLE[Enc])>>SHIFT;
 			}
 		}
 
-		*bufl++ = ICLIP16(smpl>>3);
-		*bufr++ = ICLIP16(smpr>>3);
+		*bufl++ = ICLIP16(smpl>>2);
+		*bufr++ = ICLIP16(smpr>>2);
 
 		SCSP_TimersAddTicks(SCSP, 1);
 		CheckPendingIRQ(SCSP);
diff -Nru aosdk_base/eng_ssf/scspdsp.c aosdk/eng_ssf/scspdsp.c
--- aosdk_base/eng_ssf/scspdsp.c	2007-10-26 19:43:40.000000000 -0700
+++ aosdk/eng_ssf/scspdsp.c	2007-12-09 03:58:38.000000000 -0800
@@ -7,19 +7,49 @@
 
 static UINT16 PACK(INT32 val)
 {
-	//cut to 16 bits
-	INT32 f=((UINT32 ) val)>>8;
-	return f;
+	UINT32 temp;
+	int sign,exponent,k;
+
+	sign = (val >> 23) & 0x1;
+	temp = (val ^ (val << 1)) & 0xFFFFFF;
+	exponent = 0;
+	for (k=0; k<12; k++)
+	{
+		if (temp & 0x800000)
+			break;
+		temp <<= 1;
+		exponent += 1;
+	}
+	if (exponent < 12)
+		val = (val << exponent) & 0x3FFFFF;
+	else
+		val <<= 11;
+	val >>= 11;
+	val |= sign << 15;
+	val |= exponent << 11;
+
+	return (UINT16)val;
 }
 
 static INT32 UNPACK(UINT16 val)
 {
-	INT32 r=val<<8;
-	r<<=8;
-	r>>=8;
-	//if(r&0x00800000)
-	//  r|=0xFF000000;
-	return r;
+	int sign,exponent,mantissa;
+	INT32 uval;
+
+	sign = (val >> 15) & 0x1;
+	exponent = (val >> 11) & 0xF;
+	mantissa = val & 0x7FF;
+	uval = mantissa << 11;
+	if (exponent > 11)
+		exponent = 11;
+	else
+		uval |= (sign ^ 1) << 22;
+	uval |= sign << 23;
+	uval <<= 8;
+	uval >>= 8;
+	uval >>= exponent;
+
+	return uval;
 }
 
 void SCSPDSP_Init(struct _SCSPDSP *DSP)
@@ -126,7 +156,7 @@
 		if(IRA<=0x1f)
 			INPUTS=DSP->MEMS[IRA];
 		else if(IRA<=0x2F)
-			INPUTS=DSP->MIXS[IRA-0x20]<<8;	//MIXS is 16 bit
+			INPUTS=DSP->MIXS[IRA-0x20]<<4;	//MIXS is 20 bit
 		else if(IRA<=0x31)
 			INPUTS=0;
 
@@ -298,7 +328,7 @@
 void SCSPDSP_SetSample(struct _SCSPDSP *DSP,INT32 sample,int SEL,int MXL)
 {
 	//DSP->MIXS[SEL]+=sample<<(MXL+1)/*7*/;
-	DSP->MIXS[SEL]+=sample<<7;
+	DSP->MIXS[SEL]+=sample;
 //  if(MXL)
 //      int a=1;
 }
diff -Nru aosdk_base/eng_ssf/scsplfo.c aosdk/eng_ssf/scsplfo.c
--- aosdk_base/eng_ssf/scsplfo.c	2007-10-26 19:43:36.000000000 -0700
+++ aosdk/eng_ssf/scsplfo.c	2007-12-08 07:01:00.000000000 -0800
@@ -47,7 +47,7 @@
 		if(i<128)
 			p=i;
 		else
-			p=255-i;    
+			p=i-256;    
 		ALFO_SAW[i]=a;
 		PLFO_SAW[i]=p;
 	

Changes:
- Added effect in mixer
- Added DSP floating-point support
- Added bounds check to the DECAY1 EG output
- Fixed the saw PLFO waveform

Joined: Mar 2001
Posts: 17,215
Likes: 234
R
Very Senior Member
OP Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 17,215
Likes: 234
Wow, that fixes a lot of problems! Thanks again! smile

Joined: Mar 2001
Posts: 17,215
Likes: 234
R
Very Senior Member
OP Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 17,215
Likes: 234
These new fixes are now in version 1.1.3 of the SDK, for those playing along at home.

Joined: Mar 2004
Posts: 698
Likes: 2
Senior Member
Offline
Senior Member
Joined: Mar 2004
Posts: 698
Likes: 2
Is that expected that make OSTYPE=linux is required for Linux build?

Page 2 of 55 1 2 3 4 54 55

Moderated by  R. Belmont, Richard Bannister 

Link Copied to Clipboard
Who's Online Now
1 members (AJR), 275 guests, and 1 robot.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,320
Posts121,923
Members5,074
Most Online1,283
Dec 21st, 2022
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com