Previous 199869 Revisions Next

r20665 Saturday 2nd February, 2013 at 04:29:30 UTC by R. Belmont
(MESS) isa_sblaster: fully hooked up MPU-401 input and output for SB16 [R. Belmont]
[src/mess/machine]isa_sblaster.c isa_sblaster.h

trunk/src/mess/machine/isa_sblaster.c
r20664r20665
284284   m_tx_busy = false;
285285   m_xmit_read = m_xmit_write = 0;
286286   m_recv_read = m_recv_write = 0;
287   m_rx_waiting = m_tx_waiting = false;
287   m_rx_waiting = m_tx_waiting = 0;
288288
289289   //printf("%02x\n",data);
290290}
r20664r20665
298298   if (m_uart_midi)
299299   {
300300      UINT8 rv = m_recvring[m_recv_read++];
301      if (m_recv_read >= MIDI_RING_SIZE)
302      {
303         m_recv_read = 0;
304      }
305
301306      if (m_rx_waiting)
302307      {
303308         m_rx_waiting--;
r20664r20665
777782   irq_w(0, IRQ_MPU);
778783   if(offset == 0) // data
779784   {
780      if(m_head != m_tail)
785      res = m_recvring[m_recv_read++];
786      if (m_recv_read >= MIDI_RING_SIZE)
781787      {
782         res = m_mpu_queue[m_tail++];
783         m_tail %= 16;
788         m_recv_read = 0;
784789      }
785      else
786         res = 0xff;
790
791      if (m_rx_waiting)
792      {
793         m_rx_waiting--;
794      }
787795   }
788796   else // status
789797   {
790      res = ((m_head != m_tail)?0:0x80) | 0x3f; // bit 7 queue empty (DSR), bit 6 DRR (Data Receive Ready?)
798      res = 0;
799      if (m_tx_waiting >= MIDI_RING_SIZE)
800      {
801         res |= 0x40;   // tx full
802      }
803      if (m_rx_waiting == 0)
804      {
805         res |= 0x80;   // rx empty
806      }
791807   }
792808
793809   return res;
r20664r20665
811827      {
812828         case 0x3f: // enter MPU-401 UART mode
813829            irq_w(1, IRQ_MPU);
814            m_head = m_tail = 0;
815            m_mpu_queue[m_head++] = 0xfe;
830            m_recv_read = m_recv_write = 0;
831            m_xmit_read = m_xmit_write = m_tx_waiting = 0;
832            m_recvring[m_recv_write++] = 0xfe;
833            m_rx_waiting = 1;
816834            m_mpu_midi = true;
817835            break;
818836
819837         case 0xff: // reset
820838            irq_w(1, IRQ_MPU);
821            m_head = m_tail = 0;
822            m_mpu_queue[m_head++] = 0xfe;
839            m_recv_read = m_recv_write = 0;
840            m_recvring[m_recv_write++] = 0xfe;
841            m_rx_waiting = 1;
823842            m_mpu_midi = false;
824843            break;
825844      }
r20664r20665
11991218   m_isa->install_device(subdevice("ymf262"),    0x0220, 0x0223, 0, 0, FUNC(ymf262_r), FUNC(ymf262_w) );
12001219   m_isa->install_device(subdevice("ymf262"),    0x0228, 0x0229, 0, 0, FUNC(ymf262_r), FUNC(ymf262_w) );
12011220
1202   m_head = 0;
1203   m_tail = 0;
12041221   m_timer = timer_alloc(0, NULL);
12051222}
12061223
r20664r20665
12381255   m_tx_busy = false;
12391256   m_xmit_read = m_xmit_write = 0;
12401257   m_recv_read = m_recv_write = 0;
1241   m_rx_waiting = m_tx_waiting = false;
1258   m_rx_waiting = m_tx_waiting = 0;
12421259
12431260   // MIDI is 31250 baud, 8-N-1
12441261   set_rcv_rate(31250);
r20664r20665
15441561   if (m_uart_midi)
15451562   {
15461563      m_recvring[m_recv_write++] = data;
1564      if (m_recv_write >= MIDI_RING_SIZE)
1565      {
1566         m_recv_write = 0;
1567      }
1568
15471569      if (m_recv_write != m_recv_read)
15481570      {
15491571         m_rx_waiting++;
r20664r20665
15601582   receive_register_extract();
15611583   UINT8 data = get_received_char();
15621584
1563   // in UART MIDI mode, we set the DMA8 IRQ on receiving a character
1564   if (m_uart_midi)
1585   // for UART or MPU, add character to the receive queue
1586   if (m_uart_midi || m_mpu_midi)
15651587   {
15661588      m_recvring[m_recv_write++] = data;
1589      if (m_recv_write >= MIDI_RING_SIZE)
1590      {
1591         m_recv_write = 0;
1592      }
1593
15671594      if (m_recv_write != m_recv_read)
15681595      {
15691596         m_rx_waiting++;
15701597      }
1598
15711599      if (m_uart_irq)
15721600      {
15731601         irq_w(1, IRQ_DMA8);
15741602      }
1575   }
15761603
1577   // in MPU MIDI mode, do this instead
1578   if (m_mpu_midi)
1579   {
1580      m_mpu_queue[m_head++] = data;
1581      if (m_head >= 16)
1604      if (m_mpu_midi)
15821605      {
1583         m_head = 0;
1606         irq_w(1, IRQ_MPU);
15841607      }
1585      irq_w(1, IRQ_MPU);
15861608   }
15871609}
15881610
trunk/src/mess/machine/isa_sblaster.h
r20664r20665
222222      void mixer_set();
223223      virtual void rcv_complete();    // Rx completed receiving byte
224224private:
225      UINT8 m_mpu_queue[16];
226      UINT8 m_tail;
227      UINT8 m_head;
228225      struct sb16_mixer m_mixer;
229226};
230227

Previous 199869 Revisions Next


© 1997-2024 The MAME Team