summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/hexbus/tp0370.h
blob: 9aafc27804a8e312eccef694efb5a243712bc8c4 (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
// license:BSD-3-Clause
// copyright-holders:Michael Zapf
/****************************************************************************

    Intelligent peripheral bus controller (IBC)

    This is a simple circuit used to connect to the Hexbus infrastructure.

    See tp0370.cpp for documentation

    Michael Zapf

*****************************************************************************/
#ifndef MAME_BUS_HEXBUS_TP0370_H
#define MAME_BUS_HEXBUS_TP0370_H

#pragma once

namespace bus::hexbus {

class ibc_device : public device_t
{
public:
	ibc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	void device_start() override;
	void device_reset() override;

	uint8_t read(offs_t offset);
	void write(offs_t offset, uint8_t data);

	// Callbacks
	auto int_cb() { return m_int.bind(); }
	auto hexbus_cb() { return m_hexout.bind(); }
	auto hsklatch_cb() { return m_latch.bind(); }

	// INT line
	devcb_write_line m_int;

	// Outgoing connection to Hexbus
	devcb_write8 m_hexout;

	// Callback to set the HSK latch
	devcb_write_line m_latch;

	// Incoming connection
	void from_hexbus(uint8_t val);

	// Update the lines from the Hexbus
	void update_lines(bool bav, bool hsk);

private:
	bool m_inhibit;
	bool m_disable;
	bool m_bav;
	bool m_hsk;
	bool m_bavold;
	bool m_hskold;
	bool m_int_pending;
	bool m_incoming_message;
	bool m_message_started;
	bool m_latch_inhibit;

	uint8_t m_data;
	uint8_t m_transmit;

	uint8_t m_last_status;

	void set_disable_inhibit(bool dis, bool inh);
	void set_lines(bool bav, bool hsk);
};

} // namespace bus::hexbus

DECLARE_DEVICE_TYPE_NS(IBC, bus::hexbus, ibc_device)
#endif