summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/output_latch.cpp
blob: bc8dcb8ea09be902dd3cb312ada68c27d66fb462 (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
// license:BSD-3-Clause
// copyright-holders:smf
#include "emu.h"
#include "output_latch.h"

DEFINE_DEVICE_TYPE(OUTPUT_LATCH, output_latch_device, "output_latch", "Output Latch")

output_latch_device::output_latch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, OUTPUT_LATCH, tag, owner, clock)
	, m_bit_handlers(*this)
	, m_bits{ -1, -1, -1, -1, -1, -1, -1, -1 }
{
}

void output_latch_device::device_start()
{
	save_item(NAME(m_bits));
}

void output_latch_device::write(uint8_t data)
{
	for (unsigned i = 0; 8 > i; ++i)
	{
		int const bit = BIT(data, i);
		if (bit != m_bits[i])
		{
			m_bits[i] = bit;
			m_bit_handlers[i](bit);
		}
	}
}