diff options
Diffstat (limited to 'src/devices/machine/terminal.h')
-rw-r--r-- | src/devices/machine/terminal.h | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/devices/machine/terminal.h b/src/devices/machine/terminal.h index 47988d64138..dc430f2a83f 100644 --- a/src/devices/machine/terminal.h +++ b/src/devices/machine/terminal.h @@ -1,39 +1,44 @@ // license:BSD-3-Clause // copyright-holders:Miodrag Milanovic -#ifndef MAME_DEVICES_TERMINAL_H -#define MAME_DEVICES_TERMINAL_H +#ifndef MAME_MACHINE_TERMINAL_H +#define MAME_MACHINE_TERMINAL_H + +#pragma once #include "machine/keyboard.h" #include "sound/beep.h" + #define TERMINAL_SCREEN_TAG "terminal_screen" + /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_GENERIC_TERMINAL_KEYBOARD_CB(_devcb) \ - devcb = &generic_terminal_device::set_keyboard_callback(*device, DEVCB_##_devcb); +#define MCFG_GENERIC_TERMINAL_KEYBOARD_CB(cb) \ + generic_terminal_device::set_keyboard_callback(*device, (KEYBOARDCB_##cb)); + /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ -#define TERMINAL_WIDTH 80 -#define TERMINAL_HEIGHT 24 - INPUT_PORTS_EXTERN( generic_terminal ); class generic_terminal_device : public device_t { public: - generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source); + static constexpr unsigned TERMINAL_WIDTH = 80; + static constexpr unsigned TERMINAL_HEIGHT = 24; + generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<generic_terminal_device &>(device).m_keyboard_cb.set_callback(object); } + template <class Object> static void set_keyboard_callback(device_t &device, Object &&cb) + { downcast<generic_terminal_device &>(device).m_keyboard_cb = std::forward<Object>(cb); } DECLARE_WRITE8_MEMBER(write) { term_write(data); } - DECLARE_WRITE8_MEMBER(kbd_put); + void kbd_put(u8 data); uint32_t update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect); virtual ioport_constructor device_input_ports() const override; @@ -42,16 +47,20 @@ public: protected: enum { BELL_TIMER_ID = 20'000 }; + generic_terminal_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, unsigned w, unsigned h); + virtual void term_write(uint8_t data); virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; - virtual void send_key(uint8_t code) { m_keyboard_cb((offs_t)0, code); } + virtual void send_key(uint8_t code) { m_keyboard_cb(code); } optional_device<palette_device> m_palette; required_ioport m_io_term_conf; - uint8_t m_buffer[TERMINAL_WIDTH * 50]; // make big enough for teleprinter + unsigned const m_width; + unsigned const m_height; + std::unique_ptr<uint8_t []> m_buffer; uint8_t m_x_pos; private: @@ -64,9 +73,9 @@ private: emu_timer *m_bell_timer; required_device<beep_device> m_beeper; - devcb_write8 m_keyboard_cb; + generic_keyboard_device::output_delegate m_keyboard_cb; }; -extern const device_type GENERIC_TERMINAL; +DECLARE_DEVICE_TYPE(GENERIC_TERMINAL, generic_terminal_device) -#endif /* MAME_DEVICES_TERMINAL_H */ +#endif // MAME_DEVICES_TERMINAL_H |