diff options
Diffstat (limited to 'src/devices/video/hlcd0515.cpp')
-rw-r--r-- | src/devices/video/hlcd0515.cpp | 119 |
1 files changed, 93 insertions, 26 deletions
diff --git a/src/devices/video/hlcd0515.cpp b/src/devices/video/hlcd0515.cpp index 5a7f4e911e5..aa9066fc5ec 100644 --- a/src/devices/video/hlcd0515.cpp +++ b/src/devices/video/hlcd0515.cpp @@ -16,7 +16,9 @@ TODO: */ #include "emu.h" -#include "video/hlcd0515.h" +#include "hlcd0515.h" + +#include <tuple> DEFINE_DEVICE_TYPE(HLCD0515, hlcd0515_device, "hlcd0515", "Hughes HLCD 0515 LCD Driver") @@ -30,9 +32,13 @@ DEFINE_DEVICE_TYPE(HLCD0601, hlcd0601_device, "hlcd0601", "Hughes HLCD 0601 LCD hlcd0515_device::hlcd0515_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 colmax) : device_t(mconfig, type, tag, owner, clock), + device_nvram_interface(mconfig, *this), m_colmax(colmax), m_write_cols(*this), m_write_data(*this) -{ } +{ + // disable nvram by default + nvram_enable_backup(false); +} hlcd0515_device::hlcd0515_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : hlcd0515_device(mconfig, HLCD0515, tag, owner, clock, 25) @@ -56,21 +62,9 @@ hlcd0601_device::hlcd0601_device(const machine_config &mconfig, const char *tag, // device_start - device-specific startup //------------------------------------------------- -void hlcd0515_device::device_start() +void hlcd0515_device::internal_clear() { - // resolve callbacks - m_write_cols.resolve_safe(); - m_write_data.resolve_safe(); - - // timer - m_lcd_timer = timer_alloc(); - m_lcd_timer->adjust(attotime::from_hz(clock() / 2), 0, attotime::from_hz(clock() / 2)); - - // zerofill - m_cs = 0; - m_clk = 0; - m_data = 0; - m_dataout = 0; + // clear internal registers and RAM m_count = 0; m_control = 0; m_blank = false; @@ -79,6 +73,21 @@ void hlcd0515_device::device_start() m_rowsel = 0; m_buffer = 0; memset(m_ram, 0, sizeof(m_ram)); +} + +void hlcd0515_device::device_start() +{ + // timer + m_lcd_timer = timer_alloc(FUNC(hlcd0515_device::scan_lcd), this); + attotime period = attotime::from_hz(clock() / 2); + m_lcd_timer->adjust(period, 0, period); + + // zerofill + internal_clear(); + m_cs = 0; + m_clk = 0; + m_data = 0; + m_dataout = 0; // register for savestates save_item(NAME(m_cs)); @@ -98,10 +107,74 @@ void hlcd0515_device::device_start() //------------------------------------------------- -// device_timer - handler timer events +// nvram (when VDD is battery-backed) +//------------------------------------------------- + +bool hlcd0515_device::nvram_write(util::write_stream &file) +{ + std::error_condition err; + size_t actual; + + // misc internal registers + u8 buf[6]; + buf[0] = m_count; + buf[1] = m_control; + buf[2] = m_blank ? 1 : 0; + buf[3] = m_rowmax; + buf[4] = m_rowout; + buf[5] = m_rowsel; + + std::tie(err, actual) = write(file, &buf, sizeof(buf)); + if (err) + return false; + + // shift register and RAM + std::tie(err, actual) = write(file, &m_buffer, sizeof(m_buffer)); + if (err) + return false; + std::tie(err, actual) = write(file, &m_ram, sizeof(m_ram)); + if (err) + return false; + + return true; +} + +bool hlcd0515_device::nvram_read(util::read_stream &file) +{ + std::error_condition err; + size_t actual; + + // misc internal registers + u8 buf[6]; + std::tie(err, actual) = read(file, &buf, sizeof(buf)); + if (err || (sizeof(buf) != actual)) + return false; + + m_count = buf[0]; + m_control = buf[1]; + m_blank = bool(buf[2]); + m_rowmax = buf[3] & 7; + m_rowout = buf[4] & 7; + m_rowsel = buf[5] & 7; + + // shift register and RAM + std::tie(err, actual) = read(file, &m_buffer, sizeof(m_buffer)); + if (err || (sizeof(m_buffer) != actual)) + return false; + std::tie(err, actual) = read(file, &m_ram, sizeof(m_ram)); + if (err || (sizeof(m_ram) != actual)) + return false; + + return true; +} + + + +//------------------------------------------------- +// I/O handlers //------------------------------------------------- -void hlcd0515_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(hlcd0515_device::scan_lcd) { if (m_rowout > m_rowmax) m_rowout = 0; @@ -112,11 +185,6 @@ void hlcd0515_device::device_timer(emu_timer &timer, device_timer_id id, int par } - -//------------------------------------------------- -// handlers -//------------------------------------------------- - void hlcd0515_device::set_control() { // clock 0,1,2: row select @@ -167,7 +235,7 @@ void hlcd0515_device::clock_data(int col) } -WRITE_LINE_MEMBER(hlcd0515_device::clock_w) +void hlcd0515_device::clock_w(int state) { state = (state) ? 1 : 0; @@ -181,7 +249,6 @@ WRITE_LINE_MEMBER(hlcd0515_device::clock_w) if (m_count == 4) set_control(); } - else clock_data(m_count - 5); @@ -193,7 +260,7 @@ WRITE_LINE_MEMBER(hlcd0515_device::clock_w) } -WRITE_LINE_MEMBER(hlcd0515_device::cs_w) +void hlcd0515_device::cs_w(int state) { state = (state) ? 1 : 0; |