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
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
#ifndef MAME_EMU_EMUMEM_HET_H
#define MAME_EMU_EMUMEM_HET_H
#pragma once
// handler_entry_read_tap/handler_entry_write_tap
// handler which tap on a bus access and possibly change the data value through a std::function
template<int Width, int AddrShift> class handler_entry_read_tap : public handler_entry_read_passthrough<Width, AddrShift>
{
public:
using uX = typename emu::detail::handler_entry_size<Width>::uX;
handler_entry_read_tap(address_space *space, emu::detail::memory_passthrough_handler_impl &mph, std::string name, std::function<void (offs_t offset, uX &data, uX mem_mask)> tap) : handler_entry_read_passthrough<Width, AddrShift>(space, mph, 4), m_name(name), m_tap(std::move(tap)) {}
~handler_entry_read_tap() = default;
uX read(offs_t offset, uX mem_mask) const override;
uX read_interruptible(offs_t offset, uX mem_mask) const override;
std::pair<uX, u16> read_flags(offs_t offset, uX mem_mask) const override;
u16 lookup_flags(offs_t offset, uX mem_mask) const override;
std::string name() const override;
handler_entry_read_tap<Width, AddrShift> *instantiate(handler_entry_read<Width, AddrShift> *next) const override;
protected:
std::string m_name;
std::function<void (offs_t offset, uX &data, uX mem_mask)> m_tap;
handler_entry_read_tap(address_space *space, emu::detail::memory_passthrough_handler_impl &mph, handler_entry_read<Width, AddrShift> *next, std::string name, std::function<void (offs_t offset, uX &data, uX mem_mask)> tap) : handler_entry_read_passthrough<Width, AddrShift>(space, mph, 4, next), m_name(name), m_tap(tap) {}
};
template<int Width, int AddrShift> class handler_entry_write_tap : public handler_entry_write_passthrough<Width, AddrShift>
{
public:
using uX = typename emu::detail::handler_entry_size<Width>::uX;
handler_entry_write_tap(address_space *space, emu::detail::memory_passthrough_handler_impl &mph, std::string name, std::function<void (offs_t offset, uX &data, uX mem_mask)> tap) : handler_entry_write_passthrough<Width, AddrShift>(space, mph, 4), m_name(name), m_tap(std::move(tap)) {}
~handler_entry_write_tap() = default;
void write(offs_t offset, uX data, uX mem_mask) const override;
void write_interruptible(offs_t offset, uX data, uX mem_mask) const override;
u16 write_flags(offs_t offset, uX data, uX mem_mask) const override;
u16 lookup_flags(offs_t offset, uX mem_mask) const override;
std::string name() const override;
handler_entry_write_tap<Width, AddrShift> *instantiate(handler_entry_write<Width, AddrShift> *next) const override;
protected:
std::string m_name;
std::function<void (offs_t offset, uX &data, uX mem_mask)> m_tap;
handler_entry_write_tap(address_space *space, emu::detail::memory_passthrough_handler_impl &mph, handler_entry_write<Width, AddrShift> *next, std::string name, std::function<void (offs_t offset, uX &data, uX mem_mask)> tap) : handler_entry_write_passthrough<Width, AddrShift>(space, mph, 4, next), m_name(name), m_tap(tap) {}
};
#endif // MAME_EMU_EMUMEM_HET_H
|