From 79cf761a31a3207b6eb34daba99aa34574fa075b Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Tue, 5 Apr 2011 20:27:55 +0000 Subject: [PATCH] Imported DM9368 7 segment LED from MESS. (no whatsnew) --- .gitattributes | 2 + src/emu/emu.mak | 1 + src/emu/video/dm9368.c | 180 +++++++++++++++++++++++++++++++++++++++++ src/emu/video/dm9368.h | 120 +++++++++++++++++++++++++++ 4 files changed, 303 insertions(+) create mode 100644 src/emu/video/dm9368.c create mode 100644 src/emu/video/dm9368.h diff --git a/.gitattributes b/.gitattributes index fe71b88e152..0b37baf42a0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1202,6 +1202,8 @@ src/emu/video/crt9021.c svneol=native#text/plain src/emu/video/crt9021.h svneol=native#text/plain src/emu/video/crt9212.c svneol=native#text/plain src/emu/video/crt9212.h svneol=native#text/plain +src/emu/video/dm9368.c svneol=native#text/plain +src/emu/video/dm9368.h svneol=native#text/plain src/emu/video/generic.c svneol=native#text/plain src/emu/video/generic.h svneol=native#text/plain src/emu/video/hd61830.c svneol=native#text/plain diff --git a/src/emu/emu.mak b/src/emu/emu.mak index a38e408004c..d0056841b2d 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -231,6 +231,7 @@ EMUVIDEOOBJS = \ $(EMUVIDEO)/crt9007.o \ $(EMUVIDEO)/crt9021.o \ $(EMUVIDEO)/crt9212.o \ + $(EMUVIDEO)/dm9368.o \ $(EMUVIDEO)/generic.o \ $(EMUVIDEO)/hd61830.o \ $(EMUVIDEO)/hd63484.o \ diff --git a/src/emu/video/dm9368.c b/src/emu/video/dm9368.c new file mode 100644 index 00000000000..624443d2fe3 --- /dev/null +++ b/src/emu/video/dm9368.c @@ -0,0 +1,180 @@ +/********************************************************************** + + Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "emu.h" +#include "dm9368.h" +#include "machine/devhelpr.h" + + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** + +#define LOG 1 + + +static const UINT8 OUTPUT[16] = +{ + 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 +}; + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// devices +const device_type DM9368 = dm9368_device_config::static_alloc_device_config; + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +GENERIC_DEVICE_CONFIG_SETUP(dm9368, "DM9368") + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void dm9368_device_config::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_func, 0, sizeof(m_in_rbi_func)); + memset(&m_out_rbo_func, 0, sizeof(m_out_rbo_func)); + } +} + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// get_rbi - +//------------------------------------------------- + +inline int dm9368_device::get_rbi() +{ + if (m_in_rbi_func.target != NULL) + { + m_rbi = devcb_call_read_line(&m_in_rbi_func); + } + + return m_rbi; +} + + +//------------------------------------------------- +// set_rbo - +//------------------------------------------------- + +inline void dm9368_device::set_rbo(int state) +{ + m_rbo = state; + + devcb_call_write_line(&m_out_rbo_func, m_rbo); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// dm9368_device - constructor +//------------------------------------------------- + +dm9368_device::dm9368_device(running_machine &_machine, const dm9368_device_config &config) + : device_t(_machine, config), + m_rbi(1), + m_rbo(1), + m_config(config) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void dm9368_device::device_start() +{ + // resolve callbacks + devcb_resolve_read_line(&m_in_rbi_func, &m_config.m_in_rbi_func, this); + devcb_resolve_write_line(&m_out_rbo_func, &m_config.m_out_rbo_func, this); + + // register for state saving + save_item(NAME(m_rbi)); +} + + +//------------------------------------------------- +// a_w - +//------------------------------------------------- + +void dm9368_device::a_w(UINT8 data) +{ + int a = data & 0x0f; + + if (!get_rbi() && !a) + { + if (LOG) logerror("DM9368 '%s' Blanked Rippling Zero\n", tag()); + + // blank rippling 0 + output_set_digit_value(m_config.m_digit, 0); + + set_rbo(0); + } + else + { + if (LOG) logerror("DM9368 '%s' Output Data: %u = %02x\n", tag(), a, OUTPUT[a]); + + output_set_digit_value(m_config.m_digit, OUTPUT[a]); + + set_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; +} diff --git a/src/emu/video/dm9368.h b/src/emu/video/dm9368.h new file mode 100644 index 00000000000..693ec783009 --- /dev/null +++ b/src/emu/video/dm9368.h @@ -0,0 +1,120 @@ +/********************************************************************** + + Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +********************************************************************** + _____ _____ + A1 1 |* \_/ | 16 Vcc + A2 2 | | 15 F + _LE 3 | | 14 G + _RBO 4 | DM9368 | 13 A + _RBI 5 | | 12 B + A3 6 | | 11 C + A0 7 | | 10 D + GND 8 |_____________| 9 E + +**********************************************************************/ + +#pragma once + +#ifndef __DM9368__ +#define __DM9368__ + +#include "emu.h" + + + +//************************************************************************** +// 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) = + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> dm9368_interface + +struct dm9368_interface +{ + int m_digit; + + devcb_read_line m_in_rbi_func; + devcb_write_line m_out_rbo_func; +}; + + + +// ======================> dm9368_device_config + +class dm9368_device_config : public device_config, + public dm9368_interface +{ + friend class dm9368_device; + + // construction/destruction + dm9368_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + + +// ======================> dm9368_device + +class dm9368_device : public device_t +{ + friend class dm9368_device_config; + + // construction/destruction + dm9368_device(running_machine &_machine, const dm9368_device_config &_config); + +public: + void a_w(UINT8 data); + DECLARE_WRITE_LINE_MEMBER( rbi_w ); + DECLARE_READ_LINE_MEMBER( rbo_r ); + +protected: + // device-level overrides + 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; + + int m_rbi; + int m_rbo; + + const dm9368_device_config &m_config; +}; + + +// device type definition +extern const device_type DM9368; + + + +#endif