From 89e38850b15d212c3a6c582172e36b681b5f4245 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 9 Jan 2025 12:56:32 +0100 Subject: dm9368: update output when rbi is written, seabattl,elf: remove unneeded 7seg output trampoline, didact: #define pia6820_device pia6821_device, please don't do that --- src/devices/video/dm9368.cpp | 47 +++++++++++++++++++++++++++++++----------- src/devices/video/dm9368.h | 10 +++++---- src/mame/netronics/elf.cpp | 13 ++++-------- src/mame/netronics/elf.h | 12 +++++------ src/mame/skeleton/cosmicos.cpp | 5 +---- src/mame/skeleton/didact.cpp | 44 ++++++++++++++++++++------------------- src/mame/zaccaria/seabattl.cpp | 18 +++++++--------- 7 files changed, 81 insertions(+), 68 deletions(-) diff --git a/src/devices/video/dm9368.cpp b/src/devices/video/dm9368.cpp index 57d59366e2e..eb94796670d 100644 --- a/src/devices/video/dm9368.cpp +++ b/src/devices/video/dm9368.cpp @@ -40,32 +40,55 @@ dm9368_device::dm9368_device(const machine_config &mconfig, const char *tag, dev device_t(mconfig, DM9368, tag, owner, clock), m_update_cb(*this), m_rbo_cb(*this), + m_a(0), m_rbi(1), m_rbo(1) { } +void dm9368_device::device_start() +{ + // state saving + save_item(NAME(m_a)); + save_item(NAME(m_rbi)); + save_item(NAME(m_rbo)); +} + + +// interface void dm9368_device::a_w(u8 data) { - int const a(data & 0x0f); - int const rbo((m_rbi || a) ? 1 : 0); - u8 const value(rbo ? s_segment_data[a] : 0); + data &= 0xf; + if (data != m_a) + { + m_a = data; + update(); + } +} + +void dm9368_device::rbi_w(int state) +{ + state = state ? 1 : 0; + if (state != m_rbi) + { + m_rbi = state; + update(); + } +} + +void dm9368_device::update() +{ + // RBI blanks the display only if A0-A3 is 0 + int const rbo((m_rbi || m_a) ? 1 : 0); + u8 const value(rbo ? s_segment_data[m_a] : 0); if (!rbo) LOG("DM9368 Blanked Rippling Zero\n"); else - LOG("DM9368 Output Data: %u = %02x\n", a, value); + LOG("DM9368 Output Data: %u = %02x\n", m_a, value); m_update_cb(0, value, 0x7f); if (rbo != m_rbo) m_rbo_cb(m_rbo = rbo); } - - -void dm9368_device::device_start() -{ - // state saving - save_item(NAME(m_rbi)); - save_item(NAME(m_rbo)); -} diff --git a/src/devices/video/dm9368.h b/src/devices/video/dm9368.h index 7eb2bae9ea0..ec04855c271 100644 --- a/src/devices/video/dm9368.h +++ b/src/devices/video/dm9368.h @@ -36,27 +36,29 @@ public: auto rbo_cb() { return m_rbo_cb.bind(); } // construction/destruction - dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); void a_w(u8 data); - void rbi_w(int state) { m_rbi = state; } + void rbi_w(int state); int rbo_r() { return m_rbo; } protected: // device_t implementation virtual void device_start() override ATTR_COLD; - - void update(); + virtual void device_reset() override ATTR_COLD { update(); } private: devcb_write8 m_update_cb; devcb_write_line m_rbo_cb; + u8 m_a; int m_rbi; int m_rbo; static const u8 s_segment_data[16]; + + void update(); }; diff --git a/src/mame/netronics/elf.cpp b/src/mame/netronics/elf.cpp index 60d7c7d54fc..c95e23d2385 100644 --- a/src/mame/netronics/elf.cpp +++ b/src/mame/netronics/elf.cpp @@ -92,7 +92,7 @@ void elf2_state::elf2_io(address_map &map) /* Input Ports */ -INPUT_CHANGED_MEMBER( elf2_state::input_w ) +INPUT_CHANGED_MEMBER(elf2_state::input_w) { if (newval) { @@ -206,11 +206,6 @@ void elf2_state::machine_start() m_led.resolve(); - /* initialize LED displays */ - m_7segs.resolve(); - m_led_l->rbi_w(1); - m_led_h->rbi_w(1); - /* setup memory banking */ program.install_rom(0x0000, 0x00ff, m_ram->pointer()); program.install_write_handler(0x0000, 0x00ff, write8sm_delegate(*this, FUNC(elf2_state::memory_w))); @@ -268,8 +263,8 @@ void elf2_state::elf2(machine_config &config) m_kb->x3_rd_callback().set_ioport("X3"); m_kb->x4_rd_callback().set_ioport("X4"); - DM9368(config, m_led_h, 0).update_cb().set(FUNC(elf2_state::digit_w<0>)); - DM9368(config, m_led_l, 0).update_cb().set(FUNC(elf2_state::digit_w<1>)); + DM9368(config, m_led_h).update_cb().set_output("digit0"); + DM9368(config, m_led_l).update_cb().set_output("digit1"); SPEAKER(config, "mono").front_center(); @@ -292,4 +287,4 @@ ROM_END /* System Drivers */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS -COMP( 1978, elf2, 0, 0, elf2, elf2, elf2_state, empty_init, "Netronics", "Elf II", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND) +COMP( 1978, elf2, 0, 0, elf2, elf2, elf2_state, empty_init, "Netronics", "Elf II", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) diff --git a/src/mame/netronics/elf.h b/src/mame/netronics/elf.h index fa417950b85..2f5194ca1ef 100644 --- a/src/mame/netronics/elf.h +++ b/src/mame/netronics/elf.h @@ -35,13 +35,15 @@ public: , m_cassette(*this, "cassette") , m_ram(*this, RAM_TAG) , m_special(*this, "SPECIAL") - , m_7segs(*this, "digit%u", 0U) , m_led(*this, "led0") { } void elf2(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER( input_w ); + DECLARE_INPUT_CHANGED_MEMBER(input_w); + +protected: + virtual void machine_start() override ATTR_COLD; private: uint8_t dispon_r(); @@ -55,14 +57,11 @@ private: uint8_t dma_r(); void sc_w(uint8_t data); void da_w(int state); - template void digit_w(uint8_t data) { m_7segs[N] = data; } - DECLARE_QUICKLOAD_LOAD_MEMBER( quickload_cb ); + DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb); void elf2_io(address_map &map) ATTR_COLD; void elf2_mem(address_map &map) ATTR_COLD; - virtual void machine_start() override ATTR_COLD; - required_device m_maincpu; required_device m_vdc; required_device m_kb; @@ -71,7 +70,6 @@ private: required_device m_cassette; required_device m_ram; required_ioport m_special; - output_finder<2> m_7segs; output_finder<> m_led; // display state diff --git a/src/mame/skeleton/cosmicos.cpp b/src/mame/skeleton/cosmicos.cpp index c3bc38b9e55..e47b9f82269 100644 --- a/src/mame/skeleton/cosmicos.cpp +++ b/src/mame/skeleton/cosmicos.cpp @@ -605,9 +605,6 @@ void cosmicos_state::machine_start() m_digits.resolve(); m_leds.resolve(); - /* initialize LED display */ - m_led->rbi_w(1); - /* register for state saving */ save_item(NAME(m_wait)); save_item(NAME(m_clear)); @@ -672,7 +669,7 @@ void cosmicos_state::cosmicos(machine_config &config) /* video hardware */ config.set_default_layout(layout_cosmicos); - DM9368(config, m_led, 0); + DM9368(config, m_led); TIMER(config, "digit").configure_periodic(FUNC(cosmicos_state::digit_tick), attotime::from_hz(100)); TIMER(config, "interrupt").configure_periodic(FUNC(cosmicos_state::int_tick), attotime::from_hz(1000)); diff --git a/src/mame/skeleton/didact.cpp b/src/mame/skeleton/didact.cpp index 5c79a00d18e..f383f442380 100644 --- a/src/mame/skeleton/didact.cpp +++ b/src/mame/skeleton/didact.cpp @@ -95,7 +95,7 @@ namespace { /* Didact base class */ class didact_state : public driver_device { - public: +public: didact_state(const machine_config &mconfig, device_type type, const char * tag) : driver_device(mconfig, type, tag) , m_cass(*this, "cassette") @@ -107,6 +107,7 @@ class didact_state : public driver_device DECLARE_INPUT_CHANGED_MEMBER(trigger_reset); DECLARE_INPUT_CHANGED_MEMBER(trigger_shift); + protected: virtual void machine_start() override { m_led.resolve(); } @@ -327,14 +328,12 @@ void md6802_state::md6802_map(address_map &map) */ /* Didact mp68a driver class */ -// Just a statement that the real mp68a hardware was designed with 6820 and not 6821 +// The real mp68a hardware was designed with 6820 and not 6821. // They are functional equivalents BUT has different electrical characteristics. // 2019-07-27 Cassette added: saves ok, load is unreliable, probably an original design problem. -#define pia6820_device pia6821_device -#define PIA6820 PIA6821 class mp68a_state : public didact_state { - public: +public: mp68a_state(const machine_config &mconfig, device_type type, const char * tag) : didact_state(mconfig, type, tag) , m_maincpu(*this, "maincpu") @@ -361,9 +360,10 @@ class mp68a_state : public didact_state virtual void machine_start() override ATTR_COLD; void mp68a(machine_config &config); void mp68a_map(address_map &map) ATTR_COLD; + protected: - required_device m_pia1; - required_device m_pia2; + required_device m_pia1; + required_device m_pia2; }; INPUT_CHANGED_MEMBER(didact_state::trigger_shift) @@ -425,13 +425,13 @@ uint8_t mp68a_state::pia2_kbB_r() while (a012 > 0 && !(line & (1 << --a012))); a012 += 8; } - if ( a012 == 0 && (line = ((m_lines[2]) | m_lines[3])) != 0) + if (a012 == 0 && (line = ((m_lines[2]) | m_lines[3])) != 0) { a012 = 8; while (a012 > 0 && !(line & (1 << --a012))); } - pb = a012; // A0-A2 -> PB0-PB3 + pb = a012; // A0-A2 -> PB0-PB3 if (m_shift) { @@ -486,8 +486,8 @@ void mp68a_state::machine_start() void mp68a_state::mp68a_map(address_map &map) { map(0x0000, 0x00ff).ram().mirror(0xf000); - map(0x0500, 0x0503).rw(m_pia1, FUNC(pia6820_device::read), FUNC(pia6820_device::write)).mirror(0xf0fc); - map(0x0600, 0x0603).rw(m_pia2, FUNC(pia6820_device::read), FUNC(pia6820_device::write)).mirror(0xf0fc); + map(0x0500, 0x0503).rw(m_pia1, FUNC(pia6821_device::read), FUNC(pia6821_device::write)).mirror(0xf0fc); + map(0x0600, 0x0603).rw(m_pia2, FUNC(pia6821_device::read), FUNC(pia6821_device::write)).mirror(0xf0fc); map(0x0700, 0x07ff).ram().mirror(0xf000); map(0x0800, 0x0bff).rom().mirror(0xf400).region("maincpu", 0x0800); } @@ -536,7 +536,7 @@ void mp68a_state::mp68a_map(address_map &map) /* Didact modulab driver class */ class modulab_state : public didact_state { - public: +public: modulab_state(const machine_config &mconfig, device_type type, const char * tag) : didact_state(mconfig, type, tag) , m_maincpu(*this, "maincpu") @@ -553,10 +553,12 @@ class modulab_state : public didact_state virtual void machine_reset() override ATTR_COLD; virtual void machine_start() override ATTR_COLD; void modulab(machine_config &config); + protected: uint8_t io_r(offs_t offset); void io_w(offs_t offset, u8 data); void da_w(int state); + private: void modulab_map(address_map &map) ATTR_COLD; // Offsets for display and keyboard i/o @@ -571,7 +573,7 @@ private: class shift8 { public: - shift8(){ byte = 0; } + shift8() { byte = 0; } void shiftIn(uint8_t in){ byte = ((byte << 1) & 0xfe) | (in & 1 ? 1 : 0); } uint8_t byte; }; @@ -850,10 +852,10 @@ void mp68a_state::mp68a(machine_config &config) /* Devices */ /* PIA #1 0x500-0x503 - used differently by laborations and loaded software */ - PIA6820(config, m_pia1, 0); + PIA6821(config, m_pia1, 0); // actually 6820 /* PIA #2 Keyboard & Display 0x600-0x603 */ - PIA6820(config, m_pia2, 0); + PIA6821(config, m_pia2, 0); // actually 6820 /* --PIA inits----------------------- */ /* 0x0BAF 0x601 (Control A) = 0x30 - CA2 is low and enable DDRA */ /* 0x0BB1 0x603 (Control B) = 0x30 - CB2 is low and enable DDRB */ @@ -886,12 +888,12 @@ void mp68a_state::mp68a(machine_config &config) /* 0x086B 0x600 (Port A) = 0x70 */ /* 0x086B 0x600 (Port A) = 0x50 */ /* 0x086B 0x600 (Port A) = 0x70 */ - DM9368(config, m_digits[0], 0).update_cb().set(FUNC(mp68a_state::digit_w<0>)); - DM9368(config, m_digits[1], 0).update_cb().set(FUNC(mp68a_state::digit_w<1>)); - DM9368(config, m_digits[2], 0).update_cb().set(FUNC(mp68a_state::digit_w<2>)); - DM9368(config, m_digits[3], 0).update_cb().set(FUNC(mp68a_state::digit_w<3>)); - DM9368(config, m_digits[4], 0).update_cb().set(FUNC(mp68a_state::digit_w<4>)); - DM9368(config, m_digits[5], 0).update_cb().set(FUNC(mp68a_state::digit_w<5>)); + DM9368(config, m_digits[0]).update_cb().set(FUNC(mp68a_state::digit_w<0>)); + DM9368(config, m_digits[1]).update_cb().set(FUNC(mp68a_state::digit_w<1>)); + DM9368(config, m_digits[2]).update_cb().set(FUNC(mp68a_state::digit_w<2>)); + DM9368(config, m_digits[3]).update_cb().set(FUNC(mp68a_state::digit_w<3>)); + DM9368(config, m_digits[4]).update_cb().set(FUNC(mp68a_state::digit_w<4>)); + DM9368(config, m_digits[5]).update_cb().set(FUNC(mp68a_state::digit_w<5>)); /* Cassette */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/zaccaria/seabattl.cpp b/src/mame/zaccaria/seabattl.cpp index db117b10a82..1058fe3a9ab 100644 --- a/src/mame/zaccaria/seabattl.cpp +++ b/src/mame/zaccaria/seabattl.cpp @@ -54,9 +54,8 @@ public: m_videoram(*this, "videoram"), m_colorram(*this, "colorram"), m_objram(*this, "objram"), - m_digits(*this, { "sc_thousand", "sc_hundred", "sc_half", "sc_unity", "tm_half", "tm_unity" }), + m_digits(*this, "digit%u", 0U), m_s2636(*this, "s2636"), - m_7segs(*this, "digit%u", 0U), m_lamp(*this, "lamp0"), m_waveenable(false), m_collision(0), @@ -86,7 +85,6 @@ private: void time_display_w(uint8_t data); void score_display_w(uint8_t data); void score2_display_w(uint8_t data); - template void digit_w(uint8_t data) { m_7segs[N] = data; } void seabattl_palette(palette_device &palette) const; uint32_t screen_update_seabattl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -100,7 +98,6 @@ private: required_shared_ptr m_objram; required_device_array m_digits; required_device m_s2636; - output_finder<6> m_7segs; output_finder<> m_lamp; tilemap_t *m_bg_tilemap = nullptr; @@ -240,7 +237,6 @@ uint32_t seabattl_state::screen_update_seabattl(screen_device &screen, bitmap_in void seabattl_state::video_start() { - m_7segs.resolve(); m_screen->register_screen_bitmap(m_collision_bg); m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(seabattl_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); m_bg_tilemap->set_transparent_pen(0); @@ -496,12 +492,12 @@ void seabattl_state::seabattl(machine_config &config) m_s2636->set_offsets(-13, -29); m_s2636->add_route(ALL_OUTPUTS, "mono", 0.10); - DM9368(config, m_digits[0], 0).update_cb().set(FUNC(seabattl_state::digit_w<0>)); - DM9368(config, m_digits[1], 0).update_cb().set(FUNC(seabattl_state::digit_w<1>)); - DM9368(config, m_digits[2], 0).update_cb().set(FUNC(seabattl_state::digit_w<2>)); - DM9368(config, m_digits[3], 0).update_cb().set(FUNC(seabattl_state::digit_w<3>)); - DM9368(config, m_digits[4], 0).update_cb().set(FUNC(seabattl_state::digit_w<4>)); - DM9368(config, m_digits[5], 0).update_cb().set(FUNC(seabattl_state::digit_w<5>)); + DM9368(config, m_digits[0]).update_cb().set_output("digit0"); + DM9368(config, m_digits[1]).update_cb().set_output("digit1"); + DM9368(config, m_digits[2]).update_cb().set_output("digit2"); + DM9368(config, m_digits[3]).update_cb().set_output("digit3"); + DM9368(config, m_digits[4]).update_cb().set_output("digit4"); + DM9368(config, m_digits[5]).update_cb().set_output("digit5"); /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); -- cgit v1.2.3