src/mess/machine/c64_4cga.c
| r0 | r14768 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Classical Games/Protovision 4 Player Interface emulation
|
| 4 | |
| 5 | http://www.protovision-online.com/hardw/4_player.htm
|
| 6 | http://hitmen.c02.at/html/hardware.html
|
| 7 | |
| 8 | Copyright MESS Team.
|
| 9 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 10 | |
| 11 | **********************************************************************/
|
| 12 | |
| 13 | #include "c64_4cga.h"
|
| 14 | |
| 15 | |
| 16 | |
| 17 | //**************************************************************************
|
| 18 | // DEVICE DEFINITIONS
|
| 19 | //**************************************************************************
|
| 20 | |
| 21 | const device_type C64_4CGA = &device_creator<c64_4cga_device>;
|
| 22 | |
| 23 | |
| 24 | static INPUT_PORTS_START( c64_4player )
|
| 25 | PORT_START("JOY3")
|
| 26 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
|
| 27 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
|
| 28 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
|
| 29 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
|
| 30 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 31 | |
| 32 | PORT_START("JOY4")
|
| 33 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(4)
|
| 34 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(4)
|
| 35 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(4)
|
| 36 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(4)
|
| 37 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 38 | |
| 39 | PORT_START("FIRE")
|
| 40 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
|
| 41 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(4)
|
| 42 | PORT_BIT( 0xcf, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 43 | INPUT_PORTS_END
|
| 44 | |
| 45 | |
| 46 | //-------------------------------------------------
|
| 47 | // input_ports - device-specific input ports
|
| 48 | //-------------------------------------------------
|
| 49 | |
| 50 | ioport_constructor c64_4cga_device::device_input_ports() const
|
| 51 | {
|
| 52 | return INPUT_PORTS_NAME( c64_4player );
|
| 53 | }
|
| 54 | |
| 55 | |
| 56 | |
| 57 | //**************************************************************************
|
| 58 | // LIVE DEVICE
|
| 59 | //**************************************************************************
|
| 60 | |
| 61 | //-------------------------------------------------
|
| 62 | // c64_4cga_device - constructor
|
| 63 | //-------------------------------------------------
|
| 64 | |
| 65 | c64_4cga_device::c64_4cga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
| 66 | device_t(mconfig, C64_4CGA, "C64 Protovision 4 Player Interface", tag, owner, clock),
|
| 67 | device_c64_user_port_interface(mconfig, *this),
|
| 68 | m_port(0)
|
| 69 | {
|
| 70 | }
|
| 71 | |
| 72 | |
| 73 | //-------------------------------------------------
|
| 74 | // device_start - device-specific startup
|
| 75 | //-------------------------------------------------
|
| 76 | |
| 77 | void c64_4cga_device::device_start()
|
| 78 | {
|
| 79 | // state saving
|
| 80 | save_item(NAME(m_port));
|
| 81 | }
|
| 82 | |
| 83 | |
| 84 | //-------------------------------------------------
|
| 85 | // c64_pb_r - port B read
|
| 86 | //-------------------------------------------------
|
| 87 | |
| 88 | UINT8 c64_4cga_device::c64_pb_r(address_space &space, offs_t offset)
|
| 89 | {
|
| 90 | UINT8 data = input_port_read(*this, "FIRE");
|
| 91 | |
| 92 | if (m_port)
|
| 93 | {
|
| 94 | data &= input_port_read(*this, "JOY3");
|
| 95 | }
|
| 96 | else
|
| 97 | {
|
| 98 | data &= input_port_read(*this, "JOY4");
|
| 99 | }
|
| 100 | |
| 101 | return data;
|
| 102 | }
|
| 103 | |
| 104 | |
| 105 | //-------------------------------------------------
|
| 106 | // c64_pb_w - port B write
|
| 107 | //-------------------------------------------------
|
| 108 | |
| 109 | void c64_4cga_device::c64_pb_w(address_space &space, offs_t offset, UINT8 data)
|
| 110 | {
|
| 111 | m_port = BIT(data, 7);
|
| 112 | }
|
src/mess/machine/c64_4cga.h
| r0 | r14768 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | Classical Games/Protovision 4 Player Interface emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************/
|
| 9 | |
| 10 | #pragma once
|
| 11 | |
| 12 | #ifndef __C64_4CGA__
|
| 13 | #define __C64_4CGA__
|
| 14 | |
| 15 | #define ADDRESS_MAP_MODERN
|
| 16 | |
| 17 | #include "emu.h"
|
| 18 | #include "machine/c64user.h"
|
| 19 | |
| 20 | |
| 21 | |
| 22 | //**************************************************************************
|
| 23 | // TYPE DEFINITIONS
|
| 24 | //**************************************************************************
|
| 25 | |
| 26 | // ======================> c64_4cga_device
|
| 27 | |
| 28 | class c64_4cga_device : public device_t,
|
| 29 | public device_c64_user_port_interface
|
| 30 | {
|
| 31 | public:
|
| 32 | // construction/destruction
|
| 33 | c64_4cga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
| 34 | |
| 35 | // optional information overrides
|
| 36 | virtual ioport_constructor device_input_ports() const;
|
| 37 | |
| 38 | protected:
|
| 39 | // device-level overrides
|
| 40 | virtual void device_start();
|
| 41 | virtual void device_config_complete() { m_shortname = "c64_4player"; }
|
| 42 | |
| 43 | // device_c64_user_port_interface overrides
|
| 44 | virtual UINT8 c64_pb_r(address_space &space, offs_t offset);
|
| 45 | virtual void c64_pb_w(address_space &space, offs_t offset, UINT8 data);
|
| 46 | |
| 47 | private:
|
| 48 | int m_port;
|
| 49 | };
|
| 50 | |
| 51 | |
| 52 | // device type definition
|
| 53 | extern const device_type C64_4CGA;
|
| 54 | |
| 55 | |
| 56 | #endif
|