trunk/src/emu/bus/nes_ctrl/miracle.c
| r243212 | r243213 | |
| 2 | 2 | |
| 3 | 3 | Nintendo Entertainment System - Miracle Piano Keyboard |
| 4 | 4 | |
| 5 | | TODO: basically everything, this is just a skeleton with no |
| 6 | | real MIDI handling at the moment. |
| 5 | TODO: MIDI input, output is now working. |
| 7 | 6 | |
| 8 | 7 | Copyright MESS Team. |
| 9 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| r243212 | r243213 | |
| 13 | 12 | #include "miracle.h" |
| 14 | 13 | |
| 15 | 14 | #define MIRACLE_MIDI_WAITING 0 |
| 16 | | #define MIRACLE_MIDI_RECEIVE 1 // receive byte from piano |
| 17 | | #define MIRACLE_MIDI_SEND 2 // send byte to piano |
| 15 | #define MIRACLE_MIDI_RECEIVE 1 // receive byte from piano |
| 16 | #define MIRACLE_MIDI_SEND 2 // send byte to piano |
| 18 | 17 | |
| 19 | 18 | //************************************************************************** |
| 20 | 19 | // DEVICE DEFINITIONS |
| r243212 | r243213 | |
| 44 | 43 | { |
| 45 | 44 | m_strobe_clock++; |
| 46 | 45 | } |
| 46 | else |
| 47 | { |
| 48 | device_serial_interface::device_timer(timer, id, param, ptr); |
| 49 | } |
| 47 | 50 | } |
| 48 | 51 | |
| 49 | 52 | //************************************************************************** |
| r243212 | r243213 | |
| 129 | 132 | |
| 130 | 133 | void nes_miracle_device::write(UINT8 data) |
| 131 | 134 | { |
| 132 | | // printf("write: %d (%d %02x %d)\n", data & 1, m_sent_bits, m_data_sent, m_midi_mode); |
| 135 | // printf("write: %d (%d %02x %d)\n", data & 1, m_sent_bits, m_data_sent, m_midi_mode); |
| 133 | 136 | |
| 134 | 137 | if (m_midi_mode == MIRACLE_MIDI_SEND) |
| 135 | 138 | { |
| r243212 | r243213 | |
| 142 | 145 | // then we go back to waiting |
| 143 | 146 | if (m_sent_bits == 8) |
| 144 | 147 | { |
| 145 | | // printf("xmit MIDI byte %02x\n", m_data_sent); |
| 148 | // printf("xmit MIDI byte %02x\n", m_data_sent); |
| 146 | 149 | xmit_char(m_data_sent); |
| 147 | 150 | m_midi_mode = MIRACLE_MIDI_WAITING; |
| 148 | 151 | m_sent_bits = 0; |
| r243212 | r243213 | |
| 163 | 166 | // was timer running? |
| 164 | 167 | if (m_strobe_clock > 0) |
| 165 | 168 | { |
| 166 | | // printf("got strobe at %d clocks\n", m_strobe_clock); |
| 169 | // printf("got strobe at %d clocks\n", m_strobe_clock); |
| 167 | 170 | |
| 168 | 171 | if (m_strobe_clock < 66 && data == 0) |
| 169 | 172 | { |
| r243212 | r243213 | |
| 199 | 202 | void nes_miracle_device::rcv_complete() // Rx completed receiving byte |
| 200 | 203 | { |
| 201 | 204 | receive_register_extract(); |
| 202 | | // UINT8 rcv = get_received_char(); |
| 205 | // UINT8 rcv = get_received_char(); |
| 203 | 206 | } |
| 204 | 207 | |
| 205 | 208 | void nes_miracle_device::tra_complete() // Tx completed sending byte |
| 206 | 209 | { |
| 207 | | // printf("Tx complete\n"); |
| 208 | 210 | // is there more waiting to send? |
| 209 | 211 | if (m_xmit_read != m_xmit_write) |
| 210 | 212 | { |
| r243212 | r243213 | |
| 222 | 224 | |
| 223 | 225 | void nes_miracle_device::tra_callback() // Tx send bit |
| 224 | 226 | { |
| 227 | UINT8 bit = transmit_register_get_data_bit(); |
| 228 | |
| 225 | 229 | // send this to midi out |
| 226 | | m_midiout->write_txd(transmit_register_get_data_bit()); |
| 230 | m_midiout->write_txd(bit); |
| 227 | 231 | } |
| 228 | 232 | |
| 229 | 233 | void nes_miracle_device::xmit_char(UINT8 data) |
| 230 | 234 | { |
| 231 | | // printf("xmit %02x\n", data); |
| 232 | | |
| 233 | 235 | // if tx is busy it'll pick this up automatically when it completes |
| 234 | 236 | // if not, send now! |
| 235 | 237 | if (!m_tx_busy) |
| r243212 | r243213 | |
| 247 | 249 | } |
| 248 | 250 | } |
| 249 | 251 | } |
| 252 | |