summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/74610.h
blob: c289b5f0731822041d0b3b60a44aef93b5c5c10c (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// license:BSD-3-Clause
// copyright-holders:Michael Zapf
/*****************************************************************************

    74610: Memory mappers

    Variant   Output       Type
    ----------------------------------------
    74610     latched      tristate
    74611     latched      open collector
    74612     direct       tristate
    74613     direct       open collector

    Michael Zapf
    June 2025

**********************************************************************/

#ifndef MAME_MACHINE_74610_H
#define MAME_MACHINE_74610_H

#pragma once

/*
    Overall base class
*/
class ttl7461x_device : public device_t
{
public:
	auto map_output_cb() { return m_map_output.bind(); }

	void set_register(int num, uint16_t value);
	uint16_t get_register(int num);

	void mapper_output_rz(uint8_t num, uint16_t& value);
	uint16_t get_mapper_output(uint8_t num);

	void map_mode_w(int mapping);
	void map_enable_w(int enable);

protected:
	ttl7461x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	// device-level overrides
	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;

	bool m_has_tristate;
	bool m_enabled;
	devcb_write16 m_map_output;
	uint16_t m_map[16];
	bool m_map_mode;
};

/*
    Base class for the latched variants
*/
class ttl7461x_latched_device : public ttl7461x_device
{
public:
	void set_map_address(uint8_t num);
	uint16_t get_mapper_output();
	void mapper_output_rz(uint16_t& value);
	void latch_enable_w(int enable);

protected:
	ttl7461x_latched_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	bool m_latch_enabled;
	uint16_t m_latched_output;

	virtual void device_start() override ATTR_COLD;
};


/*
    Variants
*/
class ttl74610_device : public ttl7461x_latched_device
{
public:
	ttl74610_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
};

class ttl74611_device : public ttl7461x_latched_device
{
public:
	ttl74611_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
};

class ttl74612_device : public ttl7461x_device
{
public:
	ttl74612_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
};

class ttl74613_device : public ttl7461x_device
{
public:
	ttl74613_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
};


// device type definition
DECLARE_DEVICE_TYPE(TTL74610, ttl74610_device)
DECLARE_DEVICE_TYPE(TTL74611, ttl74611_device)
DECLARE_DEVICE_TYPE(TTL74612, ttl74612_device)
DECLARE_DEVICE_TYPE(TTL74613, ttl74613_device)

#endif // MAME_MACHINE_74160_H