trunk/src/mess/machine/3c505.c
| r21733 | r21734 | |
| 642 | 642 | // m_response.data.rcv_resp.buf_ofs = htole16(0); |
| 643 | 643 | // m_response.data.rcv_resp.buf_seg = htole16(0); |
| 644 | 644 | // m_response.data.rcv_resp.buf_len = htole16(buf_len); |
| 645 | | m_response.data.rcv_resp.pkt_len = htole16(m_rx_data_buffer.get_length()); |
| 646 | | m_response.data.rcv_resp.timeout = htole16(0); // successful completion |
| 647 | | m_response.data.rcv_resp.status = htole16(m_rx_data_buffer.get_length() > 0 ? 0 : 0xffff); |
| 648 | | m_response.data.rcv_resp.timetag = htole32(0); // TODO: time tag |
| 649 | 645 | |
| 646 | // htole16 and friends are not portable beyond Linux. It's named differently on *BSD and differently again on OS X. Avoid! |
| 647 | #ifdef LSB_FIRST |
| 648 | m_response.data.rcv_resp.pkt_len = m_rx_data_buffer.get_length(); |
| 649 | m_response.data.rcv_resp.timeout = 0; // successful completion |
| 650 | m_response.data.rcv_resp.status = m_rx_data_buffer.get_length() > 0 ? 0 : 0xffff; |
| 651 | m_response.data.rcv_resp.timetag = 0; // TODO: time tag |
| 652 | #else |
| 653 | UINT16 temp; |
| 654 | temp = m_rx_data_buffer.get_length(); |
| 655 | m_response.data.rcv_resp.pkt_len = (temp << 8) | (temp>>8); |
| 656 | m_response.data.rcv_resp.timeout = 0; // successful completion |
| 657 | temp = m_rx_data_buffer.get_length() > 0 ? 0 : 0xffff; |
| 658 | m_response.data.rcv_resp.status = (temp << 8) | (temp>>8); |
| 659 | m_response.data.rcv_resp.timetag = 0; // TODO: time tag |
| 660 | #endif |
| 661 | |
| 650 | 662 | // compute and check no of bytes to be DMA'ed (must be even) |
| 651 | | UINT16 buf_len = le16toh(m_response.data.rcv_resp.buf_len) & ~1; |
| 663 | #ifdef LSB_FIRST |
| 664 | UINT16 buf_len = m_response.data.rcv_resp.buf_len & ~1; |
| 665 | #else |
| 666 | UINT16 buf_len = ((m_response.data.rcv_resp.buf_len&0xff)<<8) || ((m_response.data.rcv_resp.buf_len&0xff00)>>8) & ~1; |
| 667 | #endif |
| 652 | 668 | if (m_rx_data_buffer.get_length() > buf_len) |
| 653 | 669 | { |
| 654 | 670 | LOG1(("do_receive_command !!! buffer size too small (%d < %d)", buf_len, m_rx_data_buffer.get_length())); |
| 655 | | m_response.data.rcv_resp.pkt_len = htole16(buf_len); |
| 671 | #ifdef LSB_FIRST |
| 672 | m_response.data.rcv_resp.pkt_len = buf_len; |
| 673 | #else |
| 674 | m_response.data.rcv_resp.pkt_len = ((buf_len & 0xff)<<8) | ((buf_len & 0xff00)>>8); |
| 675 | #endif |
| 656 | 676 | m_response.data.rcv_resp.status = 0xffff; |
| 657 | 677 | } |
| 658 | 678 | else |
| 659 | 679 | { |
| 660 | 680 | buf_len = (m_rx_data_buffer.get_length() + 1) & ~1; |
| 661 | | m_response.data.rcv_resp.buf_len = htole16(buf_len); |
| 681 | #ifdef LSB_FIRST |
| 682 | m_response.data.rcv_resp.pkt_len = buf_len; |
| 683 | #else |
| 684 | m_response.data.rcv_resp.pkt_len = ((buf_len & 0xff)<<8) | ((buf_len & 0xff00)>>8); |
| 685 | #endif |
| 662 | 686 | } |
| 663 | 687 | |
| 664 | 688 | m_response_length = m_response.length + 2; |