ie15_keyboard_device: converted to devcb2. Also removed some machine().first_screen() from ie15.c (nw)

This commit is contained in:
Ivan Vangelista 2014-04-14 19:59:10 +00:00
parent 98596fb8c6
commit e741d4e6d3
3 changed files with 20 additions and 44 deletions

View File

@ -56,6 +56,7 @@ public:
m_maincpu(*this, "maincpu"),
m_beeper(*this, "beeper"),
m_rs232(*this, "rs232"),
m_screen(*this, "screen"),
m_io_keyboard(*this, "keyboard")
{ }
@ -127,6 +128,7 @@ protected:
required_device<cpu_device> m_maincpu;
required_device<beep_device> m_beeper;
required_device<rs232_port_device> m_rs232;
required_device<screen_device> m_screen;
required_ioport m_io_keyboard;
};
@ -337,13 +339,13 @@ READ8_MEMBER( ie15_state::flag_r ) {
switch (offset)
{
case 0: // hsync pulse (not hblank)
ret = machine().first_screen()->hpos() < IE15_HORZ_START;
ret = m_screen->hpos() < IE15_HORZ_START;
break;
case 1: // marker scanline
ret = (machine().first_screen()->vpos() % 11) > 7;
ret = (m_screen->vpos() % 11) > 7;
break;
case 2: // vblank
ret = !machine().first_screen()->vblank();
ret = !m_screen->vblank();
break;
case 4:
ret = m_kb_ruslat;
@ -438,11 +440,6 @@ WRITE16_MEMBER( ie15_state::kbd_put )
}
}
static IE15_KEYBOARD_INTERFACE( keyboard_intf )
{
DEVCB_DRIVER_MEMBER16(ie15_state, kbd_put)
};
void ie15_state::machine_reset()
{
memset(&m_video, 0, sizeof(m_video));
@ -509,7 +506,7 @@ UINT32 ie15_state::draw_scanline(UINT16 *p, UINT16 offset, UINT8 scanline)
UINT16 x, chr;
bg = 0; fg = 1; ra = scanline % 8;
blink = (machine().first_screen()->frame_number() % 10) > 4;
blink = (m_screen->frame_number() % 10) > 4;
red = m_io_keyboard->read() & IE_KB_RED;
for (x = offset; x < offset + 80; x++)
@ -559,11 +556,11 @@ void ie15_state::update_leds()
*/
TIMER_DEVICE_CALLBACK_MEMBER(ie15_state::scanline_callback)
{
UINT16 y = machine().first_screen()->vpos();
UINT16 y = m_screen->vpos();
DBG_LOG(3,"scanline_cb",
("addr %03x frame %" I64FMT "d x %.4d y %.3d row %.2d e:c:s %d:%d:%d\n",
m_video.ptr2, machine().first_screen()->frame_number(), machine().first_screen()->hpos(), y,
m_video.ptr2, m_screen->frame_number(), m_screen->hpos(), y,
y%11, m_video.enable, m_video.cursor, m_video.line25));
if (y < IE15_VERT_START) return;
@ -625,7 +622,8 @@ static MACHINE_CONFIG_START( ie15, ie15_state )
MCFG_DEFAULT_LAYOUT( layout_ie15 )
/* Devices */
MCFG_IE15_KEYBOARD_ADD("keyboard", keyboard_intf)
MCFG_DEVICE_ADD("keyboard", IE15_KEYBOARD, 0)
MCFG_IE15_KEYBOARD_CB(WRITE16(ie15_state, kbd_put))
MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, NULL)
MCFG_RS232_RXD_HANDLER(WRITELINE(ie15_state, serial_rx_callback))

View File

@ -19,6 +19,7 @@ ie15_keyboard_device::ie15_keyboard_device(const machine_config &mconfig, device
, m_io_kbd2(*this, "TERM_LINE2")
, m_io_kbd3(*this, "TERM_LINE3")
, m_io_kbdc(*this, "TERM_LINEC")
, m_keyboard_cb(*this)
{
}
@ -29,6 +30,7 @@ ie15_keyboard_device::ie15_keyboard_device(const machine_config &mconfig, const
, m_io_kbd2(*this, "TERM_LINE2")
, m_io_kbd3(*this, "TERM_LINE3")
, m_io_kbdc(*this, "TERM_LINEC")
, m_keyboard_cb(*this)
{
}
@ -152,24 +154,11 @@ machine_config_constructor ie15_keyboard_device::device_mconfig_additions() cons
void ie15_keyboard_device::device_start()
{
m_keyboard_func.resolve(m_keyboard_cb, *this);
m_keyboard_cb.resolve_safe();
m_timer = timer_alloc();
m_rom = (UINT8*)memregion("ie15kbd")->base();
}
void ie15_keyboard_device::device_config_complete()
{
const ie15_keyboard_interface *intf = reinterpret_cast<const ie15_keyboard_interface *>(static_config());
if(intf != NULL)
{
*static_cast<ie15_keyboard_interface *>(this) = *intf;
}
else
{
memset(&m_keyboard_cb, 0, sizeof(m_keyboard_cb));
}
}
void ie15_keyboard_device::device_reset()
{
m_last_code = 0;

View File

@ -24,36 +24,26 @@
#define IE_KB_SI 0x0f
#define IE_KB_SO 0x0e
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
struct ie15_keyboard_interface
{
devcb_write16 m_keyboard_cb;
};
#define IE15_KEYBOARD_INTERFACE(name) const ie15_keyboard_interface (name) =
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_IE15_KEYBOARD_ADD(_tag, _intrf) \
MCFG_DEVICE_ADD(_tag, IE15_KEYBOARD, 0) \
MCFG_DEVICE_CONFIG(_intrf)
#define MCFG_IE15_KEYBOARD_CB(_devcb) \
devcb = &ie15_keyboard_device::set_keyboard_callback(*device, DEVCB2_##_devcb);
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
class ie15_keyboard_device :
public device_t,
public ie15_keyboard_interface
public device_t
{
public:
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);
ie15_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
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); }
virtual ioport_constructor device_input_ports() const;
virtual machine_config_constructor device_mconfig_additions() const;
@ -69,8 +59,7 @@ protected:
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
virtual void device_config_complete();
virtual void send_key(UINT16 code) { m_keyboard_func(0, code); }
virtual void send_key(UINT16 code) { m_keyboard_cb((offs_t)0, code); }
emu_timer *m_timer;
private:
@ -81,7 +70,7 @@ private:
UINT8 m_ruslat;
UINT8 *m_rom;
devcb_resolved_write16 m_keyboard_func;
devcb2_write16 m_keyboard_cb;
};
extern const device_type IE15_KEYBOARD;