mirror of
https://github.com/holub/mame
synced 2025-07-03 09:06:08 +03:00
MIDI: preliminary SysEx reception support [R. Belmont]
This commit is contained in:
parent
7731ec7923
commit
70a9d274ac
@ -24,6 +24,7 @@ struct osd_midi_device
|
|||||||
UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
|
UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
|
||||||
int xmit_cnt;
|
int xmit_cnt;
|
||||||
UINT8 last_status;
|
UINT8 last_status;
|
||||||
|
bool rx_sysex;
|
||||||
};
|
};
|
||||||
|
|
||||||
void osd_list_midi_devices(void)
|
void osd_list_midi_devices(void)
|
||||||
@ -192,6 +193,42 @@ int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
|
|||||||
for (int msg = 0; msg < msgsRead; msg++)
|
for (int msg = 0; msg < msgsRead; msg++)
|
||||||
{
|
{
|
||||||
UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message);
|
UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message);
|
||||||
|
|
||||||
|
if (dev->rx_sysex)
|
||||||
|
{
|
||||||
|
if (status & 0x80) // sys real-time imposing on us?
|
||||||
|
{
|
||||||
|
if ((status == 0xf2) || (status == 0xf3))
|
||||||
|
{
|
||||||
|
*pOut++ = status;
|
||||||
|
*pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
|
||||||
|
*pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
|
||||||
|
bytesOut += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pOut++ = status;
|
||||||
|
bytesOut++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // shift out the sysex bytes
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
UINT8 byte = dev->rx_evBuf[msg].message & 0xff;
|
||||||
|
*pOut++ = byte;
|
||||||
|
bytesOut++;
|
||||||
|
if (byte == MIDI_EOX)
|
||||||
|
{
|
||||||
|
dev->rx_sysex = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dev->rx_evBuf[msg].message >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
switch ((status>>4) & 0xf)
|
switch ((status>>4) & 0xf)
|
||||||
{
|
{
|
||||||
case 0xc: // 2-byte messages
|
case 0xc: // 2-byte messages
|
||||||
@ -205,7 +242,12 @@ int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
|
|||||||
switch (status & 0xf)
|
switch (status & 0xf)
|
||||||
{
|
{
|
||||||
case 0: // System Exclusive
|
case 0: // System Exclusive
|
||||||
printf("No SEx please!\n");
|
*pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe
|
||||||
|
*pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff;
|
||||||
|
*pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff;
|
||||||
|
*pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff;
|
||||||
|
bytesOut += 4;
|
||||||
|
dev->rx_sysex = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: // End of System Exclusive
|
case 7: // End of System Exclusive
|
||||||
@ -234,6 +276,7 @@ int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return bytesOut;
|
return bytesOut;
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user