summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/hlcd0538.cpp
blob: 153a687067960d5e4bf61ad8f49f2cb4807f4bd2 (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

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

*/

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


const device_type HLCD0538 = device_creator<hlcd0538_device>;
const device_type HLCD0539 = device_creator<hlcd0539_device>;

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

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

hlcd0538_device::hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: hlcd0538_device(mconfig, HLCD0538, "HLCD 0538 LCD Driver", tag, owner, clock, "hlcd0538", __FILE__)
{
}

hlcd0539_device::hlcd0539_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: hlcd0538_device(mconfig, HLCD0539, "HLCD 0539 LCD Driver", tag, owner, clock, "hlcd0539", __FILE__)
{
}



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

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

	// zerofill
	m_int = 0;
	m_clk = 0;
	m_data = 0;
	m_shift = 0;

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



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

WRITE_LINE_MEMBER(hlcd0538_device::write_clk)
{
	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::write_int)
{
	state = (state) ? 1 : 0;
	
	// transfer to latches on rising edge
	if (state && !m_int)
	{
		m_write_cols(0, m_shift, ~0);
		m_shift = 0;
	}

	m_int = state;
}