Previous 199869 Revisions Next

r20711 Sunday 3rd February, 2013 at 21:26:37 UTC by R. Belmont
MIDI: preliminary SysEx reception support [R. Belmont]
[src/osd/portmedia]pmmidi.c

trunk/src/osd/portmedia/pmmidi.c
r20710r20711
2424   UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
2525   int xmit_cnt;
2626   UINT8 last_status;
27   bool rx_sysex;
2728};
2829
2930void osd_list_midi_devices(void)
r20710r20711
192193   for (int msg = 0; msg < msgsRead; msg++)
193194   {
194195      UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message);
195      switch ((status>>4) & 0xf)
196
197      if (dev->rx_sysex)
196198      {
197         case 0xc:   // 2-byte messages
198         case 0xd:
199            *pOut++ = status;
200            *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
201            bytesOut += 2;
202            break;
203
204         case 0xf:   // system common
205            switch (status & 0xf)
199         if (status & 0x80)   // sys real-time imposing on us?
200         {
201            if ((status == 0xf2) || (status == 0xf3))
206202            {
207               case 0:   // System Exclusive
208                  printf("No SEx please!\n");
203               *pOut++ = status;
204               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
205               *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
206               bytesOut += 3;
207            }
208            else
209            {
210               *pOut++ = status;
211               bytesOut++;
212            }
213         }
214         else   // shift out the sysex bytes
215         {
216            for (int i = 0; i < 4; i++)
217            {
218               UINT8 byte = dev->rx_evBuf[msg].message & 0xff;
219               *pOut++ = byte;
220               bytesOut++;
221               if (byte == MIDI_EOX)
222               {
223                  dev->rx_sysex = false;
209224                  break;
225               }
226               dev->rx_evBuf[msg].message >>= 8;
227            }
228         }
229      }
230      else
231      {
232         switch ((status>>4) & 0xf)
233         {
234            case 0xc:   // 2-byte messages
235            case 0xd:
236               *pOut++ = status;
237               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
238               bytesOut += 2;
239               break;
210240
211               case 7:   // End of System Exclusive
212                  *pOut++ = status;
213                  bytesOut += 1;
214                  break;
241            case 0xf:   // system common
242               switch (status & 0xf)
243               {
244                  case 0:   // System Exclusive
245                     *pOut++ = status;   // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe
246                     *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff;
247                     *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff;
248                     *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff;
249                     bytesOut += 4;
250                     dev->rx_sysex = true;
251                     break;
215252
216               case 2:   // song pos
217               case 3:   // song select
218                  *pOut++ = status;
219                  *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
220                  *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
221                  bytesOut += 3;
222                  break;
253                  case 7:   // End of System Exclusive
254                     *pOut++ = status;
255                     bytesOut += 1;
256                     break;
223257
224               default:   // all other defined Fx messages are 1 byte
225                  break;
226            }
227            break;
258                  case 2:   // song pos
259                  case 3:   // song select
260                     *pOut++ = status;
261                     *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
262                     *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
263                     bytesOut += 3;
264                     break;
228265
229         default:
230            *pOut++ = status;
231            *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
232            *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
233            bytesOut += 3;
234            break;
266                  default:   // all other defined Fx messages are 1 byte
267                     break;
268               }
269               break;
270
271            default:
272               *pOut++ = status;
273               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
274               *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
275               bytesOut += 3;
276               break;
277         }
235278      }
236279   }
237280

Previous 199869 Revisions Next


© 1997-2024 The MAME Team