diff --git a/.gitattributes b/.gitattributes index 00571af4618..3cd37210b45 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1668,6 +1668,8 @@ src/emu/dinetwork.c svneol=native#text/plain src/emu/dinetwork.h svneol=native#text/plain src/emu/dinvram.c svneol=native#text/plain src/emu/dinvram.h svneol=native#text/plain +src/emu/dioutput.c svneol=native#text/plain +src/emu/dioutput.h svneol=native#text/plain src/emu/dirtc.c svneol=native#text/plain src/emu/dirtc.h svneol=native#text/plain src/emu/diserial.c svneol=native#text/plain diff --git a/src/emu/dioutput.c b/src/emu/dioutput.c new file mode 100644 index 00000000000..059a520cc29 --- /dev/null +++ b/src/emu/dioutput.c @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + dirtc.c + + Device Output interfaces. + +***************************************************************************/ + +#include "emu.h" + + + +//************************************************************************** +// DEVICE OUTPUT INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_output_interface - constructor +//------------------------------------------------- + +device_output_interface::device_output_interface(const machine_config &mconfig, device_t &device) : + device_interface(device), + m_output_index(0), + m_output_name(NULL) +{ +} + +void device_output_interface::set_output_value(int value) +{ + if (m_output_name) + output_set_value(m_output_name, value); + else + fatalerror("Output name not set!"); +} + +void device_output_interface::set_led_value(int value) +{ + if (m_output_name) + output_set_value(m_output_name, value); + else + output_set_led_value(m_output_index, value); +} + +void device_output_interface::set_lamp_value(int value) +{ + if (m_output_name) + output_set_value(m_output_name, value); + else + output_set_lamp_value(m_output_index, value); +} + +void device_output_interface::set_digit_value(int value) +{ + if (m_output_name) + output_set_value(m_output_name, value); + else + output_set_digit_value(m_output_index, value); +} diff --git a/src/emu/dioutput.h b/src/emu/dioutput.h new file mode 100644 index 00000000000..a254eaa04c8 --- /dev/null +++ b/src/emu/dioutput.h @@ -0,0 +1,62 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + dioutput.h + + Device Output interfaces. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DIOUTPUT_H__ +#define __DIOUTPUT_H__ + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +#define MCFG_OUTPUT_INDEX(_index) \ + device_output_interface::set_output_index(*device, _index); + +#define MCFG_OUTPUT_NAME(_name) \ + device_output_interface::set_output_name(*device, _name); + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> device_output_interface + +class device_output_interface : public device_interface +{ +public: + // construction/destruction + device_output_interface(const machine_config &mconfig, device_t &device); + virtual ~device_output_interface() { }; + + static void set_output_index(device_t &device, int index) { dynamic_cast(device).m_output_index = index; } + static void set_output_name(device_t &device, const char *name) { dynamic_cast(device).m_output_name = name; } + + void set_output_value(int value); + void set_led_value(int value); + void set_lamp_value(int value); + void set_digit_value(int value); + +protected: + int m_output_index; + const char *m_output_name; +}; + + + +#endif /* __DIOUTPUT_H__ */ diff --git a/src/emu/emu.h b/src/emu/emu.h index 425613dd547..44c2eff4d71 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -67,6 +67,7 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_ #include "diexec.h" #include "opresolv.h" #include "diimage.h" +#include "dioutput.h" #include "diserial.h" #include "dislot.h" #include "disound.h" diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 8ceb5244a87..5c1704b7bcb 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -102,6 +102,7 @@ EMUOBJS = \ $(EMUOBJ)/dimemory.o \ $(EMUOBJ)/dinetwork.o \ $(EMUOBJ)/dinvram.o \ + $(EMUOBJ)/dioutput.o \ $(EMUOBJ)/dirtc.o \ $(EMUOBJ)/diserial.o \ $(EMUOBJ)/dislot.o \ diff --git a/src/emu/video/dm9368.c b/src/emu/video/dm9368.c index fe1d7dfeaa1..cd30bb184dd 100644 --- a/src/emu/video/dm9368.c +++ b/src/emu/video/dm9368.c @@ -9,60 +9,32 @@ **********************************************************************/ -#include "emu.h" #include "dm9368.h" +//************************************************************************** +// DEVICE DEFINITION +//************************************************************************** + +const device_type DM9368 = &device_creator; + + + //************************************************************************** // MACROS / CONSTANTS //************************************************************************** -#define LOG 1 - -// device type definition -const device_type DM9368 = &device_creator; +#define LOG 0 -static const UINT8 OUTPUT[16] = +const UINT8 dm9368_device::m_segment_data[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 }; -//************************************************************************** -// INLINE HELPERS -//************************************************************************** - -//------------------------------------------------- -// get_rbi - -//------------------------------------------------- - -inline int dm9368_device::get_rbi() -{ - if (!m_in_rbi_func.isnull()) - { - m_rbi = m_in_rbi_func(); - } - - return m_rbi; -} - - -//------------------------------------------------- -// set_rbo - -//------------------------------------------------- - -inline void dm9368_device::set_rbo(int state) -{ - m_rbo = state; - - m_out_rbo_func(m_rbo); -} - - - //************************************************************************** // LIVE DEVICE //************************************************************************** @@ -71,36 +43,16 @@ inline void dm9368_device::set_rbo(int state) // dm9368_device - constructor //------------------------------------------------- -dm9368_device::dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, DM9368, "DM9368", tag, owner, clock, "dm9368", __FILE__), - m_rbi(1), - m_rbo(1) +dm9368_device::dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, DM9368, "DM9368", tag, owner, clock, "dm9368", __FILE__), + device_output_interface(mconfig, *this), + m_write_rbo(*this), + m_rbi(1), + m_rbo(1) { } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void dm9368_device::device_config_complete() -{ - // inherit a copy of the static data - const dm9368_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - memset(&m_in_rbi_cb, 0, sizeof(m_in_rbi_cb)); - memset(&m_out_rbo_cb, 0, sizeof(m_out_rbo_cb)); - } -} - - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -108,11 +60,11 @@ void dm9368_device::device_config_complete() void dm9368_device::device_start() { // resolve callbacks - m_in_rbi_func.resolve(m_in_rbi_cb, *this); - m_out_rbo_func.resolve(m_out_rbo_cb, *this); + m_write_rbo.resolve_safe(); - // register for state saving + // state saving save_item(NAME(m_rbi)); + save_item(NAME(m_rbo)); } @@ -123,44 +75,25 @@ void dm9368_device::device_start() void dm9368_device::a_w(UINT8 data) { int a = data & 0x0f; + UINT8 value = 0; - if (!get_rbi() && !a) + if (!m_rbi && !a) { if (LOG) logerror("DM9368 '%s' Blanked Rippling Zero\n", tag()); // blank rippling 0 - output_set_digit_value(m_digit, 0); - - set_rbo(0); + m_rbo = 0; } else { - if (LOG) logerror("DM9368 '%s' Output Data: %u = %02x\n", tag(), a, OUTPUT[a]); + if (LOG) logerror("DM9368 '%s' Output Data: %u = %02x\n", tag(), a, m_segment_data[a]); - output_set_digit_value(m_digit, OUTPUT[a]); + value = m_segment_data[a]; - set_rbo(1); + m_rbo = 1; } -} - - -//------------------------------------------------- -// rbi_w - ripple blanking input -//------------------------------------------------- - -WRITE_LINE_MEMBER( dm9368_device::rbi_w ) -{ - if (LOG) logerror("DM9368 '%s' Ripple Blanking Input: %u\n", tag(), state); - - m_rbi = state; -} - - -//------------------------------------------------- -// rbo_r - ripple blanking output -//------------------------------------------------- - -READ_LINE_MEMBER( dm9368_device::rbo_r ) -{ - return m_rbo; + + set_digit_value(value); + + m_write_rbo(m_rbo); } diff --git a/src/emu/video/dm9368.h b/src/emu/video/dm9368.h index 3dd6b3cdb1c..d686d752dcb 100644 --- a/src/emu/video/dm9368.h +++ b/src/emu/video/dm9368.h @@ -33,13 +33,8 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_DM9368_ADD(_tag, _config) \ - MCFG_DEVICE_ADD(_tag, DM9368, 0) \ - MCFG_DEVICE_CONFIG(_config) - - -#define DM9368_INTERFACE(name) \ - const dm9368_interface (name) = +#define MCFG_DM9368_RBO_CALLBACK(_write) \ + devcb = &dm9368_device::set_rbo_wr_callback(*device, DEVCB2_##_read); @@ -47,46 +42,31 @@ // TYPE DEFINITIONS //************************************************************************** - -// ======================> dm9368_interface - -struct dm9368_interface -{ - int m_digit; - - devcb_read_line m_in_rbi_cb; - devcb_write_line m_out_rbo_cb; -}; - - - // ======================> dm9368_device class dm9368_device : public device_t, - public dm9368_interface + public device_output_interface { public: // construction/destruction dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); void a_w(UINT8 data); - DECLARE_WRITE_LINE_MEMBER( rbi_w ); - DECLARE_READ_LINE_MEMBER( rbo_r ); + + DECLARE_WRITE_LINE_MEMBER( rbi_w ) { m_rbi = state; } + DECLARE_READ_LINE_MEMBER( rbo_r ) { return m_rbo; } protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); private: - inline int get_rbi(); - inline void set_rbo(int state); - - devcb_resolved_read_line m_in_rbi_func; - devcb_resolved_write_line m_out_rbo_func; + devcb2_write_line m_write_rbo; int m_rbi; int m_rbo; + + static const UINT8 m_segment_data[]; }; diff --git a/src/mame/drivers/seabattl.c b/src/mame/drivers/seabattl.c index 9bd18c6fc79..1ff031f9cf6 100644 --- a/src/mame/drivers/seabattl.c +++ b/src/mame/drivers/seabattl.c @@ -479,48 +479,6 @@ static const s2636_interface s2636_config = //"s2636snd" }; -static DM9368_INTERFACE( digit_score_thousand_intf ) -{ - 0, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( digit_score_hundred_intf ) -{ - 1, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( digit_score_half_a_score_intf ) -{ - 2, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( digit_score_unity_intf ) -{ - 3, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( digit_time_half_a_score_intf ) -{ - 4, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( digit_time_unity_intf ) -{ - 5, - DEVCB_NULL, - DEVCB_NULL -}; - static MACHINE_CONFIG_START( seabattl, seabattl_state ) /* basic machine hardware */ @@ -532,12 +490,18 @@ static MACHINE_CONFIG_START( seabattl, seabattl_state ) MCFG_S2636_ADD("s2636", s2636_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) - MCFG_DM9368_ADD("sc_thousand", digit_score_thousand_intf) - MCFG_DM9368_ADD("sc_hundred", digit_score_hundred_intf) - MCFG_DM9368_ADD("sc_half", digit_score_half_a_score_intf) - MCFG_DM9368_ADD("sc_unity", digit_score_unity_intf) - MCFG_DM9368_ADD("tm_half", digit_time_half_a_score_intf) - MCFG_DM9368_ADD("tm_unity", digit_time_unity_intf) + MCFG_DEVICE_ADD("sc_thousand", DM9368, 0) + MCFG_OUTPUT_INDEX(0) + MCFG_DEVICE_ADD("sc_hundred", DM9368, 0) + MCFG_OUTPUT_INDEX(1) + MCFG_DEVICE_ADD("sc_half", DM9368, 0) + MCFG_OUTPUT_INDEX(2) + MCFG_DEVICE_ADD("sc_unity", DM9368, 0) + MCFG_OUTPUT_INDEX(3) + MCFG_DEVICE_ADD("tm_half", DM9368, 0) + MCFG_OUTPUT_INDEX(4) + MCFG_DEVICE_ADD("tm_unity", DM9368, 0) + MCFG_OUTPUT_INDEX(5) /* video hardware */ MCFG_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE) diff --git a/src/mess/drivers/cosmicos.c b/src/mess/drivers/cosmicos.c index d20cb18cbcc..582c30b0840 100644 --- a/src/mess/drivers/cosmicos.c +++ b/src/mess/drivers/cosmicos.c @@ -509,13 +509,6 @@ static const cassette_interface cosmicos_cassette_interface = NULL }; -static DM9368_INTERFACE( led_intf ) -{ - 0, - DEVCB_NULL, - DEVCB_NULL -}; - static MACHINE_CONFIG_START( cosmicos, cosmicos_state ) /* basic machine hardware */ MCFG_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz) @@ -533,7 +526,7 @@ static MACHINE_CONFIG_START( cosmicos, cosmicos_state ) /* video hardware */ MCFG_DEFAULT_LAYOUT( layout_cosmicos ) - MCFG_DM9368_ADD(DM9368_TAG, led_intf) + MCFG_DEVICE_ADD(DM9368_TAG, DM9368, 0) MCFG_TIMER_DRIVER_ADD_PERIODIC("digit", cosmicos_state, digit_tick, attotime::from_hz(100)) MCFG_TIMER_DRIVER_ADD_PERIODIC("interrupt", cosmicos_state, int_tick, attotime::from_hz(1000)) diff --git a/src/mess/drivers/elf.c b/src/mess/drivers/elf.c index 69f5c44e87d..b3ce20527f7 100644 --- a/src/mess/drivers/elf.c +++ b/src/mess/drivers/elf.c @@ -236,20 +236,6 @@ static const cassette_interface elf_cassette_interface = NULL }; -static DM9368_INTERFACE( led_h_intf ) -{ - 0, - DEVCB_NULL, - DEVCB_NULL -}; - -static DM9368_INTERFACE( led_l_intf ) -{ - 1, - DEVCB_NULL, - DEVCB_NULL -}; - QUICKLOAD_LOAD_MEMBER( elf2_state, elf ) { int size = image.length(); @@ -278,15 +264,17 @@ static MACHINE_CONFIG_START( elf2, elf2_state ) MCFG_COSMAC_SC_CALLBACK(WRITE8(elf2_state, sc_w)) /* video hardware */ - MCFG_DEFAULT_LAYOUT( layout_elf2 ) + MCFG_DEFAULT_LAYOUT(layout_elf2) MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) MCFG_SCREEN_UPDATE_DEVICE(CDP1861_TAG, cdp1861_device, screen_update) MCFG_SCREEN_RAW_PARAMS(XTAL_3_579545MHz/2, CDP1861_SCREEN_WIDTH, CDP1861_HBLANK_END, CDP1861_HBLANK_START, CDP1861_TOTAL_SCANLINES, CDP1861_SCANLINE_VBLANK_END, CDP1861_SCANLINE_VBLANK_START) /* devices */ MCFG_MM74C923_ADD(MM74C923_TAG, keyboard_intf) - MCFG_DM9368_ADD(DM9368_H_TAG, led_h_intf) - MCFG_DM9368_ADD(DM9368_L_TAG, led_l_intf) + MCFG_DEVICE_ADD(DM9368_H_TAG, DM9368, 0) + MCFG_OUTPUT_NAME("digit0") + MCFG_DEVICE_ADD(DM9368_L_TAG, DM9368, 0) + MCFG_OUTPUT_NAME("digit1") MCFG_CDP1861_ADD(CDP1861_TAG, SCREEN_TAG, XTAL_3_579545MHz/2, INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1)) MCFG_CASSETTE_ADD("cassette", elf_cassette_interface) MCFG_QUICKLOAD_ADD("quickload", elf2_state, elf, "bin", 0)