trunk/src/emu/bus/nes_ctrl/miracle.c
| r243225 | r243226 | |
| 24 | 24 | |
| 25 | 25 | MACHINE_CONFIG_FRAGMENT( nes_miracle ) |
| 26 | 26 | MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin") |
| 27 | MCFG_MIDI_RX_HANDLER(WRITELINE(nes_miracle_device, rx_w)) |
| 28 | |
| 27 | 29 | MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout") |
| 28 | 30 | MACHINE_CONFIG_END |
| 29 | 31 | |
| r243225 | r243226 | |
| 99 | 101 | set_tra_rate(31250); |
| 100 | 102 | |
| 101 | 103 | m_xmit_read = m_xmit_write = 0; |
| 104 | m_recv_read = m_recv_write = 0; |
| 105 | m_read_status = m_status_bit = false; |
| 102 | 106 | m_tx_busy = false; |
| 103 | 107 | } |
| 104 | 108 | |
| r243225 | r243226 | |
| 107 | 111 | // read |
| 108 | 112 | //------------------------------------------------- |
| 109 | 113 | |
| 110 | | // TODO: here, reads from serial midi in bit0, when in MIDI_SEND mode |
| 111 | | |
| 112 | 114 | UINT8 nes_miracle_device::read_bit0() |
| 113 | 115 | { |
| 114 | 116 | UINT8 ret = 0; |
| 115 | 117 | |
| 116 | 118 | if (m_midi_mode == MIRACLE_MIDI_RECEIVE) |
| 117 | 119 | { |
| 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 | } |
| 120 | 130 | } |
| 121 | 131 | |
| 122 | 132 | return ret; |
| r243225 | r243226 | |
| 126 | 136 | // write |
| 127 | 137 | //------------------------------------------------- |
| 128 | 138 | |
| 129 | | // TODO: here, writes to serial midi in bit0, when in MIDI_RECEIVE mode |
| 130 | 139 | // c4fc = start of recv routine |
| 131 | 140 | // c53a = start of send routine |
| 132 | 141 | |
| r243225 | r243226 | |
| 175 | 184 | strobe_timer->reset(); |
| 176 | 185 | m_strobe_on = 0; |
| 177 | 186 | 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 | } |
| 178 | 204 | return; |
| 179 | 205 | } |
| 180 | 206 | else if (m_strobe_clock >= 66) |
| r243225 | r243226 | |
| 202 | 228 | void nes_miracle_device::rcv_complete() // Rx completed receiving byte |
| 203 | 229 | { |
| 204 | 230 | 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 | } |
| 206 | 239 | } |
| 207 | 240 | |
| 208 | 241 | void nes_miracle_device::tra_complete() // Tx completed sending byte |
trunk/src/emu/bus/nes_ctrl/miracle.h
| r243225 | r243226 | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | static const int XMIT_RING_SIZE = 64; |
| 32 | static const int RECV_RING_SIZE = 64; |
| 32 | 33 | |
| 33 | 34 | // construction/destruction |
| 34 | 35 | nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| r243225 | r243226 | |
| 59 | 60 | int m_strobe_on, m_midi_mode, m_sent_bits; |
| 60 | 61 | UINT32 m_strobe_clock; |
| 61 | 62 | UINT8 m_data_sent; |
| 62 | | UINT8 m_xmitring[XMIT_RING_SIZE]; |
| 63 | UINT8 m_xmitring[XMIT_RING_SIZE], m_recvring[RECV_RING_SIZE]; |
| 63 | 64 | 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; |
| 65 | 67 | }; |
| 66 | 68 | |
| 67 | 69 | // device type definition |