Previous 15994 Revisions Next

r12949 Wednesday 28th September, 2011 at 08:48:28 UTC by Miodrag Milanović
ttl74145 is now c++ device (no whatsnew)
[src/mess/drivers]acrnsys1.c
[src/mess/machine]74145.c 74145.h mz700.c sym1.c

src/mess/machine/74145.c
r12948r12949
4646#include "74145.h"
4747#include "coreutil.h"
4848
49/***************************************************************************
50    TYPE DEFINITIONS
51***************************************************************************/
52
53typedef struct _ttl74145_t ttl74145_t;
54struct _ttl74145_t
55{
56   devcb_resolved_write_line output_line_0;
57   devcb_resolved_write_line output_line_1;
58   devcb_resolved_write_line output_line_2;
59   devcb_resolved_write_line output_line_3;
60   devcb_resolved_write_line output_line_4;
61   devcb_resolved_write_line output_line_5;
62   devcb_resolved_write_line output_line_6;
63   devcb_resolved_write_line output_line_7;
64   devcb_resolved_write_line output_line_8;
65   devcb_resolved_write_line output_line_9;
66
67   /* decoded number */
68   int number;
69};
70
71
7249/*****************************************************************************
7350    GLOBAL VARIABLES
7451*****************************************************************************/
r12948r12949
8865};
8966
9067
68const device_type TTL74145 = &device_creator<ttl74145_device>;
69
9170/***************************************************************************
92    IMPLEMENTATION
71    DEVICE INTERFACE
9372***************************************************************************/
73//-------------------------------------------------
74//  ttl74145_device - constructor
75//-------------------------------------------------
9476
95INLINE ttl74145_t *get_safe_token(device_t *device)
77ttl74145_device::ttl74145_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
78    : device_t(mconfig, TTL74145, "TTL74145", tag, owner, clock)
9679{
97   assert(device != NULL);
98   assert(device->type() == TTL74145);
99
100   return (ttl74145_t *)downcast<legacy_device_base *>(device)->token();
10180}
10281
10382
104WRITE8_DEVICE_HANDLER( ttl74145_w )
83//-------------------------------------------------
84//  device_start - device-specific startup
85//-------------------------------------------------
86
87void ttl74145_device::device_start()
10588{
106   ttl74145_t *ttl74145 = get_safe_token(device);
89   /* resolve callbacks */
90   m_output_line_0_func.resolve(m_output_line_0_cb, *this);
91   m_output_line_1_func.resolve(m_output_line_1_cb, *this);
92   m_output_line_2_func.resolve(m_output_line_2_cb, *this);
93   m_output_line_3_func.resolve(m_output_line_3_cb, *this);
94   m_output_line_4_func.resolve(m_output_line_4_cb, *this);
95   m_output_line_5_func.resolve(m_output_line_5_cb, *this);
96   m_output_line_6_func.resolve(m_output_line_6_cb, *this);
97   m_output_line_7_func.resolve(m_output_line_7_cb, *this);
98   m_output_line_8_func.resolve(m_output_line_8_cb, *this);
99   m_output_line_9_func.resolve(m_output_line_9_cb, *this);
107100
108   /* decode number */
109   int new_number = bcd_2_dec(data & 0x0f);
101   // register for state saving
102   save_item(NAME(m_number));
103}
110104
111   /* call output callbacks if the number changed */
112   if (new_number != ttl74145->number)
105//-------------------------------------------------
106//  device_config_complete - perform any
107//  operations now that the configuration is
108//  complete
109//-------------------------------------------------
110
111void ttl74145_device::device_config_complete()
112{
113   // inherit a copy of the static data
114   const ttl74145_interface *intf = reinterpret_cast<const ttl74145_interface *>(static_config());
115   if (intf != NULL)
116      *static_cast<ttl74145_interface *>(this) = *intf;
117
118   // or initialize to defaults if none provided
119   else
113120   {
114      ttl74145->output_line_0(new_number == 0);
115      ttl74145->output_line_1(new_number == 1);
116      ttl74145->output_line_2(new_number == 2);
117      ttl74145->output_line_3(new_number == 3);
118      ttl74145->output_line_4(new_number == 4);
119      ttl74145->output_line_5(new_number == 5);
120      ttl74145->output_line_6(new_number == 6);
121      ttl74145->output_line_7(new_number == 7);
122      ttl74145->output_line_8(new_number == 8);
123      ttl74145->output_line_9(new_number == 9);
121      memset(&m_output_line_0_cb, 0, sizeof(m_output_line_0_cb));
122      memset(&m_output_line_1_cb, 0, sizeof(m_output_line_1_cb));
123      memset(&m_output_line_2_cb, 0, sizeof(m_output_line_2_cb));
124      memset(&m_output_line_3_cb, 0, sizeof(m_output_line_3_cb));
125      memset(&m_output_line_4_cb, 0, sizeof(m_output_line_4_cb));
126      memset(&m_output_line_5_cb, 0, sizeof(m_output_line_5_cb));
127      memset(&m_output_line_6_cb, 0, sizeof(m_output_line_6_cb));
128      memset(&m_output_line_7_cb, 0, sizeof(m_output_line_7_cb));
129      memset(&m_output_line_8_cb, 0, sizeof(m_output_line_8_cb));
130      memset(&m_output_line_9_cb, 0, sizeof(m_output_line_9_cb));
124131   }
125
126   /* update state */
127   ttl74145->number = new_number;
128132}
129133
134//-------------------------------------------------
135//  device_start - device-specific reset
136//-------------------------------------------------
130137
131READ16_DEVICE_HANDLER( ttl74145_r )
138void ttl74145_device::device_reset()
132139{
133   ttl74145_t *ttl74145 = get_safe_token(device);
134
135   return (1 << ttl74145->number) & 0x3ff;
140   m_number = 0;
136141}
137142
138
139143/***************************************************************************
140    DEVICE INTERFACE
144    IMPLEMENTATION
141145***************************************************************************/
142146
143static DEVICE_START( ttl74145 )
147void ttl74145_device::write(UINT8 data)
144148{
145   const ttl74145_interface *intf = (const ttl74145_interface *)device->static_config();
146   ttl74145_t *ttl74145 = get_safe_token(device);
149   /* decode number */
150   UINT16 new_number = bcd_2_dec(data & 0x0f);
147151
148   /* validate arguments */
149   assert(device->static_config() != NULL);
152   /* call output callbacks if the number changed */
153   if (new_number != m_number)
154   {
155      m_output_line_0_func(new_number == 0);
156      m_output_line_1_func(new_number == 1);
157      m_output_line_2_func(new_number == 2);
158      m_output_line_3_func(new_number == 3);
159      m_output_line_4_func(new_number == 4);
160      m_output_line_5_func(new_number == 5);
161      m_output_line_6_func(new_number == 6);
162      m_output_line_7_func(new_number == 7);
163      m_output_line_8_func(new_number == 8);
164      m_output_line_9_func(new_number == 9);
165   }
150166
151   /* initialize with 0 */
152   ttl74145->number = 0;
153
154   /* resolve callbacks */
155   ttl74145->output_line_0.resolve(intf->output_line_0, *device);
156   ttl74145->output_line_1.resolve(intf->output_line_1, *device);
157   ttl74145->output_line_2.resolve(intf->output_line_2, *device);
158   ttl74145->output_line_3.resolve(intf->output_line_3, *device);
159   ttl74145->output_line_4.resolve(intf->output_line_4, *device);
160   ttl74145->output_line_5.resolve(intf->output_line_5, *device);
161   ttl74145->output_line_6.resolve(intf->output_line_6, *device);
162   ttl74145->output_line_7.resolve(intf->output_line_7, *device);
163   ttl74145->output_line_8.resolve(intf->output_line_8, *device);
164   ttl74145->output_line_9.resolve(intf->output_line_9, *device);
165
166   /* register for state saving */
167   state_save_register_item(device->machine(), "ttl74145", device->tag(), 0, ttl74145->number);
167   /* update state */
168   m_number = new_number;
168169}
169170
170171
171static DEVICE_RESET( ttl74145 )
172UINT16 ttl74145_device::read()
172173{
173   ttl74145_t *ttl74145 = get_safe_token(device);
174   ttl74145->number = 0;
174   return (1 << m_number) & 0x3ff;
175175}
176176
177177
178DEVICE_GET_INFO( ttl74145 )
179{
180   switch (state)
181   {
182      /* --- the following bits of info are returned as 64-bit signed integers --- */
183      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(ttl74145_t);            break;
184      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;                        break;
185178
186      /* --- the following bits of info are returned as pointers to data or functions --- */
187      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(ttl74145);   break;
188      case DEVINFO_FCT_STOP:               /* Nothing */                        break;
189      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(ttl74145);   break;
190
191      /* --- the following bits of info are returned as NULL-terminated strings --- */
192      case DEVINFO_STR_NAME:               strcpy(info->s, "TTL74145");            break;
193      case DEVINFO_STR_FAMILY:            strcpy(info->s, "TTL74145");            break;
194      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.2");                  break;
195      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);               break;
196      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");      break;
197   }
198}
199
200DEFINE_LEGACY_DEVICE(TTL74145, ttl74145);
src/mess/machine/74145.h
r12948r12949
99#ifndef __TTL74145_H__
1010#define __TTL74145_H__
1111
12#include "devcb.h"
12//**************************************************************************
13//  INTERFACE CONFIGURATION MACROS
14//**************************************************************************
15#define MCFG_TTL74145_ADD(_tag, _intf) \
16   MCFG_DEVICE_ADD(_tag, TTL74145, 0) \
17   MCFG_DEVICE_CONFIG(_intf)
18   
1319
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
1423
15/***************************************************************************
16    TYPE DEFINITIONS
17***************************************************************************/
24// ======================> ttl74145_interface
1825
19typedef struct _ttl74145_interface ttl74145_interface;
20struct _ttl74145_interface
26struct ttl74145_interface
2127{
22   devcb_write_line output_line_0;
23   devcb_write_line output_line_1;
24   devcb_write_line output_line_2;
25   devcb_write_line output_line_3;
26   devcb_write_line output_line_4;
27   devcb_write_line output_line_5;
28   devcb_write_line output_line_6;
29   devcb_write_line output_line_7;
30   devcb_write_line output_line_8;
31   devcb_write_line output_line_9;
28   devcb_write_line m_output_line_0_cb;
29   devcb_write_line m_output_line_1_cb;
30   devcb_write_line m_output_line_2_cb;
31   devcb_write_line m_output_line_3_cb;
32   devcb_write_line m_output_line_4_cb;
33   devcb_write_line m_output_line_5_cb;
34   devcb_write_line m_output_line_6_cb;
35   devcb_write_line m_output_line_7_cb;
36   devcb_write_line m_output_line_8_cb;
37   devcb_write_line m_output_line_9_cb;
3238};
3339
40// ======================> ttl74145_device
3441
35/***************************************************************************
36    FUNCTION PROTOTYPES
37***************************************************************************/
42class ttl74145_device :  public device_t,
43                  public ttl74145_interface
44{
45public:
46    // construction/destruction
47    ttl74145_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3848
39/* standard handlers */
40WRITE8_DEVICE_HANDLER( ttl74145_w );
41READ16_DEVICE_HANDLER( ttl74145_r );
49   UINT16 read();
50   void write(UINT8 data);
51protected:
52    // device-level overrides
53    virtual void device_start();
54   virtual void device_reset();
55    virtual void device_config_complete();
4256
57private:
58   devcb_resolved_write_line   m_output_line_0_func;
59   devcb_resolved_write_line   m_output_line_1_func;
60   devcb_resolved_write_line   m_output_line_2_func;
61   devcb_resolved_write_line   m_output_line_3_func;
62   devcb_resolved_write_line   m_output_line_4_func;
63   devcb_resolved_write_line   m_output_line_5_func;
64   devcb_resolved_write_line   m_output_line_6_func;
65   devcb_resolved_write_line   m_output_line_7_func;
66   devcb_resolved_write_line   m_output_line_8_func;
67   devcb_resolved_write_line   m_output_line_9_func;
4368
44/***************************************************************************
45    DEVICE CONFIGURATION MACROS
46***************************************************************************/
69   /* decoded number */
70   UINT16 m_number;
71};
4772
48DECLARE_LEGACY_DEVICE(TTL74145, ttl74145);
73// device type definition
74extern const device_type TTL74145;
4975
50#define MCFG_TTL74145_ADD(_tag, _intf) \
51   MCFG_DEVICE_ADD(_tag, TTL74145, 0) \
52   MCFG_DEVICE_CONFIG(_intf)
76//**************************************************************************
77//  DEFAULT INTERFACES
78//**************************************************************************
5379
54
55/***************************************************************************
56    DEFAULT INTERFACES
57***************************************************************************/
58
5980extern const ttl74145_interface default_ttl74145;
6081
6182
62#endif /* __TTL74145_H__ */
83#endif /* TTL74145 */
src/mess/machine/mz700.c
r12948r12949
451451
452452static READ8_DEVICE_HANDLER( pio_port_b_r )
453453{
454   int key_line = ttl74145_r(device, 0, 0);
454   int key_line = dynamic_cast<ttl74145_device *>(device)->read();
455455
456456   switch (key_line)
457457   {
r12948r12949
506506   LOG(2,"mz700_pio_port_a_w",("%02X\n", data),device->machine());
507507
508508   /* the ls145 is connected to PA0-PA3 */
509   ttl74145_w(device, 0, data & 0x07);
509   dynamic_cast<ttl74145_device *>(device)->write(data & 0x07);
510510
511511   /* ne556 reset is connected to PA7 */
512512   timer->enable(BIT(data, 7));
src/mess/machine/sym1.c
r12948r12949
139139   state->m_riot_port_b = data;
140140
141141   /* first 4 pins are connected to the 74145 */
142   ttl74145_w(device->machine().device("ttl74145"), 0, data & 0x0f);
142   device->machine().device<ttl74145_device>("ttl74145")->write(data & 0x0f);
143143}
144144
145145
src/mess/drivers/acrnsys1.c
r12948r12949
4747   { }
4848
4949   required_device<cpu_device> m_maincpu;
50   required_device<device_t> m_ttl74145;
50   required_device<ttl74145_device> m_ttl74145;
5151   DECLARE_READ8_MEMBER(ins8154_b1_port_a_r);
5252   DECLARE_WRITE8_MEMBER(ins8154_b1_port_a_w);
5353   DECLARE_WRITE8_MEMBER(acrnsys1_led_segment_w);
r12948r12949
6262// bit 7 is cassin
6363READ8_MEMBER( acrnsys1_state::ins8154_b1_port_a_r )
6464{
65   UINT8 data = 0xff, i, key_line = ttl74145_r(m_ttl74145, 0, 0);
65   UINT8 data = 0xff, i, key_line = m_ttl74145->read();
6666
6767   for (i = 0; i < 8; i++)
6868   {
r12948r12949
8282WRITE8_MEMBER( acrnsys1_state::ins8154_b1_port_a_w )
8383{
8484   m_digit = data & 0xc7;
85   ttl74145_w(m_ttl74145, 0, m_digit & 7);
85   m_ttl74145->write(m_digit & 7);
8686}
8787
8888
r12948r12949
9292
9393WRITE8_MEMBER( acrnsys1_state::acrnsys1_led_segment_w )
9494{
95   UINT8 key_line = ttl74145_r(m_ttl74145, 0, 0);
95   UINT8 key_line = m_ttl74145->read();
9696
9797   output_set_digit_value(key_line, data);
9898}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team