mirror of
https://github.com/holub/mame
synced 2025-06-04 20:06:28 +03:00
Merge pull request #4431 from cam900/scsp_tag
scsp.cpp : Use shorter type values, Remove hardcoded tags, Unnecessar…
This commit is contained in:
commit
bd598d6ca5
@ -36,12 +36,12 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
static constexpr int32_t clip16(int x) { return std::min(32767, std::max(-32768, x)); }
|
static constexpr s32 clip16(int x) { return std::min(32767, std::max(-32768, x)); }
|
||||||
static constexpr int32_t clip18(int x) { return std::min(131071, std::max(-131072, x)); }
|
static constexpr s32 clip18(int x) { return std::min(131071, std::max(-131072, x)); }
|
||||||
|
|
||||||
#define SHIFT 12
|
#define SHIFT 12
|
||||||
#define LFO_SHIFT 8
|
#define LFO_SHIFT 8
|
||||||
#define FIX(v) ((uint32_t) ((float) (1 << SHIFT) * (v)))
|
#define FIX(v) ((u32) ((float) (1 << SHIFT) * (v)))
|
||||||
|
|
||||||
|
|
||||||
#define EG_SHIFT 16
|
#define EG_SHIFT 16
|
||||||
@ -145,14 +145,13 @@ static const float SDLT[8] = {-1000000.0f,-36.0f,-30.0f,-24.0f,-18.0f,-12.0f,-6.
|
|||||||
|
|
||||||
DEFINE_DEVICE_TYPE(SCSP, scsp_device, "scsp", "Yamaha 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, u32 clock)
|
||||||
: device_t(mconfig, SCSP, tag, owner, clock),
|
: device_t(mconfig, SCSP, tag, owner, clock),
|
||||||
device_sound_interface(mconfig, *this),
|
device_sound_interface(mconfig, *this),
|
||||||
device_rom_interface(mconfig, *this, 20, ENDIANNESS_BIG, 16),
|
device_rom_interface(mconfig, *this, 20, ENDIANNESS_BIG, 16),
|
||||||
m_irq_cb(*this),
|
m_irq_cb(*this),
|
||||||
m_main_irq_cb(*this),
|
m_main_irq_cb(*this),
|
||||||
m_BUFPTR(0),
|
m_BUFPTR(0),
|
||||||
m_Master(0),
|
|
||||||
m_stream(nullptr),
|
m_stream(nullptr),
|
||||||
m_IrqTimA(0),
|
m_IrqTimA(0),
|
||||||
m_IrqTimBC(0),
|
m_IrqTimBC(0),
|
||||||
@ -331,10 +330,10 @@ void scsp_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
|
|||||||
DoMasterSamples(samples);
|
DoMasterSamples(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t scsp_device::DecodeSCI(uint8_t irq)
|
u8 scsp_device::DecodeSCI(u8 irq)
|
||||||
{
|
{
|
||||||
uint8_t SCI = 0;
|
u8 SCI = 0;
|
||||||
uint8_t v;
|
u8 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;
|
||||||
@ -346,8 +345,8 @@ uint8_t scsp_device::DecodeSCI(uint8_t irq)
|
|||||||
|
|
||||||
void scsp_device::CheckPendingIRQ()
|
void scsp_device::CheckPendingIRQ()
|
||||||
{
|
{
|
||||||
uint32_t pend = m_udata.data[0x20/2];
|
u32 pend = m_udata.data[0x20/2];
|
||||||
uint32_t en = m_udata.data[0x1e/2];
|
u32 en = m_udata.data[0x1e/2];
|
||||||
if (m_MidiW != m_MidiR)
|
if (m_MidiW != m_MidiR)
|
||||||
{
|
{
|
||||||
m_udata.data[0x20/2] |= 8;
|
m_udata.data[0x20/2] |= 8;
|
||||||
@ -384,7 +383,7 @@ void scsp_device::CheckPendingIRQ()
|
|||||||
m_irq_cb((offs_t)0, CLEAR_LINE);
|
m_irq_cb((offs_t)0, CLEAR_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scsp_device::MainCheckPendingIRQ(uint16_t irq_type)
|
void scsp_device::MainCheckPendingIRQ(u16 irq_type)
|
||||||
{
|
{
|
||||||
m_mcipd |= irq_type;
|
m_mcipd |= irq_type;
|
||||||
|
|
||||||
@ -398,7 +397,7 @@ void scsp_device::MainCheckPendingIRQ(uint16_t irq_type)
|
|||||||
|
|
||||||
void scsp_device::ResetInterrupts()
|
void scsp_device::ResetInterrupts()
|
||||||
{
|
{
|
||||||
uint32_t reset = m_udata.data[0x22/2];
|
u32 reset = m_udata.data[0x22/2];
|
||||||
|
|
||||||
if (reset & 0x40)
|
if (reset & 0x40)
|
||||||
{
|
{
|
||||||
@ -416,7 +415,7 @@ void scsp_device::ResetInterrupts()
|
|||||||
CheckPendingIRQ();
|
CheckPendingIRQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_CALLBACK_MEMBER( scsp_device::timerA_cb )
|
TIMER_CALLBACK_MEMBER(scsp_device::timerA_cb)
|
||||||
{
|
{
|
||||||
m_TimCnt[0] = 0xFFFF;
|
m_TimCnt[0] = 0xFFFF;
|
||||||
m_udata.data[0x20/2] |= 0x40;
|
m_udata.data[0x20/2] |= 0x40;
|
||||||
@ -427,7 +426,7 @@ TIMER_CALLBACK_MEMBER( scsp_device::timerA_cb )
|
|||||||
MainCheckPendingIRQ(0x40);
|
MainCheckPendingIRQ(0x40);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_CALLBACK_MEMBER( scsp_device::timerB_cb )
|
TIMER_CALLBACK_MEMBER(scsp_device::timerB_cb)
|
||||||
{
|
{
|
||||||
m_TimCnt[1] = 0xFFFF;
|
m_TimCnt[1] = 0xFFFF;
|
||||||
m_udata.data[0x20/2] |= 0x80;
|
m_udata.data[0x20/2] |= 0x80;
|
||||||
@ -437,7 +436,7 @@ TIMER_CALLBACK_MEMBER( scsp_device::timerB_cb )
|
|||||||
CheckPendingIRQ();
|
CheckPendingIRQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_CALLBACK_MEMBER( scsp_device::timerC_cb )
|
TIMER_CALLBACK_MEMBER(scsp_device::timerC_cb)
|
||||||
{
|
{
|
||||||
m_TimCnt[2] = 0xFFFF;
|
m_TimCnt[2] = 0xFFFF;
|
||||||
m_udata.data[0x20/2] |= 0x100;
|
m_udata.data[0x20/2] |= 0x100;
|
||||||
@ -527,10 +526,10 @@ int scsp_device::EG_Update(SCSP_SLOT *slot)
|
|||||||
return (slot->EG.volume >> EG_SHIFT) << (SHIFT - 10);
|
return (slot->EG.volume >> EG_SHIFT) << (SHIFT - 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t scsp_device::Step(SCSP_SLOT *slot)
|
u32 scsp_device::Step(SCSP_SLOT *slot)
|
||||||
{
|
{
|
||||||
int octave = (OCT(slot) ^ 8) - 8 + SHIFT - 10;
|
int octave = (OCT(slot) ^ 8) - 8 + SHIFT - 10;
|
||||||
uint32_t Fn = FNS(slot) + (1 << 10);
|
u32 Fn = FNS(slot) + (1 << 10);
|
||||||
if (octave >= 0)
|
if (octave >= 0)
|
||||||
{
|
{
|
||||||
Fn <<= octave;
|
Fn <<= octave;
|
||||||
@ -592,16 +591,6 @@ void scsp_device::init()
|
|||||||
m_MidiR=m_MidiW = 0;
|
m_MidiR=m_MidiW = 0;
|
||||||
m_MidiOutR = m_MidiOutW = 0;
|
m_MidiOutR = m_MidiOutW = 0;
|
||||||
|
|
||||||
// get SCSP RAM
|
|
||||||
if (strcmp(tag(), ":scsp") == 0 || strcmp(tag(), ":scsp1") == 0)
|
|
||||||
{
|
|
||||||
m_Master = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Master = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_DSP.space = &this->space();
|
m_DSP.space = &this->space();
|
||||||
m_timerA = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scsp_device::timerA_cb), this));
|
m_timerA = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scsp_device::timerA_cb), this));
|
||||||
m_timerB = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scsp_device::timerB_cb), this));
|
m_timerB = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scsp_device::timerB_cb), this));
|
||||||
@ -611,7 +600,7 @@ void scsp_device::init()
|
|||||||
{
|
{
|
||||||
float envDB = ((float)(3 * (i - 0x3ff))) / 32.0f;
|
float envDB = ((float)(3 * (i - 0x3ff))) / 32.0f;
|
||||||
float scale = (float)(1 << SHIFT);
|
float scale = (float)(1 << SHIFT);
|
||||||
m_EG_TABLE[i] = (int32_t)(powf(10.0f, envDB / 20.0f) * scale);
|
m_EG_TABLE[i] = (s32)(powf(10.0f, envDB / 20.0f) * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 0x10000; ++i)
|
for (i = 0; i < 0x10000; ++i)
|
||||||
@ -787,14 +776,14 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
break;
|
break;
|
||||||
case 0x18:
|
case 0x18:
|
||||||
case 0x19:
|
case 0x19:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
uint32_t time = (clock() / m_TimPris[0]) / (255 - (m_udata.data[0x18/2] & 0xff));
|
u32 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));
|
||||||
@ -804,14 +793,14 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
break;
|
break;
|
||||||
case 0x1a:
|
case 0x1a:
|
||||||
case 0x1b:
|
case 0x1b:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
uint32_t time = (clock() / m_TimPris[1]) / (255 - (m_udata.data[0x1A/2] & 0xff));
|
u32 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));
|
||||||
@ -821,14 +810,14 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
break;
|
break;
|
||||||
case 0x1C:
|
case 0x1C:
|
||||||
case 0x1D:
|
case 0x1D:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
uint32_t time = (clock() / m_TimPris[2]) / (255 - (m_udata.data[0x1C/2] & 0xff));
|
u32 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));
|
||||||
@ -838,7 +827,7 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
break;
|
break;
|
||||||
case 0x1e: // SCIEB
|
case 0x1e: // SCIEB
|
||||||
case 0x1f:
|
case 0x1f:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
CheckPendingIRQ();
|
CheckPendingIRQ();
|
||||||
|
|
||||||
@ -848,7 +837,7 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
break;
|
break;
|
||||||
case 0x20: // SCIPD
|
case 0x20: // SCIPD
|
||||||
case 0x21:
|
case 0x21:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
if (m_udata.data[0x1e/2] & m_udata.data[0x20/2] & 0x20)
|
if (m_udata.data[0x1e/2] & m_udata.data[0x20/2] & 0x20)
|
||||||
popmessage("SCSP SCIPD write %04x, contact MAMEdev",m_udata.data[0x20/2]);
|
popmessage("SCSP SCIPD write %04x, contact MAMEdev",m_udata.data[0x20/2]);
|
||||||
@ -857,7 +846,7 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
case 0x22: //SCIRE
|
case 0x22: //SCIRE
|
||||||
case 0x23:
|
case 0x23:
|
||||||
|
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
m_udata.data[0x20/2] &= ~m_udata.data[0x22/2];
|
m_udata.data[0x20/2] &= ~m_udata.data[0x22/2];
|
||||||
ResetInterrupts();
|
ResetInterrupts();
|
||||||
@ -884,7 +873,7 @@ void scsp_device::UpdateReg(int reg)
|
|||||||
case 0x27:
|
case 0x27:
|
||||||
case 0x28:
|
case 0x28:
|
||||||
case 0x29:
|
case 0x29:
|
||||||
if (m_Master)
|
if (!m_irq_cb.isnull())
|
||||||
{
|
{
|
||||||
m_IrqTimA = DecodeSCI(SCITMA);
|
m_IrqTimA = DecodeSCI(SCITMA);
|
||||||
m_IrqTimBC = DecodeSCI(SCITMB);
|
m_IrqTimBC = DecodeSCI(SCITMB);
|
||||||
@ -924,7 +913,7 @@ void scsp_device::UpdateRegR(int reg)
|
|||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
uint16_t v = m_udata.data[0x4/2];
|
u16 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
|
||||||
@ -942,11 +931,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
|
||||||
uint8_t MSLC = (m_udata.data[0x8/2] >> 11) & 0x1f;
|
u8 MSLC = (m_udata.data[0x8/2] >> 11) & 0x1f;
|
||||||
SCSP_SLOT *slot = m_Slots + MSLC;
|
SCSP_SLOT *slot = m_Slots + MSLC;
|
||||||
uint32_t SGC = (slot->EG.state) & 3;
|
u32 SGC = (slot->EG.state) & 3;
|
||||||
uint32_t CA = (slot->cur_addr >> (SHIFT + 12)) & 0xf;
|
u32 CA = (slot->cur_addr >> (SHIFT + 12)) & 0xf;
|
||||||
uint32_t EG = (0x1f - (slot->EG.volume >> (EG_SHIFT + 5))) & 0x1f;
|
u32 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;
|
||||||
}
|
}
|
||||||
@ -976,21 +965,21 @@ void scsp_device::UpdateRegR(int reg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scsp_device::w16(uint32_t addr, uint16_t val)
|
void scsp_device::w16(u32 addr, u16 val)
|
||||||
{
|
{
|
||||||
addr &= 0xffff;
|
addr &= 0xffff;
|
||||||
if (addr < 0x400)
|
if (addr < 0x400)
|
||||||
{
|
{
|
||||||
int slot = addr / 0x20;
|
int slot = addr / 0x20;
|
||||||
addr &= 0x1f;
|
addr &= 0x1f;
|
||||||
*((uint16_t *) (m_Slots[slot].udata.datab + (addr))) = val;
|
*((u16 *) (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)
|
||||||
{
|
{
|
||||||
*((uint16_t *) (m_udata.datab + ((addr & 0x3f)))) = val;
|
*((u16 *) (m_udata.datab + ((addr & 0x3f)))) = val;
|
||||||
UpdateReg(addr & 0x3f);
|
UpdateReg(addr & 0x3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1000,11 +989,11 @@ void scsp_device::w16(uint32_t addr, uint16_t val)
|
|||||||
{
|
{
|
||||||
//DSP
|
//DSP
|
||||||
if (addr < 0x780) //COEF
|
if (addr < 0x780) //COEF
|
||||||
*((uint16_t *) (m_DSP.COEF + (addr - 0x700) / 2)) = val;
|
*((u16 *) (m_DSP.COEF + (addr - 0x700) / 2)) = val;
|
||||||
else if (addr < 0x7c0)
|
else if (addr < 0x7c0)
|
||||||
*((uint16_t *) (m_DSP.MADRS + (addr - 0x780) / 2)) = val;
|
*((u16 *) (m_DSP.MADRS + (addr - 0x780) / 2)) = val;
|
||||||
else if (addr < 0x800) // MADRS is mirrored twice
|
else if (addr < 0x800) // MADRS is mirrored twice
|
||||||
*((uint16_t *) (m_DSP.MADRS + (addr - 0x7c0) / 2)) = val;
|
*((u16 *) (m_DSP.MADRS + (addr - 0x7c0) / 2)) = val;
|
||||||
else if (addr < 0xC00)
|
else if (addr < 0xC00)
|
||||||
{
|
{
|
||||||
*((uint16_t *) (m_DSP.MPRO + (addr - 0x800) / 2)) = val;
|
*((uint16_t *) (m_DSP.MPRO + (addr - 0x800) / 2)) = val;
|
||||||
@ -1017,23 +1006,23 @@ void scsp_device::w16(uint32_t addr, uint16_t val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t scsp_device::r16(uint32_t addr)
|
u16 scsp_device::r16(u32 addr)
|
||||||
{
|
{
|
||||||
uint16_t v = 0;
|
u16 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 = *((uint16_t *) (m_Slots[slot].udata.datab + (addr)));
|
v = *((u16 *) (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 = *((uint16_t *) (m_udata.datab + ((addr & 0x3f))));
|
v = *((u16 *) (m_udata.datab + ((addr & 0x3f))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (addr < 0x700)
|
else if (addr < 0x700)
|
||||||
@ -1042,13 +1031,13 @@ uint16_t scsp_device::r16(uint32_t addr)
|
|||||||
{
|
{
|
||||||
//DSP
|
//DSP
|
||||||
if (addr < 0x780) //COEF
|
if (addr < 0x780) //COEF
|
||||||
v= *((uint16_t *) (m_DSP.COEF + (addr - 0x700) / 2));
|
v= *((u16 *) (m_DSP.COEF + (addr - 0x700) / 2));
|
||||||
else if (addr < 0x7c0)
|
else if (addr < 0x7c0)
|
||||||
v= *((uint16_t *) (m_DSP.MADRS + (addr - 0x780) / 2));
|
v= *((u16 *) (m_DSP.MADRS + (addr - 0x780) / 2));
|
||||||
else if (addr < 0x800)
|
else if (addr < 0x800)
|
||||||
v= *((uint16_t *) (m_DSP.MADRS + (addr - 0x7c0) / 2));
|
v= *((u16 *) (m_DSP.MADRS + (addr - 0x7c0) / 2));
|
||||||
else if (addr < 0xC00)
|
else if (addr < 0xC00)
|
||||||
v= *((uint16_t *) (m_DSP.MPRO + (addr - 0x800) / 2));
|
v= *((u16 *) (m_DSP.MPRO + (addr - 0x800) / 2));
|
||||||
else if (addr < 0xE00)
|
else if (addr < 0xE00)
|
||||||
{
|
{
|
||||||
if (addr & 2)
|
if (addr & 2)
|
||||||
@ -1071,7 +1060,7 @@ uint16_t scsp_device::r16(uint32_t 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 = *((uint16_t *) (m_DSP.EFREG + (addr - 0xec0) / 2));
|
v = *((u16 *) (m_DSP.EFREG + (addr - 0xec0) / 2));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/**!
|
/**!
|
||||||
@ -1112,14 +1101,14 @@ uint16_t scsp_device::r16(uint32_t 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 = *((uint16_t *) (m_DSP.EXTS + (addr - 0xee0) / 2));
|
v = *((u16 *) (m_DSP.EXTS + (addr - 0xee0) / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
inline s32 scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
||||||
{
|
{
|
||||||
if (SSCTL(slot) == 3) // manual says cannot be used
|
if (SSCTL(slot) == 3) // manual says cannot be used
|
||||||
{
|
{
|
||||||
@ -1127,11 +1116,11 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sample = 0; // NB: Shouldn't be necessary, but GCC 8.2.1 claims otherwise.
|
s32 sample = 0; // NB: Shouldn't be necessary, but GCC 8.2.1 claims otherwise.
|
||||||
int step = slot->step;
|
int step = slot->step;
|
||||||
uint32_t addr1, addr2, addr_select; // current and next sample addresses
|
u32 addr1, addr2, addr_select; // current and next sample addresses
|
||||||
uint32_t *addr[2] = {&addr1, &addr2}; // used for linear interpolation
|
u32 *addr[2] = {&addr1, &addr2}; // used for linear interpolation
|
||||||
uint32_t *slot_addr[2] = {&(slot->cur_addr), &(slot->nxt_addr)}; //
|
u32 *slot_addr[2] = {&(slot->cur_addr), &(slot->nxt_addr)}; //
|
||||||
|
|
||||||
if (PLFOS(slot) != 0)
|
if (PLFOS(slot) != 0)
|
||||||
{
|
{
|
||||||
@ -1152,7 +1141,7 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
|||||||
|
|
||||||
if (MDL(slot) != 0 || MDXSL(slot) != 0 || MDYSL(slot) != 0)
|
if (MDL(slot) != 0 || MDXSL(slot) != 0 || MDYSL(slot) != 0)
|
||||||
{
|
{
|
||||||
int32_t smp = (m_RINGBUF[(m_BUFPTR + MDXSL(slot)) & 63] + m_RINGBUF[(m_BUFPTR + MDYSL(slot)) & 63]) / 2;
|
s32 smp = (m_RINGBUF[(m_BUFPTR + MDXSL(slot)) & 63] + m_RINGBUF[(m_BUFPTR + MDYSL(slot)) & 63]) / 2;
|
||||||
|
|
||||||
smp <<= 0xA; // associate cycle with 1024
|
smp <<= 0xA; // associate cycle with 1024
|
||||||
smp >>= 0x1A - MDL(slot); // ex. for MDL=0xF, sample range corresponds to +/- 64 pi (32=2^5 cycles) so shift by 11 (16-5 == 0x1A-0xF)
|
smp >>= 0x1A - MDL(slot); // ex. for MDL=0xF, sample range corresponds to +/- 64 pi (32=2^5 cycles) so shift by 11 (16-5 == 0x1A-0xF)
|
||||||
@ -1167,30 +1156,30 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
|||||||
{
|
{
|
||||||
int8_t p1 = read_byte(SA(slot) + addr1);
|
int8_t p1 = read_byte(SA(slot) + addr1);
|
||||||
int8_t p2 = read_byte(SA(slot) + addr2);
|
int8_t p2 = read_byte(SA(slot) + addr2);
|
||||||
int32_t s;
|
s32 s;
|
||||||
int32_t fpart=slot->cur_addr & ((1 << SHIFT) - 1);
|
s32 fpart=slot->cur_addr & ((1 << SHIFT) - 1);
|
||||||
s = (int) (p1 << 8) * ((1 << SHIFT) - fpart) + (int) (p2 << 8) * fpart;
|
s = (int) (p1 << 8) * ((1 << SHIFT) - fpart) + (int) (p2 << 8) * fpart;
|
||||||
sample = (s >> SHIFT);
|
sample = (s >> SHIFT);
|
||||||
}
|
}
|
||||||
else //16 bit signed (endianness?)
|
else //16 bit signed (endianness?)
|
||||||
{
|
{
|
||||||
int16_t p1 = read_word(SA(slot) + addr1);
|
s16 p1 = read_word(SA(slot) + addr1);
|
||||||
int16_t p2 = read_word(SA(slot) + addr2);
|
s16 p2 = read_word(SA(slot) + addr2);
|
||||||
int32_t s;
|
s32 s;
|
||||||
int32_t fpart = slot->cur_addr & ((1 << SHIFT) - 1);
|
s32 fpart = slot->cur_addr & ((1 << SHIFT) - 1);
|
||||||
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)
|
else if (SSCTL(slot) == 1) // Internally generated data (Noise)
|
||||||
sample = (int16_t)(machine().rand() & 0xffff); // Unknown algorithm
|
sample = (s16)(machine().rand() & 0xffff); // Unknown algorithm
|
||||||
else if (SSCTL(slot) >= 2) // Internally generated data (All 0)
|
else if (SSCTL(slot) >= 2) // Internally generated data (All 0)
|
||||||
sample = 0;
|
sample = 0;
|
||||||
|
|
||||||
if (SBCTL(slot) & 0x1)
|
if (SBCTL(slot) & 0x1)
|
||||||
sample ^= 0x7FFF;
|
sample ^= 0x7FFF;
|
||||||
if (SBCTL(slot) & 0x2)
|
if (SBCTL(slot) & 0x2)
|
||||||
sample = (int16_t)(sample ^ 0x8000);
|
sample = (s16)(sample ^ 0x8000);
|
||||||
|
|
||||||
if (slot->Backwards)
|
if (slot->Backwards)
|
||||||
slot->cur_addr -= step;
|
slot->cur_addr -= step;
|
||||||
@ -1209,7 +1198,7 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
|||||||
|
|
||||||
for (addr_select = 0; addr_select < 2; addr_select++)
|
for (addr_select = 0; addr_select < 2; addr_select++)
|
||||||
{
|
{
|
||||||
int32_t rem_addr;
|
s32 rem_addr;
|
||||||
switch (LPCTL(slot))
|
switch (LPCTL(slot))
|
||||||
{
|
{
|
||||||
case 0: //no loop
|
case 0: //no loop
|
||||||
@ -1274,12 +1263,12 @@ inline int32_t scsp_device::UpdateSlot(SCSP_SLOT *slot)
|
|||||||
{
|
{
|
||||||
if (!SDIR(slot))
|
if (!SDIR(slot))
|
||||||
{
|
{
|
||||||
uint16_t Enc = ((TL(slot)) << 0x0) | (0x7 << 0xd);
|
u16 Enc = ((TL(slot)) << 0x0) | (0x7 << 0xd);
|
||||||
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
|
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint16_t Enc = (0 << 0x0) | (0x7 << 0xd);
|
u16 Enc = (0 << 0x0) | (0x7 << 0xd);
|
||||||
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
|
*m_RBUFDST = (sample * m_LPANTABLE[Enc]) >> (SHIFT + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1299,7 +1288,7 @@ void scsp_device::DoMasterSamples(int nsamples)
|
|||||||
|
|
||||||
for (int s = 0; s < nsamples; ++s)
|
for (int s = 0; s < nsamples; ++s)
|
||||||
{
|
{
|
||||||
int32_t smpl = 0, smpr = 0;
|
s32 smpl = 0, smpr = 0;
|
||||||
|
|
||||||
for (int sl = 0; sl < 32; ++sl)
|
for (int sl = 0; sl < 32; ++sl)
|
||||||
{
|
{
|
||||||
@ -1311,9 +1300,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;
|
||||||
uint16_t Enc;
|
u16 Enc;
|
||||||
|
|
||||||
int32_t sample = UpdateSlot(slot);
|
s32 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));
|
||||||
@ -1342,7 +1331,7 @@ void scsp_device::DoMasterSamples(int nsamples)
|
|||||||
SCSP_SLOT *slot = m_Slots + i;
|
SCSP_SLOT *slot = m_Slots + i;
|
||||||
if (EFSDL(slot))
|
if (EFSDL(slot))
|
||||||
{
|
{
|
||||||
uint16_t Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd);
|
u16 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;
|
||||||
}
|
}
|
||||||
@ -1354,7 +1343,7 @@ void scsp_device::DoMasterSamples(int nsamples)
|
|||||||
if (EFSDL(slot))
|
if (EFSDL(slot))
|
||||||
{
|
{
|
||||||
m_DSP.EXTS[i] = exts[i][s];
|
m_DSP.EXTS[i] = exts[i][s];
|
||||||
uint16_t Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd);
|
u16 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;
|
||||||
}
|
}
|
||||||
@ -1379,7 +1368,7 @@ void scsp_device::DoMasterSamples(int nsamples)
|
|||||||
/* TODO: this needs to be timer-ized */
|
/* TODO: this needs to be timer-ized */
|
||||||
void scsp_device::exec_dma()
|
void scsp_device::exec_dma()
|
||||||
{
|
{
|
||||||
static uint16_t tmp_dma[3];
|
static u16 tmp_dma[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
logerror("SCSP: DMA transfer START\n"
|
logerror("SCSP: DMA transfer START\n"
|
||||||
@ -1411,7 +1400,7 @@ void scsp_device::exec_dma()
|
|||||||
{
|
{
|
||||||
for (i = 0; i < m_dma.dtlg; i += 2)
|
for (i = 0; i < m_dma.dtlg; i += 2)
|
||||||
{
|
{
|
||||||
uint16_t tmp;
|
u16 tmp;
|
||||||
tmp = r16(m_dma.drga);
|
tmp = r16(m_dma.drga);
|
||||||
this->space().write_word(m_dma.dmea, tmp);
|
this->space().write_word(m_dma.dmea, tmp);
|
||||||
m_dma.dmea += 2;
|
m_dma.dmea += 2;
|
||||||
@ -1434,7 +1423,7 @@ void scsp_device::exec_dma()
|
|||||||
{
|
{
|
||||||
for (i = 0; i < m_dma.dtlg; i += 2)
|
for (i = 0; i < m_dma.dtlg; i += 2)
|
||||||
{
|
{
|
||||||
uint16_t tmp = read_word(m_dma.dmea);
|
u16 tmp = read_word(m_dma.dmea);
|
||||||
w16(m_dma.drga, tmp);
|
w16(m_dma.drga, tmp);
|
||||||
m_dma.dmea += 2;
|
m_dma.dmea += 2;
|
||||||
m_dma.drga += 2;
|
m_dma.drga += 2;
|
||||||
@ -1468,17 +1457,17 @@ int IRQCB(void *param)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
READ16_MEMBER( scsp_device::read )
|
READ16_MEMBER(scsp_device::read)
|
||||||
{
|
{
|
||||||
m_stream->update();
|
m_stream->update();
|
||||||
return r16(offset * 2);
|
return r16(offset * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE16_MEMBER( scsp_device::write )
|
WRITE16_MEMBER(scsp_device::write)
|
||||||
{
|
{
|
||||||
m_stream->update();
|
m_stream->update();
|
||||||
|
|
||||||
uint16_t tmp = r16(offset * 2);
|
u16 tmp = r16(offset * 2);
|
||||||
COMBINE_DATA(&tmp);
|
COMBINE_DATA(&tmp);
|
||||||
w16(offset * 2, tmp);
|
w16(offset * 2, tmp);
|
||||||
}
|
}
|
||||||
@ -1493,9 +1482,9 @@ void scsp_device::midi_in(u8 data)
|
|||||||
CheckPendingIRQ();
|
CheckPendingIRQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
READ16_MEMBER( scsp_device::midi_out_r )
|
READ16_MEMBER(scsp_device::midi_out_r)
|
||||||
{
|
{
|
||||||
uint8_t val;
|
u8 val;
|
||||||
|
|
||||||
val = m_MidiStack[m_MidiR++];
|
val = m_MidiStack[m_MidiR++];
|
||||||
m_MidiR &= 31;
|
m_MidiR &= 31;
|
||||||
@ -1504,7 +1493,7 @@ READ16_MEMBER( scsp_device::midi_out_r )
|
|||||||
|
|
||||||
//LFO handling
|
//LFO handling
|
||||||
|
|
||||||
#define LFIX(v) ((uint32_t) ((float) (1 << LFO_SHIFT) * (v)))
|
#define LFIX(v) ((u32) ((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))
|
||||||
@ -1590,7 +1579,7 @@ void scsp_device::LFO_Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t scsp_device::PLFO_Step(SCSP_LFO_t *LFO)
|
s32 scsp_device::PLFO_Step(SCSP_LFO_t *LFO)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
LFO->phase += LFO->phase_step;
|
LFO->phase += LFO->phase_step;
|
||||||
@ -1602,7 +1591,7 @@ int32_t scsp_device::PLFO_Step(SCSP_LFO_t *LFO)
|
|||||||
return p << (SHIFT - LFO_SHIFT);
|
return p << (SHIFT - LFO_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t scsp_device::ALFO_Step(SCSP_LFO_t *LFO)
|
s32 scsp_device::ALFO_Step(SCSP_LFO_t *LFO)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
LFO->phase += LFO->phase_step;
|
LFO->phase += LFO->phase_step;
|
||||||
@ -1614,10 +1603,10 @@ int32_t scsp_device::ALFO_Step(SCSP_LFO_t *LFO)
|
|||||||
return p << (SHIFT - LFO_SHIFT);
|
return p << (SHIFT - LFO_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,u32 LFOF,u32 LFOWS,u32 LFOS,int ALFO)
|
||||||
{
|
{
|
||||||
float step = (float) LFOFreq[LFOF] * 256.0f / 44100.0f;
|
float step = (float) LFOFreq[LFOF] * 256.0f / 44100.0f;
|
||||||
LFO->phase_step = (uint32_t) ((float) (1 << LFO_SHIFT) * step);
|
LFO->phase_step = (u32) ((float) (1 << LFO_SHIFT) * step);
|
||||||
if (ALFO)
|
if (ALFO)
|
||||||
{
|
{
|
||||||
switch (LFOWS)
|
switch (LFOWS)
|
||||||
|
@ -20,20 +20,20 @@ class scsp_device : public device_t,
|
|||||||
public device_rom_interface
|
public device_rom_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr feature_type imperfect_features() { return feature::SOUND; } // DSP incorrections, etc
|
static constexpr feature_type imperfect_features() { return feature::SOUND; } // DSP / EG incorrections, etc
|
||||||
|
|
||||||
scsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 22'579'200);
|
scsp_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 22'579'200);
|
||||||
|
|
||||||
auto irq_cb() { return m_irq_cb.bind(); }
|
auto irq_cb() { return m_irq_cb.bind(); }
|
||||||
auto main_irq_cb() { return m_main_irq_cb.bind(); }
|
auto main_irq_cb() { return m_main_irq_cb.bind(); }
|
||||||
|
|
||||||
// SCSP register access
|
// SCSP register access
|
||||||
DECLARE_READ16_MEMBER( read );
|
DECLARE_READ16_MEMBER(read);
|
||||||
DECLARE_WRITE16_MEMBER( write );
|
DECLARE_WRITE16_MEMBER(write);
|
||||||
|
|
||||||
// MIDI I/O access (used for comms on Model 2/3)
|
// MIDI I/O access (used for comms on Model 2/3)
|
||||||
void midi_in(u8 data);
|
void midi_in(u8 data);
|
||||||
DECLARE_READ16_MEMBER( midi_out_r );
|
DECLARE_READ16_MEMBER(midi_out_r);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// device-level overrides
|
// device-level overrides
|
||||||
@ -61,14 +61,14 @@ private:
|
|||||||
int RR; //Release
|
int RR; //Release
|
||||||
|
|
||||||
int DL; //Decay level
|
int DL; //Decay level
|
||||||
uint8_t EGHOLD;
|
u8 EGHOLD;
|
||||||
uint8_t LPLINK;
|
u8 LPLINK;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCSP_LFO_t
|
struct SCSP_LFO_t
|
||||||
{
|
{
|
||||||
uint16_t phase;
|
u16 phase;
|
||||||
uint32_t phase_step;
|
u32 phase_step;
|
||||||
int *table;
|
int *table;
|
||||||
int *scale;
|
int *scale;
|
||||||
};
|
};
|
||||||
@ -77,20 +77,20 @@ private:
|
|||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint16_t data[0x10]; //only 0x1a bytes used
|
u16 data[0x10]; //only 0x1a bytes used
|
||||||
uint8_t datab[0x20];
|
u8 datab[0x20];
|
||||||
} udata;
|
} udata;
|
||||||
|
|
||||||
uint8_t Backwards; //the wave is playing backwards
|
u8 Backwards; //the wave is playing backwards
|
||||||
uint8_t active; //this slot is currently playing
|
u8 active; //this slot is currently playing
|
||||||
uint32_t cur_addr; //current play address (24.8)
|
u32 cur_addr; //current play address (24.8)
|
||||||
uint32_t nxt_addr; //next play address
|
u32 nxt_addr; //next play address
|
||||||
uint32_t step; //pitch step (24.8)
|
u32 step; //pitch step (24.8)
|
||||||
SCSP_EG_t EG; //Envelope
|
SCSP_EG_t EG; //Envelope
|
||||||
SCSP_LFO_t PLFO; //Phase LFO
|
SCSP_LFO_t PLFO; //Phase LFO
|
||||||
SCSP_LFO_t ALFO; //Amplitude LFO
|
SCSP_LFO_t ALFO; //Amplitude LFO
|
||||||
int slot;
|
int slot;
|
||||||
int16_t Prev; //Previous sample (for interpolation)
|
s16 Prev; //Previous sample (for interpolation)
|
||||||
};
|
};
|
||||||
|
|
||||||
devcb_write8 m_irq_cb; /* irq callback */
|
devcb_write8 m_irq_cb; /* irq callback */
|
||||||
@ -98,29 +98,28 @@ private:
|
|||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint16_t data[0x30/2];
|
u16 data[0x30/2];
|
||||||
uint8_t datab[0x30];
|
u8 datab[0x30];
|
||||||
} m_udata;
|
} m_udata;
|
||||||
|
|
||||||
SCSP_SLOT m_Slots[32];
|
SCSP_SLOT m_Slots[32];
|
||||||
int16_t m_RINGBUF[128];
|
s16 m_RINGBUF[128];
|
||||||
uint8_t m_BUFPTR;
|
u8 m_BUFPTR;
|
||||||
#if SCSP_FM_DELAY
|
#if SCSP_FM_DELAY
|
||||||
int16_t m_DELAYBUF[SCSP_FM_DELAY];
|
s16 m_DELAYBUF[SCSP_FM_DELAY];
|
||||||
uint8_t m_DELAYPTR;
|
u8 m_DELAYPTR;
|
||||||
#endif
|
#endif
|
||||||
char m_Master;
|
|
||||||
sound_stream * m_stream;
|
sound_stream * m_stream;
|
||||||
|
|
||||||
uint32_t m_IrqTimA;
|
u32 m_IrqTimA;
|
||||||
uint32_t m_IrqTimBC;
|
u32 m_IrqTimBC;
|
||||||
uint32_t m_IrqMidi;
|
u32 m_IrqMidi;
|
||||||
|
|
||||||
uint8_t m_MidiOutW, m_MidiOutR;
|
u8 m_MidiOutW, m_MidiOutR;
|
||||||
uint8_t m_MidiStack[32];
|
u8 m_MidiStack[32];
|
||||||
uint8_t m_MidiW, m_MidiR;
|
u8 m_MidiW, m_MidiR;
|
||||||
|
|
||||||
int32_t m_EG_TABLE[0x400];
|
s32 m_EG_TABLE[0x400];
|
||||||
|
|
||||||
int m_LPANTABLE[0x10000];
|
int m_LPANTABLE[0x10000];
|
||||||
int m_RPANTABLE[0x10000];
|
int m_RPANTABLE[0x10000];
|
||||||
@ -134,15 +133,15 @@ private:
|
|||||||
// DMA stuff
|
// DMA stuff
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t dmea;
|
u32 dmea;
|
||||||
uint16_t drga;
|
u16 drga;
|
||||||
uint16_t dtlg;
|
u16 dtlg;
|
||||||
uint8_t dgate;
|
u8 dgate;
|
||||||
uint8_t ddir;
|
u8 ddir;
|
||||||
} m_dma;
|
} m_dma;
|
||||||
|
|
||||||
uint16_t m_mcieb;
|
u16 m_mcieb;
|
||||||
uint16_t m_mcipd;
|
u16 m_mcipd;
|
||||||
|
|
||||||
int m_ARTABLE[64], m_DRTABLE[64];
|
int m_ARTABLE[64], m_DRTABLE[64];
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ private:
|
|||||||
|
|
||||||
int m_length;
|
int m_length;
|
||||||
|
|
||||||
int16_t *m_RBUFDST; //this points to where the sample will be stored in the RingBuf
|
s16 *m_RBUFDST; //this points to where the sample will be stored in the RingBuf
|
||||||
|
|
||||||
//LFO
|
//LFO
|
||||||
int m_PLFO_TRI[256], m_PLFO_SQR[256], m_PLFO_SAW[256], m_PLFO_NOI[256];
|
int m_PLFO_TRI[256], m_PLFO_SQR[256], m_PLFO_SAW[256], m_PLFO_NOI[256];
|
||||||
@ -164,18 +163,18 @@ private:
|
|||||||
int m_ASCALES[8][256];
|
int m_ASCALES[8][256];
|
||||||
|
|
||||||
void exec_dma(); /*state DMA transfer function*/
|
void exec_dma(); /*state DMA transfer function*/
|
||||||
uint8_t DecodeSCI(uint8_t irq);
|
u8 DecodeSCI(u8 irq);
|
||||||
void CheckPendingIRQ();
|
void CheckPendingIRQ();
|
||||||
void MainCheckPendingIRQ(uint16_t irq_type);
|
void MainCheckPendingIRQ(u16 irq_type);
|
||||||
void ResetInterrupts();
|
void ResetInterrupts();
|
||||||
TIMER_CALLBACK_MEMBER( timerA_cb );
|
TIMER_CALLBACK_MEMBER(timerA_cb);
|
||||||
TIMER_CALLBACK_MEMBER( timerB_cb );
|
TIMER_CALLBACK_MEMBER(timerB_cb);
|
||||||
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);
|
||||||
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);
|
u32 Step(SCSP_SLOT *slot);
|
||||||
void Compute_LFO(SCSP_SLOT *slot);
|
void Compute_LFO(SCSP_SLOT *slot);
|
||||||
void StartSlot(SCSP_SLOT *slot);
|
void StartSlot(SCSP_SLOT *slot);
|
||||||
void StopSlot(SCSP_SLOT *slot, int keyoff);
|
void StopSlot(SCSP_SLOT *slot, int keyoff);
|
||||||
@ -184,16 +183,16 @@ private:
|
|||||||
void UpdateReg(int reg);
|
void UpdateReg(int reg);
|
||||||
void UpdateSlotRegR(int slot, int reg);
|
void UpdateSlotRegR(int slot, int reg);
|
||||||
void UpdateRegR(int reg);
|
void UpdateRegR(int reg);
|
||||||
void w16(uint32_t addr, uint16_t val);
|
void w16(u32 addr, u16 val);
|
||||||
uint16_t r16(uint32_t addr);
|
u16 r16(u32 addr);
|
||||||
inline int32_t UpdateSlot(SCSP_SLOT *slot);
|
inline s32 UpdateSlot(SCSP_SLOT *slot);
|
||||||
void DoMasterSamples(int nsamples);
|
void DoMasterSamples(int nsamples);
|
||||||
|
|
||||||
//LFO
|
//LFO
|
||||||
void LFO_Init();
|
void LFO_Init();
|
||||||
int32_t PLFO_Step(SCSP_LFO_t *LFO);
|
s32 PLFO_Step(SCSP_LFO_t *LFO);
|
||||||
int32_t ALFO_Step(SCSP_LFO_t *LFO);
|
s32 ALFO_Step(SCSP_LFO_t *LFO);
|
||||||
void LFO_ComputeStep(SCSP_LFO_t *LFO, uint32_t LFOF, uint32_t LFOWS, uint32_t LFOS, int ALFO);
|
void LFO_ComputeStep(SCSP_LFO_t *LFO, u32 LFOF, u32 LFOWS, u32 LFOS, int ALFO);
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(SCSP, scsp_device)
|
DECLARE_DEVICE_TYPE(SCSP, scsp_device)
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
uint16_t PACK(int32_t val)
|
u16 PACK(s32 val)
|
||||||
{
|
{
|
||||||
int const sign = BIT(val, 23);
|
int const sign = BIT(val, 23);
|
||||||
uint32_t temp = (val ^ (val << 1)) & 0xFFFFFF;
|
u32 temp = (val ^ (val << 1)) & 0xFFFFFF;
|
||||||
int exponent = 0;
|
int exponent = 0;
|
||||||
for (int k = 0; k < 12; k++)
|
for (int k = 0; k < 12; k++)
|
||||||
{
|
{
|
||||||
@ -29,15 +29,15 @@ uint16_t PACK(int32_t val)
|
|||||||
val |= sign << 15;
|
val |= sign << 15;
|
||||||
val |= exponent << 11;
|
val |= exponent << 11;
|
||||||
|
|
||||||
return uint16_t(val);
|
return u16(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t UNPACK(uint16_t val)
|
static s32 UNPACK(u16 val)
|
||||||
{
|
{
|
||||||
int const sign = BIT(val, 15);
|
int const sign = BIT(val, 15);
|
||||||
int exponent = (val >> 11) & 0xF;
|
int exponent = (val >> 11) & 0xF;
|
||||||
int const mantissa = val & 0x7FF;
|
int const mantissa = val & 0x7FF;
|
||||||
int32_t uval = mantissa << 11;
|
s32 uval = mantissa << 11;
|
||||||
if (exponent > 11)
|
if (exponent > 11)
|
||||||
{
|
{
|
||||||
exponent = 11;
|
exponent = 11;
|
||||||
@ -79,48 +79,48 @@ void SCSPDSP::Step()
|
|||||||
f=fopen("dsp.txt","wt");
|
f=fopen("dsp.txt","wt");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t ACC = 0; //26 bit
|
s32 ACC = 0; //26 bit
|
||||||
int32_t MEMVAL = 0;
|
s32 MEMVAL = 0;
|
||||||
int32_t FRC_REG = 0; //13 bit
|
s32 FRC_REG = 0; //13 bit
|
||||||
int32_t Y_REG = 0; //24 bit
|
s32 Y_REG = 0; //24 bit
|
||||||
uint32_t ADRS_REG = 0; //13 bit
|
u32 ADRS_REG = 0; //13 bit
|
||||||
|
|
||||||
for (int step = 0; step < /*128*/LastStep; ++step)
|
for (int step = 0; step < /*128*/LastStep; ++step)
|
||||||
{
|
{
|
||||||
uint16_t *const IPtr = MPRO + (step * 4);
|
u16 *const IPtr = MPRO + (step * 4);
|
||||||
|
|
||||||
//if (!IPtr[0] && !IPtr[1] && !IPtr[2] && !IPtr[3])
|
//if (!IPtr[0] && !IPtr[1] && !IPtr[2] && !IPtr[3])
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
uint32_t const TRA = (IPtr[0] >> 8) & 0x7F;
|
u32 const TRA = (IPtr[0] >> 8) & 0x7F;
|
||||||
uint32_t const TWT = (IPtr[0] >> 7) & 0x01;
|
u32 const TWT = (IPtr[0] >> 7) & 0x01;
|
||||||
uint32_t const TWA = (IPtr[0] >> 0) & 0x7F;
|
u32 const TWA = (IPtr[0] >> 0) & 0x7F;
|
||||||
|
|
||||||
uint32_t const XSEL = (IPtr[1] >> 15) & 0x01;
|
u32 const XSEL = (IPtr[1] >> 15) & 0x01;
|
||||||
uint32_t const YSEL = (IPtr[1] >> 13) & 0x03;
|
u32 const YSEL = (IPtr[1] >> 13) & 0x03;
|
||||||
uint32_t const IRA = (IPtr[1] >> 6) & 0x3F;
|
u32 const IRA = (IPtr[1] >> 6) & 0x3F;
|
||||||
uint32_t const IWT = (IPtr[1] >> 5) & 0x01;
|
u32 const IWT = (IPtr[1] >> 5) & 0x01;
|
||||||
uint32_t const IWA = (IPtr[1] >> 0) & 0x1F;
|
u32 const IWA = (IPtr[1] >> 0) & 0x1F;
|
||||||
|
|
||||||
uint32_t const TABLE = (IPtr[2] >> 15) & 0x01;
|
u32 const TABLE = (IPtr[2] >> 15) & 0x01;
|
||||||
uint32_t const MWT = (IPtr[2] >> 14) & 0x01;
|
u32 const MWT = (IPtr[2] >> 14) & 0x01;
|
||||||
uint32_t const MRD = (IPtr[2] >> 13) & 0x01;
|
u32 const MRD = (IPtr[2] >> 13) & 0x01;
|
||||||
uint32_t const EWT = (IPtr[2] >> 12) & 0x01;
|
u32 const EWT = (IPtr[2] >> 12) & 0x01;
|
||||||
uint32_t const EWA = (IPtr[2] >> 8) & 0x0F;
|
u32 const EWA = (IPtr[2] >> 8) & 0x0F;
|
||||||
uint32_t const ADRL = (IPtr[2] >> 7) & 0x01;
|
u32 const ADRL = (IPtr[2] >> 7) & 0x01;
|
||||||
uint32_t const FRCL = (IPtr[2] >> 6) & 0x01;
|
u32 const FRCL = (IPtr[2] >> 6) & 0x01;
|
||||||
uint32_t const SHIFT = (IPtr[2] >> 4) & 0x03;
|
u32 const SHIFT = (IPtr[2] >> 4) & 0x03;
|
||||||
uint32_t const YRL = (IPtr[2] >> 3) & 0x01;
|
u32 const YRL = (IPtr[2] >> 3) & 0x01;
|
||||||
uint32_t const NEGB = (IPtr[2] >> 2) & 0x01;
|
u32 const NEGB = (IPtr[2] >> 2) & 0x01;
|
||||||
uint32_t const ZERO = (IPtr[2] >> 1) & 0x01;
|
u32 const ZERO = (IPtr[2] >> 1) & 0x01;
|
||||||
uint32_t const BSEL = (IPtr[2] >> 0) & 0x01;
|
u32 const BSEL = (IPtr[2] >> 0) & 0x01;
|
||||||
|
|
||||||
uint32_t const NOFL = (IPtr[3] >> 15) & 0x01; //????
|
u32 const NOFL = (IPtr[3] >> 15) & 0x01; //????
|
||||||
uint32_t const COEF = (IPtr[3] >> 9) & 0x3f;
|
u32 const COEF = (IPtr[3] >> 9) & 0x3f;
|
||||||
|
|
||||||
uint32_t const MASA = (IPtr[3] >> 2) & 0x1f; //???
|
u32 const MASA = (IPtr[3] >> 2) & 0x1f; //???
|
||||||
uint32_t const ADREB = (IPtr[3] >> 1) & 0x01;
|
u32 const ADREB = (IPtr[3] >> 1) & 0x01;
|
||||||
uint32_t const NXADR = (IPtr[3] >> 0) & 0x01;
|
u32 const NXADR = (IPtr[3] >> 0) & 0x01;
|
||||||
|
|
||||||
//operations are done at 24 bit precision
|
//operations are done at 24 bit precision
|
||||||
#if 0
|
#if 0
|
||||||
@ -154,7 +154,7 @@ void SCSPDSP::Step()
|
|||||||
//INPUTS RW
|
//INPUTS RW
|
||||||
// colmns97 hits this
|
// colmns97 hits this
|
||||||
//assert(IRA < 0x32);
|
//assert(IRA < 0x32);
|
||||||
int32_t INPUTS; // 24-bit
|
s32 INPUTS; // 24-bit
|
||||||
if (IRA <= 0x1f)
|
if (IRA <= 0x1f)
|
||||||
INPUTS = MEMS[IRA];
|
INPUTS = MEMS[IRA];
|
||||||
else if (IRA <= 0x2F)
|
else if (IRA <= 0x2F)
|
||||||
@ -177,7 +177,7 @@ void SCSPDSP::Step()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Operand sel
|
//Operand sel
|
||||||
int32_t B; // 26-bit
|
s32 B; // 26-bit
|
||||||
if (!ZERO)
|
if (!ZERO)
|
||||||
{
|
{
|
||||||
if (BSEL)
|
if (BSEL)
|
||||||
@ -196,7 +196,7 @@ void SCSPDSP::Step()
|
|||||||
else
|
else
|
||||||
B = 0;
|
B = 0;
|
||||||
|
|
||||||
int32_t X; // 24-bit
|
s32 X; // 24-bit
|
||||||
if (XSEL)
|
if (XSEL)
|
||||||
X = INPUTS;
|
X = INPUTS;
|
||||||
else
|
else
|
||||||
@ -208,7 +208,7 @@ void SCSPDSP::Step()
|
|||||||
//X |= 0xFF000000;
|
//X |= 0xFF000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Y = 0; //13 bit
|
s32 Y = 0; //13 bit
|
||||||
if (YSEL == 0)
|
if (YSEL == 0)
|
||||||
Y = FRC_REG;
|
Y = FRC_REG;
|
||||||
else if (YSEL == 1)
|
else if (YSEL == 1)
|
||||||
@ -222,11 +222,11 @@ void SCSPDSP::Step()
|
|||||||
Y_REG = INPUTS;
|
Y_REG = INPUTS;
|
||||||
|
|
||||||
//Shifter
|
//Shifter
|
||||||
int32_t SHIFTED = 0; //24 bit
|
s32 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<s32>(std::min<s32>(ACC, 0x007FFFFF), -0x00800000);
|
||||||
else if (SHIFT == 1)
|
else if (SHIFT == 1)
|
||||||
SHIFTED = std::max<int32_t>(std::min<int32_t>(ACC * 2, 0x007FFFFF), -0x00800000);
|
SHIFTED = std::max<s32>(std::min<s32>(ACC * 2, 0x007FFFFF), -0x00800000);
|
||||||
else if (SHIFT == 2)
|
else if (SHIFT == 2)
|
||||||
{
|
{
|
||||||
SHIFTED = ACC * 2;
|
SHIFTED = ACC * 2;
|
||||||
@ -269,7 +269,7 @@ void SCSPDSP::Step()
|
|||||||
if (MRD || MWT)
|
if (MRD || MWT)
|
||||||
//if (0)
|
//if (0)
|
||||||
{
|
{
|
||||||
uint32_t ADDR = MADRS[MASA];
|
u32 ADDR = MADRS[MASA];
|
||||||
if (!TABLE)
|
if (!TABLE)
|
||||||
ADDR += DEC;
|
ADDR += DEC;
|
||||||
if (ADREB)
|
if (ADREB)
|
||||||
@ -315,7 +315,7 @@ void SCSPDSP::Step()
|
|||||||
//fclose(f);
|
//fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSPDSP::SetSample(int32_t sample, int SEL, int MXL)
|
void SCSPDSP::SetSample(s32 sample, int SEL, int MXL)
|
||||||
{
|
{
|
||||||
//MIXS[SEL] += sample << (MXL + 1)/*7*/;
|
//MIXS[SEL] += sample << (MXL + 1)/*7*/;
|
||||||
MIXS[SEL] += sample;
|
MIXS[SEL] += sample;
|
||||||
@ -329,7 +329,7 @@ void SCSPDSP::Start()
|
|||||||
int i;
|
int i;
|
||||||
for (i = 127; i >= 0; --i)
|
for (i = 127; i >= 0; --i)
|
||||||
{
|
{
|
||||||
uint16_t const *const IPtr = MPRO + (i * 4);
|
u16 const *const IPtr = MPRO + (i * 4);
|
||||||
if (IPtr[0] || IPtr[1] || IPtr[2] || IPtr[3])
|
if (IPtr[0] || IPtr[1] || IPtr[2] || IPtr[3])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -10,30 +10,30 @@ struct SCSPDSP
|
|||||||
{
|
{
|
||||||
//Config
|
//Config
|
||||||
address_space *space;
|
address_space *space;
|
||||||
uint32_t RBP; //Ring buf pointer
|
u32 RBP; //Ring buf pointer
|
||||||
uint32_t RBL; //Delay ram (Ring buffer) size in words
|
u32 RBL; //Delay ram (Ring buffer) size in words
|
||||||
|
|
||||||
//context
|
//context
|
||||||
|
|
||||||
int16_t COEF[64]; //16 bit signed
|
s16 COEF[64]; //16 bit signed
|
||||||
uint16_t MADRS[32]; //offsets (in words), 16 bit
|
u16 MADRS[32]; //offsets (in words), 16 bit
|
||||||
uint16_t MPRO[128*4]; //128 steps 64 bit
|
u16 MPRO[128*4]; //128 steps 64 bit
|
||||||
int32_t TEMP[128]; //TEMP regs,24 bit signed
|
s32 TEMP[128]; //TEMP regs,24 bit signed
|
||||||
int32_t MEMS[32]; //MEMS regs,24 bit signed
|
s32 MEMS[32]; //MEMS regs,24 bit signed
|
||||||
uint32_t DEC;
|
u32 DEC;
|
||||||
|
|
||||||
//input
|
//input
|
||||||
int32_t MIXS[16]; //MIXS, 24 bit signed
|
s32 MIXS[16]; //MIXS, 24 bit signed
|
||||||
int16_t EXTS[2]; //External inputs (CDDA) 16 bit signed
|
s16 EXTS[2]; //External inputs (CDDA) 16 bit signed
|
||||||
|
|
||||||
//output
|
//output
|
||||||
int16_t EFREG[16]; //EFREG, 16 bit signed
|
s16 EFREG[16]; //EFREG, 16 bit signed
|
||||||
|
|
||||||
bool Stopped;
|
bool Stopped;
|
||||||
int LastStep;
|
int LastStep;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void SetSample(int32_t sample, int32_t SEL, int32_t MXL);
|
void SetSample(s32 sample, s32 SEL, s32 MXL);
|
||||||
void Step();
|
void Step();
|
||||||
void Start();
|
void Start();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user