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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
#ifndef MAME_MACHINE_DC_CTRL_H
#define MAME_MACHINE_DC_CTRL_H
#pragma once
#include "mapledev.h"
class dc_common_device : public maple_device
{
public:
// construction/destruction
dc_common_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);
template <uint8_t Which, typename T>
void set_port_tag(T &&port_tag) { port[Which].set_tag(std::forward<T>(port_tag)); }
template <uint8_t First = 0U, typename T, typename... U>
void set_port_tags(T &&first_tag, U &&... other_tags)
{
set_port_tag<First>(std::forward<T>(first_tag));
set_port_tags<First + 1>(std::forward<U>(other_tags)...);
}
// TODO: we probably don't need these setters
void set_model(const char *new_id) { model = new_id; }
void set_license(const char *new_license) { license = new_license; }
void set_versions(const char *new_versions) { versions = new_versions; }
void maple_w(const uint32_t *data, uint32_t in_size) override;
protected:
template <uint8_t First> void set_port_tags() { }
// device-level overrides
virtual void device_start() override;
const char *model = nullptr, *license = nullptr, *versions = nullptr;
uint32_t id = 0;
uint32_t electric_current = 0;
uint32_t region = 0;
optional_ioport_array<8> port;
virtual void fixed_status(uint32_t *dest) = 0;
virtual void free_status(uint32_t *dest) = 0;
virtual void read(uint32_t *dest) = 0;
};
class dc_controller_device : public dc_common_device
{
public:
// construction/destruction
template <typename T>
dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock, T &&host_tag, int host_port)
: dc_controller_device(mconfig, tag, owner, clock)
{
host.set_tag(std::forward<T>(host_tag));
set_host_port(host_port);
}
dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
private:
void fixed_status(uint32_t *dest) override;
void free_status(uint32_t *dest) override;
void read(uint32_t *dest) override;
};
class dc_keyboard_device : public dc_common_device
{
public:
// construction/destruction
template <typename T>
dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock, T &&host_tag, int host_port)
: dc_keyboard_device(mconfig, tag, owner, clock)
{
host.set_tag(std::forward<T>(host_tag));
set_host_port(host_port);
}
dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
//protected:
private:
void fixed_status(uint32_t *dest) override;
void free_status(uint32_t *dest) override;
void read(uint32_t *dest) override;
};
DECLARE_DEVICE_TYPE(DC_CONTROLLER, dc_controller_device)
DECLARE_DEVICE_TYPE(DC_KEYBOARD, dc_keyboard_device)
#endif // MAME_MACHINE_DC_CTRL_H
|