From 226605c8eca4d4f1a731251114cf2c092bdbe6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20DEL=20NERO?= Date: Tue, 1 Feb 2022 13:21:19 +0100 Subject: [PATCH] Minitel 2 driver : 24C02 I2C EEPROM support. (#9232) * minitel_2_rpic.cpp: Fix O and Q keys. * minitel_2_rpic.cpp: 24C02 I2C EEPROM support implemented. Password and others internals settings are now saved in the nvram folder. * minitel_2_rpic.cpp: move the "Fonction" key from F9 to Alt-Gr. * minitel_2_rpic.cpp: Fix the control register bits assignations. The previous definitions was definitively wrong (checked against the real hardware). --- src/mame/drivers/minitel_2_rpic.cpp | 37 +++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/mame/drivers/minitel_2_rpic.cpp b/src/mame/drivers/minitel_2_rpic.cpp index 3718ed40813..24976ea9e07 100644 --- a/src/mame/drivers/minitel_2_rpic.cpp +++ b/src/mame/drivers/minitel_2_rpic.cpp @@ -20,12 +20,12 @@ - Main MCU - Video output - Keyboard + - 24C02 EPROM What is not yet implemented : - Modem and sound output. - The rear serial port. - - Parameters I2C 24C02 EEPROM. - Screen should go blank when switched off The original firmware and the experimental demo rom are currently both working. @@ -40,8 +40,8 @@ F6 -> Guide F7 -> Sommaire F8 -> Connexion/Fin - F9 -> Fonction F10-> ON / OFF + Alt Gr -> Fonction With the official ROM you need to press F10 to switch on the CRT. @@ -50,6 +50,7 @@ #include "emu.h" #include "cpu/mcs51/mcs51.h" +#include "machine/i2cmem.h" #include "machine/timer.h" #include "video/ef9345.h" @@ -62,11 +63,11 @@ // IO expander latch usage definitions enum { - CTRL_REG_DTMF = 0x02, - CTRL_REG_MCBC = 0x04, - CTRL_REG_OPTO = 0x08, - CTRL_REG_RELAY = 0x10, - CTRL_REG_CRTON = 0x20 + CTRL_REG_MCBC = 0x01, + CTRL_REG_DTMF = 0x02, + CTRL_REG_CRTON = 0x08, + CTRL_REG_OPTO = 0x10, + CTRL_REG_RELAY = 0x20 }; // 80C32 Port IO usage definitions @@ -90,6 +91,7 @@ public: , m_maincpu(*this, "maincpu") , m_ts9347(*this, "ts9347") , m_palette(*this, "palette") + , m_i2cmem(*this, "i2cmem") , m_io_kbd(*this, "Y%u", 0) { } @@ -100,6 +102,7 @@ private: required_device m_maincpu; required_device m_ts9347; required_device m_palette; + required_device m_i2cmem; TIMER_DEVICE_CALLBACK_MEMBER(minitel_scanline); @@ -108,7 +111,7 @@ private: uint8_t port1_r(); uint8_t port3_r(); - void dev_crtl_reg_w(offs_t offset, uint8_t data); + void dev_ctrl_reg_w(offs_t offset, uint8_t data); uint8_t dev_keyb_ser_r(offs_t offset); uint8_t ts9347_io_r(offs_t offset); @@ -182,11 +185,13 @@ void minitel_state::port1_w(uint8_t data) if( (port1 ^ data) & PORT_1_SCL ) { LOG("PORT_1_SCL : %d \n", data & PORT_1_SCL ); + m_i2cmem->write_scl( (data & PORT_1_SCL) ? 1 : 0); } if( (port1 ^ data) & PORT_1_SDA ) { LOG("PORT_1_SDA : %d \n", data & PORT_1_SDA ); + m_i2cmem->write_sda( (data & PORT_1_SDA) ? 1 : 0); } port1 = data; @@ -200,8 +205,14 @@ void minitel_state::port3_w(uint8_t data) uint8_t minitel_state::port1_r() { + uint8_t data; + LOG("port_r: read %02X from PORT1 - Keyboard -> %x\n", port1,((keyboard_x_row_reg>>7)&1)); - return ( (port1&0xFE) | ((keyboard_x_row_reg>>7)&1) ) ; + + data = ( ( (port1 & (0xFE & ~PORT_1_SDA) ) | ( (keyboard_x_row_reg>>7)&1) ) ); + data |= (m_i2cmem->read_sda() ? PORT_1_SDA : 0); + + return data; } uint8_t minitel_state::port3_r() @@ -210,7 +221,7 @@ uint8_t minitel_state::port3_r() return port3; } -void minitel_state::dev_crtl_reg_w(offs_t offset, uint8_t data) +void minitel_state::dev_ctrl_reg_w(offs_t offset, uint8_t data) { if( last_ctrl_reg != data) { @@ -288,7 +299,7 @@ void minitel_state::mem_prg(address_map &map) void minitel_state::mem_io(address_map &map) { - map(0x2000, 0x3fff).rw(FUNC(minitel_state::dev_keyb_ser_r), FUNC(minitel_state::dev_crtl_reg_w)); + map(0x2000, 0x3fff).rw(FUNC(minitel_state::dev_keyb_ser_r), FUNC(minitel_state::dev_ctrl_reg_w)); /* ts9347 */ map(0x4000, 0x5ffF).rw(FUNC(minitel_state::ts9347_io_r), FUNC(minitel_state::ts9347_io_w)); } @@ -311,7 +322,7 @@ static INPUT_PORTS_START( minitel2 ) PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Connexion/Fin") PORT_CODE(KEYCODE_F8) - PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Fonction") PORT_CODE(KEYCODE_F9) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Fonction") PORT_CODE(KEYCODE_RALT) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT) // Right maj PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) // Left maj @@ -412,6 +423,8 @@ void minitel_state::minitel2(machine_config &config) m_maincpu->port_in_cb<3>().set(FUNC(minitel_state::port3_r)); m_maincpu->port_out_cb<3>().set(FUNC(minitel_state::port3_w)); + I2C_24C02(config, m_i2cmem); + TS9347(config, m_ts9347, 0); m_ts9347->set_palette_tag(m_palette);