Previous 199869 Revisions Next

r29638 Monday 14th April, 2014 at 17:07:14 UTC by Osso
ay31015_device: converted to devcb2 (nw)
[src/emu/machine]ay31015.c ay31015.h
[src/mess/drivers]nascom1.c ptcsol.c sorcerer.c trs80.c z80ne.c

trunk/src/emu/machine/ay31015.c
r29637r29638
9696const device_type AY51013 = &device_creator<ay51013_device>;
9797
9898ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
99            : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
99            : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
100            m_rx_clock(0),
101            m_tx_clock(0),
102            m_read_si_cb(*this),
103            m_write_so_cb(*this),
104            m_status_changed_cb(*this)
100105{
101106}
102107
103108ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
104            : device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock, "ay31015", __FILE__)
109            : device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock, "ay31015", __FILE__),
110            m_read_si_cb(*this),
111            m_write_so_cb(*this),
112            m_status_changed_cb(*this)
105113{
106114}
107115
r29637r29638
111119}
112120
113121//-------------------------------------------------
114//  device_config_complete - perform any
115//  operations now that the configuration is
116//  complete
117//-------------------------------------------------
118
119void ay31015_device::device_config_complete()
120{
121   // inherit a copy of the static data
122   const ay31015_config *intf = reinterpret_cast<const ay31015_config *>(static_config());
123   if (intf != NULL)
124      *static_cast<ay31015_config *>(this) = *intf;
125
126   // or initialize to defaults if none provided
127   else
128   {
129      memset(&read_si_cb, 0, sizeof(read_si_cb));
130      memset(&write_so_cb, 0, sizeof(write_so_cb));
131      memset(&status_changed_cb, 0, sizeof(status_changed_cb));
132      transmitter_clock = 0;
133      receiver_clock = 0;
134   }
135}
136
137//-------------------------------------------------
138122//  device_start - device-specific startup
139123//-------------------------------------------------
140124
141125void ay31015_device::device_start()
142126{
143   m_read_si.resolve(read_si_cb, *this);
144   m_write_so.resolve(write_so_cb, *this);
145   m_status_changed.resolve(status_changed_cb, *this);
127   m_read_si_cb.resolve();
128   m_write_so_cb.resolve();
129   m_status_changed_cb.resolve();
146130
147   m_tx_clock = transmitter_clock;
148   m_rx_clock = receiver_clock;
149
150131   m_rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::rx_process),this));
151132   m_tx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::tx_process),this));
152133
r29637r29638
191172
192173inline UINT8 ay31015_device::get_si()
193174{
194   if (!m_read_si.isnull())
195      m_pins[AY31015_SI] = m_read_si(0) ? 1 : 0;
175   if (!m_read_si_cb.isnull())
176      m_pins[AY31015_SI] = m_read_si_cb(0) ? 1 : 0;
196177
197178   return m_pins[AY31015_SI];
198179}
r29637r29638
202183{
203184   m_pins[AY31015_SO] = data ? 1 : 0;
204185
205   if (!m_write_so.isnull())
206      m_write_so(0, m_pins[AY31015_SO]);
186   if (!m_write_so_cb.isnull())
187      m_write_so_cb((offs_t)0, m_pins[AY31015_SO]);
207188}
208189
209190
r29637r29638
238219   }
239220   status_pins_changed += update_status_pin(STATUS_EOC, AY31015_EOC);
240221
241   if (status_pins_changed && !m_status_changed.isnull())
222   if (status_pins_changed && !m_status_changed_cb.isnull())
242223   {
243      m_status_changed(0, status_pins_changed);
224      m_status_changed_cb((offs_t)0, status_pins_changed);
244225   }
245226}
246227
trunk/src/emu/machine/ay31015.h
r29637r29638
3939};
4040
4141
42struct  ay31015_config
43{
44   double              transmitter_clock;          /* TCP - pin 40 */
45   double              receiver_clock;             /* RCP - pin 17 */
46   devcb_read8         read_si_cb;                 /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
47   devcb_write8        write_so_cb;                /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
48   devcb_write8        status_changed_cb;          /* This will be called whenever one of the status pins may have changed. Optional */
49};
50
51
5242/***************************************************************************
5343    DEVICE INTERFACE
5444***************************************************************************/
r29637r29638
6656
6757ALLOW_SAVE_TYPE(state_t);
6858
69class ay31015_device : public device_t,
70                  public ay31015_config
59class ay31015_device : public device_t
7160{
7261public:
7362   ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7463   ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
7564   ~ay31015_device() {}
7665
77
66   static void set_tx_clock(device_t &device, double tx_clock) { downcast<ay31015_device &>(device).m_tx_clock = tx_clock; }
67   static void set_rx_clock(device_t &device, double rx_clock) { downcast<ay31015_device &>(device).m_rx_clock = rx_clock; }
68   template<class _Object> static devcb2_base &set_read_si_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_read_si_cb.set_callback(object); }
69   template<class _Object> static devcb2_base &set_write_so_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_write_so_cb.set_callback(object); }
70   template<class _Object> static devcb2_base &set_status_changed_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_status_changed_cb.set_callback(object); }
71   
7872   /* Set an input pin */
7973   void set_input_pin( ay31015_input_pin_t pin, int data );
8074
r29637r29638
10296
10397protected:
10498   // device-level overrides
105   virtual void device_config_complete();
10699   virtual void device_start();
107100   virtual void device_reset();
108101
r29637r29638
133126   UINT8 m_rx_bit_count;
134127   UINT8 m_rx_parity;
135128   UINT16 m_rx_pulses;   // total pulses left
136   double m_rx_clock;
129   double m_rx_clock;    /* RCP - pin 17 */
137130   emu_timer *m_rx_timer;
138131
139132   state_t m_tx_state;
r29637r29638
141134   UINT8 m_tx_buffer;    // next byte to send
142135   UINT8 m_tx_parity;
143136   UINT16 m_tx_pulses;   // total pulses left
144   double m_tx_clock;
137   double m_tx_clock;    /* TCP - pin 40 */
145138   emu_timer *m_tx_timer;
146139
147   devcb_resolved_read8    m_read_si;                /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
148   devcb_resolved_write8   m_write_so;               /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
149   devcb_resolved_write8   m_status_changed;         /* This will be called whenever one of the status pins may have changed. Optional */
140   devcb2_read8 m_read_si_cb;                 /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
141   devcb2_write8 m_write_so_cb;                /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
142   devcb2_write8 m_status_changed_cb;          /* This will be called whenever one of the status pins may have changed. Optional */
150143};
151144
152145class ay51013_device : public ay31015_device
r29637r29638
168161 DEVICE CONFIGURATION MACROS
169162 ***************************************************************************/
170163
171#define MCFG_AY31015_ADD(_tag, _config) \
172   MCFG_DEVICE_ADD(_tag, AY31015, 0)       \
173   MCFG_DEVICE_CONFIG(_config)
174164
165#define MCFG_AY31015_TX_CLOCK(_txclk) \
166   ay31015_device::set_tx_clock(*device, _txclk);
167   
168#define MCFG_AY31015_RX_CLOCK(_rxclk) \
169   ay31015_device::set_rx_clock(*device, _rxclk);
175170
171#define MCFG_AY31015_READ_SI_CB(_devcb) \
172   devcb = &ay31015_device::set_read_si_callback(*device, DEVCB2_##_devcb);
176173
174#define MCFG_AY31015_WRITE_SO_CB(_devcb) \
175   devcb = &ay31015_device::set_write_so_callback(*device, DEVCB2_##_devcb);
176
177#define MCFG_AY31015_STATUS_CHANGED_CB(_devcb) \
178    devcb = &ay31015_device::set_status_changed_callback(*device, DEVCB2_##_devcb);
179   
180
181#define MCFG_AY51013_TX_CLOCK(_txclk) \
182   ay51013_device::set_tx_clock(*device, _txclk);
183   
184#define MCFG_AY51013_RX_CLOCK(_rxclk) \
185   ay51013_device::set_rx_clock(*device, _rxclk);
186
187#define MCFG_AY51013_READ_SI_CB(_devcb) \
188   devcb = &ay51013_device::set_read_si_callback(*device, DEVCB2_##_devcb);
189
190#define MCFG_AY51013_WRITE_SO_CB(_devcb) \
191   devcb = &ay51013_device::set_write_so_callback(*device, DEVCB2_##_devcb);
192
193#define MCFG_AY51013_STATUS_CHANGED_CB(_devcb) \
194    devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB2_##_devcb);
195
177196#endif
trunk/src/mess/drivers/sorcerer.c
r29637r29638
386386
387387/**********************************************************************************************************/
388388
389static const ay31015_config sorcerer_ay31015_config =
390{
391   4800.0,
392   4800.0,
393   DEVCB_NULL,
394   DEVCB_NULL,
395   DEVCB_NULL
396};
397
398
399389static const cassette_interface sorcerer_cassette_interface =
400390{
401391   sorcerer_cassette_formats,
r29637r29638
445435   MCFG_SOUND_WAVE_ADD(WAVE2_TAG, "cassette2")
446436   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) // cass2 speaker
447437
448   MCFG_AY31015_ADD( "uart", sorcerer_ay31015_config )
449
438   MCFG_DEVICE_ADD( "uart", AY31015, 0 )
439   MCFG_AY31015_TX_CLOCK(4800.0)
440   MCFG_AY31015_RX_CLOCK(4800.0)
441   
450442   /* printer */
451443   MCFG_CENTRONICS_ADD("centronics", centronics_printers, "covox")
452444   MCFG_SLOT_OPTION_ADD( "covox", CENTRONICS_COVOX )
trunk/src/mess/drivers/trs80.c
r29637r29638
554554   NULL
555555};
556556
557static const ay31015_config trs80_ay31015_config =
558{
559   0.0,
560   0.0,
561   DEVCB_NULL,
562   DEVCB_NULL,
563   DEVCB_NULL
564};
565
566557static const floppy_interface trs80_floppy_interface =
567558{
568559   DEVCB_NULL,
r29637r29638
629620
630621   MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics")
631622
632   MCFG_AY31015_ADD( "tr1602", trs80_ay31015_config )
623   MCFG_DEVICE_ADD( "tr1602", AY31015, 0 )
633624MACHINE_CONFIG_END
634625
635626static MACHINE_CONFIG_DERIVED( model3, model1 )
trunk/src/mess/drivers/z80ne.c
r29637r29638
400400   rgb_t(0xff, 0xc4, 0x18)      /* ALPHANUMERIC BRIGHT ORANGE */
401401};
402402
403static const ay31015_config z80ne_ay31015_config =
404{
405   4800.0,
406   4800.0,
407   DEVCB_NULL,
408   DEVCB_NULL,
409   DEVCB_NULL
410};
411
412403static const cassette_interface z80ne_cassettea_config =
413404{
414405   cassette_default_formats,
r29637r29638
464455   MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80ne)
465456   MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80ne)
466457
467   MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
458   MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
459   MCFG_AY31015_TX_CLOCK(4800.0)
460   MCFG_AY31015_RX_CLOCK(4800.0)
468461
469462   MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
470463   MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
r29637r29638
508501   MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80netb)
509502   MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80netb)
510503
511   MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
504   MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
505   MCFG_AY31015_TX_CLOCK(4800.0)
506   MCFG_AY31015_RX_CLOCK(4800.0)
512507
513508   MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
514509   MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
r29637r29638
536531   MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80netf)
537532   MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80netf)
538533
539   MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
534   MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
535   MCFG_AY31015_TX_CLOCK(4800.0)
536   MCFG_AY31015_RX_CLOCK(4800.0)
540537
541538   MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
542539   MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
trunk/src/mess/drivers/nascom1.c
r29637r29638
258258 *
259259 *************************************/
260260
261static const ay31015_config nascom1_ay31015_config =
262{
263   ( XTAL_16MHz / 16 ) / 256,
264   ( XTAL_16MHz / 16 ) / 256,
265   DEVCB_DRIVER_MEMBER(nascom1_state, nascom1_hd6402_si),
266   DEVCB_DRIVER_MEMBER(nascom1_state, nascom1_hd6402_so),
267   DEVCB_NULL
268};
269
270
271261static Z80PIO_INTERFACE( nascom1_z80pio_intf )
272262{
273263   DEVCB_NULL,
r29637r29638
299289   MCFG_GFXDECODE_ADD("gfxdecode", "palette", nascom1)
300290   MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette")
301291
302   MCFG_AY31015_ADD( "hd6402", nascom1_ay31015_config )
292   MCFG_DEVICE_ADD( "hd6402", AY31015, 0 )
293   MCFG_AY31015_TX_CLOCK(( XTAL_16MHz / 16 ) / 256)
294   MCFG_AY31015_RX_CLOCK(( XTAL_16MHz / 16 ) / 256)
295   MCFG_AY51013_READ_SI_CB(READ8(nascom1_state, nascom1_hd6402_si))
296   MCFG_AY51013_WRITE_SO_CB(WRITE8(nascom1_state, nascom1_hd6402_so))
297   
303298
304299   MCFG_Z80PIO_ADD( "z80pio", XTAL_16MHz/8, nascom1_z80pio_intf )
305300
trunk/src/mess/drivers/ptcsol.c
r29637r29638
547547   PORT_CONFSETTING(    0x02, "6575")
548548INPUT_PORTS_END
549549
550static const ay31015_config sol20_ay31015_config =
551{
552   4800.0,
553   4800.0,
554   DEVCB_NULL,
555   DEVCB_NULL,
556   DEVCB_NULL
557};
558550
559
560551static const cassette_interface sol20_cassette_interface =
561552{
562553   sol20_cassette_formats,//cassette_default_formats,
r29637r29638
767758   // devices
768759   MCFG_CASSETTE_ADD( "cassette", sol20_cassette_interface )
769760   MCFG_CASSETTE_ADD( "cassette2", sol20_cassette_interface )
770   MCFG_AY31015_ADD( "uart", sol20_ay31015_config )
771   MCFG_AY31015_ADD( "uart_s", sol20_ay31015_config )
761   MCFG_DEVICE_ADD( "uart", AY31015, 0 )
762   MCFG_AY31015_TX_CLOCK(4800.0)
763   MCFG_AY31015_RX_CLOCK(4800.0)
764   MCFG_DEVICE_ADD( "uart_s", AY31015, 0 )
765   MCFG_AY31015_TX_CLOCK(4800.0)
766   MCFG_AY31015_RX_CLOCK(4800.0)
772767   MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
773768   MCFG_GENERIC_KEYBOARD_CB(WRITE8(sol20_state, kbd_put))
774769MACHINE_CONFIG_END

Previous 199869 Revisions Next


© 1997-2024 The MAME Team