Previous 199869 Revisions Next

r28716 Wednesday 19th March, 2014 at 13:08:02 UTC by Curt Coder
(MESS) upd65031: devcb2. (nw)
[src/mess/drivers]z88.c
[src/mess/machine]upd65031.c upd65031.h

trunk/src/mess/drivers/z88.c
r28715r28716
621621{
622622   z88_screen_update,                                      // callback for update the LCD
623623   z88_bankswitch_update,                                  // callback for update the bankswitch
624   DEVCB_DRIVER_MEMBER(z88_state, kb_r),                   // kb read input
625   DEVCB_CPU_INPUT_LINE("maincpu", 0),                     // INT line out
626   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI),        // NMI line out
627   DEVCB_DEVICE_LINE_MEMBER("speaker", speaker_sound_device, level_w)         // Speaker line out
628624};
629625
630626static const z88cart_interface z88_cart_interface =
r28715r28716
664660   MCFG_DEFAULT_LAYOUT(layout_lcd)
665661
666662   MCFG_UPD65031_ADD("blink", XTAL_9_8304MHz, z88_blink_intf)
663   MCFG_UPD65031_KB_CALLBACK(READ8(z88_state, kb_r))
664   MCFG_UPD65031_INT_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
665   MCFG_UPD65031_NMI_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI))
666   MCFG_UPD65031_SPKR_CALLBACK(DEVWRITELINE("speaker", speaker_sound_device, level_w))
667667
668668   /* sound hardware */
669669   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mess/machine/upd65031.c
r28715r28716
142142   {
143143      if (LOG) logerror("uPD65031 '%s': set int\n", tag());
144144
145      m_out_int_func(ASSERT_LINE);
145      m_write_int(ASSERT_LINE);
146146   }
147147   else
148148   {
149149      if (LOG) logerror("uPD65031 '%s': clear int\n", tag());
150150
151      m_out_int_func(CLEAR_LINE);
151      m_write_int(CLEAR_LINE);
152152   }
153153}
154154
r28715r28716
194194//-------------------------------------------------
195195
196196upd65031_device::upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
197   : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__)
197   : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__),
198   m_read_kb(*this),
199   m_write_int(*this),
200   m_write_nmi(*this),
201   m_write_spkr(*this)
198202{
199203}
200204
r28715r28716
218222   {
219223      m_screen_update_cb = NULL;
220224      m_out_mem_cb = NULL;
221      memset(&m_in_kb_cb, 0, sizeof(m_in_kb_cb));
222      memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
223      memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
224      memset(&m_out_spkr_cb, 0, sizeof(m_out_spkr_cb));
225225   }
226226}
227227
r28715r28716
233233void upd65031_device::device_start()
234234{
235235   // resolve callbacks
236   m_out_int_func.resolve(m_out_int_cb, *this);
237   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
238   m_out_spkr_func.resolve(m_out_spkr_cb, *this);
239   m_int_kb_func.resolve(m_in_kb_cb, *this);
236   m_read_kb.resolve_safe(0);
237   m_write_int.resolve_safe();
238   m_write_nmi.resolve_safe();
239   m_write_spkr.resolve_safe();
240240
241241   // allocate timers
242242   m_rtc_timer = timer_alloc(TIMER_RTC);
r28715r28716
304304   case TIMER_RTC:
305305
306306      // if a key is pressed sets the interrupt
307      if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_int_kb_func(0) != 0xff)
307      if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_read_kb(0) != 0xff)
308308      {
309309         if (LOG) logerror("uPD65031 '%s': Keyboard interrupt!\n", tag());
310310
r28715r28716
393393      break;
394394   case TIMER_SPEAKER:
395395      m_speaker_state = !m_speaker_state;
396      m_out_spkr_func(m_speaker_state ? 1 : 0);
396      m_write_spkr(m_speaker_state ? 1 : 0);
397397      break;
398398   }
399399}
r28715r28716
436436            if (LOG) logerror("uPD65031 '%s': entering snooze!\n", tag());
437437         }
438438
439         UINT8 data = m_int_kb_func(offset>>8);
439         UINT8 data = m_read_kb(offset>>8);
440440
441441         if (LOG) logerror("uPD65031 '%s': key r %02x: %02x\n", tag(), offset>>8, data);
442442
r28715r28716
516516            {
517517               // speaker controlled by SBIT
518518               m_speaker_state = BIT(data, 6);
519               m_out_spkr_func(m_speaker_state);
519               m_write_spkr(m_speaker_state);
520520            }
521521            else
522522            {
trunk/src/mess/machine/upd65031.h
r28715r28716
2424#define UPD65031_INTERFACE(name) \
2525   const upd65031_interface (name) =
2626
27#define MCFG_UPD65031_KB_CALLBACK(_read) \
28   devcb = &upd65031_device::set_kb_rd_callback(*device, DEVCB2_##_read);
2729
30#define MCFG_UPD65031_INT_CALLBACK(_write) \
31   devcb = &upd65031_device::set_int_wr_callback(*device, DEVCB2_##_write);
32
33#define MCFG_UPD65031_NMI_CALLBACK(_write) \
34   devcb = &upd65031_device::set_nmi_wr_callback(*device, DEVCB2_##_write);
35
36#define MCFG_UPD65031_SPKR_CALLBACK(_write) \
37   devcb = &upd65031_device::set_spkr_wr_callback(*device, DEVCB2_##_write);
38
39
2840//**************************************************************************
2941//  TYPE DEFINITIONS
3042//**************************************************************************
r28715r28716
4254{
4355   upd65031_screen_update_func m_screen_update_cb;  // callback for update the LCD
4456   upd65031_memory_update_func m_out_mem_cb;        // callback for update bankswitch
45   devcb_read8                 m_in_kb_cb;          // kb read input
46   devcb_write_line            m_out_int_cb;        // INT line out
47   devcb_write_line            m_out_nmi_cb;        // NMI line out
48   devcb_write_line            m_out_spkr_cb;       // Speaker line out
4957};
5058
5159
r28715r28716
5866   // construction/destruction
5967   upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6068
69   template<class _Object> static devcb2_base &set_kb_rd_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_read_kb.set_callback(object); }
70   template<class _Object> static devcb2_base &set_int_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_int.set_callback(object); }
71   template<class _Object> static devcb2_base &set_nmi_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_nmi.set_callback(object); }
72   template<class _Object> static devcb2_base &set_spkr_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_spkr.set_callback(object); }
73
6174   DECLARE_READ8_MEMBER( read );
6275   DECLARE_WRITE8_MEMBER( write );
6376   DECLARE_WRITE_LINE_MEMBER( flp_w );
r28715r28716
7992   static const device_timer_id TIMER_FLASH = 1;
8093   static const device_timer_id TIMER_SPEAKER = 2;
8194
82   devcb_resolved_write_line   m_out_int_func;
83   devcb_resolved_write_line   m_out_nmi_func;
84   devcb_resolved_write_line   m_out_spkr_func;
85   devcb_resolved_read8        m_int_kb_func;
95   devcb2_read8        m_read_kb;
96   devcb2_write_line   m_write_int;
97   devcb2_write_line   m_write_nmi;
98   devcb2_write_line   m_write_spkr;
8699
87100   int     m_mode;
88101   UINT16  m_lcd_regs[5];      // LCD registers

Previous 199869 Revisions Next


© 1997-2024 The MAME Team