summaryrefslogtreecommitdiffstats
path: root/src/mame/machine/taitoio_yoke.cpp
blob: 9d7fa7fec243cda9595065adec3c4641e10386c3 (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
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************

    Taito Yoke + Throttle Flight device

    Used in Midnight Landing, Top Landing and Air Inferno

    TODO:
    - Custom part #;
    - Air Inferno uses different limit types (helicopter inputs?), might be
      worth doing a subclass of this;
    - Get dead zones from actual HW (currently hardlocked to 0x20);

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

#include "emu.h"
#include "taitoio_yoke.h"



//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

// device type definition
DEFINE_DEVICE_TYPE(TAITOIO_YOKE, taitoio_yoke_device, "taitoio_yoke", "Taito I/O Yoke")


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  taitoio_yoke_device - constructor
//-------------------------------------------------

taitoio_yoke_device::taitoio_yoke_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, TAITOIO_YOKE, tag, owner, clock)
	, m_stick_x(*this, "STICK_X")
	, m_stick_y(*this, "STICK_Y")
	, m_throttle(*this, "THROTTLE")
{
}




//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void taitoio_yoke_device::device_start()
{
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void taitoio_yoke_device::device_reset()
{
}

// TODO: requires LEFT/RIGHT_AD_STICK in framework
static INPUT_PORTS_START( yoke_inputs )
	PORT_START("STICK_X")
	PORT_BIT( 0x0fff, 0x0000, IPT_AD_STICK_X ) PORT_MINMAX(0x00800, 0x07ff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20) PORT_NAME("Yoke X")

	PORT_START("STICK_Y")
	PORT_BIT( 0x0fff, 0x0000, IPT_AD_STICK_Y ) PORT_MINMAX(0x00800, 0x07ff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20) PORT_NAME("Yoke Y")

	PORT_START("THROTTLE")
	PORT_BIT( 0x0fff, 0x0000, IPT_AD_STICK_Y ) PORT_MINMAX(0x0800,0x07ff) PORT_SENSITIVITY(30) PORT_KEYDELTA(40) PORT_NAME("Throttle Lever")
INPUT_PORTS_END

ioport_constructor taitoio_yoke_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( yoke_inputs );
}


//**************************************************************************
//  READ/WRITE HANDLERS
//**************************************************************************

u16 taitoio_yoke_device::stickx_r()
{
	return m_stick_x->read();
}

u16 taitoio_yoke_device::sticky_r()
{
	return m_stick_y->read();
}

u16 taitoio_yoke_device::throttle_r()
{
	return m_throttle->read();
}

READ_LINE_MEMBER( taitoio_yoke_device::slot_down_r )
{
	uint16_t throttle = m_throttle->read();

	return (throttle & 0xe00) == 0x600;
}

READ_LINE_MEMBER( taitoio_yoke_device::slot_up_r )
{
	uint16_t throttle = m_throttle->read();

	return (throttle & 0xe00) == 0x800;
}

READ_LINE_MEMBER( taitoio_yoke_device::handle_left_r )
{
	uint16_t x = m_stick_x->read();

	return (x & 0xe00) == 0x800;
}

READ_LINE_MEMBER( taitoio_yoke_device::handle_right_r )
{
	uint16_t x = m_stick_x->read();

	return (x & 0xe00) == 0x600;
}

READ_LINE_MEMBER( taitoio_yoke_device::handle_up_r )
{
	uint16_t y = m_stick_y->read();

	return (y & 0xe00) == 0x800;
}

READ_LINE_MEMBER( taitoio_yoke_device::handle_down_r )
{
	uint16_t y = m_stick_y->read();

	return (y & 0xe00) == 0x600;
}