Skip to content

Commit 9a5798e

Browse files
committed
upd7801: fix port C direction bits
1 parent bc01e71 commit 9a5798e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/devices/cpu/upd7810/upd7810.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,11 @@ uint8_t upd7810_device::read_pc()
719719

720720
uint8_t upd7801_device::read_pc()
721721
{
722+
const u8 inputs = 0x84 | (m_mc & 0x03);
723+
722724
if ((m_mc & 0x87) && !m_pc_in_cb.isunset()) // NS20031301 no need to read if the port is set as output
723-
m_pc_in = m_pc_in_cb(0, 0x84 | (m_mc & 0x03));
724-
uint8_t data = (m_pc_in & 0x87) | (m_pc_out & ~0x87);
725+
m_pc_in = m_pc_in_cb(0, inputs);
726+
uint8_t data = (m_pc_in & inputs) | (m_pc_out & ~inputs);
725727
if (!BIT(m_mc, 2)) /* TODO PC2 = -SCS input */
726728
data = (data & ~0x04) | 0x04;
727729
if (!BIT(m_mc, 7)) /* TODO PC7 = HOLD input */
@@ -810,12 +812,14 @@ void upd7810_device::write_pc(uint8_t data)
810812

811813
void upd7801_device::write_pc(uint8_t data)
812814
{
813-
data = (data & 0x78) | (m_pc_pullups & ~0x78);
815+
const u8 inputs = 0x84 | (m_mc & 0x03);
816+
817+
data = (data & ~inputs) | (m_pc_pullups & inputs);
814818
if (!BIT(m_mc, 3)) /* TODO PC3 = SAK output */
815819
data = (data & ~0x08);
816820
if (!BIT(m_mc, 4)) /* PC4 = TO output */
817821
data = (data & ~0x10) | (m_to & 1 ? 0x10 : 0x00);
818-
if (!BIT(m_mc, 5)) /* TODO PC5 = IO/-M input */
822+
if (!BIT(m_mc, 5)) /* TODO PC5 = IO/-M output */
819823
data = (data & ~0x20);
820824
if (!BIT(m_mc, 6)) /* TODO PC6 = HLDA output */
821825
data = (data & ~0x40);

0 commit comments

Comments
 (0)