summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/scoop.h
blob: 24d93cced812f74bb73071fca00d62d39fa7a6e2 (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
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/***************************************************************************

    Sharp Scoop peripheral chip emulation skeleton

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

#ifndef MAME_MACHINE_SCOOP
#define MAME_MACHINE_SCOOP

#pragma once

class scoop_device : public device_t
{
public:
	scoop_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock = XTAL());

	template <unsigned Line> auto gpio_out() { return m_gpio_out[Line].bind(); }
	template <unsigned Line> void gpio_in(int state) { gpio_in((uint16_t)Line, state); }

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

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	void gpio_in(const uint16_t line, const int state);
	void update_gpio_direction(const uint16_t old_dir);
	void update_gpio_outputs(const uint16_t old_latch, const uint16_t changed);

	uint16_t m_gpwr;
	uint16_t m_gpio_in_latch;
	uint16_t m_gpcr;

	devcb_write_line::array<13> m_gpio_out;
};

DECLARE_DEVICE_TYPE(SCOOP, scoop_device)

#endif // MAME_MACHINE_SCOOP