Previous 199869 Revisions Next

r29641 Monday 14th April, 2014 at 19:59:10 UTC by Osso
ie15_keyboard_device: converted to devcb2. Also removed some machine().first_screen() from ie15.c (nw)
[src/mess/drivers]ie15.c
[src/mess/machine]ie15_kbd.c ie15_kbd.h

trunk/src/mess/drivers/ie15.c
r29640r29641
5656      m_maincpu(*this, "maincpu"),
5757      m_beeper(*this, "beeper"),
5858      m_rs232(*this, "rs232"),
59      m_screen(*this, "screen"),
5960      m_io_keyboard(*this, "keyboard")
6061   { }
6162
r29640r29641
127128   required_device<cpu_device> m_maincpu;
128129   required_device<beep_device> m_beeper;
129130   required_device<rs232_port_device> m_rs232;
131   required_device<screen_device> m_screen;
130132   required_ioport m_io_keyboard;
131133};
132134
r29640r29641
337339   switch (offset)
338340   {
339341      case 0: // hsync pulse (not hblank)
340         ret = machine().first_screen()->hpos() < IE15_HORZ_START;
342         ret = m_screen->hpos() < IE15_HORZ_START;
341343         break;
342344      case 1: // marker scanline
343         ret = (machine().first_screen()->vpos() % 11) > 7;
345         ret = (m_screen->vpos() % 11) > 7;
344346         break;
345347      case 2: // vblank
346         ret = !machine().first_screen()->vblank();
348         ret = !m_screen->vblank();
347349         break;
348350      case 4:
349351         ret = m_kb_ruslat;
r29640r29641
438440   }
439441}
440442
441static IE15_KEYBOARD_INTERFACE( keyboard_intf )
442{
443   DEVCB_DRIVER_MEMBER16(ie15_state, kbd_put)
444};
445
446443void ie15_state::machine_reset()
447444{
448445   memset(&m_video, 0, sizeof(m_video));
r29640r29641
509506   UINT16 x, chr;
510507
511508   bg = 0; fg = 1; ra = scanline % 8;
512   blink = (machine().first_screen()->frame_number() % 10) > 4;
509   blink = (m_screen->frame_number() % 10) > 4;
513510   red = m_io_keyboard->read() & IE_KB_RED;
514511
515512   for (x = offset; x < offset + 80; x++)
r29640r29641
559556*/
560557TIMER_DEVICE_CALLBACK_MEMBER(ie15_state::scanline_callback)
561558{
562   UINT16 y = machine().first_screen()->vpos();
559   UINT16 y = m_screen->vpos();
563560
564561   DBG_LOG(3,"scanline_cb",
565562      ("addr %03x frame %" I64FMT "d x %.4d y %.3d row %.2d e:c:s %d:%d:%d\n",
566      m_video.ptr2, machine().first_screen()->frame_number(), machine().first_screen()->hpos(), y,
563      m_video.ptr2, m_screen->frame_number(), m_screen->hpos(), y,
567564      y%11, m_video.enable, m_video.cursor, m_video.line25));
568565
569566   if (y < IE15_VERT_START) return;
r29640r29641
625622   MCFG_DEFAULT_LAYOUT( layout_ie15 )
626623
627624   /* Devices */
628   MCFG_IE15_KEYBOARD_ADD("keyboard", keyboard_intf)
625   MCFG_DEVICE_ADD("keyboard", IE15_KEYBOARD, 0)
626   MCFG_IE15_KEYBOARD_CB(WRITE16(ie15_state, kbd_put))
629627
630628   MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, NULL)
631629   MCFG_RS232_RXD_HANDLER(WRITELINE(ie15_state, serial_rx_callback))
trunk/src/mess/machine/ie15_kbd.c
r29640r29641
1919   , m_io_kbd2(*this, "TERM_LINE2")
2020   , m_io_kbd3(*this, "TERM_LINE3")
2121   , m_io_kbdc(*this, "TERM_LINEC")
22   , m_keyboard_cb(*this)
2223{
2324}
2425
r29640r29641
2930   , m_io_kbd2(*this, "TERM_LINE2")
3031   , m_io_kbd3(*this, "TERM_LINE3")
3132   , m_io_kbdc(*this, "TERM_LINEC")
33   , m_keyboard_cb(*this)
3234{
3335}
3436
r29640r29641
152154
153155void ie15_keyboard_device::device_start()
154156{
155   m_keyboard_func.resolve(m_keyboard_cb, *this);
157   m_keyboard_cb.resolve_safe();
156158   m_timer = timer_alloc();
157159   m_rom = (UINT8*)memregion("ie15kbd")->base();
158160}
159161
160void ie15_keyboard_device::device_config_complete()
161{
162   const ie15_keyboard_interface *intf = reinterpret_cast<const ie15_keyboard_interface *>(static_config());
163   if(intf != NULL)
164   {
165      *static_cast<ie15_keyboard_interface *>(this) = *intf;
166   }
167   else
168   {
169      memset(&m_keyboard_cb, 0, sizeof(m_keyboard_cb));
170   }
171}
172
173162void ie15_keyboard_device::device_reset()
174163{
175164   m_last_code = 0;
trunk/src/mess/machine/ie15_kbd.h
r29640r29641
2424#define IE_KB_SI    0x0f
2525#define IE_KB_SO    0x0e
2626
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
3027
31struct ie15_keyboard_interface
32{
33   devcb_write16 m_keyboard_cb;
34};
35
36#define IE15_KEYBOARD_INTERFACE(name) const ie15_keyboard_interface (name) =
37
3828/***************************************************************************
3929    DEVICE CONFIGURATION MACROS
4030***************************************************************************/
4131
42#define MCFG_IE15_KEYBOARD_ADD(_tag, _intrf) \
43   MCFG_DEVICE_ADD(_tag, IE15_KEYBOARD, 0) \
44   MCFG_DEVICE_CONFIG(_intrf)
32#define MCFG_IE15_KEYBOARD_CB(_devcb) \
33   devcb = &ie15_keyboard_device::set_keyboard_callback(*device, DEVCB2_##_devcb);
4534
4635/***************************************************************************
4736    FUNCTION PROTOTYPES
4837***************************************************************************/
4938
5039class ie15_keyboard_device :
51   public device_t,
52   public ie15_keyboard_interface
40   public device_t
5341{
5442public:
5543   ie15_keyboard_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);
5644   ie15_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
45   
46   template<class _Object> static devcb2_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<ie15_keyboard_device &>(device).m_keyboard_cb.set_callback(object); }
5747
5848   virtual ioport_constructor device_input_ports() const;
5949   virtual machine_config_constructor device_mconfig_additions() const;
r29640r29641
6959   virtual void device_start();
7060   virtual void device_reset();
7161   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
72   virtual void device_config_complete();
73   virtual void send_key(UINT16 code) { m_keyboard_func(0, code); }
62   virtual void send_key(UINT16 code) { m_keyboard_cb((offs_t)0, code); }
7463   emu_timer *m_timer;
7564
7665private:
r29640r29641
8170   UINT8 m_ruslat;
8271   UINT8 *m_rom;
8372
84   devcb_resolved_write16 m_keyboard_func;
73   devcb2_write16 m_keyboard_cb;
8574};
8675
8776extern const device_type IE15_KEYBOARD;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team