summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/namcoio.h
blob: 8930db0a2d0b36b6a4907f28a71aa5c82a8c4715 (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
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
#ifndef __NAMCOIO_H__
#define __NAMCOIO_H__


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

class namcoio_device : public device_t
{
public:
	namcoio_device(const machine_config &mconfig, device_type type, std::string name, std::string tag, device_t *owner, UINT32 clock, std::string shortname);

	template<class _Object> static devcb_base &set_in_0_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_in_0_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_in_1_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_in_1_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_in_2_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_in_2_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_in_3_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_in_3_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_0_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_out_0_cb.set_callback(object); }
	template<class _Object> static devcb_base &set_out_1_callback(device_t &device, _Object object) { return downcast<namcoio_device &>(device).m_out_1_cb.set_callback(object); }


	DECLARE_READ8_MEMBER( read );
	DECLARE_WRITE8_MEMBER( write );

	WRITE_LINE_MEMBER( set_reset_line );
	READ_LINE_MEMBER( read_reset_line );

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

	int m_device_type;

	enum {
			TYPE_NAMCO56XX,
			TYPE_NAMCO58XX,
			TYPE_NAMCO59XX
	};

	// internal state
	UINT8          m_ram[16];

	devcb_read8 m_in_0_cb;
	devcb_read8 m_in_1_cb;
	devcb_read8 m_in_2_cb;
	devcb_read8 m_in_3_cb;
	devcb_write8 m_out_0_cb;
	devcb_write8 m_out_1_cb;

	int            m_reset;
	INT32          m_lastcoins, m_lastbuttons;
	INT32          m_credits;
	INT32          m_coins[2];
	INT32          m_coins_per_cred[2];
	INT32          m_creds_per_coin[2];
	INT32          m_in_count;

	void handle_coins( int swap );

	virtual void customio_run() {}

private:

};

class namco56xx_device : public namcoio_device
{
public:
	namco56xx_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock);

	virtual void customio_run() override;
};

class namco58xx_device : public namcoio_device
{
public:
	namco58xx_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock);

	virtual void customio_run() override;
};

class namco59xx_device : public namcoio_device
{
public:
	namco59xx_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock);

	virtual void customio_run() override;
};

extern const device_type NAMCO56XX;
extern const device_type NAMCO58XX;
extern const device_type NAMCO59XX;

/***************************************************************************
    DEVICE CONFIGURATION MACROS
***************************************************************************/

#define MCFG_NAMCO56XX_IN_0_CB(_devcb) \
	devcb = &namco56xx_device::set_in_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO56XX_IN_1_CB(_devcb) \
	devcb = &namco56xx_device::set_in_1_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO56XX_IN_2_CB(_devcb) \
	devcb = &namco56xx_device::set_in_2_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO56XX_IN_3_CB(_devcb) \
	devcb = &namco56xx_device::set_in_3_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO56XX_OUT_0_CB(_devcb) \
	devcb = &namco56xx_device::set_out_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO56XX_OUT_1_CB(_devcb) \
	devcb = &namco56xx_device::set_out_1_callback(*device, DEVCB_##_devcb);


#define MCFG_NAMCO58XX_IN_0_CB(_devcb) \
	devcb = &namco58xx_device::set_in_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO58XX_IN_1_CB(_devcb) \
	devcb = &namco58xx_device::set_in_1_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO58XX_IN_2_CB(_devcb) \
	devcb = &namco58xx_device::set_in_2_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO58XX_IN_3_CB(_devcb) \
	devcb = &namco58xx_device::set_in_3_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO58XX_OUT_0_CB(_devcb) \
	devcb = &namco58xx_device::set_out_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO58XX_OUT_1_CB(_devcb) \
	devcb = &namco58xx_device::set_out_1_callback(*device, DEVCB_##_devcb);


#define MCFG_NAMCO59XX_IN_0_CB(_devcb) \
	devcb = &namco59xx_device::set_in_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO59XX_IN_1_CB(_devcb) \
	devcb = &namco59xx_device::set_in_1_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO59XX_IN_2_CB(_devcb) \
	devcb = &namco59xx_device::set_in_2_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO59XX_IN_3_CB(_devcb) \
	devcb = &namco59xx_device::set_in_3_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO59XX_OUT_0_CB(_devcb) \
	devcb = &namco59xx_device::set_out_0_callback(*device, DEVCB_##_devcb);

#define MCFG_NAMCO59XX_OUT_1_CB(_devcb) \
	devcb = &namco59xx_device::set_out_1_callback(*device, DEVCB_##_devcb);

#endif  /* __NAMCOIO_H__ */