Previous 15994 Revisions Next

r11087 Tuesday 5th April, 2011 at 20:26:53 UTC by Curt Coder
Converted DM9368 to a C++ device and moved to emu folder. (no whatsnew)
[src/emu]emu.mak
[src/emu/video]dm9368.c* dm9368.h*
[src/mess]mess.mak
[src/mess/drivers]cosmicos.c elf.c
[src/mess/includes]cosmicos.h elf.h
[src/mess/video]dm9368.c dm9368.h

src/emu/video/dm9368.c
r0r11087
1/**********************************************************************
2
3    Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "dm9368.h"
12#include "machine/devhelpr.h"
13
14
15
16//**************************************************************************
17//  MACROS / CONSTANTS
18//**************************************************************************
19
20#define LOG 1
21
22
23static const UINT8 OUTPUT[16] =
24{
25   0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
26};
27
28
29
30//**************************************************************************
31//  GLOBAL VARIABLES
32//**************************************************************************
33
34// devices
35const device_type DM9368 = dm9368_device_config::static_alloc_device_config;
36
37
38
39//**************************************************************************
40//  DEVICE CONFIGURATION
41//**************************************************************************
42
43GENERIC_DEVICE_CONFIG_SETUP(dm9368, "DM9368")
44
45
46//-------------------------------------------------
47//  device_config_complete - perform any
48//  operations now that the configuration is
49//  complete
50//-------------------------------------------------
51
52void dm9368_device_config::device_config_complete()
53{
54   // inherit a copy of the static data
55   const dm9368_interface *intf = reinterpret_cast<const dm9368_interface *>(static_config());
56   if (intf != NULL)
57      *static_cast<dm9368_interface *>(this) = *intf;
58
59   // or initialize to defaults if none provided
60   else
61   {
62      memset(&m_in_rbi_func, 0, sizeof(m_in_rbi_func));
63      memset(&m_out_rbo_func, 0, sizeof(m_out_rbo_func));
64   }
65}
66
67
68
69//**************************************************************************
70//  INLINE HELPERS
71//**************************************************************************
72
73//-------------------------------------------------
74//  get_rbi -
75//-------------------------------------------------
76
77inline int dm9368_device::get_rbi()
78{
79   if (m_in_rbi_func.target != NULL)
80   {
81      m_rbi = devcb_call_read_line(&m_in_rbi_func);
82   }
83
84   return m_rbi;
85}
86
87
88//-------------------------------------------------
89//  set_rbo -
90//-------------------------------------------------
91
92inline void dm9368_device::set_rbo(int state)
93{
94   m_rbo = state;
95
96   devcb_call_write_line(&m_out_rbo_func, m_rbo);
97}
98
99
100
101//**************************************************************************
102//  LIVE DEVICE
103//**************************************************************************
104
105//-------------------------------------------------
106//  dm9368_device - constructor
107//-------------------------------------------------
108
109dm9368_device::dm9368_device(running_machine &_machine, const dm9368_device_config &config)
110    : device_t(_machine, config),
111     m_rbi(1),
112     m_rbo(1),
113      m_config(config)
114{
115}
116
117
118//-------------------------------------------------
119//  device_start - device-specific startup
120//-------------------------------------------------
121
122void dm9368_device::device_start()
123{
124   // resolve callbacks
125   devcb_resolve_read_line(&m_in_rbi_func, &m_config.m_in_rbi_func, this);
126   devcb_resolve_write_line(&m_out_rbo_func, &m_config.m_out_rbo_func, this);
127
128   // register for state saving
129   save_item(NAME(m_rbi));
130}
131
132
133//-------------------------------------------------
134//  a_w -
135//-------------------------------------------------
136
137void dm9368_device::a_w(UINT8 data)
138{
139   int a = data & 0x0f;
140
141   if (!get_rbi() && !a)
142   {
143      if (LOG) logerror("DM9368 '%s' Blanked Rippling Zero\n", tag());
144
145      // blank rippling 0
146      output_set_digit_value(m_config.m_digit, 0);
147
148      set_rbo(0);
149   }
150   else
151   {
152      if (LOG) logerror("DM9368 '%s' Output Data: %u = %02x\n", tag(), a, OUTPUT[a]);
153
154      output_set_digit_value(m_config.m_digit, OUTPUT[a]);
155
156      set_rbo(1);
157   }
158}
159
160
161//-------------------------------------------------
162//  rbi_w - ripple blanking input
163//-------------------------------------------------
164
165WRITE_LINE_MEMBER( dm9368_device::rbi_w )
166{
167   if (LOG) logerror("DM9368 '%s' Ripple Blanking Input: %u\n", tag(), state);
168
169   m_rbi = state;
170}
171
172
173//-------------------------------------------------
174//  rbo_r - ripple blanking output
175//-------------------------------------------------
176
177READ_LINE_MEMBER( dm9368_device::rbo_r )
178{
179   return m_rbo;
180}
src/emu/video/dm9368.h
r0r11087
1/**********************************************************************
2
3    Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                            _____   _____
10                    A1   1 |*    \_/     | 16  Vcc
11                    A2   2 |             | 15  F
12                   _LE   3 |             | 14  G
13                  _RBO   4 |   DM9368    | 13  A
14                  _RBI   5 |             | 12  B
15                    A3   6 |             | 11  C
16                    A0   7 |             | 10  D
17                   GND   8 |_____________| 9   E
18
19**********************************************************************/
20
21#pragma once
22
23#ifndef __DM9368__
24#define __DM9368__
25
26#include "emu.h"
27
28
29
30//**************************************************************************
31//  INTERFACE CONFIGURATION MACROS
32//**************************************************************************
33
34#define MCFG_DM9368_ADD(_tag, _config) \
35   MCFG_DEVICE_ADD(_tag, DM9368, 0) \
36   MCFG_DEVICE_CONFIG(_config)
37
38
39#define DM9368_INTERFACE(name) \
40   const dm9368_interface (name) =
41
42
43
44//**************************************************************************
45//  TYPE DEFINITIONS
46//**************************************************************************
47
48
49// ======================> dm9368_interface
50
51struct dm9368_interface
52{
53   int   m_digit;
54
55   devcb_read_line         m_in_rbi_func;
56   devcb_write_line      m_out_rbo_func;
57};
58
59
60
61// ======================> dm9368_device_config
62
63class dm9368_device_config :   public device_config,
64                               public dm9368_interface
65{
66    friend class dm9368_device;
67
68    // construction/destruction
69    dm9368_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
70
71public:
72    // allocators
73    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
74    virtual device_t *alloc_device(running_machine &machine) const;
75
76protected:
77   // device_config overrides
78   virtual void device_config_complete();
79};
80
81
82
83// ======================> dm9368_device
84
85class dm9368_device :   public device_t
86{
87    friend class dm9368_device_config;
88
89    // construction/destruction
90    dm9368_device(running_machine &_machine, const dm9368_device_config &_config);
91
92public:
93    void a_w(UINT8 data);
94   DECLARE_WRITE_LINE_MEMBER( rbi_w );
95   DECLARE_READ_LINE_MEMBER( rbo_r );
96
97protected:
98    // device-level overrides
99    virtual void device_start();
100
101private:
102   inline int get_rbi();
103   inline void set_rbo(int state);
104
105   devcb_resolved_read_line   m_in_rbi_func;
106   devcb_resolved_write_line   m_out_rbo_func;
107
108   int m_rbi;
109   int m_rbo;
110
111   const dm9368_device_config &m_config;
112};
113
114
115// device type definition
116extern const device_type DM9368;
117
118
119
120#endif
src/emu/emu.mak
r11086r11087
231231   $(EMUVIDEO)/crt9007.o      \
232232   $(EMUVIDEO)/crt9021.o      \
233233   $(EMUVIDEO)/crt9212.o      \
234   $(EMUVIDEO)/dm9368.o      \
234235   $(EMUVIDEO)/generic.o      \
235236   $(EMUVIDEO)/hd61830.o      \
236237   $(EMUVIDEO)/hd63484.o      \
src/mess/video/dm9368.c
r11086r11087
1/**********************************************************************
2
3    Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "dm9368.h"
12
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
17#define LOG 0
18
19static const UINT8 OUTPUT[16] =
20{
21   0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
22};
23
24/***************************************************************************
25    TYPE DEFINITIONS
26***************************************************************************/
27
28typedef struct _dm9368_t dm9368_t;
29struct _dm9368_t
30{
31   int digit;
32   UINT8 latch;
33
34   int rbi;
35
36   device_t *rbo_device;
37};
38
39/***************************************************************************
40    INLINE FUNCTIONS
41***************************************************************************/
42
43INLINE dm9368_t *get_safe_token(device_t *device)
44{
45   assert(device != NULL);
46   assert(device->type() == DM9368);
47
48   return (dm9368_t *)downcast<legacy_device_base *>(device)->token();
49}
50
51INLINE dm9368_config *get_safe_config(device_t *device)
52{
53   assert(device != NULL);
54   assert(device->type() == DM9368);
55
56   return (dm9368_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
57}
58
59/***************************************************************************
60    IMPLEMENTATION
61***************************************************************************/
62
63/*-------------------------------------------------
64    dm9368_w - latch input
65-------------------------------------------------*/
66
67WRITE8_DEVICE_HANDLER( dm9368_w )
68{
69   dm9368_t *dm9368 = get_safe_token(device);
70
71   int a = data & 0x0f;
72
73   if (!dm9368->rbi && !a)
74   {
75      if (LOG) logerror("DM9368 '%s' Blanked Rippling Zero\n", device->tag());
76
77      /* blank rippling 0 */
78      output_set_digit_value(dm9368->digit, 0);
79
80      if (dm9368->rbo_device)
81      {
82         dm9368_rbi_w(dm9368->rbo_device, 0);
83      }
84   }
85   else
86   {
87      if (LOG) logerror("DM9368 '%s' Output Data: %u = %02x\n", device->tag(), a, OUTPUT[a]);
88
89      output_set_digit_value(dm9368->digit, OUTPUT[a]);
90
91      if (dm9368->rbo_device)
92      {
93         dm9368_rbi_w(dm9368->rbo_device, 1);
94      }
95   }
96}
97
98/*-------------------------------------------------
99    dm9368_rbi_w - ripple blanking input
100-------------------------------------------------*/
101
102WRITE_LINE_DEVICE_HANDLER( dm9368_rbi_w )
103{
104   dm9368_t *dm9368 = get_safe_token(device);
105
106   dm9368->rbi = state;
107
108   if (LOG) logerror("DM9368 '%s' Ripple Blanking Input: %u\n", device->tag(), state);
109}
110
111/*-------------------------------------------------
112    DEVICE_START( dm9368 )
113-------------------------------------------------*/
114
115static DEVICE_START( dm9368 )
116{
117   dm9368_t *dm9368 = get_safe_token(device);
118   const dm9368_config *config = get_safe_config(device);
119
120   dm9368->digit = config->digit;
121
122   /* get the screen device */
123   if (config->rbo_tag)
124   {
125      dm9368->rbo_device = device->machine().device(config->rbo_tag);
126   }
127
128   /* register for state saving */
129   device->save_item(NAME(dm9368->latch));
130   device->save_item(NAME(dm9368->rbi));
131}
132
133/*-------------------------------------------------
134    DEVICE_GET_INFO( dm9368 )
135-------------------------------------------------*/
136
137DEVICE_GET_INFO( dm9368 )
138{
139   switch (state)
140   {
141      /* --- the following bits of info are returned as 64-bit signed integers --- */
142      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(dm9368_t);                     break;
143      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(dm9368_config);               break;
144
145      /* --- the following bits of info are returned as pointers to data or functions --- */
146      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(dm9368);         break;
147      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
148      case DEVINFO_FCT_RESET:                     /* Nothing */                              break;
149
150      /* --- the following bits of info are returned as NULL-terminated strings --- */
151      case DEVINFO_STR_NAME:                     strcpy(info->s, "Fairchild DM9368");            break;
152      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Fairchild DM9368");            break;
153      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
154      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
155      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
156   }
157}
158
159DEFINE_LEGACY_DEVICE(DM9368, dm9368);
src/mess/video/dm9368.h
r11086r11087
1/**********************************************************************
2
3    Fairchild DM9368 7-Segment Decoder/Driver/Latch emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                            _____   _____
10                    A1   1 |*    \_/     | 16  Vcc
11                    A2   2 |             | 15  F
12                   _LE   3 |             | 14  G
13                  _RBO   4 |   DM9368    | 13  A
14                  _RBI   5 |             | 12  B
15                    A3   6 |             | 11  C
16                    A0   7 |             | 10  D
17                   GND   8 |_____________| 9   E
18
19**********************************************************************/
20
21#ifndef __DM9368__
22#define __DM9368__
23
24#include "emu.h"
25#include "devcb.h"
26
27/***************************************************************************
28    MACROS / CONSTANTS
29***************************************************************************/
30
31DECLARE_LEGACY_DEVICE(DM9368, dm9368);
32
33#define MCFG_DM9368_ADD(_tag, _digit, _rbo_tag) \
34   MCFG_DEVICE_ADD((_tag), DM9368, 0) \
35   MCFG_DEVICE_CONFIG_DATA32(dm9368_config, digit, _digit) \
36   MCFG_DEVICE_CONFIG_DATAPTR(dm9368_config, rbo_tag, _rbo_tag) \
37
38/***************************************************************************
39    TYPE DEFINITIONS
40***************************************************************************/
41
42typedef struct _dm9368_config dm9368_config;
43struct _dm9368_config
44{
45   const char *rbo_tag;      /* device to connect RBO pin to */
46
47   int digit;               /* output digit */
48};
49
50/***************************************************************************
51    PROTOTYPES
52***************************************************************************/
53/* latch input */
54WRITE8_DEVICE_HANDLER( dm9368_w );
55
56/* ripple blanking input */
57WRITE_LINE_DEVICE_HANDLER( dm9368_rbi_w );
58
59#endif
src/mess/includes/elf.h
r11086r11087
4040   required_device<cpu_device> m_maincpu;
4141   required_device<device_t> m_cti;
4242   required_device<device_t> m_kb;
43   required_device<device_t> m_led_l;
44   required_device<device_t> m_led_h;
43   required_device<dm9368_device> m_led_l;
44   required_device<dm9368_device> m_led_h;
4545   required_device<device_t> m_cassette;
4646   required_device<device_t> m_ram;
4747
src/mess/includes/cosmicos.h
r11086r11087
5555
5656   required_device<cosmac_device> m_maincpu;
5757   required_device<device_t> m_cti;
58   required_device<device_t> m_led;
58   required_device<dm9368_device> m_led;
5959   required_device<device_t> m_cassette;
6060   required_device<device_t> m_speaker;
6161   required_device<device_t> m_ram;
src/mess/mess.mak
r11086r11087
561561   $(MESS_VIDEO)/cdp1862.o      \
562562   $(MESS_VIDEO)/crtc6845.o   \
563563   $(MESS_VIDEO)/dl1416.o      \
564   $(MESS_VIDEO)/dm9368.o      \
565564   $(MESS_VIDEO)/hd44102.o      \
566565   $(MESS_VIDEO)/hd44780.o      \
567566   $(MESS_VIDEO)/hd66421.o      \
src/mess/drivers/elf.c
r11086r11087
4444
4545WRITE8_MEMBER( elf2_state::data_w )
4646{
47   dm9368_w(m_led_l, 0, data & 0x0f);
48   dm9368_w(m_led_h, 0, data >> 4);
47   m_led_l->a_w(data & 0x0f);
48   m_led_h->a_w(data >> 4);
4949}
5050
5151WRITE8_MEMBER( elf2_state::memory_w )
r11086r11087
6464      }
6565
6666      /* write data to 7 segment displays */
67      dm9368_w(m_led_l, 0, data & 0x0f);
68      dm9368_w(m_led_h, 0, data >> 4);
67      m_led_l->a_w(data & 0x0f);
68      m_led_h->a_w(data >> 4);
6969   }
7070}
7171
r11086r11087
205205      if (LOAD)
206206      {
207207         /* write data to 7 segment displays */
208         dm9368_w(m_led_l, 0, m_data & 0x0f);
209         dm9368_w(m_led_h, 0, m_data >> 4);
208         m_led_l->a_w(m_data & 0x0f);
209         m_led_h->a_w(m_data >> 4);
210210      }
211211   }
212212}
r11086r11087
248248   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
249249
250250   /* initialize LED displays */
251   dm9368_rbi_w(m_led_l, 1);
252   dm9368_rbi_w(m_led_h, 1);
251   m_led_l->rbi_w(1);
252   m_led_h->rbi_w(1);
253253
254254   /* setup memory banking */
255255   program->install_read_bank(0x0000, 0x00ff, "bank1");
r11086r11087
271271   NULL
272272};
273273
274static DM9368_INTERFACE( led_h_intf )
275{
276   0,
277   DEVCB_NULL,
278   DEVCB_NULL
279};
280
281static DM9368_INTERFACE( led_l_intf )
282{
283   1,
284   DEVCB_NULL,
285   DEVCB_NULL
286};
287
274288static QUICKLOAD_LOAD( elf )
275289{
276290   elf2_state *state = image.device().machine().driver_data<elf2_state>();
r11086r11087
305319   MCFG_PALETTE_INIT(black_and_white)
306320
307321   MCFG_MM74C923_ADD(MM74C923_TAG, keyboard_intf)
308   MCFG_DM9368_ADD(DM9368_H_TAG, 0, NULL)
309   MCFG_DM9368_ADD(DM9368_L_TAG, 1, NULL)
322   MCFG_DM9368_ADD(DM9368_H_TAG, led_h_intf)
323   MCFG_DM9368_ADD(DM9368_L_TAG, led_l_intf)
310324   MCFG_CDP1861_ADD(CDP1861_TAG, XTAL_3_579545MHz/2, elf2_cdp1861_intf)
311325
312326   /* devices */
src/mess/drivers/cosmicos.c
r11086r11087
44
55    http://retro.hansotten.nl/index.php?page=1802-cosmicos
66
7
7   
88    HEX-monitor
99
1010    0 - start user program
r11086r11087
504504   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
505505
506506   /* initialize LED display */
507   dm9368_rbi_w(m_led, 1);
507   m_led->rbi_w(1);
508508
509509   /* setup memory banking */
510510   switch (ram_get_size(m_ram))
r11086r11087
566566   NULL
567567};
568568
569static DM9368_INTERFACE( led_intf )
570{
571   0,
572   DEVCB_NULL,
573   DEVCB_NULL
574};
575
569576static MACHINE_CONFIG_START( cosmicos, cosmicos_state )
570577   /* basic machine hardware */
571578    MCFG_CPU_ADD(CDP1802_TAG, COSMAC, XTAL_1_75MHz)
r11086r11087
575582
576583    /* video hardware */
577584   MCFG_DEFAULT_LAYOUT( layout_cosmicos )
578   MCFG_DM9368_ADD(DM9368_TAG, 0, NULL)
585   MCFG_DM9368_ADD(DM9368_TAG, led_intf)
579586   MCFG_TIMER_ADD_PERIODIC("digit", digit_tick, attotime::from_hz(100))
580587   MCFG_TIMER_ADD_PERIODIC("interrupt", int_tick, attotime::from_hz(1000))
581588

Previous 15994 Revisions Next


© 1998-2018 The MESS Team