summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/neogeo_ctrl/ctrl.h
blob: bfe568d9b7e586ca980156124cb1a13c0c781bb8 (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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/**********************************************************************

   SNK Neo Geo controller port emulation

**********************************************************************/
#ifndef MAME_BUS_NEOGEO_CTRL_CTRL_H
#define MAME_BUS_NEOGEO_CTRL_CTRL_H

#pragma once


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

class neogeo_control_port_device;
class neogeo_ctrl_edge_port_device;

// ======================> device_neogeo_control_port_interface

class device_neogeo_control_port_interface : public device_slot_card_interface
{
public:
	// construction/destruction
	virtual ~device_neogeo_control_port_interface();

	virtual uint8_t read_ctrl() { return 0xff; }
	virtual uint8_t read_start_sel() { return 0xff; }
	virtual void write_ctrlsel(uint8_t data) { }

protected:
	device_neogeo_control_port_interface(const machine_config &mconfig, device_t &device);

	neogeo_control_port_device *m_port;
};

// ======================> neogeo_control_port_device

class neogeo_control_port_device : public device_t, public device_slot_interface
{
public:
	// construction/destruction
	template <typename T>
	neogeo_control_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt, bool const fixed)
		: neogeo_control_port_device(mconfig, tag, owner, (uint32_t)0)
	{
		option_reset();
		opts(*this);
		set_default_option(dflt);
		set_fixed(fixed);
	}
	neogeo_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	virtual ~neogeo_control_port_device();

	uint8_t read_ctrl();
	uint8_t read_start_sel();
	void write_ctrlsel(uint8_t data);
	DECLARE_READ8_MEMBER( ctrl_r ) { return read_ctrl(); }

protected:
	// device-level overrides
	virtual void device_start() override;

	device_neogeo_control_port_interface *m_device;
};


// ======================> device_neogeo_ctrl_edge_interface

class device_neogeo_ctrl_edge_interface : public device_slot_card_interface
{
public:
	// construction/destruction
	virtual ~device_neogeo_ctrl_edge_interface();

	virtual uint8_t read_start_sel() { return 0xff; }
	virtual DECLARE_READ8_MEMBER( in0_r ) { return 0xff; }
	virtual DECLARE_READ8_MEMBER( in1_r ) { return 0xff; }
	virtual void write_ctrlsel(uint8_t data) { }

protected:
	device_neogeo_ctrl_edge_interface(const machine_config &mconfig, device_t &device);

	neogeo_ctrl_edge_port_device *m_port;
};

// ======================> neogeo_ctrl_edge_port_device

class neogeo_ctrl_edge_port_device : public device_t, public device_slot_interface
{
public:
	// construction/destruction
	template <typename T>
	neogeo_ctrl_edge_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt, bool const fixed)
		: neogeo_ctrl_edge_port_device(mconfig, tag, owner, (uint32_t)0)
	{
		option_reset();
		opts(*this);
		set_default_option(dflt);
		set_fixed(fixed);
	}
	neogeo_ctrl_edge_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	virtual ~neogeo_ctrl_edge_port_device();

	uint8_t read_start_sel();
	DECLARE_READ8_MEMBER( in0_r );
	DECLARE_READ8_MEMBER( in1_r );
	void write_ctrlsel(uint8_t data);

protected:
	// device-level overrides
	virtual void device_start() override;

	device_neogeo_ctrl_edge_interface *m_device;
};


// device type definition
DECLARE_DEVICE_TYPE(NEOGEO_CONTROL_PORT,        neogeo_control_port_device)
DECLARE_DEVICE_TYPE(NEOGEO_CTRL_EDGE_CONNECTOR, neogeo_ctrl_edge_port_device)


void neogeo_controls(device_slot_interface &device);
void neogeo_arc_edge(device_slot_interface &device);
void neogeo_arc_edge_fixed(device_slot_interface &device);
void neogeo_arc_pin15(device_slot_interface &device);


#endif // MAME_BUS_NEOGEO_CTRL_CTRL_H