SoundUnit: actually finish it
This commit is contained in:
parent
e0c5029769
commit
6934a499c1
4 changed files with 90 additions and 16 deletions
|
|
@ -238,44 +238,65 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
tnsL=(nsL[0]+nsL[1]+nsL[2]+nsL[3]+nsL[4]+nsL[5]+nsL[6]+nsL[7])>>2;
|
||||
tnsR=(nsR[0]+nsR[1]+nsR[2]+nsR[3]+nsR[4]+nsR[5]+nsR[6]+nsR[7])>>2;
|
||||
|
||||
IL1=minval(32767,maxval(-32767,tnsL))>>8;
|
||||
IL2=minval(32767,maxval(-32767,tnsR))>>8;
|
||||
|
||||
// write input lines to sample memory
|
||||
if (ILSIZE&64) {
|
||||
if (++ilBufPeriod>=((1+(FIL1>>4))<<2)) {
|
||||
ilBufPeriod=0;
|
||||
unsigned short ilLowerBound=pcmSize-((1+(ILSIZE&63))<<7);
|
||||
short next;
|
||||
if (ilBufPos<ilLowerBound) ilBufPos=ilLowerBound;
|
||||
switch (ILCTRL&3) {
|
||||
case 0:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL0+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL0)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 1:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL1+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL1)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 2:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL2+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL2)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 3:
|
||||
ilFeedback0=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL1+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL1)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL2+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL2)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ILSIZE&128) {
|
||||
tnsL+=ilFeedback1*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback0*(signed char)FILVOL;
|
||||
} else {
|
||||
tnsL+=ilFeedback0*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback1*(signed char)FILVOL;
|
||||
if (ILCTRL&4) {
|
||||
if (ILSIZE&128) {
|
||||
tnsL+=ilFeedback1*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback0*(signed char)FILVOL;
|
||||
} else {
|
||||
tnsL+=ilFeedback0*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback1*(signed char)FILVOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -529,6 +529,16 @@ void DivPlatformSoundUnit::reset() {
|
|||
lfoMode=0;
|
||||
lfoSpeed=255;
|
||||
delay=500;
|
||||
|
||||
// set initial IL status
|
||||
ilCtrl=initIlCtrl;
|
||||
ilSize=initIlSize;
|
||||
fil1=initFil1;
|
||||
echoVol=initEchoVol;
|
||||
rWrite(0x9c,echoVol);
|
||||
rWrite(0x9d,ilCtrl);
|
||||
rWrite(0xbc,ilSize);
|
||||
rWrite(0xbd,fil1);
|
||||
}
|
||||
|
||||
bool DivPlatformSoundUnit::isStereo() {
|
||||
|
|
@ -555,6 +565,10 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) {
|
|||
for (int i=0; i<8; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
initIlCtrl=3|(flags&4);
|
||||
initIlSize=((flags>>8)&63)|((flags&4)?0x40:0)|((flags&8)?0x80:0);
|
||||
initFil1=flags>>16;
|
||||
initEchoVol=flags>>24;
|
||||
|
||||
sampleMemSize=flags&16;
|
||||
|
||||
|
|
@ -575,7 +589,7 @@ const void* DivPlatformSoundUnit::getSampleMem(int index) {
|
|||
}
|
||||
|
||||
size_t DivPlatformSoundUnit::getSampleMemCapacity(int index) {
|
||||
return (index==0)?(sampleMemSize?65536:8192):0;
|
||||
return (index==0)?((sampleMemSize?65536:8192)-((initIlSize&64)?((1+(initIlSize&63))<<7):0)):0;
|
||||
}
|
||||
|
||||
size_t DivPlatformSoundUnit::getSampleMemUsage(int index) {
|
||||
|
|
|
|||
|
|
@ -97,6 +97,9 @@ class DivPlatformSoundUnit: public DivDispatch {
|
|||
std::queue<QueuedWrite> writes;
|
||||
unsigned char lastPan;
|
||||
bool sampleMemSize;
|
||||
unsigned char ilCtrl, ilSize, fil1;
|
||||
unsigned char initIlCtrl, initIlSize, initFil1;
|
||||
signed char echoVol, initEchoVol;
|
||||
|
||||
int cycles, curChan, delay;
|
||||
short tempL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue