void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { if (id) { device_serial_interface::device_timer(timer, id, param, ptr); return; } UINT8 buf[8192*4]; int bytesRead; if (m_midi == NULL) { return; } while (m_midi->poll()) { bytesRead = m_midi->read(buf); if (bytesRead > 0) { for (int i = 0; i < bytesRead; i++) { xmit_char(buf[i]); } } } }
static void rs_put_char(struct s3c3410_serial *info, char ch) { unsigned long flags = 0; save_flags(flags); cli(); xmit_char(info, ch); restore_flags(flags); }
void apollo_kbd_device::putdata(const UINT8 *data, int data_length) { // send data only if no real Apollo keyboard has been connected if (m_mode > KBD_MODE_1_KEYSTATE) { set_mode(KBD_MODE_1_KEYSTATE); } for (int i = 0; i < data_length; i++) { xmit_char(data[i]); } }
void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { UINT8 buf[8192*4]; int bytesRead; if (m_midi == NULL) { return; } while (osd_poll_midi_channel(m_midi)) { bytesRead = osd_read_midi_channel(m_midi, buf); if (bytesRead > 0) { for (int i = 0; i < bytesRead; i++) { xmit_char(buf[i]); } } } }
void snes_miracle_device::write_strobe(UINT8 data) { // printf("%02x to strobe\n", data); if (m_midi_mode == MIRACLE_MIDI_SEND) { // console writes (data & 1) to Miracle Piano. // 1st write is data present flag (1=data present) // next 8 writes are actual data bits (with ^1) m_sent_bits++; m_data_sent <<= 1; m_data_sent |= (data & 1); // then we go back to waiting if (m_sent_bits == 8) { // printf("xmit MIDI byte %02x\n", m_data_sent); xmit_char(m_data_sent); m_midi_mode = MIRACLE_MIDI_WAITING; m_sent_bits = 0; } return; } if (data == 1 && !m_strobe_on) { strobe_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1)); m_strobe_on = 1; return; } if (m_strobe_on) { // was timer running? if (m_strobe_clock > 0) { // printf("got strobe at %d clocks\n", m_strobe_clock); if (m_strobe_clock < 500 && data == 0) { // short delay is receive mode m_midi_mode = MIRACLE_MIDI_RECEIVE; strobe_timer->reset(); m_strobe_on = 0; m_strobe_clock = 0; m_status_bit = true; if (m_recv_read != m_recv_write) { // printf("Getting %02x from Miracle[%d]\n", m_recvring[m_recv_read], m_recv_read); m_data_sent = m_recvring[m_recv_read++]; if (m_recv_read >= RECV_RING_SIZE) { m_recv_read = 0; } m_read_status = true; } else { m_read_status = false; // printf("Miracle has no data\n"); } return; } else if (m_strobe_clock >= 500) { // more than ~520 clocks since strobe on write means send mode // (ranges from 522-528 have been seen) m_midi_mode = MIRACLE_MIDI_SEND; strobe_timer->reset(); m_strobe_on = 0; m_strobe_clock = 0; m_sent_bits = 1; m_data_sent <<= 1; m_data_sent |= (data & 1); return; } } if (m_midi_mode == MIRACLE_MIDI_SEND && data == 0) { // strobe off after the end of a byte m_midi_mode = MIRACLE_MIDI_WAITING; } } }
void apollo_kbd_device::set_mode(UINT16 mode) { xmit_char(0xff); xmit_char(mode); m_mode = mode; }
void esqpanel_device::rcv_complete() // Rx completed receiving byte { receive_register_extract(); UINT8 data = get_received_char(); // if (data >= 0xe0) printf("Got %02x from motherboard (second %s)\n", data, m_bCalibSecondByte ? "yes" : "no"); send_to_display(data); if (m_bCalibSecondByte) { // printf("second byte is %02x\n", data); if (data == 0xfd) // calibration request { // printf("let's send reply!\n"); xmit_char(0xff); // this is the correct response for "calibration OK" } m_bCalibSecondByte = false; } else if (m_bButtonLightSecondByte) { // Lights on the Buttons, on the VFX-SD: // Number Button // 0 1-6 // 1 8 // 2 6 // 3 4 // 4 2 // 5 Compare // 6 1 // 7 Presets // 8 7-12 // 9 9 // a 7 // b 5 // c 3 // d Sounds // e 0 // f Cart // int lightNumber = data & 0x3f; // Light states: // 0 = Off // 2 = On // 3 = Blinking // int lightState = (data & 0xc0) >> 6; // TODO: do something with the button information! // printf("Setting light %d to %s\n", lightNumber, lightState == 3 ? "Blink" : lightState == 2 ? "On" : "Off"); m_bButtonLightSecondByte = false; } else if (data == 0xfb) // request calibration { m_bCalibSecondByte = true; } else if (data == 0xff) // button light state command { m_bButtonLightSecondByte = true; } else { // EPS wants a throwaway reply byte for each byte sent to the KPC // VFX-SD and SD-1 definitely don't :) if (m_eps_mode) { if (data == 0xe7) { xmit_char(0x00); // actual value of response is never checked } else if (data == 0x71) { xmit_char(0x00); // actual value of response is never checked } else { xmit_char(data); // actual value of response is never checked } } } }