summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/rad_eu3a05gpio.h
blob: ad72f61008a85cdf1a64afd45d33d85942c3c551 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood

#ifndef MAME_AUDIO_RAD_EU3A05GPIO_H
#define MAME_AUDIO_RAD_EU3A05GPIO_H

#define MCFG_RADICA6502_GPIO_READ_PORT0_CB(_devcb) \
	devcb = &radica6502_gpio_device::set_gpio_read_0_callback(*device, DEVCB_##_devcb);

#define MCFG_RADICA6502_GPIO_READ_PORT1_CB(_devcb) \
	devcb = &radica6502_gpio_device::set_gpio_read_1_callback(*device, DEVCB_##_devcb);

#define MCFG_RADICA6502_GPIO_READ_PORT2_CB(_devcb) \
	devcb = &radica6502_gpio_device::set_gpio_read_2_callback(*device, DEVCB_##_devcb);


class radica6502_gpio_device : public device_t
{
public:
	radica6502_gpio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	template <class Object> static devcb_base &set_gpio_read_0_callback(device_t &device, Object &&cb) { return downcast<radica6502_gpio_device &>(device).m_space_read0_cb.set_callback(std::forward<Object>(cb)); }
	template <class Object> static devcb_base &set_gpio_read_1_callback(device_t &device, Object &&cb) { return downcast<radica6502_gpio_device &>(device).m_space_read1_cb.set_callback(std::forward<Object>(cb)); }
	template <class Object> static devcb_base &set_gpio_read_2_callback(device_t &device, Object &&cb) { return downcast<radica6502_gpio_device &>(device).m_space_read2_cb.set_callback(std::forward<Object>(cb)); }

	DECLARE_READ8_MEMBER(gpio_r);
	DECLARE_WRITE8_MEMBER(gpio_w);

	DECLARE_WRITE8_MEMBER(gpio_unk_w);

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

private:
	devcb_read8 m_space_read0_cb;
	devcb_read8 m_space_read1_cb;
	devcb_read8 m_space_read2_cb;

	uint8_t read_port_data(int which);
	uint8_t read_direction(int which);
	void write_port_data(int which, uint8_t data);
	void write_direction(int which, uint8_t data);

	uint8_t m_ddr[3];
	uint8_t m_unk[3];
};

DECLARE_DEVICE_TYPE(RADICA6502_GPIO, radica6502_gpio_device)

#endif // MAME_AUDIO_RAD_EU3A05GPIO_H