Written a device core for the Namco 6-speed gearbox [Angelo Salese]

(Used by Driver's Eyes, Ridge Racer DX and Ace Driver)
This commit is contained in:
angelosa 2016-12-28 19:52:06 +01:00
parent fe22ab174b
commit e252486d17
5 changed files with 200 additions and 36 deletions

View File

@ -2692,6 +2692,8 @@ files {
MAME_DIR .. "src/mame/machine/namco62.h",
MAME_DIR .. "src/mame/machine/namcomcu.cpp",
MAME_DIR .. "src/mame/machine/namcomcu.h",
MAME_DIR .. "src/mame/machine/namcoio_gearbox.cpp",
MAME_DIR .. "src/mame/machine/namcoio_gearbox.h",
MAME_DIR .. "src/mame/audio/namco52.cpp",
MAME_DIR .. "src/mame/audio/namco52.h",
MAME_DIR .. "src/mame/audio/namco54.cpp",

View File

@ -1724,47 +1724,15 @@ static INPUT_PORTS_START( winrungp )
PORT_DIPSETTING( 0x00, "4M" )
INPUT_PORTS_END
/* 1 3 5
|-|-| Gearbox scheme is identical to Ridge Racer deluxe and Ace Driver
2 4 6
*/
// TODO: convert to namcoio_gearbox_device
CUSTOM_INPUT_MEMBER(namcos21_state::driveyes_gearbox_r)
{
bool clutch_pressed = (ioport("PORTB")->read() & 8) == 0;
const char gearbox_output[16] = { '1', '-', '-', '-',
'-', '6', '5', 'N',
'-', '2', '1', 'N',
'-', '4', '3', 'N' };
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
}
//static const ioport_value gearbox_table[] = { 0x0f, 0x0a, 0x09, 0x0e, 0x0d, 0x06, 0x05 };
static INPUT_PORTS_START( driveyes )
PORT_INCLUDE(winrungp)
PORT_MODIFY("PORTB")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Clutch Pedal")
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("gearbox", namcoio_gearbox_device, clutch_r )
PORT_BIT( 0x37, IP_ACTIVE_LOW, IPT_UNUSED )
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_MODIFY("DIAL0")
PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, namcos21_state,driveyes_gearbox_r, nullptr)
//PORT_BIT( 0x0f, 0x00, IPT_POSITIONAL_V ) PORT_POSITIONS(7) PORT_REMAP_TABLE(gearbox_table) PORT_SENSITIVITY(15) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_PLAYER(1) PORT_NAME("GearBox")
PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("gearbox", namcoio_gearbox_device, in_r, nullptr )
PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_MODIFY("PORTH") /* 63B05Z0 - PORT H */
@ -1982,6 +1950,7 @@ static MACHINE_CONFIG_START( driveyes, namcos21_state )
MCFG_MACHINE_RESET_OVERRIDE(namcos21_state,namcos2)
MCFG_NVRAM_ADD_1FILL("nvram")
MCFG_DEVICE_ADD("gearbox", NAMCOIO_GEARBOX, 0)
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)

View File

@ -5,6 +5,7 @@
*/
#include "namcos2.h"
#include "machine/namcoio_gearbox.h"
#define NAMCOS21_POLY_FRAME_WIDTH 496
#define NAMCOS21_POLY_FRAME_HEIGHT 480
@ -52,7 +53,9 @@ public:
m_master_dsp_code(*this,"master_dsp_code"),
m_ptrom24(*this,"point24"),
m_ptrom16(*this,"point16"),
m_dsp(*this, "dsp") { }
m_dsp(*this, "dsp"),
m_io_gearbox(*this, "gearbox")
{ }
optional_shared_ptr<uint16_t> m_winrun_dspbios;
optional_shared_ptr<uint16_t> m_winrun_polydata;
@ -64,7 +67,8 @@ public:
optional_region_ptr<uint16_t> m_ptrom16;
optional_device<cpu_device> m_dsp;
optional_device<namcoio_gearbox_device> m_io_gearbox;
std::unique_ptr<uint8_t[]> m_videoram;
std::unique_ptr<uint16_t[]> m_winrun_dspcomram;
uint16_t m_winrun_poly_buf[WINRUN_MAX_POLY_PARAM];

View File

@ -0,0 +1,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;
}

View File

@ -0,0 +1,60 @@
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************
Namco 6-speed Gearbox device
***************************************************************************/
#pragma once
#ifndef __NAMCOIO_GEARBOXDEV_H__
#define __NAMCOIO_GEARBOXDEV_H__
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_NAMCOIO_GEARBOX_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, NAMCOIO_GEARBOX, 0)
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> namcoio_gearbox_device
class namcoio_gearbox_device : public device_t
{
public:
// construction/destruction
namcoio_gearbox_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// I/O operations
DECLARE_CUSTOM_INPUT_MEMBER( in_r );
DECLARE_READ_LINE_MEMBER( clutch_r );
uint8_t m_gearbox_state;
virtual ioport_constructor device_input_ports() const override;
protected:
// device-level overrides
// virtual void device_validity_check(validity_checker &valid) const;
virtual void device_start() override;
virtual void device_reset() override;
};
// device type definition
extern const device_type NAMCOIO_GEARBOX;
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
#endif