diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-12-28 13:16:03 -0500 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-12-28 13:21:17 -0500 |
commit | 65bfb2654f0c73235f114e9145c766245bed9790 (patch) | |
tree | 2ae962f10081e6f03f89b5682e851dd53818ecad | |
parent | 0d6f9037fd40b169f0a4b555675089ccb0687931 (diff) |
diserial: Actually check parity of received bytes in modes other than PARITY_NONE; fix transmission of parity bit in PARITY_EVEN mode
i8251: Flag parity and framing errors in status register
-rw-r--r-- | src/devices/machine/i8251.cpp | 4 | ||||
-rw-r--r-- | src/emu/diserial.cpp | 52 |
2 files changed, 26 insertions, 30 deletions
diff --git a/src/devices/machine/i8251.cpp b/src/devices/machine/i8251.cpp index 27d8ed7e641..773262b617e 100644 --- a/src/devices/machine/i8251.cpp +++ b/src/devices/machine/i8251.cpp @@ -145,6 +145,10 @@ void i8251_device::receive_clock() if (is_receive_register_full()) { receive_register_extract(); + if (is_receive_parity_error()) + m_status |= I8251_STATUS_PARITY_ERROR; + if (is_receive_framing_error()) + m_status |= I8251_STATUS_FRAMING_ERROR; receive_character(get_received_char()); } } diff --git a/src/emu/diserial.cpp b/src/emu/diserial.cpp index 01bb07bf8c7..dc508324852 100644 --- a/src/emu/diserial.cpp +++ b/src/emu/diserial.cpp @@ -308,41 +308,31 @@ void device_serial_interface::receive_register_extract() if(m_df_parity == PARITY_NONE) return; - //unsigned char computed_parity; - //unsigned char parity_received; - /* get state of parity bit received */ - //parity_received = (m_rcv_register_data>>m_df_word length) & 0x01; + u8 parity_received = (m_rcv_register_data >> (16 - m_rcv_bit_count + m_df_word_length)) & 0x01; /* parity enable? */ switch (m_df_parity) { - /* check parity */ - case PARITY_ODD: - case PARITY_EVEN: - { - /* compute parity for received bits */ - //computed_parity = serial_helper_get_parity(data); - - if (m_df_parity == PARITY_ODD) - { - /* odd parity */ - - - } - else - { - /* even parity */ + case PARITY_ODD: + if (parity_received != serial_helper_get_parity(data)) + m_rcv_parity_error = true; + break; + case PARITY_EVEN: + if (parity_received == serial_helper_get_parity(data)) + m_rcv_parity_error = true; + break; - } + case PARITY_MARK: + if (!parity_received) + m_rcv_parity_error = true; + break; - } + case PARITY_SPACE: + if (parity_received) + m_rcv_parity_error = true; break; - case PARITY_MARK: - case PARITY_SPACE: - //computed_parity = parity_received; - break; } } @@ -369,7 +359,7 @@ void device_serial_interface::transmit_register_add_bit(int bit) void device_serial_interface::transmit_register_setup(u8 data_byte) { int i; - unsigned char transmit_data; + u8 transmit_data; if(m_tra_clock && !m_tra_rate.is_never()) m_tra_clock->adjust(m_tra_rate, 0, m_tra_rate); @@ -401,10 +391,9 @@ void device_serial_interface::transmit_register_setup(u8 data_byte) if (m_df_parity!=PARITY_NONE) { /* odd or even parity */ - unsigned char parity = 0; - switch(m_df_parity) + u8 parity = 0; + switch (m_df_parity) { - case PARITY_EVEN: case PARITY_ODD: /* get parity */ @@ -412,6 +401,9 @@ void device_serial_interface::transmit_register_setup(u8 data_byte) /* if parity = 1, data has odd parity - i.e. there is an odd number of one bits in the data */ parity = serial_helper_get_parity(data_byte); break; + case PARITY_EVEN: + parity = serial_helper_get_parity(data_byte) ^ 1; + break; case PARITY_MARK: parity = 1; break; |