diff --git a/src/emu/cpu/mcs51/mcs51.c b/src/emu/cpu/mcs51/mcs51.c index c212047e739..5cac651371c 100644 --- a/src/emu/cpu/mcs51/mcs51.c +++ b/src/emu/cpu/mcs51/mcs51.c @@ -286,6 +286,11 @@ mcs51_cpu_device::mcs51_cpu_device(const machine_config &mconfig, device_type ty m_ds5002fp.mcon = 0; m_ds5002fp.rpctl = 0; m_ds5002fp.crc = 0; + + /* default to standard cmos interfacing */ + + for (int i=0; i < ARRAY_LENGTH(m_forced_inputs); i++) + m_forced_inputs[i] = 0; } @@ -2079,10 +2084,10 @@ UINT8 mcs51_cpu_device::sfr_read(size_t offset) { /* Read/Write/Modify operations read the port latch ! */ /* Move to memory map */ - case ADDR_P0: return RWM ? P0 : P0 & IN(MCS51_PORT_P0); - case ADDR_P1: return RWM ? P1 : P1 & IN(MCS51_PORT_P1); - case ADDR_P2: return RWM ? P2 : P2 & IN(MCS51_PORT_P2); - case ADDR_P3: return RWM ? P3 : P3 & IN(MCS51_PORT_P3); + case ADDR_P0: return RWM ? P0 : (P0 | m_forced_inputs[0]) & IN(MCS51_PORT_P0); + case ADDR_P1: return RWM ? P1 : (P1 | m_forced_inputs[1]) & IN(MCS51_PORT_P1); + case ADDR_P2: return RWM ? P2 : (P2 | m_forced_inputs[2]) & IN(MCS51_PORT_P2); + case ADDR_P3: return RWM ? P3 : (P3 | m_forced_inputs[3]) & IN(MCS51_PORT_P3); case ADDR_PSW: case ADDR_ACC: diff --git a/src/emu/cpu/mcs51/mcs51.h b/src/emu/cpu/mcs51/mcs51.h index 50069ae3070..cb33c4f9252 100644 --- a/src/emu/cpu/mcs51/mcs51.h +++ b/src/emu/cpu/mcs51/mcs51.h @@ -72,6 +72,16 @@ enum MCS51_PORT_TX = 0x20004, /* P3.1 */ }; +/* At least CMOS devices may be forced to read from ports configured as output. + * All you need is a low impedance output connect to the port. + */ + +#define MCFG_MCS51_PORT1_CONFIG(_forced_inputs) \ + mcs51_cpu_device::set_port_forced_input(*device, 1, _forced_inputs); +#define MCFG_MCS51_PORT2_CONFIG(_forced_inputs) \ + mcs51_cpu_device::set_port_forced_input(*device, 2, _forced_inputs); +#define MCFG_MCS51_PORT3_CONFIG(_forced_inputs) \ + mcs51_cpu_device::set_port_forced_input(*device, 3, _forced_inputs); class mcs51_cpu_device : public cpu_device { @@ -82,6 +92,9 @@ public: void i8051_set_serial_tx_callback(write8_delegate tx_func); void i8051_set_serial_rx_callback(read8_delegate rx_func); + // configuration helpers + static void set_port_forced_input(device_t &device, UINT8 port, UINT8 forced_input) { downcast(device).m_forced_inputs[port] = forced_input; } + protected: // device-level overrides virtual void device_start(); @@ -137,6 +150,8 @@ protected: UINT8 m_irq_active; /* mask which irq levels are serviced */ UINT8 m_irq_prio[8]; /* interrupt priority */ + UINT8 m_forced_inputs[4]; /* allow read even if configured as output */ + int m_icount; struct mcs51_uart