Previous 199869 Revisions Next

r20664 Saturday 2nd February, 2013 at 03:40:55 UTC by R. Belmont
(MESS) isa_sblaster: working SB-MIDI In (tested w/MIDI Monitor for Windows) [R. Belmont]
[src/mess/machine]isa_sblaster.c isa_sblaster.h

trunk/src/mess/machine/isa_sblaster.c
r20663r20664
7171   NULL
7272};
7373
74static SLOT_INTERFACE_START(midiin_slot)
75   SLOT_INTERFACE("midiin", MIDIIN_PORT)
76SLOT_INTERFACE_END
77
78static const serial_port_interface midiin_intf =
79{
80   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, sb_device, midi_rx_w)
81};
82
7483static SLOT_INTERFACE_START(midiout_slot)
7584   SLOT_INTERFACE("midiout", MIDIOUT_PORT)
7685SLOT_INTERFACE_END
r20663r20664
99108   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00)
100109
101110   MCFG_PC_JOY_ADD("joy")
111   MCFG_SERIAL_PORT_ADD("mdin", midiin_intf, midiin_slot, "midiin", NULL)
102112   MCFG_SERIAL_PORT_ADD("mdout", midiout_intf, midiout_slot, "midiout", NULL)
103113MACHINE_CONFIG_END
104114
r20663r20664
116126   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00)
117127
118128   MCFG_PC_JOY_ADD("joy")
129   MCFG_SERIAL_PORT_ADD("mdin", midiin_intf, midiin_slot, "midiin", NULL)
119130   MCFG_SERIAL_PORT_ADD("mdout", midiout_intf, midiout_slot, "midiout", NULL)
120131MACHINE_CONFIG_END
121132
r20663r20664
133144   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00)
134145
135146   MCFG_PC_JOY_ADD("joy")
147   MCFG_SERIAL_PORT_ADD("mdin", midiin_intf, midiin_slot, "midiin", NULL)
136148   MCFG_SERIAL_PORT_ADD("mdout", midiout_intf, midiout_slot, "midiout", NULL)
137149MACHINE_CONFIG_END
138150
r20663r20664
272284   m_tx_busy = false;
273285   m_xmit_read = m_xmit_write = 0;
274286   m_recv_read = m_recv_write = 0;
275   m_uart_xmitfull = false;
287   m_rx_waiting = m_tx_waiting = false;
276288
277289   //printf("%02x\n",data);
278290}
r20663r20664
285297
286298   if (m_uart_midi)
287299   {
288      UINT8 rv = m_recvring[m_recv_read];
289
290      // only advance the read pointer if the ring wasn't empty
291      if (m_recv_read != m_xmit_read)
300      UINT8 rv = m_recvring[m_recv_read++];
301      if (m_rx_waiting)
292302      {
293         m_recv_read++;
303         m_rx_waiting--;
294304      }
295305
296306      return rv;
r20663r20664
325335   // to read.
326336   if (m_uart_midi || m_onebyte_midi)
327337   {
328      if (m_recv_read != m_recv_write)
338      if (m_rx_waiting)
329339      {
330340         return 0x80;
331341      }
r20663r20664
347357   // set = buffer full
348358   if (m_uart_midi || m_onebyte_midi)
349359   {
350      if (m_uart_xmitfull)
360      if (m_tx_waiting >= MIDI_RING_SIZE)
351361      {
352362          return 0x80;
353363      }
r20663r20664
429439
430440         case 0x34:
431441            m_uart_midi = true;
432            m_uart_irq = true;
442            m_uart_irq = false;
433443            break;
434444
435445         case 0x35:
436446            m_uart_midi = true;
437            m_uart_irq = false;
447            m_uart_irq = true;
438448            break;
439449
440450         case 0x36:
r20663r20664
12281238   m_tx_busy = false;
12291239   m_xmit_read = m_xmit_write = 0;
12301240   m_recv_read = m_recv_write = 0;
1231   m_uart_xmitfull = false;
1241   m_rx_waiting = m_tx_waiting = false;
12321242
12331243   // MIDI is 31250 baud, 8-N-1
12341244   set_rcv_rate(31250);
r20663r20664
15341544   if (m_uart_midi)
15351545   {
15361546      m_recvring[m_recv_write++] = data;
1537
1538      // if not polling mode, trigger the DMA8 IRQ
1547      if (m_recv_write != m_recv_read)
1548      {
1549         m_rx_waiting++;
1550      }
15391551      if (m_uart_irq)
15401552      {
15411553         irq_w(1, IRQ_DMA8);
r20663r20664
15521564   if (m_uart_midi)
15531565   {
15541566      m_recvring[m_recv_write++] = data;
1555      irq_w(1, IRQ_DMA8);
1567      if (m_recv_write != m_recv_read)
1568      {
1569         m_rx_waiting++;
1570      }
1571      if (m_uart_irq)
1572      {
1573         irq_w(1, IRQ_DMA8);
1574      }
15561575   }
15571576
15581577   // in MPU MIDI mode, do this instead
r20663r20664
15711590{
15721591//   printf("Tx complete\n");
15731592   // is there more waiting to send?
1574   if ((m_xmit_read != m_xmit_write) || (m_uart_xmitfull))
1593   if (m_tx_waiting)
15751594   {
15761595      transmit_register_setup(m_xmitring[m_xmit_read++]);
15771596      if (m_xmit_read >= MIDI_RING_SIZE)
15781597      {
15791598         m_xmit_read = 0;
15801599      }
1581      m_uart_xmitfull = false;
1600      m_tx_waiting--;
15821601   }
15831602   else
15841603   {
r20663r20664
16101629      {
16111630         m_xmit_write = 0;
16121631      }
1613
1614      if (m_xmit_write == m_xmit_read)
1615      {
1616         m_uart_xmitfull = true;
1617      }
1632      m_tx_waiting++;
16181633   }
16191634}
16201635
trunk/src/mess/machine/isa_sblaster.h
r20663r20664
117117      DECLARE_WRITE8_MEMBER(dsp_rbuf_status_w);
118118      DECLARE_WRITE8_MEMBER(dsp_cmd_w);
119119
120      DECLARE_WRITE_LINE_MEMBER( midi_rx_w ) { check_for_start((UINT8)state); }
121
120122protected:
121123      // device-level overrides
122124      virtual void device_reset();
r20663r20664
140142      struct sb8_dsp_state m_dsp;
141143      UINT8 m_dack_out;
142144      void xmit_char(UINT8 data);
143      bool m_onebyte_midi, m_uart_midi, m_uart_irq, m_mpu_midi, m_uart_xmitfull;
145      bool m_onebyte_midi, m_uart_midi, m_uart_irq, m_mpu_midi;
146      int m_rx_waiting, m_tx_waiting;
144147      UINT8 m_recvring[MIDI_RING_SIZE];
145148      UINT8 m_xmitring[MIDI_RING_SIZE];
146149      int m_xmit_read, m_xmit_write;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team