summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/hlcd0538.cpp
blob: a5f731313e9d0b25ec7614cc89d99d40b36a3f58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// license:BSD-3-Clause
// copyright-holders:hap
/*

Hughes HLCD 0538(A)/0539(A) LCD Driver

0538: 8 rows, 26 columns
0539: 0 rows, 34 columns

"LCD" pin can be used in 2 modes, either direct drive, or as an oscillator.
In latter case, output frequency is approximately 1/RC.

TODO:
- the only difference between 0538/0539 is row pins voltage levels?

*/

#include "emu.h"
#include "video/hlcd0538.h"


DEFINE_DEVICE_TYPE(HLCD0538, hlcd0538_device, "hlcd0538", "Hughes HLCD 0538 LCD Driver")
DEFINE_DEVICE_TYPE(HLCD0539, hlcd0539_device, "hlcd0539", "Hughes HLCD 0539 LCD Driver")

//-------------------------------------------------
//  constructor
//-------------------------------------------------

hlcd0538_device::hlcd0538_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) :
	device_t(mconfig, type, tag, owner, clock),
	m_write_cols(*this), m_write_interrupt(*this)
{ }

hlcd0538_device::hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
	hlcd0538_device(mconfig, HLCD0538, tag, owner, clock)
{ }

hlcd0539_device::hlcd0539_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
	hlcd0538_device(mconfig, HLCD0539, tag, owner, clock)
{ }


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void hlcd0538_device::device_start()
{
	// resolve callbacks
	m_write_cols.resolve_safe();
	m_write_interrupt.resolve_safe();

	// timer (when LCD pin is oscillator)
	m_lcd_timer = timer_alloc();
	attotime period = (clock() != 0) ? attotime::from_hz(2 * clock()) : attotime::never;
	m_lcd_timer->adjust(period, 0, period);

	// register for savestates
	save_item(NAME(m_lcd));
	save_item(NAME(m_clk));
	save_item(NAME(m_data));
	save_item(NAME(m_shift));
}


//-------------------------------------------------
//  handlers
//-------------------------------------------------

WRITE_LINE_MEMBER(hlcd0538_device::clk_w)
{
	state = (state) ? 1 : 0;

	// clock in data on falling edge
	if (!state && m_clk)
		m_shift = (m_shift << 1 | m_data) & u64(0x3ffffffff);

	m_clk = state;
}

WRITE_LINE_MEMBER(hlcd0538_device::lcd_w)
{
	state = (state) ? 1 : 0;

	// transfer to latches on rising edge
	if (state && !m_lcd)
	{
		m_write_cols(0, m_shift);
		m_shift = 0;
	}

	m_lcd = state;

	// interrupt output follows lcd input
	m_write_interrupt(state);
}