summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/scsp.cpp
diff options
context:
space:
mode:
author Matthew Daniels <108370479+gm-matthew@users.noreply.github.com>2025-03-26 07:18:44 +0000
committer GitHub <noreply@github.com>2025-03-26 08:18:44 +0100
commitd8f21c57f8ba9ec7b4123feab2893609cfaa9a5d (patch)
treebb5b959cf47084e3051b15bb6c9d81e85a125a46 /src/devices/sound/scsp.cpp
parent9fd89a456e9610a4d55a4b2210d45f0c20633ef0 (diff)
scsp: improve handling of MIDI interrupts (#13521)
Diffstat (limited to 'src/devices/sound/scsp.cpp')
-rw-r--r--src/devices/sound/scsp.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp
index be8fc35cdc7..2caec3580ae 100644
--- a/src/devices/sound/scsp.cpp
+++ b/src/devices/sound/scsp.cpp
@@ -166,6 +166,7 @@ scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_
{
std::fill(std::begin(m_RINGBUF), std::end(m_RINGBUF), 0);
std::fill(std::begin(m_MidiStack), std::end(m_MidiStack), 0);
+ std::fill(std::begin(m_MidiOutStack), std::end(m_MidiOutStack), 0);
std::fill(std::begin(m_LPANTABLE), std::end(m_LPANTABLE), 0);
std::fill(std::begin(m_RPANTABLE), std::end(m_RPANTABLE), 0);
std::fill(std::begin(m_TimPris), std::end(m_TimPris), 0);
@@ -243,6 +244,7 @@ void scsp_device::device_start()
save_item(NAME(m_IrqTimBC));
save_item(NAME(m_IrqMidi));
+ save_item(NAME(m_MidiOutStack));
save_item(NAME(m_MidiOutW));
save_item(NAME(m_MidiOutR));
save_item(NAME(m_MidiStack));
@@ -359,7 +361,6 @@ void scsp_device::CheckPendingIRQ()
if (en & 8)
{
m_irq_cb(m_IrqMidi, ASSERT_LINE);
- m_udata.data[0x20/2] &= ~8;
return;
}
@@ -733,7 +734,7 @@ void scsp_device::UpdateReg(int reg)
break;
case 0x6:
case 0x7:
- midi_in(m_udata.data[0x6/2] & 0xff);
+ midi_out_w(m_udata.data[0x6/2] & 0xff);
break;
case 8:
case 9:
@@ -899,13 +900,17 @@ void scsp_device::UpdateRegR(int reg)
u16 v = m_udata.data[0x4/2];
v &= 0xff00;
v |= m_MidiStack[m_MidiR];
- m_irq_cb(m_IrqMidi, CLEAR_LINE); // cancel the IRQ
logerror("Read %x from SCSP MIDI\n", v);
if (m_MidiR != m_MidiW)
{
++m_MidiR;
m_MidiR &= 31;
}
+ if (m_MidiR == m_MidiW) // if the input FIFO is empty, clear the IRQ
+ {
+ m_irq_cb(m_IrqMidi, CLEAR_LINE);
+ m_udata.data[0x20 / 2] &= ~8;
+ }
m_udata.data[0x4/2] = v;
}
break;
@@ -1451,11 +1456,19 @@ void scsp_device::midi_in(u8 data)
u16 scsp_device::midi_out_r()
{
- u8 val = m_MidiStack[m_MidiR++];
- m_MidiR &= 31;
+ u8 val = m_MidiOutStack[m_MidiOutR++];
+ m_MidiOutR &= 31;
return val;
}
+void scsp_device::midi_out_w(u8 data)
+{
+ m_MidiOutStack[m_MidiOutW++] = data;
+ m_MidiOutW &= 31;
+
+ //CheckPendingIRQ();
+}
+
//LFO handling
#define LFIX(v) ((u32) ((float) (1 << LFO_SHIFT) * (v)))