summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/pcfx_intc.h
blob: 67f95ba7c641aeec0043c1ad4dab0606eb3c5945 (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
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol, Angelo Salese

#ifndef MAME_MACHINE_PCFX_INTC_H
#define MAME_MACHINE_PCFX_INTC_H

#pragma once

#include <cassert>


class pcfx_intc_device : public device_t
{
public:
	pcfx_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);

	auto int_cb() { return m_int_w.bind(); }

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

	template <unsigned Which> void irq_w(int state)  { static_assert((Which >= 8) && (Which <= 15)); set_irq_line(Which, state); }

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

private:
	devcb_write8 m_int_w;

	u16 m_irq_mask;
	u16 m_irq_pending;
	u8 m_irq_priority[8];

	void check_irqs();
	void set_irq_line(int line, int state);
};

DECLARE_DEVICE_TYPE(PCFX_INTC, pcfx_intc_device)

#endif // MAME_MACHINE_PCFX_INTC_H