From c37d2a946d133a2d29f3a33914b8cd032d9c3cbf Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Wed, 8 Mar 2023 08:54:51 +0200 Subject: abc1600: Cleanup --- src/devices/bus/abckb/abc77.cpp | 91 ++++++++-------------------------- src/devices/bus/abckb/abc77.h | 17 +++---- src/devices/bus/abckb/abc99.cpp | 107 +++++++++++++++++++++++----------------- src/devices/bus/abckb/abc99.h | 14 ++++-- src/devices/cpu/mcs48/mcs48.h | 3 ++ 5 files changed, 102 insertions(+), 130 deletions(-) diff --git a/src/devices/bus/abckb/abc77.cpp b/src/devices/bus/abckb/abc77.cpp index 442ff553e2f..38f8659eadd 100644 --- a/src/devices/bus/abckb/abc77.cpp +++ b/src/devices/bus/abckb/abc77.cpp @@ -41,6 +41,14 @@ Notes: */ +/* + + TODO: + + - serial input is not working, fails systest1600 keyboard test + +*/ + #include "emu.h" #include "abc77.h" #include "speaker.h" @@ -166,7 +174,7 @@ INPUT_CHANGED_MEMBER( abc77_device::keyboard_reset ) // INPUT_PORTS( abc55 ) //------------------------------------------------- -INPUT_PORTS_START( abc55 ) +static INPUT_PORTS_START( abc55 ) PORT_START("X0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -323,7 +331,7 @@ ioport_constructor abc55_device::device_input_ports() const // INPUT_PORTS( abc77 ) //------------------------------------------------- -INPUT_PORTS_START( abc77 ) +static INPUT_PORTS_START( abc77 ) PORT_INCLUDE( abc55 ) PORT_MODIFY("X9") @@ -363,21 +371,6 @@ ioport_constructor abc77_device::device_input_ports() const // INLINE HELPERS //************************************************************************** -//------------------------------------------------- -// serial_output - -//------------------------------------------------- - -inline void abc77_device::serial_output(int state) -{ - if (m_txd != state) - { - m_txd = state; - - m_slot->write_rx(m_txd); - } -} - - //------------------------------------------------- // serial_clock - //------------------------------------------------- @@ -390,20 +383,6 @@ TIMER_CALLBACK_MEMBER(abc77_device::serial_clock) } -//------------------------------------------------- -// keydown - -//------------------------------------------------- - -inline void abc77_device::key_down(int state) -{ - if (m_keydown != state) - { - m_slot->keydown_w(state); - m_keydown = state; - } -} - - //************************************************************************** // LIVE DEVICE @@ -421,10 +400,12 @@ abc77_device::abc77_device(const machine_config &mconfig, device_type type, cons m_discrete(*this, DISCRETE_TAG), m_x(*this, "X%u", 0), m_dsw(*this, "DSW"), - m_txd(1), m_keylatch(0), - m_keydown(1), - m_clock(0), m_hys(0), - m_stb(1), m_j3(0), m_serial_timer(nullptr), m_reset_timer(nullptr) + m_keylatch(0), + m_clock(0), + m_stb(1), + m_j3(0), + m_serial_timer(nullptr), + m_reset_timer(nullptr) { } @@ -443,7 +424,8 @@ void abc77_device::device_start() { // allocate timers m_serial_timer = timer_alloc(FUNC(abc77_device::serial_clock), this); - m_serial_timer->adjust(attotime::from_hz(19200), 0, attotime::from_hz(19200)); // ALE/32 + attotime serial_clock = attotime::from_hz((m_maincpu->get_ale_clock()/32)*2); // 600 bps + m_serial_timer->adjust(serial_clock, 0, serial_clock); m_reset_timer = timer_alloc(FUNC(abc77_device::reset_tick), this); } @@ -558,41 +540,8 @@ void abc77_device::p2_w(uint8_t data) m_discrete->write(NODE_01, BIT(data, 4)); // transmit data - serial_output(BIT(data, 5)); + m_slot->write_rx(BIT(data, 5)); // key down - key_down(BIT(data, 6)); - - // hysteresis - m_hys = BIT(data, 7); -} - - -//------------------------------------------------- -// t1_r - -//------------------------------------------------- - -READ_LINE_MEMBER( abc77_device::t1_r ) -{ - return m_clock; -} - - -//------------------------------------------------- -// prog_w - -//------------------------------------------------- - -WRITE_LINE_MEMBER( abc77_device::prog_w ) -{ - m_stb = state; -} - - -//------------------------------------------------- -// j3_w - -//------------------------------------------------- - -void abc77_device::j3_w(uint8_t data) -{ - m_j3 = data; + m_slot->keydown_w(BIT(data, 6)); } diff --git a/src/devices/bus/abckb/abc77.h b/src/devices/bus/abckb/abc77.h index 4982c746570..7564be954fe 100644 --- a/src/devices/bus/abckb/abc77.h +++ b/src/devices/bus/abckb/abc77.h @@ -26,7 +26,8 @@ // ======================> abc77_device -class abc77_device : public device_t, public abc_keyboard_interface +class abc77_device : public device_t, + public abc_keyboard_interface { public: // construction/destruction @@ -50,9 +51,6 @@ protected: virtual void txd_w(int state) override; private: - void serial_output(int state); - void key_down(int state); - TIMER_CALLBACK_MEMBER(serial_clock); TIMER_CALLBACK_MEMBER(reset_tick); @@ -62,11 +60,8 @@ private: required_ioport_array<12> m_x; required_ioport m_dsw; - int m_txd; // transmit data int m_keylatch; // keyboard row latch - int m_keydown; // key down int m_clock; // transmit clock - int m_hys; // hysteresis int m_stb; // strobe uint8_t m_j3; @@ -76,16 +71,16 @@ private: uint8_t p1_r(); void p2_w(uint8_t data); - DECLARE_READ_LINE_MEMBER( t1_r ); - DECLARE_WRITE_LINE_MEMBER( prog_w ); - void j3_w(uint8_t data); + DECLARE_READ_LINE_MEMBER( t1_r ) { return m_clock; } + DECLARE_WRITE_LINE_MEMBER( prog_w ) { m_stb = state; } + void j3_w(uint8_t data) { m_j3 = data; } void abc77_io(address_map &map); void abc77_map(address_map &map); }; -class abc55_device : public abc77_device +class abc55_device : public abc77_device { public: // construction/destruction diff --git a/src/devices/bus/abckb/abc99.cpp b/src/devices/bus/abckb/abc99.cpp index f25c5bcd807..7a8ab51e72a 100644 --- a/src/devices/bus/abckb/abc99.cpp +++ b/src/devices/bus/abckb/abc99.cpp @@ -43,8 +43,8 @@ Notes: TODO: - - watchdog - - language DIP + - watchdog clock + - output leds */ @@ -104,47 +104,31 @@ const tiny_rom_entry *abc99_device::device_rom_region() const //------------------------------------------------- -// ADDRESS_MAP( abc99_z2_mem ) +// ADDRESS_MAP( keyboard_mem ) //------------------------------------------------- -void abc99_device::abc99_z2_mem(address_map &map) +void abc99_device::keyboard_mem(address_map &map) { map(0x0000, 0x0fff).rom().region(I8035_Z2_TAG, 0); } //------------------------------------------------- -// ADDRESS_MAP( abc99_z2_io ) +// ADDRESS_MAP( keyboard_io ) //------------------------------------------------- -void abc99_device::abc99_z2_io(address_map &map) +void abc99_device::keyboard_io(address_map &map) { - map(0x21, 0x21).w(FUNC(abc99_device::z2_led_w)); - map(0x30, 0x3f).nopw(); - map(0x30, 0x30).portr("X0"); - map(0x31, 0x31).portr("X1"); - map(0x32, 0x32).portr("X2"); - map(0x33, 0x33).portr("X3"); - map(0x34, 0x34).portr("X4"); - map(0x35, 0x35).portr("X5"); - map(0x36, 0x36).portr("X6"); - map(0x37, 0x37).portr("X7"); - map(0x38, 0x38).portr("X8"); - map(0x39, 0x39).portr("X9"); - map(0x3a, 0x3a).portr("X10"); - map(0x3b, 0x3b).portr("X11"); - map(0x3c, 0x3c).portr("X12"); - map(0x3d, 0x3d).portr("X13"); - map(0x3e, 0x3e).portr("X14"); - map(0x3f, 0x3f).portr("X15"); + map(0x21, 0x21).w(FUNC(abc99_device::led_w)); + map(0x30, 0x3f).rw(FUNC(abc99_device::key_y_r), FUNC(abc99_device::key_x_w)); } //------------------------------------------------- -// ADDRESS_MAP( abc99_z5_mem ) +// ADDRESS_MAP( mouse_mem ) //------------------------------------------------- -void abc99_device::abc99_z5_mem(address_map &map) +void abc99_device::mouse_mem(address_map &map) { map(0x0000, 0x07ff).rom().region(I8035_Z5_TAG, 0); } @@ -158,8 +142,8 @@ void abc99_device::device_add_mconfig(machine_config &config) { // keyboard CPU I8035(config, m_maincpu, 0); // from Z5 T0 output - m_maincpu->set_addrmap(AS_PROGRAM, &abc99_device::abc99_z2_mem); - m_maincpu->set_addrmap(AS_IO, &abc99_device::abc99_z2_io); + m_maincpu->set_addrmap(AS_PROGRAM, &abc99_device::keyboard_mem); + m_maincpu->set_addrmap(AS_IO, &abc99_device::keyboard_io); m_maincpu->p1_out_cb().set(FUNC(abc99_device::z2_p1_w)); m_maincpu->p2_in_cb().set(FUNC(abc99_device::z2_p2_r)); m_maincpu->t0_in_cb().set_constant(0); // mouse connected @@ -167,12 +151,15 @@ void abc99_device::device_add_mconfig(machine_config &config) // mouse CPU I8035(config, m_mousecpu, XTAL(6'000'000)); - m_mousecpu->set_addrmap(AS_PROGRAM, &abc99_device::abc99_z5_mem); + m_mousecpu->set_addrmap(AS_PROGRAM, &abc99_device::mouse_mem); m_mousecpu->p1_in_cb().set(FUNC(abc99_device::z5_p1_r)); m_mousecpu->p2_out_cb().set(FUNC(abc99_device::z5_p2_w)); m_mousecpu->set_t0_clk_cb(I8035_Z2_TAG, FUNC(device_t::set_unscaled_clock_int)); m_mousecpu->t1_in_cb().set(FUNC(abc99_device::z5_t1_r)); + // watchdog + WATCHDOG_TIMER(config, m_watchdog).set_time(attotime::from_hz(0)); + // mouse LUXOR_R8(config, m_mouse, 0); @@ -241,7 +228,7 @@ CUSTOM_INPUT_MEMBER( abc99_device::cursor_x6_r ) return data; } -INPUT_PORTS_START( abc99 ) +static INPUT_PORTS_START( abc99 ) PORT_START("X0") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PF13") PORT_CODE(KEYCODE_PRTSCR) @@ -402,14 +389,14 @@ INPUT_PORTS_START( abc99 ) PORT_START("Z14") PORT_DIPNAME( 0x07, 0x00, DEF_STR( Language ) ) PORT_DIPLOCATION("Z14:1,2,3") - PORT_DIPSETTING( 0x00, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x01, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x02, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x03, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x04, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x05, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x06, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x07, DEF_STR( Unknown ) ) + PORT_DIPSETTING( 0x00, "Swedish" ) + PORT_DIPSETTING( 0x01, "US English" ) + PORT_DIPSETTING( 0x02, "Spanish" ) + PORT_DIPSETTING( 0x03, "Danish" ) + PORT_DIPSETTING( 0x04, "Norwegian" ) + PORT_DIPSETTING( 0x05, DEF_STR( Unused ) ) + PORT_DIPSETTING( 0x06, DEF_STR( Unused ) ) + PORT_DIPSETTING( 0x07, DEF_STR( Unused ) ) PORT_DIPNAME( 0x08, 0x08, "Keyboard Program" ) PORT_DIPLOCATION("Z14:4") PORT_DIPSETTING( 0x00, "Internal (8048)" ) PORT_DIPSETTING( 0x08, "External PROM" ) @@ -472,11 +459,14 @@ abc99_device::abc99_device(const machine_config &mconfig, const char *tag, devic m_serial_timer(nullptr), m_maincpu(*this, I8035_Z2_TAG), m_mousecpu(*this, I8035_Z5_TAG), + m_watchdog(*this, "watchdog"), m_speaker(*this, "speaker"), m_mouse(*this, R8_TAG), + m_x(*this, "X%u", 0), m_z14(*this, "Z14"), m_cursor(*this, "CURSOR"), m_leds(*this, "led%u", 0U), + m_keylatch(0), m_si(1), m_si_en(1), m_so_z2(1), @@ -499,9 +489,11 @@ void abc99_device::device_start() // allocate timers m_serial_timer = timer_alloc(FUNC(abc99_device::serial_clock), this); - m_serial_timer->adjust(MCS48_ALE_CLOCK(XTAL(6'000'000)/3), 0, MCS48_ALE_CLOCK(XTAL(6'000'000)/3)); + attotime serial_clock = MCS48_ALE_CLOCK(m_mousecpu->get_t0_clock()); // 8333 bps + m_serial_timer->adjust(serial_clock, 0, serial_clock); // state saving + save_item(NAME(m_keylatch)); save_item(NAME(m_si)); save_item(NAME(m_si_en)); save_item(NAME(m_so_z2)); @@ -542,13 +534,15 @@ void abc99_device::txd_w(int state) //------------------------------------------------- -// z2_bus_w - +// key_x_w - //------------------------------------------------- -void abc99_device::z2_led_w(uint8_t data) +void abc99_device::led_w(uint8_t data) { if (m_led_en) return; + machine().output().set_value("led0", !BIT(data, 2)); + m_leds[LED_1] = BIT(data, 0); m_leds[LED_2] = BIT(data, 1); m_leds[LED_3] = BIT(data, 2); @@ -560,6 +554,31 @@ void abc99_device::z2_led_w(uint8_t data) } +//------------------------------------------------- +// key_y_r - +//------------------------------------------------- + +uint8_t abc99_device::key_y_r() +{ + return m_x[m_keylatch]->read(); +} + + +//------------------------------------------------- +// key_x_w - +//------------------------------------------------- + +void abc99_device::key_x_w(offs_t offset, uint8_t data) +{ + m_keylatch = offset & 0x0f; + + if (m_keylatch == 14) + { + m_watchdog->watchdog_reset(); + } +} + + //------------------------------------------------- // z2_p1_w - //------------------------------------------------- @@ -592,9 +611,9 @@ void abc99_device::z2_p1_w(uint8_t data) m_t1_z5 = BIT(data, 2); // key LEDs - m_leds[LED_INS] = BIT(data, 3); - m_leds[LED_ALT] = BIT(data, 4); - m_leds[LED_CAPS_LOCK] = BIT(data, 5); + m_leds[LED_INS] = !BIT(data, 3); + m_leds[LED_ALT] = !BIT(data, 4); + m_leds[LED_CAPS_LOCK] = !BIT(data, 5); // speaker output m_speaker->level_w(!BIT(data, 6)); diff --git a/src/devices/bus/abckb/abc99.h b/src/devices/bus/abckb/abc99.h index 6e028201226..69c14bc6a68 100644 --- a/src/devices/bus/abckb/abc99.h +++ b/src/devices/bus/abckb/abc99.h @@ -15,6 +15,7 @@ #include "bus/abckb/r8.h" #include "cpu/mcs48/mcs48.h" +#include "machine/watchdog.h" #include "sound/spkrdev.h" @@ -69,29 +70,34 @@ private: void serial_input(); TIMER_CALLBACK_MEMBER(serial_clock); + uint8_t key_y_r(); + void key_x_w(offs_t offset, uint8_t data); void z2_p1_w(uint8_t data); uint8_t z2_p2_r(); DECLARE_READ_LINE_MEMBER( z2_t1_r ) { return m_t1_z2; } - void z2_led_w(uint8_t data); + void led_w(uint8_t data); uint8_t z5_p1_r(); void z5_p2_w(uint8_t data); DECLARE_READ_LINE_MEMBER( z5_t1_r ) { return m_t1_z5; } - void abc99_z2_io(address_map &map); - void abc99_z2_mem(address_map &map); - void abc99_z5_mem(address_map &map); + void keyboard_io(address_map &map); + void keyboard_mem(address_map &map); + void mouse_mem(address_map &map); emu_timer *m_serial_timer; required_device m_maincpu; required_device m_mousecpu; + required_device m_watchdog; required_device m_speaker; required_device m_mouse; + required_ioport_array<16> m_x; required_ioport m_z14; required_ioport m_cursor; output_finder<11> m_leds; + int m_keylatch; int m_si; int m_si_en; int m_so_z2; diff --git a/src/devices/cpu/mcs48/mcs48.h b/src/devices/cpu/mcs48/mcs48.h index bb5d3da44f9..421641fb607 100644 --- a/src/devices/cpu/mcs48/mcs48.h +++ b/src/devices/cpu/mcs48/mcs48.h @@ -137,6 +137,9 @@ public: template void set_t0_clk_cb(T &&... args) { m_t0_clk_func.set(std::forward(args)...); } + u32 get_ale_clock() { return m_clock / 3 / 5; } + u32 get_t0_clock() { return m_clock / 3; } + protected: typedef void (mcs48_cpu_device::*mcs48_ophandler)(); -- cgit v1.2.3