Previous 199869 Revisions Next

r29595 Sunday 13th April, 2014 at 10:09:43 UTC by Fabio Priuli
updated ttl74148 and ttl74153 to use delegates. nw.
[src/emu/machine]74148.c 74148.h 74153.c 74153.h
[src/mame/drivers]carpolo.c vertigo.c
[src/mame/includes]carpolo.h vertigo.h
[src/mame/machine]carpolo.c vertigo.c

trunk/src/mame/drivers/carpolo.c
r29594r29595
221221   GFXDECODE_ENTRY( "gfx3", 0, alphalayout,  12*2+2*16, 4 )
222222GFXDECODE_END
223223
224static const ttl74148_config carpolo_ttl74148_intf =
225{
226   carpolo_74148_3s_cb
227};
228
229static const ttl74153_config carpolo_ttl74153_intf =
230{
231   NULL
232};
233
234224/*************************************
235225 *
236226 *  Machine driver
r29594r29595
280270   MCFG_DEVICE_ADD("7474_1a_1", TTL7474, 0)
281271   MCFG_DEVICE_ADD("7474_1a_2", TTL7474, 0)
282272
283   MCFG_74148_ADD("74148_3s", carpolo_ttl74148_intf)
284   MCFG_74153_ADD("74153_1k", carpolo_ttl74153_intf)
273   MCFG_DEVICE_ADD("74148_3s", TTL74148, 0)
274   MCFG_74148_OUTPUT_CB(carpolo_state, ttl74148_3s_cb)
285275
276   MCFG_DEVICE_ADD("74153_1k", TTL74153, 0)
277
286278   /* video hardware */
287279   MCFG_SCREEN_ADD("screen", RASTER)
288280   MCFG_SCREEN_REFRESH_RATE(60)
trunk/src/mame/drivers/vertigo.c
r29594r29595
103103INPUT_PORTS_END
104104
105105
106static const ttl74148_config vertigo_ttl74148_intf =
107{
108   vertigo_update_irq
109};
110106/*************************************
111107 *
112108 *  Machine driver
r29594r29595
129125   MCFG_PIT8253_OUT1_HANDLER(WRITELINE(vertigo_state, v_irq3_w))
130126   MCFG_PIT8253_CLK2(240000)
131127
132   MCFG_74148_ADD( "74148", vertigo_ttl74148_intf )
128   MCFG_DEVICE_ADD("74148", TTL74148, 0)
129   MCFG_74148_OUTPUT_CB(vertigo_state, update_irq)
133130
134131   /* motor controller */
135132   /*
trunk/src/mame/machine/carpolo.c
r29594r29595
5555#define CAR_BORDER_EXTRA_BITS       0x50
5656
5757
58void carpolo_74148_3s_cb(device_t *device)
58TTL74148_OUTPUT_CB(carpolo_state::ttl74148_3s_cb)
5959{
60   carpolo_state *state = device->machine().driver_data<carpolo_state>();
61   state->m_maincpu->set_input_line(M6502_IRQ_LINE, state->m_ttl74148_3s->output_valid_r() ? CLEAR_LINE : ASSERT_LINE);
60   m_maincpu->set_input_line(M6502_IRQ_LINE, m_ttl74148_3s->output_valid_r() ? CLEAR_LINE : ASSERT_LINE);
6261}
6362
6463
trunk/src/mame/machine/vertigo.c
r29594r29595
3030 *
3131 *************************************/
3232
33void vertigo_update_irq(device_t *device)
33TTL74148_OUTPUT_CB(vertigo_state::update_irq)
3434{
35   vertigo_state *state = device->machine().driver_data<vertigo_state>();
36   if (state->m_irq_state < 7)
37      state->m_maincpu->set_input_line(state->m_irq_state ^ 7, CLEAR_LINE);
35   if (m_irq_state < 7)
36      m_maincpu->set_input_line(m_irq_state ^ 7, CLEAR_LINE);
3837
39   state->m_irq_state = state->m_ttl74148->output_r();
38   m_irq_state = m_ttl74148->output_r();
4039
41   if (state->m_irq_state < 7)
42      state->m_maincpu->set_input_line(state->m_irq_state ^ 7, ASSERT_LINE);
40   if (m_irq_state < 7)
41      m_maincpu->set_input_line(m_irq_state ^ 7, ASSERT_LINE);
4342}
4443
4544
trunk/src/mame/includes/carpolo.h
r29594r29595
107107   DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_1_q_cb);
108108   DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_2_q_cb);
109109
110   TTL74148_OUTPUT_CB(ttl74148_3s_cb);
111
110112   void remap_sprite_code(int bank, int code, int *remapped_code, int *flipy);
111113   void normalize_coordinates(int *x1, int *y1, int *x2, int *y2);
112114   int check_sprite_left_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only);
r29594r29595
123125                              int x2, int y2, int code2, int flipy2,
124126                              int *col_x, int *col_y);
125127};
126
127
128/*----------- defined in machine/carpolo.c -----------*/
129
130void carpolo_74148_3s_cb(device_t *device);
trunk/src/mame/includes/vertigo.h
r29594r29595
130130   TIMER_CALLBACK_MEMBER(sound_command_w);
131131   DECLARE_WRITE_LINE_MEMBER(v_irq4_w);
132132   DECLARE_WRITE_LINE_MEMBER(v_irq3_w);
133   TTL74148_OUTPUT_CB(update_irq);
134
133135   void vertigo_vproc_init();
134136   void vertigo_vproc_reset();
135137   void am2901x4 (am2901 *bsp, microcode *mc);
r29594r29595
137139   void vertigo_vproc(int cycles, int irq4);
138140   void update_irq_encoder(int line, int state);
139141};
140
141/*----------- defined in machine/vertigo.c -----------*/
142
143void vertigo_update_irq(device_t *device);
trunk/src/emu/machine/74153.c
r29594r29595
4040const device_type TTL74153 = &device_creator<ttl74153_device>;
4141
4242ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
43   : device_t(mconfig, TTL74153, "74153 TTL", tag, owner, clock, "74153", __FILE__),
44   m_a(0),
45   m_b(0)
43            : device_t(mconfig, TTL74153, "74153 TTL", tag, owner, clock, "74153", __FILE__),
44               m_a(0),
45               m_b(0)
4646{
4747   m_input_lines[0][0] = 0;
4848   m_input_lines[0][1] = 0;
r29594r29595
5454   m_input_lines[1][3] = 0;
5555
5656   for (int i = 0; i < 2; i++)
57   m_enable[i] = 0;
57      m_enable[i] = 0;
5858
5959   for (int i = 0; i < 2; i++)
60   m_output[i] = 0;
60      m_output[i] = 0;
6161
6262   for (int i = 0; i < 2; i++)
63   m_last_output[i] = 0;
63      m_last_output[i] = 0;
6464}
6565
6666//-------------------------------------------------
67//  device_config_complete - perform any
68//  operations now that the configuration is
69//  complete
70//-------------------------------------------------
71
72void ttl74153_device::device_config_complete()
73{
74   // inherit a copy of the static data
75   const ttl74153_config *intf = reinterpret_cast<const ttl74153_config *>(static_config());
76   if (intf != NULL)
77   *static_cast<ttl74153_config *>(this) = *intf;
78
79   // or initialize to defaults if none provided
80   else
81   {
82   }
83}
84
85//-------------------------------------------------
8667//  device_start - device-specific startup
8768//-------------------------------------------------
8869
8970void ttl74153_device::device_start()
9071{
72   m_output_cb.bind_relative_to(*owner());
73
9174   save_item(NAME(m_enable));
9275   save_item(NAME(m_last_output));
9376   save_item(NAME(m_input_lines[0][0]));
r29594r29595
146129
147130
148131   /* call callback if either of the outputs changed */
149   if (  m_output_cb &&
150      ((m_output[0] != m_last_output[0]) ||
151         (m_output[1] != m_last_output[1])))
132   if (!m_output_cb.isnull() &&
133      ((m_output[0] != m_last_output[0]) || (m_output[1] != m_last_output[1])))
152134   {
153135      m_last_output[0] = m_output[0];
154136      m_last_output[1] = m_output[1];
155137
156      m_output_cb(this);
138      m_output_cb();
157139   }
158140}
159141
trunk/src/emu/machine/74153.h
r29594r29595
3737#define TTL74153_H
3838
3939
40typedef device_delegate<void (void)> ttl74153_output_delegate;
4041
41struct ttl74153_config
42{
43   void (*m_output_cb)(device_t *device);
44};
42#define TTL74153_OUTPUT_CB(_name) void _name(void)
4543
4644
47class ttl74153_device : public device_t,
48                           public ttl74153_config
45class ttl74153_device : public device_t
4946{
5047public:
5148   ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5249   ~ttl74153_device() {}
5350
51   static void set_output_callback(device_t &device, ttl74153_output_delegate callback) { downcast<ttl74153_device &>(device).m_output_cb = callback; }
52
5453   /* must call update() after setting the inputs */
5554   void update();
5655
r29594r29595
6261
6362protected:
6463   // device-level overrides
65   virtual void device_config_complete();
6664   virtual void device_start();
6765   virtual void device_reset();
6866
6967private:
7068   // internal state
69   ttl74153_output_delegate m_output_cb;
7170
7271   /* inputs */
7372   int m_a;                  /* pin 14 */
r29594r29595
8483
8584extern const device_type TTL74153;
8685
87#define MCFG_74153_ADD(_tag, _config) \
88   MCFG_DEVICE_ADD(_tag, TTL74153, 0) \
89   MCFG_DEVICE_CONFIG(_config)
9086
87#define MCFG_74153_OUTPUT_CB(_class, _method) \
88   ttl74153_device::set_output_callback(*device, ttl74153_output_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
89
9190#endif
trunk/src/emu/machine/74148.c
r29594r29595
4545const device_type TTL74148 = &device_creator<ttl74148_device>;
4646
4747ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
48   : device_t(mconfig, TTL74148, "74148 TTL", tag, owner, clock, "74148", __FILE__),
49   m_enable_input(0),
50   m_output(0),
51   m_output_valid(0),
52   m_enable_output(0),
53   m_last_output(0),
54   m_last_output_valid(0),
55   m_last_enable_output(0)
48            : device_t(mconfig, TTL74148, "74148 TTL", tag, owner, clock, "74148", __FILE__),
49               m_enable_input(0),
50               m_output(0),
51               m_output_valid(0),
52               m_enable_output(0),
53               m_last_output(0),
54               m_last_output_valid(0),
55               m_last_enable_output(0)
5656{
5757   for (int i = 0; i < 8; i++)
58   m_input_lines[i] = 0;
58      m_input_lines[i] = 0;
5959}
6060
6161//-------------------------------------------------
62//  device_config_complete - perform any
63//  operations now that the configuration is
64//  complete
65//-------------------------------------------------
66
67void ttl74148_device::device_config_complete()
68{
69   // inherit a copy of the static data
70   const ttl74148_config *intf = reinterpret_cast<const ttl74148_config *>(static_config());
71   if (intf != NULL)
72   *static_cast<ttl74148_config *>(this) = *intf;
73
74   // or initialize to defaults if none provided
75   else
76   {
77   }
78
79}
80
81//-------------------------------------------------
8262//  device_start - device-specific startup
8363//-------------------------------------------------
8464
8565void ttl74148_device::device_start()
8666{
67   m_output_cb.bind_relative_to(*owner());
68
8769   save_item(NAME(m_input_lines));
8870   save_item(NAME(m_enable_input));
8971   save_item(NAME(m_output));
r29594r29595
171153
172154
173155   /* call callback if any of the outputs changed */
174   if (  m_output_cb &&
175      ((m_output        != m_last_output) ||
176         (m_output_valid  != m_last_output_valid) ||
177         (m_enable_output != m_last_enable_output)))
156   if (!m_output_cb.isnull() &&
157      ((m_output != m_last_output) ||
158         (m_output_valid != m_last_output_valid) || (m_enable_output != m_last_enable_output)))
178159   {
179160      m_last_output = m_output;
180161      m_last_output_valid = m_output_valid;
181162      m_last_enable_output = m_enable_output;
182163
183      m_output_cb(this);
164      m_output_cb();
184165   }
185166}
186167
trunk/src/emu/machine/74148.h
r29594r29595
4242#define TTL74148_H
4343
4444
45typedef device_delegate<void (void)> ttl74148_output_delegate;
4546
46struct ttl74148_config
47{
48   void (*m_output_cb)(device_t *device);
49};
47#define TTL74148_OUTPUT_CB(_name) void _name(void)
5048
5149
52class ttl74148_device : public device_t,
53                              public ttl74148_config
50class ttl74148_device : public device_t
5451{
5552public:
5653   ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5754   ~ttl74148_device() {}
5855
56   static void set_output_callback(device_t &device, ttl74148_output_delegate callback) { downcast<ttl74148_device &>(device).m_output_cb = callback; }
57
5958   /* must call update() after setting the inputs */
6059   void update();
6160
r29594r29595
6766
6867protected:
6968   // device-level overrides
70   virtual void device_config_complete();
7169   virtual void device_start();
7270   virtual void device_reset();
7371private:
7472   // internal state
73   ttl74148_output_delegate m_output_cb;
7574
7675   /* inputs */
7776   int m_input_lines[8]; /* pins 1-4,10-13 */
r29594r29595
9089
9190extern const device_type TTL74148;
9291
93#define MCFG_74148_ADD(_tag, _config) \
94   MCFG_DEVICE_ADD(_tag, TTL74148, 0) \
95   MCFG_DEVICE_CONFIG(_config)
9692
93#define MCFG_74148_OUTPUT_CB(_class, _method) \
94   ttl74148_device::set_output_callback(*device, ttl74148_output_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
95
96
9797#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team