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
|
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************
Namco 6-speed Gearbox device
Used in Ridge Racer deluxe cabinet, Ace Driver and Driver's Eyes
User side gear scheme:
1 3 5
|-|-|
2 4 6
Being a mechanical part there are currently two methods hooked up,
emulated and natural.
First one just uses whatever is read in the inputs, second one
simulates clutch lock as in a real car.
TODO:
- check clutch lock via real HW, and get a way to lock current gear via
MAME's input system;
- Custom part #;
- gear output for artwork system;
***************************************************************************/
#include "emu.h"
#include "namcoio_gearbox.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definition
const device_type NAMCOIO_GEARBOX = &device_creator<namcoio_gearbox_device>;
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// namcoio_gearbox_device - constructor
//-------------------------------------------------
namcoio_gearbox_device::namcoio_gearbox_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, NAMCOIO_GEARBOX, "Namco I/O Gearbox", tag, owner, clock, "namcoio_gearbox", __FILE__)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void namcoio_gearbox_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void namcoio_gearbox_device::device_reset()
{
m_gearbox_state = 0xf;
}
static INPUT_PORTS_START( gearbox_inputs )
PORT_START("GEARBOX")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_NAME("Gearbox Up")
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("Gearbox Down")
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_NAME("Gearbox Left")
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_NAME("Gearbox Right")
PORT_START("CLUTCH")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Clutch Pedal")
PORT_START("CONFIG")
PORT_CONFNAME( 0x01, 0x01, "Clutch Mode" )
PORT_CONFSETTING( 0x01, "Emulated" )
PORT_CONFSETTING( 0x00, "Natural" )
PORT_CONFNAME( 0x02, 0x02, "Gearbox Debug")
PORT_CONFSETTING( 0x02, DEF_STR( Yes ) )
PORT_CONFSETTING( 0x00, DEF_STR( No ) )
INPUT_PORTS_END
ioport_constructor namcoio_gearbox_device::device_input_ports() const
{
return INPUT_PORTS_NAME( gearbox_inputs );
}
//**************************************************************************
// READ/WRITE HANDLERS
//**************************************************************************
//static const ioport_value gearbox_table[] = { 0x0f, 0x0a, 0x09, 0x0e, 0x0d, 0x06, 0x05 };
CUSTOM_INPUT_MEMBER( namcoio_gearbox_device::in_r )
{
if(ioport("CONFIG")->read() & 1)
return ioport("GEARBOX")->read() & 0xf;
bool clutch_pressed = (ioport("CLUTCH")->read() & 1) == 0;
const char gearbox_output[16] = { '-', '-', '-', '-',
'-', '6', '5', 'N',
'-', '2', '1', 'N',
'-', '4', '3', 'N' };
if(ioport("CONFIG")->read() & 2)
popmessage("%c %c",gearbox_output[m_gearbox_state],clutch_pressed == true ? '*' : '.');
if(clutch_pressed == false)
return m_gearbox_state;
m_gearbox_state = ioport("GEARBOX")->read() & 0xf;
return 0xf; // return neutral while changing gear
}
READ_LINE_MEMBER( namcoio_gearbox_device::clutch_r )
{
return ioport("CLUTCH")->read() & 1;
}
|