Previous 199869 Revisions Next

r34714 Thursday 29th January, 2015 at 04:53:51 UTC by R. Belmont
(MESS) nes: MIDI In support for Miracle Piano [R. Belmont]
[src/emu/bus/nes_ctrl]ctrl.c miracle.c miracle.h

trunk/src/emu/bus/nes_ctrl/ctrl.c
r243225r243226
168168   SLOT_INTERFACE("joypad", NES_JOYPAD)
169169   SLOT_INTERFACE("zapper", NES_ZAPPER)
170170   SLOT_INTERFACE("4score_p1p3", NES_4SCORE_P1P3)
171//  SLOT_INTERFACE("miracle_piano", NES_MIRACLE)
171   SLOT_INTERFACE("miracle_piano", NES_MIRACLE)
172172SLOT_INTERFACE_END
173173
174174SLOT_INTERFACE_START( nes_control_port2_devices )
trunk/src/emu/bus/nes_ctrl/miracle.c
r243225r243226
2424
2525MACHINE_CONFIG_FRAGMENT( nes_miracle )
2626   MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
27   MCFG_MIDI_RX_HANDLER(WRITELINE(nes_miracle_device, rx_w))
28
2729   MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
2830MACHINE_CONFIG_END
2931
r243225r243226
99101   set_tra_rate(31250);
100102
101103   m_xmit_read = m_xmit_write = 0;
104   m_recv_read = m_recv_write = 0;
105   m_read_status = m_status_bit = false;
102106   m_tx_busy = false;
103107}
104108
r243225r243226
107111//  read
108112//-------------------------------------------------
109113
110// TODO: here, reads from serial midi in bit0, when in MIDI_SEND mode
111
112114UINT8 nes_miracle_device::read_bit0()
113115{
114116   UINT8 ret = 0;
115117
116118   if (m_midi_mode == MIRACLE_MIDI_RECEIVE)
117119   {
118      //NES reads from Miracle Piano!
119      // ret |= ...
120      if (m_status_bit)
121      {
122         m_status_bit = false;
123         ret = (m_read_status) ? 1 : 0;
124      }
125      else
126      {
127         ret = (m_data_sent & 0x80) ? 0 : 1;
128         m_data_sent <<= 1;
129      }
120130   }
121131
122132   return ret;
r243225r243226
126136//  write
127137//-------------------------------------------------
128138
129// TODO: here, writes to serial midi in bit0, when in MIDI_RECEIVE mode
130139// c4fc = start of recv routine
131140// c53a = start of send routine
132141
r243225r243226
175184            strobe_timer->reset();
176185            m_strobe_on = 0;
177186            m_strobe_clock = 0;
187
188            m_status_bit = true;
189            if (m_recv_read != m_recv_write)
190            {
191//               printf("Getting %02x from Miracle[%d]\n", m_recvring[m_recv_read], m_recv_read);
192               m_data_sent = m_recvring[m_recv_read++];
193               if (m_recv_read >= RECV_RING_SIZE)
194               {
195                  m_recv_read = 0;
196               }
197               m_read_status = true;
198            }
199            else
200            {
201               m_read_status = false;
202//               printf("Miracle has no data\n");
203            }
178204            return;
179205         }
180206         else if (m_strobe_clock >= 66)
r243225r243226
202228void nes_miracle_device::rcv_complete()    // Rx completed receiving byte
203229{
204230   receive_register_extract();
205//   UINT8 rcv = get_received_char();
231   UINT8 rcv = get_received_char();
232
233//   printf("Got %02x -> [%d]\n", rcv, m_recv_write);
234   m_recvring[m_recv_write++] = rcv;
235   if (m_recv_write >= RECV_RING_SIZE)
236   {
237      m_recv_write = 0;
238   }
206239}
207240
208241void nes_miracle_device::tra_complete()    // Tx completed sending byte
trunk/src/emu/bus/nes_ctrl/miracle.h
r243225r243226
2929{
3030public:
3131   static const int XMIT_RING_SIZE = 64;
32   static const int RECV_RING_SIZE = 64;
3233
3334   // construction/destruction
3435   nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r243225r243226
5960   int m_strobe_on, m_midi_mode, m_sent_bits;
6061   UINT32 m_strobe_clock;
6162   UINT8 m_data_sent;
62   UINT8 m_xmitring[XMIT_RING_SIZE];
63   UINT8 m_xmitring[XMIT_RING_SIZE], m_recvring[RECV_RING_SIZE];
6364   int m_xmit_read, m_xmit_write;
64   bool m_tx_busy;
65   int m_recv_read, m_recv_write;
66   bool m_tx_busy, m_read_status, m_status_bit;
6567};
6668
6769// device type definition


Previous 199869 Revisions Next


© 1997-2024 The MAME Team