summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/emumem_hea.h
blob: 9ee6f8c8a1e90a72830b72d4fc6cc8ad08b388ac (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:Olivier Galibert

// handler_entry_read_address/handler_entry_write_address

// parent class for final handlers which want an address base and a mask

template<int Width, int AddrShift> class handler_entry_read_address : public handler_entry_read<Width, AddrShift>
{
public:
	using uX = emu::detail::handler_entry_size_t<Width>;

	handler_entry_read_address(address_space *space, u32 flags) : handler_entry_read<Width, AddrShift>(space, flags) {}
	~handler_entry_read_address() = default;

	inline void set_address_info(offs_t base, offs_t mask) {
		m_address_base = base & ~handler_entry_read<Width, AddrShift>::NATIVE_MASK;
		m_address_mask = mask;
	}

protected:
	offs_t m_address_base, m_address_mask;
};

template<int Width, int AddrShift> class handler_entry_write_address : public handler_entry_write<Width, AddrShift>
{
public:
	using uX = emu::detail::handler_entry_size_t<Width>;

	static constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? (1 << (Width + AddrShift)) - 1 : 0;

	handler_entry_write_address(address_space *space, u32 flags) : handler_entry_write<Width, AddrShift>(space, flags) {}
	~handler_entry_write_address() = default;

	inline void set_address_info(offs_t base, offs_t mask) {
		m_address_base = base & ~handler_entry_write<Width, AddrShift>::NATIVE_MASK;
		m_address_mask = mask;
	}

protected:
	offs_t m_address_base, m_address_mask;
};