summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/terminal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/terminal.cpp')
-rw-r--r--src/devices/machine/terminal.cpp171
1 files changed, 100 insertions, 71 deletions
diff --git a/src/devices/machine/terminal.cpp b/src/devices/machine/terminal.cpp
index a2be090b261..b4d0d4b6c4a 100644
--- a/src/devices/machine/terminal.cpp
+++ b/src/devices/machine/terminal.cpp
@@ -141,24 +141,20 @@ static const UINT8 terminal_font[256*16] =
};
generic_terminal_device::generic_terminal_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)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_palette(*this, "palette"),
- m_io_term_conf(*this, "TERM_CONF"),
- m_x_pos(0),
- m_framecnt(0),
- m_y_pos(0),
- m_keyboard_cb(*this)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+ , m_palette(*this, "palette")
+ , m_io_term_conf(*this, "TERM_CONF")
+ , m_x_pos(0)
+ , m_framecnt(0)
+ , m_y_pos(0)
+ , m_bell_timer(nullptr)
+ , m_beeper(*this, "beeper")
+ , m_keyboard_cb(*this)
{
}
generic_terminal_device::generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, GENERIC_TERMINAL, "Generic Terminal", tag, owner, clock, "generic_terminal", __FILE__),
- m_palette(*this, "palette"),
- m_io_term_conf(*this, "TERM_CONF"),
- m_x_pos(0),
- m_framecnt(0),
- m_y_pos(0),
- m_keyboard_cb(*this)
+ : generic_terminal_device(mconfig, GENERIC_TERMINAL, "Generic Terminal", tag, owner, clock, "generic_terminal", __FILE__)
{
}
@@ -186,7 +182,7 @@ void generic_terminal_device::write_char(UINT8 data)
void generic_terminal_device::clear()
{
- memset(m_buffer,0x20,TERMINAL_WIDTH*TERMINAL_HEIGHT);
+ std::fill(std::begin(m_buffer), std::end(m_buffer), 0x20);
m_x_pos = 0;
m_y_pos = 0;
}
@@ -196,44 +192,52 @@ void generic_terminal_device::term_write(UINT8 data)
if (data > 0x1f)
{
// printable char
- if (data!=0x7f) write_char(data);
+ if (data != 0x7f) write_char(data);
}
else
{
+ const UINT16 options = m_io_term_conf->read();
switch(data)
{
- case 0x07 : // bell
- break;
-
- case 0x08: if (m_x_pos) m_x_pos--;
- break;
-
- case 0x09: m_x_pos = (m_x_pos & 0xf8) + 8;
- if (m_x_pos >= TERMINAL_WIDTH)
- m_x_pos = TERMINAL_WIDTH-1;
- break;
-
- case 0x0a: m_y_pos++;
- m_x_pos = 0;
- if (m_y_pos >= TERMINAL_HEIGHT)
- {
- scroll_line();
- m_y_pos = TERMINAL_HEIGHT-1;
- }
- break;
-
- case 0x0b: if (m_y_pos) m_y_pos--;
- break;
+ case 0x07: // bell
+ m_beeper->set_state(1);
+ m_bell_timer->reset(attotime::from_msec(250));
+ break;
+
+ case 0x08: // backspace
+ if (m_x_pos) m_x_pos--;
+ break;
+
+ case 0x09: // horizontal tab
+ m_x_pos = (std::min<UINT8>)((m_x_pos & 0xf8) + 8, TERMINAL_WIDTH - 1);
+ break;
+
+ case 0x0d: // carriage return
+ m_x_pos = 0;
+ if (!(options & 0x080)) break;
+
+ case 0x0a: // linefeed
+ m_y_pos++;
+ if (m_y_pos >= TERMINAL_HEIGHT)
+ {
+ scroll_line();
+ m_y_pos = TERMINAL_HEIGHT - 1;
+ }
+ if (options & 0x040) m_x_pos = 0;
+ break;
- case 0x0c: clear();
- break;
+ case 0x0b: // vertical tab
+ if (m_y_pos) m_y_pos--;
+ break;
- case 0x0d: m_x_pos = 0;
- break;
+ case 0x0c: // form feed
+ clear();
+ break;
- case 0x1e: m_x_pos = 0;
- m_y_pos = 0;
- break;
+ case 0x1e: // record separator
+ m_x_pos = 0;
+ m_y_pos = 0;
+ break;
}
}
}
@@ -243,17 +247,17 @@ void generic_terminal_device::term_write(UINT8 data)
***************************************************************************/
UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- UINT8 options = m_io_term_conf->read();
+ const UINT16 options = m_io_term_conf->read();
UINT16 cursor = m_y_pos * TERMINAL_WIDTH + m_x_pos;
UINT8 y,ra,chr,gfx;
UINT16 sy=0,ma=0,x;
- switch (options & 0x30)
+ switch (options & 0x030)
{
- case 0x10:
+ case 0x010:
m_palette->set_pen_color(1, rgb_t(0xf7, 0xaa, 0x00));
break;
- case 0x20:
+ case 0x020:
m_palette->set_pen_color(1, rgb_t::white);
break;
default:
@@ -275,16 +279,16 @@ UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitm
chr = m_buffer[x];
gfx = terminal_font[(chr<<4) | ra ];
- if ((x == cursor) && (options & 1)) // at cursor position and want a cursor
+ if ((x == cursor) && (options & 0x001)) // at cursor position and want a cursor
{
if ((options & 2) || (ra == 9)) // block, or underline & at bottom line
{
- if ((options & 4) && (m_framecnt & 8)) // want blink & time to blink
+ if ((options & 0x004) && (m_framecnt & 8)) // want blink & time to blink
{
}
else
{
- if (options & 8)
+ if (options & 0x008)
gfx ^= 0xff; // invert
else
gfx |= 0xff; // overwrite
@@ -303,15 +307,15 @@ UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitm
*p++ = (BIT( gfx, 0 ))?font_color:0;
}
}
- ma+=TERMINAL_WIDTH;
+ ma += TERMINAL_WIDTH;
}
return 0;
}
WRITE8_MEMBER( generic_terminal_device::kbd_put )
{
- if (data)
- send_key(data);
+ if (m_io_term_conf->read() & 0x100) term_write(data);
+ send_key(data);
}
/***************************************************************************
@@ -330,6 +334,10 @@ static MACHINE_CONFIG_FRAGMENT( generic_terminal )
MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
MCFG_GENERIC_KEYBOARD_CB(WRITE8(generic_terminal_device, kbd_put))
+
+ MCFG_SPEAKER_STANDARD_MONO("bell")
+ MCFG_SOUND_ADD("beeper", BEEP, 2'000)
+ MCFG_SOUND_ROUTE(ALL_OUTPUTS, "bell", 1.0)
MACHINE_CONFIG_END
machine_config_constructor generic_terminal_device::device_mconfig_additions() const
@@ -339,6 +347,7 @@ machine_config_constructor generic_terminal_device::device_mconfig_additions() c
void generic_terminal_device::device_start()
{
+ m_bell_timer = timer_alloc(BELL_TIMER_ID);
m_keyboard_cb.resolve_safe();
save_item(NAME(m_buffer));
save_item(NAME(m_x_pos));
@@ -348,10 +357,21 @@ void generic_terminal_device::device_start()
void generic_terminal_device::device_reset()
{
+ m_beeper->set_state(0);
clear();
m_framecnt = 0;
}
+void generic_terminal_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ switch (id)
+ {
+ case BELL_TIMER_ID:
+ m_beeper->set_state(0);
+ break;
+ }
+}
+
/*
Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
-------------------------------------------------------------------------------------
@@ -391,22 +411,31 @@ Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct
*/
INPUT_PORTS_START( generic_terminal )
PORT_START("TERM_CONF")
- PORT_CONFNAME( 0x01, 0x01, "Cursor")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x01, DEF_STR(Yes))
- PORT_CONFNAME( 0x02, 0x02, "Type")
- PORT_CONFSETTING( 0x00, "Underline")
- PORT_CONFSETTING( 0x02, "Block")
- PORT_CONFNAME( 0x04, 0x04, "Blinking")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x04, DEF_STR(Yes))
- PORT_CONFNAME( 0x08, 0x08, "Invert")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x08, DEF_STR(Yes))
- PORT_CONFNAME( 0x30, 0x00, "Color")
- PORT_CONFSETTING( 0x00, "Green")
- PORT_CONFSETTING( 0x10, "Amber")
- PORT_CONFSETTING( 0x20, "White")
+ PORT_CONFNAME( 0x001, 0x001, "Cursor" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x001, DEF_STR(Yes) )
+ PORT_CONFNAME( 0x002, 0x002, "Type" )
+ PORT_CONFSETTING( 0x000, "Underline" )
+ PORT_CONFSETTING( 0x002, "Block" )
+ PORT_CONFNAME( 0x004, 0x004, "Blinking" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x004, DEF_STR(Yes) )
+ PORT_CONFNAME( 0x008, 0x008, "Invert" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x008, DEF_STR(Yes) )
+ PORT_CONFNAME( 0x030, 0x000, "Color" )
+ PORT_CONFSETTING( 0x000, "Green" )
+ PORT_CONFSETTING( 0x010, "Amber" )
+ PORT_CONFSETTING( 0x020, "White" )
+ PORT_CONFNAME( 0x040, 0x000, "Auto CR on LF" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x040, DEF_STR(Yes) )
+ PORT_CONFNAME( 0x080, 0x000, "Auto LF on CR" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x080, DEF_STR(Yes) )
+ PORT_CONFNAME( 0x100, 0x000, "Local echo" )
+ PORT_CONFSETTING( 0x000, DEF_STR(No) )
+ PORT_CONFSETTING( 0x100, DEF_STR(Yes) )
INPUT_PORTS_END
ioport_constructor generic_terminal_device::device_input_ports() const