diff options
Diffstat (limited to 'src/devices/video/hd44780.h')
-rw-r--r-- | src/devices/video/hd44780.h | 95 |
1 files changed, 56 insertions, 39 deletions
diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h index 71b88f6f6b4..71bb5b30058 100644 --- a/src/devices/video/hd44780.h +++ b/src/devices/video/hd44780.h @@ -2,7 +2,7 @@ // copyright-holders:Sandro Ronco /*************************************************************************** - Hitachi HD44780 LCD controller + Hitachi HD44780 LCD controller ***************************************************************************/ @@ -19,7 +19,12 @@ #define HD44780_PIXEL_UPDATE(name) void name(bitmap_ind16 &bitmap, u8 line, u8 pos, u8 y, u8 x, int state) -// ======================> hd44780_device +// device type declarations +DECLARE_DEVICE_TYPE(HD44780, hd44780_device) +DECLARE_DEVICE_TYPE(HD44780U, hd44780u_device) +DECLARE_DEVICE_TYPE(SED1278, sed1278_device) +DECLARE_DEVICE_TYPE(KS0066, ks0066_device) + class hd44780_device : public device_t { @@ -27,12 +32,13 @@ public: typedef device_delegate<void (bitmap_ind16 &bitmap, u8 line, u8 pos, u8 y, u8 x, int state)> pixel_update_delegate; // construction/destruction - hd44780_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + hd44780_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // static configuration helpers void set_lcd_size(int lines, int chars) { m_lines = lines; m_chars = chars; } template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb.set(std::forward<T>(args)...); } void set_busy_factor(float f) { m_busy_factor = f; } // it's a workaround for inaccurate busy flag emulation + void set_function_set_at_any_time(bool v = true) { m_function_set_at_any_time = v; } // device interface void write(offs_t offset, u8 data); @@ -44,9 +50,9 @@ public: u8 db_r(); void db_w(u8 data); - DECLARE_WRITE_LINE_MEMBER(rs_w); - DECLARE_WRITE_LINE_MEMBER(rw_w); - DECLARE_WRITE_LINE_MEMBER(e_w); + void rs_w(int state); + void rw_w(int state); + void e_w(int state); const u8 *render(); virtual uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -54,39 +60,26 @@ public: protected: hd44780_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device-level overrides + // device_t implementation 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; - - // optional information overrides + virtual void device_clock_changed() override; + virtual void device_validity_check(validity_checker &valid) const override; virtual const tiny_rom_entry *device_rom_region() const override; - // charset - enum - { - CHARSET_HD44780_A00, - CHARSET_KS0066_F05 /*, - CHARSET_HD44780_A01, - CHARSET_HD44780_A02, - CHARSET_KS0066_F00, - CHARSET_KS0066_F03, - CHARSET_KS0066_F04, - CHARSET_KS0066_F06, - CHARSET_KS0066_F59 - */ - }; + TIMER_CALLBACK_MEMBER(clear_busy_flag); + TIMER_CALLBACK_MEMBER(blink_tick); virtual void control_write(u8 data); virtual u8 control_read(); virtual void data_write(u8 data); virtual u8 data_read(); - void set_charset_type(int type); - private: + enum { DDRAM, CGRAM }; + // internal helper - void set_busy_flag(uint16_t usec); + void set_busy_flag(uint16_t cycles); void correct_ac(); void update_ac(int direction); void update_nibble(int rs, int rw); @@ -94,11 +87,8 @@ private: void pixel_update(bitmap_ind16 &bitmap, u8 line, u8 pos, u8 y, u8 x, int state); // internal state - static constexpr device_timer_id TIMER_BUSY = 0; - static constexpr device_timer_id TIMER_BLINKING = 1; - - emu_timer * m_blink_timer; emu_timer * m_busy_timer; + emu_timer * m_blink_timer; u8 m_lines; // number of lines u8 m_chars; // chars for line @@ -132,23 +122,50 @@ private: int m_rs_state; int m_rw_state; bool m_nibble; - int m_charset_type; u8 m_render_buf[80 * 16]; + bool m_function_set_at_any_time; +}; - enum { DDRAM, CGRAM }; + +class hd44780u_device : public hd44780_device +{ +public: + // construction/destruction + hd44780u_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + static auto parent_rom_device_type() { return &HD44780; } + +protected: + // device_t implementation + virtual const tiny_rom_entry *device_rom_region() const override; }; -// ======================> ks0066_f05_device -class ks0066_f05_device : public hd44780_device +class sed1278_device : public hd44780_device { public: // construction/destruction - ks0066_f05_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + sed1278_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + static auto parent_rom_device_type() { return &HD44780; } + +protected: + // device_t implementation + virtual const tiny_rom_entry *device_rom_region() const override; }; -// device type definition -DECLARE_DEVICE_TYPE(HD44780, hd44780_device) -DECLARE_DEVICE_TYPE(KS0066_F05, ks0066_f05_device) + +class ks0066_device : public hd44780_device +{ +public: + // construction/destruction + ks0066_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + static auto parent_rom_device_type() { return &HD44780; } + +protected: + // device_t implementation + virtual const tiny_rom_entry *device_rom_region() const override; +}; #endif // MAME_VIDEO_HD44780_H |