summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/pce_ctrl/joypad6.h
blob: 66b579309b6e6b4b97335f55de08d9d7b59852ca (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
// license:BSD-3-Clause
// copyright-holders:cam900
/**********************************************************************

    NEC PC Engine/TurboGrafx-16 6 Button Joypad emulation

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

#ifndef MAME_BUS_PCE_CTRL_JOYPAD6_H
#define MAME_BUS_PCE_CTRL_JOYPAD6_H

#pragma once


#include "machine/74157.h"
#include "pcectrl.h"



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

// ======================> pce_joypad6_base_device

class pce_joypad6_base_device : public device_t,
							public device_pce_control_port_interface
{
public:
	DECLARE_INPUT_CHANGED_MEMBER(joypad_mode_changed);

protected:
	// construction/destruction
	pce_joypad6_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual void device_reset() override;

	// device_pce_control_port_interface overrides
	virtual u8 peripheral_r() override;
	virtual void sel_w(int state) override;
	virtual void clr_w(int state) override;

	// button handlers
	void buttonset_update();

	// devices
	required_device_array<ls157_device, 3> m_muxer;

	// IO ports
	required_ioport m_joypad_mode;

	// internal states
	u8 m_counter; // buttonset select, autofire counter (74xx163 QA-QB pin)
	bool m_prev_clr; // previous CLR pin state
};


// ======================> pce_avenue_pad_6_device

class pce_avenue_pad_6_device : public pce_joypad6_base_device
{
public:
	// construction/destruction
	pce_avenue_pad_6_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

protected:
	// construction/destruction
	pce_avenue_pad_6_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);

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

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;

	template<unsigned Buttonset> u8 buttons_r();

	// IO ports
	required_ioport_array<2> m_buttons_io;
	required_ioport m_turbo_io;
};


// ======================> pce_arcade_pad_6_device

class pce_arcade_pad_6_device : public pce_avenue_pad_6_device
{
public:
	// construction/destruction
	pce_arcade_pad_6_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

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


// device type definition
DECLARE_DEVICE_TYPE(PCE_AVENUE_PAD_6, pce_avenue_pad_6_device)
DECLARE_DEVICE_TYPE(PCE_ARCADE_PAD_6, pce_arcade_pad_6_device)


#endif // MAME_BUS_PCE_CTRL_JOYPAD6_H