summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/intv_ctrl/ecs_ctrl.h
blob: 8a723c64949dce91d2300a73ec212824ce4bb4ea (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/**********************************************************************

   Mattel Intellivision ECS hack for controller port emulation

**********************************************************************/

#ifndef MAME_BUS_INTV_CTRL_ECS_CTRL_H
#define MAME_BUS_INTV_CTRL_ECS_CTRL_H

#pragma once


#include "bus/intv_ctrl/ctrl.h"
#include "bus/intv_ctrl/handctrl.h"

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

class intvecs_control_port_device;

// ======================> device_intvecs_control_port_interface

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

	virtual uint8_t read_portA() { return 0xff; }
	virtual uint8_t read_portB() { return 0xff; }
	virtual void write_portA(uint8_t data) { }

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

	intvecs_control_port_device *m_port;
};

// ======================> intvecs_control_port_device

class intvecs_control_port_device : public device_t,
								public device_slot_interface
{
public:
	// construction/destruction
	template <typename T>
	intvecs_control_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt)
		: intvecs_control_port_device(mconfig, tag, owner, 0)
	{
		option_reset();
		opts(*this);
		set_default_option(dflt);
		set_fixed(false);
	}

	intvecs_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
	virtual ~intvecs_control_port_device();

	DECLARE_READ8_MEMBER( portA_r ) { return read_portA(); }
	DECLARE_READ8_MEMBER( portB_r ) { return read_portB(); }
	DECLARE_WRITE8_MEMBER( portA_w ) { return write_portA(data); }

protected:
	// device-level overrides
	virtual void device_start() override;
	uint8_t read_portA();
	uint8_t read_portB();
	void write_portA(uint8_t data);

	device_intvecs_control_port_interface *m_device;
};


// device type definition
DECLARE_DEVICE_TYPE(INTVECS_CONTROL_PORT, intvecs_control_port_device)


void intvecs_control_port_devices(device_slot_interface &device);


//**************************************************************************
//  ACTUAL SLOT DEVICES - included here until core issues are solved...
//**************************************************************************

// ======================> intvecs_ctrls_device

class intvecs_ctrls_device : public device_t,
						public device_intvecs_control_port_interface
{
public:
	// construction/destruction
	intvecs_ctrls_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

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

	// optional information overrides
	virtual void device_add_mconfig(machine_config &config) override;

	virtual uint8_t read_portA() override;
	virtual uint8_t read_portB() override;

private:
	required_device<intv_control_port_device> m_hand1;
	required_device<intv_control_port_device> m_hand2;
};

// ======================> intvecs_keybd_device

class intvecs_keybd_device : public device_t,
						public device_intvecs_control_port_interface
{
public:
	// construction/destruction
	intvecs_keybd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// optional information overrides
	virtual ioport_constructor device_input_ports() const override;

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

	virtual uint8_t read_portB() override;
	virtual void write_portA(uint8_t data) override;

private:
	uint8_t m_psg_portA;
	required_ioport_array<7> m_keybd;
};

// ======================> intvecs_synth_device

class intvecs_synth_device : public device_t,
						public device_intvecs_control_port_interface
{
public:
	// construction/destruction
	intvecs_synth_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// optional information overrides
	virtual ioport_constructor device_input_ports() const override;

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

	virtual uint8_t read_portB() override;
	virtual void write_portA(uint8_t data) override;

private:
	uint8_t m_psg_portA;
	required_ioport_array<7> m_synth;
};


// device type definition
DECLARE_DEVICE_TYPE(ECS_CTRLS, intvecs_ctrls_device)
DECLARE_DEVICE_TYPE(ECS_KEYBD, intvecs_keybd_device)
DECLARE_DEVICE_TYPE(ECS_SYNTH, intvecs_synth_device)


#endif // MAME_BUS_INTV_CTRL_ECS_CTRL_H