Merge pull request #4362 from cam900/scsp_minor

scsp.cpp : Minor updates
This commit is contained in:
R. Belmont 2018-12-02 07:49:54 -05:00 committed by GitHub
commit 57a0782136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 545 additions and 574 deletions

View File

@ -143,7 +143,7 @@ static const double DRTimes[64]={100000/*infinity*/,100000/*infinity*/,118200.0,
static const float SDLT[8] = {-1000000.0f,-36.0f,-30.0f,-24.0f,-18.0f,-12.0f,-6.0f,0.0f}; static const float SDLT[8] = {-1000000.0f,-36.0f,-30.0f,-24.0f,-18.0f,-12.0f,-6.0f,0.0f};
DEFINE_DEVICE_TYPE(SCSP, scsp_device, "scsp", "YMF292-F SCSP") DEFINE_DEVICE_TYPE(SCSP, scsp_device, "scsp", "Yamaha YMF292-F SCSP")
scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, SCSP, tag, owner, clock), : device_t(mconfig, SCSP, tag, owner, clock),
@ -331,10 +331,10 @@ void scsp_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
DoMasterSamples(samples); DoMasterSamples(samples);
} }
unsigned char scsp_device::DecodeSCI(unsigned char irq) uint8_t scsp_device::DecodeSCI(uint8_t irq)
{ {
unsigned char SCI=0; uint8_t SCI = 0;
unsigned char v; uint8_t v;
v = (SCILV0() & (1 << irq)) ? 1 : 0; v = (SCILV0() & (1 << irq)) ? 1 : 0;
SCI |= v; SCI |= v;
v = (SCILV1() & (1 << irq)) ? 1 : 0; v = (SCILV1() & (1 << irq)) ? 1 : 0;
@ -450,25 +450,13 @@ TIMER_CALLBACK_MEMBER( scsp_device::timerC_cb )
int scsp_device::Get_AR(int base, int R) int scsp_device::Get_AR(int base, int R)
{ {
int Rate = base + (R << 1); int Rate = base + (R << 1);
if(Rate>63) Rate=63; return m_ARTABLE[std::min(63, std::max(0, Rate))];
if(Rate<0) Rate=0;
return m_ARTABLE[Rate];
} }
int scsp_device::Get_DR(int base, int R) int scsp_device::Get_DR(int base, int R)
{ {
int Rate = base + (R << 1); int Rate = base + (R << 1);
if(Rate>63) Rate=63; return m_DRTABLE[std::min(63, std::max(0, Rate))];
if(Rate<0) Rate=0;
return m_DRTABLE[Rate];
}
int scsp_device::Get_RR(int base, int R)
{
int Rate=base+(R<<1);
if(Rate>63) Rate=63;
if(Rate<0) Rate=0;
return m_DRTABLE[Rate];
} }
void scsp_device::Compute_EG(SCSP_SLOT *slot) void scsp_device::Compute_EG(SCSP_SLOT *slot)
@ -484,7 +472,7 @@ void scsp_device::Compute_EG(SCSP_SLOT *slot)
slot->EG.AR = Get_AR(rate,AR(slot)); slot->EG.AR = Get_AR(rate,AR(slot));
slot->EG.D1R = Get_DR(rate,D1R(slot)); slot->EG.D1R = Get_DR(rate,D1R(slot));
slot->EG.D2R = Get_DR(rate,D2R(slot)); slot->EG.D2R = Get_DR(rate,D2R(slot));
slot->EG.RR=Get_RR(rate,RR(slot)); slot->EG.RR = Get_DR(rate,RR(slot));
slot->EG.DL = 0x1f - DL(slot); slot->EG.DL = 0x1f - DL(slot);
slot->EG.EGHOLD = EGHOLD(slot); slot->EG.EGHOLD = EGHOLD(slot);
} }
@ -594,8 +582,6 @@ void scsp_device::StopSlot(SCSP_SLOT *slot,int keyoff)
slot->udata.data[0] &= ~0x800; slot->udata.data[0] &= ~0x800;
} }
#define log_base_2(n) (log((double)(n))/log(2.0))
void scsp_device::init() void scsp_device::init()
{ {
int i; int i;
@ -683,8 +669,8 @@ void scsp_device::init()
m_ARTABLE[1] = m_DRTABLE[1] = 0; //Infinite time m_ARTABLE[1] = m_DRTABLE[1] = 0; //Infinite time
for (i = 2; i < 64; ++i) for (i = 2; i < 64; ++i)
{ {
double t,step,scale; double step, scale;
t=ARTimes[i]; //In ms double t = ARTimes[i]; //In ms
if (t != 0.0) if (t != 0.0)
{ {
step = (1023 * 1000.0) / (44100.0 * t); step = (1023 * 1000.0) / (44100.0 * t);
@ -719,14 +705,13 @@ void scsp_device::init()
void scsp_device::UpdateSlotReg(int s,int r) void scsp_device::UpdateSlotReg(int s,int r)
{ {
SCSP_SLOT *slot = m_Slots + s; SCSP_SLOT *slot = m_Slots + s;
int sl;
switch (r & 0x3f) switch (r & 0x3f)
{ {
case 0: case 0:
case 1: case 1:
if (KEYONEX(slot)) if (KEYONEX(slot))
{ {
for(sl=0;sl<32;++sl) for (int sl=0; sl < 32; ++sl)
{ {
SCSP_SLOT *s2 = m_Slots + sl; SCSP_SLOT *s2 = m_Slots + sl;
{ {
@ -749,7 +734,7 @@ void scsp_device::UpdateSlotReg(int s,int r)
break; break;
case 0xA: case 0xA:
case 0xB: case 0xB:
slot->EG.RR=Get_RR(0,RR(slot)); slot->EG.RR = Get_DR(0, RR(slot));
slot->EG.DL = 0x1f - DL(slot); slot->EG.DL = 0x1f - DL(slot);
break; break;
case 0x12: case 0x12:
@ -770,16 +755,8 @@ void scsp_device::UpdateReg(int reg)
case 0x2: case 0x2:
case 0x3: case 0x3:
{ {
unsigned int v=RBL(); m_DSP.RBL = (8 * 1024) << RBL(); // 8 / 16 / 32 / 64 kwords
m_DSP.RBP = RBP(); m_DSP.RBP = RBP();
if(v==0)
m_DSP.RBL=8*1024;
else if(v==1)
m_DSP.RBL=16*1024;
if(v==2)
m_DSP.RBL=32*1024;
if(v==3)
m_DSP.RBL=64*1024;
} }
break; break;
case 0x6: case 0x6:
@ -812,14 +789,12 @@ void scsp_device::UpdateReg(int reg)
case 0x19: case 0x19:
if (m_Master) if (m_Master)
{ {
uint32_t time;
m_TimPris[0] = 1 << ((m_udata.data[0x18/2] >> 8) & 0x7); m_TimPris[0] = 1 << ((m_udata.data[0x18/2] >> 8) & 0x7);
m_TimCnt[0] = (m_udata.data[0x18/2] & 0xff) << 8; m_TimCnt[0] = (m_udata.data[0x18/2] & 0xff) << 8;
if ((m_udata.data[0x18/2] & 0xff) != 255) if ((m_udata.data[0x18/2] & 0xff) != 255)
{ {
time = (clock() / m_TimPris[0]) / (255-(m_udata.data[0x18/2]&0xff)); uint32_t time = (clock() / m_TimPris[0]) / (255 - (m_udata.data[0x18/2] & 0xff));
if (time) if (time)
{ {
m_timerA->adjust(attotime::from_ticks(512, time)); m_timerA->adjust(attotime::from_ticks(512, time));
@ -831,14 +806,12 @@ void scsp_device::UpdateReg(int reg)
case 0x1b: case 0x1b:
if (m_Master) if (m_Master)
{ {
uint32_t time;
m_TimPris[1] = 1 << ((m_udata.data[0x1A/2] >> 8) & 0x7); m_TimPris[1] = 1 << ((m_udata.data[0x1A/2] >> 8) & 0x7);
m_TimCnt[1] = (m_udata.data[0x1A/2] & 0xff) << 8; m_TimCnt[1] = (m_udata.data[0x1A/2] & 0xff) << 8;
if ((m_udata.data[0x1A/2] & 0xff) != 255) if ((m_udata.data[0x1A/2] & 0xff) != 255)
{ {
time = (clock() / m_TimPris[1]) / (255-(m_udata.data[0x1A/2]&0xff)); uint32_t time = (clock() / m_TimPris[1]) / (255 - (m_udata.data[0x1A/2] & 0xff));
if (time) if (time)
{ {
m_timerB->adjust(attotime::from_ticks(512, time)); m_timerB->adjust(attotime::from_ticks(512, time));
@ -850,14 +823,12 @@ void scsp_device::UpdateReg(int reg)
case 0x1D: case 0x1D:
if (m_Master) if (m_Master)
{ {
uint32_t time;
m_TimPris[2] = 1 << ((m_udata.data[0x1C/2] >> 8) & 0x7); m_TimPris[2] = 1 << ((m_udata.data[0x1C/2] >> 8) & 0x7);
m_TimCnt[2] = (m_udata.data[0x1C/2] & 0xff) << 8; m_TimCnt[2] = (m_udata.data[0x1C/2] & 0xff) << 8;
if ((m_udata.data[0x1C/2] & 0xff) != 255) if ((m_udata.data[0x1C/2] & 0xff) != 255)
{ {
time = (clock() / m_TimPris[2]) / (255-(m_udata.data[0x1C/2]&0xff)); uint32_t time = (clock() / m_TimPris[2]) / (255 - (m_udata.data[0x1C/2] & 0xff));
if (time) if (time)
{ {
m_timerC->adjust(attotime::from_ticks(512, time)); m_timerC->adjust(attotime::from_ticks(512, time));
@ -953,7 +924,7 @@ void scsp_device::UpdateRegR(int reg)
case 4: case 4:
case 5: case 5:
{ {
unsigned short v=m_udata.data[0x5/2]; uint16_t v = m_udata.data[0x4/2];
v &= 0xff00; v &= 0xff00;
v |= m_MidiStack[m_MidiR]; v |= m_MidiStack[m_MidiR];
m_irq_cb(m_IrqMidi, CLEAR_LINE); // cancel the IRQ m_irq_cb(m_IrqMidi, CLEAR_LINE); // cancel the IRQ
@ -963,7 +934,7 @@ void scsp_device::UpdateRegR(int reg)
++m_MidiR; ++m_MidiR;
m_MidiR &= 31; m_MidiR &= 31;
} }
m_udata.data[0x5/2]=v; m_udata.data[0x4/2] = v;
} }
break; break;
case 8: case 8:
@ -971,11 +942,11 @@ void scsp_device::UpdateRegR(int reg)
{ {
// MSLC | CA |SGC|EG // MSLC | CA |SGC|EG
// f e d c b a 9 8 7 6 5 4 3 2 1 0 // f e d c b a 9 8 7 6 5 4 3 2 1 0
unsigned char MSLC=(m_udata.data[0x8/2]>>11)&0x1f; uint8_t MSLC = (m_udata.data[0x8/2] >> 11) & 0x1f;
SCSP_SLOT *slot = m_Slots + MSLC; SCSP_SLOT *slot = m_Slots + MSLC;
unsigned int SGC = (slot->EG.state) & 3; uint32_t SGC = (slot->EG.state) & 3;
unsigned int CA = (slot->cur_addr>>(SHIFT+12)) & 0xf; uint32_t CA = (slot->cur_addr >> (SHIFT + 12)) & 0xf;
unsigned int EG = (0x1f - (slot->EG.volume>>(EG_SHIFT+5))) & 0x1f; uint32_t EG = (0x1f - (slot->EG.volume >> (EG_SHIFT + 5))) & 0x1f;
/* note: according to the manual MSLC is write only, CA, SGC and EG read only. */ /* note: according to the manual MSLC is write only, CA, SGC and EG read only. */
m_udata.data[0x8/2] = /*(MSLC << 11) |*/ (CA << 7) | (SGC << 5) | EG; m_udata.data[0x8/2] = /*(MSLC << 11) |*/ (CA << 7) | (SGC << 5) | EG;
} }
@ -1005,21 +976,21 @@ void scsp_device::UpdateRegR(int reg)
} }
} }
void scsp_device::w16(unsigned int addr,unsigned short val) void scsp_device::w16(uint32_t addr, uint16_t val)
{ {
addr &= 0xffff; addr &= 0xffff;
if (addr < 0x400) if (addr < 0x400)
{ {
int slot = addr / 0x20; int slot = addr / 0x20;
addr &= 0x1f; addr &= 0x1f;
*((unsigned short *) (m_Slots[slot].udata.datab+(addr))) = val; *((uint16_t *) (m_Slots[slot].udata.datab + (addr))) = val;
UpdateSlotReg(slot, addr & 0x1f); UpdateSlotReg(slot, addr & 0x1f);
} }
else if (addr < 0x600) else if (addr < 0x600)
{ {
if (addr < 0x430) if (addr < 0x430)
{ {
*((unsigned short *) (m_udata.datab+((addr&0x3f)))) = val; *((uint16_t *) (m_udata.datab + ((addr & 0x3f)))) = val;
UpdateReg(addr & 0x3f); UpdateReg(addr & 0x3f);
} }
} }
@ -1029,14 +1000,14 @@ void scsp_device::w16(unsigned int addr,unsigned short val)
{ {
//DSP //DSP
if (addr < 0x780) //COEF if (addr < 0x780) //COEF
*((unsigned short *) (m_DSP.COEF+(addr-0x700)/2))=val; *((uint16_t *) (m_DSP.COEF + (addr - 0x700) / 2)) = val;
else if (addr < 0x7c0) else if (addr < 0x7c0)
*((unsigned short *) (m_DSP.MADRS+(addr-0x780)/2))=val; *((uint16_t *) (m_DSP.MADRS + (addr - 0x780) / 2)) = val;
else if (addr < 0x800) // MADRS is mirrored twice else if (addr < 0x800) // MADRS is mirrored twice
*((unsigned short *) (m_DSP.MADRS+(addr-0x7c0)/2))=val; *((uint16_t *) (m_DSP.MADRS + (addr - 0x7c0) / 2)) = val;
else if (addr < 0xC00) else if (addr < 0xC00)
{ {
*((unsigned short *) (m_DSP.MPRO+(addr-0x800)/2))=val; *((uint16_t *) (m_DSP.MPRO + (addr - 0x800) / 2)) = val;
if (addr == 0xBF0) if (addr == 0xBF0)
{ {
@ -1046,23 +1017,23 @@ void scsp_device::w16(unsigned int addr,unsigned short val)
} }
} }
unsigned short scsp_device::r16(unsigned int addr) uint16_t scsp_device::r16(uint32_t addr)
{ {
unsigned short v=0; uint16_t v = 0;
addr &= 0xffff; addr &= 0xffff;
if (addr < 0x400) if (addr < 0x400)
{ {
int slot = addr / 0x20; int slot = addr / 0x20;
addr &= 0x1f; addr &= 0x1f;
UpdateSlotRegR(slot, addr & 0x1f); UpdateSlotRegR(slot, addr & 0x1f);
v=*((unsigned short *) (m_Slots[slot].udata.datab+(addr))); v = *((uint16_t *) (m_Slots[slot].udata.datab + (addr)));
} }
else if (addr < 0x600) else if (addr < 0x600)
{ {
if (addr < 0x430) if (addr < 0x430)
{ {
UpdateRegR(addr & 0x3f); UpdateRegR(addr & 0x3f);
v= *((unsigned short *) (m_udata.datab+((addr&0x3f)))); v = *((uint16_t *) (m_udata.datab + ((addr & 0x3f))));
} }
} }
else if (addr < 0x700) else if (addr < 0x700)
@ -1071,13 +1042,13 @@ unsigned short scsp_device::r16(unsigned int addr)
{ {
//DSP //DSP
if (addr < 0x780) //COEF if (addr < 0x780) //COEF
v= *((unsigned short *) (m_DSP.COEF+(addr-0x700)/2)); v= *((uint16_t *) (m_DSP.COEF + (addr - 0x700) / 2));
else if (addr < 0x7c0) else if (addr < 0x7c0)
v= *((unsigned short *) (m_DSP.MADRS+(addr-0x780)/2)); v= *((uint16_t *) (m_DSP.MADRS + (addr - 0x780) / 2));
else if (addr < 0x800) else if (addr < 0x800)
v= *((unsigned short *) (m_DSP.MADRS+(addr-0x7c0)/2)); v= *((uint16_t *) (m_DSP.MADRS + (addr - 0x7c0) / 2));
else if (addr < 0xC00) else if (addr < 0xC00)
v= *((unsigned short *) (m_DSP.MPRO+(addr-0x800)/2)); v= *((uint16_t *) (m_DSP.MPRO + (addr - 0x800) / 2));
else if (addr < 0xE00) else if (addr < 0xE00)
{ {
if (addr & 2) if (addr & 2)
@ -1100,7 +1071,7 @@ unsigned short scsp_device::r16(unsigned int addr)
v = m_DSP.MIXS[(addr >> 2) & 0xf] >> 16; v = m_DSP.MIXS[(addr >> 2) & 0xf] >> 16;
} }
else if (addr < 0xEE0) else if (addr < 0xEE0)
v= *((unsigned short *) (m_DSP.EFREG+(addr-0xec0)/2)); v = *((uint16_t *) (m_DSP.EFREG + (addr - 0xec0) / 2));
else else
{ {
/**! /**!
@ -1141,26 +1112,27 @@ unsigned short scsp_device::r16(unsigned int addr)
*/ */
logerror("SCSP: Reading from EXTS register %08x\n", addr); logerror("SCSP: Reading from EXTS register %08x\n", addr);
if (addr < 0xEE4) if (addr < 0xEE4)
v = *((unsigned short *) (m_DSP.EXTS+(addr-0xee0)/2)); v = *((uint16_t *) (m_DSP.EXTS + (addr - 0xee0) / 2));
} }
} }
return v; return v;
} }
#define REVSIGN(v) ((~v)+1)
inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot) inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
{ {
if (SSCTL(slot) == 3) // manual says cannot be used
{
logerror("SCSP: Invaild SSCTL setting at slot %02x\n", slot->slot);
return 0;
}
int32_t sample; int32_t sample;
int step = slot->step; int step = slot->step;
uint32_t addr1, addr2, addr_select; // current and next sample addresses uint32_t addr1, addr2, addr_select; // current and next sample addresses
uint32_t *addr[2] = {&addr1, &addr2}; // used for linear interpolation uint32_t *addr[2] = {&addr1, &addr2}; // used for linear interpolation
uint32_t *slot_addr[2] = {&(slot->cur_addr), &(slot->nxt_addr)}; // uint32_t *slot_addr[2] = {&(slot->cur_addr), &(slot->nxt_addr)}; //
if(SSCTL(slot)!=0) //no FM or noise yet
return 0;
if (PLFOS(slot) != 0) if (PLFOS(slot) != 0)
{ {
step = step * PLFO_Step(&(slot->PLFO)); step = step * PLFO_Step(&(slot->PLFO));
@ -1189,6 +1161,8 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
addr1 += smp; addr2 += smp; addr1 += smp; addr2 += smp;
} }
if (SSCTL(slot) == 0) // External DRAM data
{
if (PCM8B(slot)) //8 bit signed if (PCM8B(slot)) //8 bit signed
{ {
int8_t p1 = read_byte(SA(slot) + addr1); int8_t p1 = read_byte(SA(slot) + addr1);
@ -1207,6 +1181,11 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
s = (int)(p1) * ((1 << SHIFT) - fpart) + (int)(p2) * fpart; s = (int)(p1) * ((1 << SHIFT) - fpart) + (int)(p2) * fpart;
sample = (s >> SHIFT); sample = (s >> SHIFT);
} }
}
else if (SSCTL(slot) == 1) // Internally generated data (Noise)
sample = (int16_t)(machine().rand() & 0xffff); // Unknown algorithm
else if (SSCTL(slot) >= 2) // Internally generated data (All 0)
sample = 0;
if (SBCTL(slot) & 0x1) if (SBCTL(slot) & 0x1)
sample ^= 0x7FFF; sample ^= 0x7FFF;
@ -1295,12 +1274,12 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
{ {
if (!SDIR(slot)) if (!SDIR(slot))
{ {
unsigned short Enc=((TL(slot))<<0x0)|(0x7<<0xd); uint16_t Enc = ((TL(slot)) << 0x0) | (0x7 << 0xd);
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1); *m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
} }
else else
{ {
unsigned short Enc=(0<<0x0)|(0x7<<0xd); uint16_t Enc = (0 << 0x0) | (0x7 << 0xd);
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1); *m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
} }
} }
@ -1312,20 +1291,17 @@ void scsp_device::DoMasterSamples(int nsamples)
{ {
stream_sample_t *bufr,*bufl; stream_sample_t *bufr,*bufl;
stream_sample_t *exts[2]; stream_sample_t *exts[2];
int sl, s, i;
bufr = m_bufferr; bufr = m_bufferr;
bufl = m_bufferl; bufl = m_bufferl;
exts[0] = m_exts0; exts[0] = m_exts0;
exts[1] = m_exts1; exts[1] = m_exts1;
for(s=0;s<nsamples;++s) for (int s = 0; s < nsamples; ++s)
{ {
int32_t smpl, smpr; int32_t smpl = 0, smpr = 0;
smpl = smpr = 0; for (int sl = 0; sl < 32; ++sl)
for(sl=0;sl<32;++sl)
{ {
#if SCSP_FM_DELAY #if SCSP_FM_DELAY
m_RBUFDST = m_DELAYBUF + m_DELAYPTR; m_RBUFDST = m_DELAYBUF + m_DELAYPTR;
@ -1335,10 +1311,9 @@ void scsp_device::DoMasterSamples(int nsamples)
if (m_Slots[sl].active) if (m_Slots[sl].active)
{ {
SCSP_SLOT *slot = m_Slots + sl; SCSP_SLOT *slot = m_Slots + sl;
unsigned short Enc; uint16_t Enc;
signed int sample;
sample=UpdateSlot(slot); int32_t sample = UpdateSlot(slot);
Enc = ((TL(slot)) << 0x0) | ((IMXL(slot)) << 0xd); Enc = ((TL(slot)) << 0x0) | ((IMXL(slot)) << 0xd);
m_DSP.SetSample((sample*m_LPANTABLE[Enc]) >> (SHIFT-2), ISEL(slot), IMXL(slot)); m_DSP.SetSample((sample*m_LPANTABLE[Enc]) >> (SHIFT-2), ISEL(slot), IMXL(slot));
@ -1362,24 +1337,24 @@ void scsp_device::DoMasterSamples(int nsamples)
m_DSP.Step(); m_DSP.Step();
for(i=0;i<16;++i) for (int i = 0; i < 16; ++i)
{ {
SCSP_SLOT *slot = m_Slots + i; SCSP_SLOT *slot = m_Slots + i;
if (EFSDL(slot)) if (EFSDL(slot))
{ {
unsigned short Enc=((EFPAN(slot))<<0x8)|((EFSDL(slot))<<0xd); uint16_t Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd);
smpl += (m_DSP.EFREG[i] * m_LPANTABLE[Enc]) >> SHIFT; smpl += (m_DSP.EFREG[i] * m_LPANTABLE[Enc]) >> SHIFT;
smpr += (m_DSP.EFREG[i] * m_RPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EFREG[i] * m_RPANTABLE[Enc]) >> SHIFT;
} }
} }
for(i=0;i<2;++i) for (int i = 0; i < 2; ++i)
{ {
SCSP_SLOT *slot = m_Slots + i + 16; // 100217, 100237 EFSDL, EFPAN for EXTS0/1 SCSP_SLOT *slot = m_Slots + i + 16; // 100217, 100237 EFSDL, EFPAN for EXTS0/1
if (EFSDL(slot)) if (EFSDL(slot))
{ {
m_DSP.EXTS[i] = exts[i][s]; m_DSP.EXTS[i] = exts[i][s];
unsigned short Enc=((EFPAN(slot))<<0x8)|((EFSDL(slot))<<0xd); uint16_t Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd);
smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT; smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT;
smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT;
} }
@ -1501,11 +1476,9 @@ READ16_MEMBER( scsp_device::read )
WRITE16_MEMBER( scsp_device::write ) WRITE16_MEMBER( scsp_device::write )
{ {
uint16_t tmp;
m_stream->update(); m_stream->update();
tmp = r16(offset*2); uint16_t tmp = r16(offset * 2);
COMBINE_DATA(&tmp); COMBINE_DATA(&tmp);
w16(offset * 2, tmp); w16(offset * 2, tmp);
} }
@ -1522,7 +1495,7 @@ void scsp_device::midi_in(u8 data)
READ16_MEMBER( scsp_device::midi_out_r ) READ16_MEMBER( scsp_device::midi_out_r )
{ {
unsigned char val; uint8_t val;
val = m_MidiStack[m_MidiR++]; val = m_MidiStack[m_MidiR++];
m_MidiR &= 31; m_MidiR &= 31;
@ -1531,7 +1504,7 @@ READ16_MEMBER( scsp_device::midi_out_r )
//LFO handling //LFO handling
#define LFIX(v) ((unsigned int) ((float) (1<<LFO_SHIFT)*(v))) #define LFIX(v) ((uint32_t) ((float) (1 << LFO_SHIFT) * (v)))
//Convert DB to multiply amplitude //Convert DB to multiply amplitude
#define DB(v) LFIX(powf(10.0f, v / 20.0f)) #define DB(v) LFIX(powf(10.0f, v / 20.0f))
@ -1551,8 +1524,7 @@ static const float PSCALE[8]={0.0f,7.0f,13.5f,27.0f,55.0f,112.0f,230.0f,494.0f};
void scsp_device::LFO_Init() void scsp_device::LFO_Init()
{ {
int i,s; for (int i = 0; i < 256; ++i)
for(i=0;i<256;++i)
{ {
int a,p; int a,p;
// float TL; // float TL;
@ -1603,22 +1575,22 @@ void scsp_device::LFO_Init()
m_PLFO_NOI[i] = p; m_PLFO_NOI[i] = p;
} }
for(s=0;s<8;++s) for (int s = 0; s < 8; ++s)
{ {
float limit = PSCALE[s]; float limit = PSCALE[s];
for(i=-128;i<128;++i) for (int i = -128; i < 128; ++i)
{ {
m_PSCALES[s][i+128] = CENTS(((limit * (float) i) / 128.0f)); m_PSCALES[s][i+128] = CENTS(((limit * (float) i) / 128.0f));
} }
limit =- ASCALE[s]; limit =- ASCALE[s];
for(i=0;i<256;++i) for (int i = 0; i < 256; ++i)
{ {
m_ASCALES[s][i] = DB(((limit * (float) i) / 256.0f)); m_ASCALES[s][i] = DB(((limit * (float) i) / 256.0f));
} }
} }
} }
signed int scsp_device::PLFO_Step(SCSP_LFO_t *LFO) int32_t scsp_device::PLFO_Step(SCSP_LFO_t *LFO)
{ {
int p; int p;
LFO->phase += LFO->phase_step; LFO->phase += LFO->phase_step;
@ -1630,7 +1602,7 @@ signed int scsp_device::PLFO_Step(SCSP_LFO_t *LFO)
return p << (SHIFT - LFO_SHIFT); return p << (SHIFT - LFO_SHIFT);
} }
signed int scsp_device::ALFO_Step(SCSP_LFO_t *LFO) int32_t scsp_device::ALFO_Step(SCSP_LFO_t *LFO)
{ {
int p; int p;
LFO->phase += LFO->phase_step; LFO->phase += LFO->phase_step;
@ -1645,7 +1617,7 @@ signed int scsp_device::ALFO_Step(SCSP_LFO_t *LFO)
void scsp_device::LFO_ComputeStep(SCSP_LFO_t *LFO,uint32_t LFOF,uint32_t LFOWS,uint32_t LFOS,int ALFO) void scsp_device::LFO_ComputeStep(SCSP_LFO_t *LFO,uint32_t LFOF,uint32_t LFOWS,uint32_t LFOS,int ALFO)
{ {
float step = (float) LFOFreq[LFOF] * 256.0f / 44100.0f; float step = (float) LFOFreq[LFOF] * 256.0f / 44100.0f;
LFO->phase_step=(unsigned int) ((float) (1<<LFO_SHIFT)*step); LFO->phase_step = (uint32_t) ((float) (1 << LFO_SHIFT) * step);
if (ALFO) if (ALFO)
{ {
switch (LFOWS) switch (LFOWS)

View File

@ -173,7 +173,6 @@ private:
TIMER_CALLBACK_MEMBER( timerC_cb ); TIMER_CALLBACK_MEMBER( timerC_cb );
int Get_AR(int base, int R); int Get_AR(int base, int R);
int Get_DR(int base, int R); int Get_DR(int base, int R);
int Get_RR(int base, int R);
void Compute_EG(SCSP_SLOT *slot); void Compute_EG(SCSP_SLOT *slot);
int EG_Update(SCSP_SLOT *slot); int EG_Update(SCSP_SLOT *slot);
uint32_t Step(SCSP_SLOT *slot); uint32_t Step(SCSP_SLOT *slot);

View File

@ -61,7 +61,7 @@ static int32_t UNPACK(uint16_t val)
void SCSPDSP::Init() void SCSPDSP::Init()
{ {
std::memset(this, 0, sizeof(*this)); std::memset(this, 0, sizeof(*this));
RBL = 0x8000; RBL = (8*1024); // Initial RBL is 0
Stopped = true; Stopped = true;
} }
@ -80,8 +80,6 @@ void SCSPDSP::Step()
#endif #endif
int32_t ACC = 0; //26 bit int32_t ACC = 0; //26 bit
int32_t SHIFTED = 0; //24 bit
int32_t Y = 0; //13 bit
int32_t MEMVAL = 0; int32_t MEMVAL = 0;
int32_t FRC_REG = 0; //13 bit int32_t FRC_REG = 0; //13 bit
int32_t Y_REG = 0; //24 bit int32_t Y_REG = 0; //24 bit
@ -210,6 +208,7 @@ void SCSPDSP::Step()
//X |= 0xFF000000; //X |= 0xFF000000;
} }
int32_t Y = 0; //13 bit
if (YSEL == 0) if (YSEL == 0)
Y = FRC_REG; Y = FRC_REG;
else if (YSEL == 1) else if (YSEL == 1)
@ -223,6 +222,7 @@ void SCSPDSP::Step()
Y_REG = INPUTS; Y_REG = INPUTS;
//Shifter //Shifter
int32_t SHIFTED = 0; //24 bit
if (SHIFT == 0) if (SHIFT == 0)
SHIFTED = std::max<int32_t>(std::min<int32_t>(ACC, 0x007FFFFF), -0x00800000); SHIFTED = std::max<int32_t>(std::min<int32_t>(ACC, 0x007FFFFF), -0x00800000);
else if (SHIFT == 1) else if (SHIFT == 1)